mirror of https://github.com/poanetwork/quorum.git
Fix for issue 576 where private transactions can cause block gas limit to be exceeded, leading to BAD BLOCK.
This commit is contained in:
parent
5af110984a
commit
50da8eaf0d
|
@ -162,9 +162,7 @@ func (st *StateTransition) buyGas() error {
|
||||||
if st.state.GetBalance(st.msg.From()).Cmp(mgval) < 0 {
|
if st.state.GetBalance(st.msg.From()).Cmp(mgval) < 0 {
|
||||||
return errInsufficientBalanceForGas
|
return errInsufficientBalanceForGas
|
||||||
}
|
}
|
||||||
log.Info("======== Attempting to subtract gas", "gasToSubtract", st.msg.Gas(), "gas", st.gp.Gas())
|
|
||||||
if err := st.gp.SubGas(st.msg.Gas()); err != nil {
|
if err := st.gp.SubGas(st.msg.Gas()); err != nil {
|
||||||
log.Info("======== Subtraction failed!!!", "err", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
st.gas += st.msg.Gas()
|
st.gas += st.msg.Gas()
|
||||||
|
@ -220,7 +218,6 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo
|
||||||
data = st.data
|
data = st.data
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("======== remaining gas prior to IntrinsicGas()", "gas", st.gas)
|
|
||||||
// Pay intrinsic gas. For a private contract this is done using the public hash passed in,
|
// Pay intrinsic gas. For a private contract this is done using the public hash passed in,
|
||||||
// not the private data retrieved above. This is because we need any (participant) validator
|
// not the private data retrieved above. This is because we need any (participant) validator
|
||||||
// node to get the same result as a (non-participant) minter node, to avoid out-of-gas issues.
|
// node to get the same result as a (non-participant) minter node, to avoid out-of-gas issues.
|
||||||
|
@ -231,7 +228,6 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo
|
||||||
if err = st.useGas(gas); err != nil {
|
if err = st.useGas(gas); err != nil {
|
||||||
return nil, 0, false, err
|
return nil, 0, false, err
|
||||||
}
|
}
|
||||||
log.Info("======== remaining gas after IntrinsicGas()", "gas", st.gas)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
leftoverGas uint64
|
leftoverGas uint64
|
||||||
|
@ -274,19 +270,15 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pay gas used during contract creation or execution (st.gas tracks remaining gas)
|
// Pay gas used during contract creation or execution (st.gas tracks remaining gas)
|
||||||
//However, if private contract then we don't want to do this else we could
|
// However, if private contract then we don't want to do this else we can get
|
||||||
//have a mismatch between a (non-participant) minter and (participant) validator,
|
// a mismatch between a (non-participant) minter and (participant) validator,
|
||||||
// which can cause a 'BAD BLOCK' crash.
|
// which can cause a 'BAD BLOCK' crash.
|
||||||
if !isPrivate {
|
if !isPrivate {
|
||||||
st.gas = leftoverGas
|
st.gas = leftoverGas
|
||||||
log.Info("======== setting leftoverGas for public transaction after Create or Call", "gas", st.gas)
|
|
||||||
}
|
}
|
||||||
log.Info("======== left over gas to be refunded", "gas", st.gas)
|
|
||||||
|
|
||||||
log.Info("======== remaining gas prior to refundGas()", "gas", st.gas)
|
|
||||||
st.refundGas()
|
st.refundGas()
|
||||||
st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice))
|
st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice))
|
||||||
log.Info("======== remaining gas after refundGas()", "gas", st.gas)
|
|
||||||
|
|
||||||
if isPrivate {
|
if isPrivate {
|
||||||
return ret, 0, vmerr != nil, err
|
return ret, 0, vmerr != nil, err
|
||||||
|
|
Loading…
Reference in New Issue