diff --git a/core/state/access_events.go b/core/state/access_events.go index b845fba303..bc6064e96d 100644 --- a/core/state/access_events.go +++ b/core/state/access_events.go @@ -237,7 +237,7 @@ func newChunkAccessKey(branchKey branchAccessKey, leafKey byte) chunkAccessKey { return lk } -// touchCodeChunksRangeOnReadAndChargeGas is a helper function to touch every chunk in a code range and charge witness gas costs +// CodeChunksRangeGas is a helper function to touch every chunk in a code range and charge witness gas costs func (aw *AccessEvents) CodeChunksRangeGas(contractAddr []byte, startPC, size uint64, codeLen uint64, isWrite bool) uint64 { // note that in the case where the copied code is outside the range of the // contract code but touches the last leaf with contract code in it, diff --git a/core/state_transition.go b/core/state_transition.go index 8a5e6329d1..fba41762ad 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -359,19 +359,6 @@ func (st *StateTransition) preCheck() error { return st.buyGas() } -// tryConsumeGas tries to subtract gas from gasPool, setting the result in gasPool -// if subtracting more gas than remains in gasPool, set gasPool = 0 and return false -// otherwise, do the subtraction setting the result in gasPool and return true -func tryConsumeGas(gasPool *uint64, gas uint64) bool { - if *gasPool < gas { - *gasPool = 0 - return false - } - - *gasPool -= gas - return true -} - // TransitionDb will transition the state by applying the current message and // returning the evm execution result with following fields. // @@ -419,12 +406,9 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { st.gasRemaining -= gas if rules.IsEIP4762 { - targetAddr := msg.To - originAddr := msg.From + st.evm.AccessEvents.AddTxOrigin(msg.From.Bytes()) - st.evm.AccessEvents.AddTxOrigin(originAddr.Bytes()) - - if msg.To != nil { + if targetAddr := msg.To; targetAddr != nil { st.evm.AccessEvents.AddTxDestination(targetAddr.Bytes(), msg.Value.Sign() != 0) // ensure the code size ends up in the access witness