mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Apply suggestions from code review
Co-authored-by: Martin HS <martin@swende.se>
This commit is contained in:
parent
0620c5cc79
commit
026ebc93b4
2 changed files with 3 additions and 19 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue