Skip to content

Commit

Permalink
extra fix (#512)
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign authored Oct 17, 2024
1 parent b2b96a2 commit 8057173
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/state/access_witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (aw *AccessWitness) TouchBasicData(addr []byte, isWrite bool, useGasFn UseG
return ok && (!warmCostCharging || chargedGas > 0 || useGasFn(params.WarmStorageReadCostEIP2929))
}

func (aw *AccessWitness) TouchCodeHash(addr []byte, isWrite bool, useGasFn UseGasFn) bool {
func (aw *AccessWitness) TouchCodeHash(addr []byte, isWrite bool, useGasFn UseGasFn, warmCostCharging bool) bool {
chargedGas, ok := aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeHashLeafKey, isWrite, useGasFn)
return ok && (chargedGas > 0 || useGasFn(params.WarmStorageReadCostEIP2929))
return ok && (!warmCostCharging || chargedGas > 0 || useGasFn(params.WarmStorageReadCostEIP2929))
}
4 changes: 2 additions & 2 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
// is a direct tx call, in which case it's covered by the intrinsic gas, or because
// of a CALL instruction, in which case BASIC_DATA has been added to the access
// list in write mode. If there is enough gas paying for the addition of the code
// hash leaf to the access list, then account creation will proceed unimpaired.
// hash leaf to the access list, then account creation will proceed unimpaired.
// Thus, only pay for the creation of the code hash leaf here.
ok := evm.Accesses.TouchCodeHash(addr.Bytes(), true, gc.consumeGas)
ok := evm.Accesses.TouchCodeHash(addr.Bytes(), true, gc.consumeGas, false)
if !ok {
evm.StateDB.RevertToSnapshot(snapshot)
return nil, 0, ErrOutOfGas
Expand Down
2 changes: 1 addition & 1 deletion core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
return nil, ErrOutOfGas
}
} else {
if !interpreter.evm.Accesses.TouchCodeHash(address[:], false, scope.Contract.UseGas) {
if !interpreter.evm.Accesses.TouchCodeHash(address[:], false, scope.Contract.UseGas, true) {
return nil, ErrOutOfGas
}
}
Expand Down

0 comments on commit 8057173

Please sign in to comment.