Apply suggestions from code review

Co-authored-by: Martin HS <martin@swende.se>
This commit is contained in:
Guillaume Ballet 2024-04-29 16:18:56 +02:00 committed by GitHub
parent 0620c5cc79
commit 026ebc93b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 19 deletions

View file

@ -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,

View file

@ -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