mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
refactor(evm): Remove duplicate defined variables (#559)
Refactor: Remove duplicate defined variables
This commit is contained in:
parent
65a3a7fc23
commit
d537451863
1 changed files with 21 additions and 21 deletions
|
|
@ -43,8 +43,10 @@ The state transitioning model does all the necessary work to work out a valid ne
|
||||||
3) Create a new state object if the recipient is \0*32
|
3) Create a new state object if the recipient is \0*32
|
||||||
4) Value transfer
|
4) Value transfer
|
||||||
== If contract creation ==
|
== If contract creation ==
|
||||||
|
|
||||||
4a) Attempt to run transaction data
|
4a) Attempt to run transaction data
|
||||||
4b) If valid, use result as code for the new state object
|
4b) If valid, use result as code for the new state object
|
||||||
|
|
||||||
== end ==
|
== end ==
|
||||||
5) Run Script section
|
5) Run Script section
|
||||||
6) Derive new state root
|
6) Derive new state root
|
||||||
|
|
@ -340,16 +342,16 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
if err := st.preCheck(); err != nil {
|
if err := st.preCheck(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
msg := st.msg
|
|
||||||
sender := vm.AccountRef(msg.From())
|
var (
|
||||||
homestead := st.evm.ChainConfig().IsHomestead(st.evm.Context.BlockNumber)
|
msg = st.msg
|
||||||
istanbul := st.evm.ChainConfig().IsIstanbul(st.evm.Context.BlockNumber)
|
sender = vm.AccountRef(msg.From())
|
||||||
shanghai := st.evm.ChainConfig().IsShanghai(st.evm.Context.BlockNumber)
|
rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber)
|
||||||
london := st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber)
|
contractCreation = msg.To() == nil
|
||||||
contractCreation := msg.To() == nil
|
)
|
||||||
|
|
||||||
// Check clauses 4-5, subtract intrinsic gas if everything is correct
|
// Check clauses 4-5, subtract intrinsic gas if everything is correct
|
||||||
gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, homestead, istanbul, shanghai)
|
gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -363,8 +365,6 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
return nil, fmt.Errorf("%w: address %v", ErrInsufficientFundsForTransfer, msg.From().Hex())
|
return nil, fmt.Errorf("%w: address %v", ErrInsufficientFundsForTransfer, msg.From().Hex())
|
||||||
}
|
}
|
||||||
|
|
||||||
rules := st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber)
|
|
||||||
|
|
||||||
// Check whether the init code size has been exceeded.
|
// Check whether the init code size has been exceeded.
|
||||||
if rules.IsShanghai && contractCreation && len(st.data) > params.MaxInitCodeSize {
|
if rules.IsShanghai && contractCreation && len(st.data) > params.MaxInitCodeSize {
|
||||||
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(st.data), params.MaxInitCodeSize)
|
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(st.data), params.MaxInitCodeSize)
|
||||||
|
|
@ -397,7 +397,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !london {
|
if !rules.IsLondon {
|
||||||
// Before EIP-3529: refunds were capped to gasUsed / 2
|
// Before EIP-3529: refunds were capped to gasUsed / 2
|
||||||
st.refundGas(params.RefundQuotient)
|
st.refundGas(params.RefundQuotient)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -405,7 +405,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
st.refundGas(params.RefundQuotientEIP3529)
|
st.refundGas(params.RefundQuotientEIP3529)
|
||||||
}
|
}
|
||||||
effectiveTip := st.gasPrice
|
effectiveTip := st.gasPrice
|
||||||
if london {
|
if rules.IsLondon {
|
||||||
if st.evm.Context.BaseFee != nil {
|
if st.evm.Context.BaseFee != nil {
|
||||||
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
|
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue