Skip to content

Commit

Permalink
rebase fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign committed Sep 12, 2024
1 parent f849433 commit 7aedcc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,10 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
// Charge the contract creation init gas in verkle mode
if evm.chainRules.IsEIP4762 {
gc := gasConsumer{availableGas: gas}
if !evm.Accesses.TouchAndChargeContractCreateCheck(address.Bytes(), gc.consumeGas){
if statelessGas > gas {
if !evm.Accesses.TouchAndChargeContractCreateCheck(address.Bytes(), gc.consumeGas) {
return nil, common.Address{}, 0, ErrOutOfGas
}
gas = gas - statelessGas
gas = gc.availableGas
}
// We add this to the access list _before_ taking a snapshot. Even if the creation fails,
// the access-list change should not be rolled back
Expand All @@ -484,11 +483,11 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,

// Charge the contract creation init gas in verkle mode
if evm.chainRules.IsEIP4762 {
statelessGas := evm.Accesses.TouchAndChargeContractCreateInit(address.Bytes())
if statelessGas > gas {
gc := gasConsumer{availableGas: gas}
if !evm.Accesses.TouchAndChargeContractCreateInit(address.Bytes(), gc.consumeGas) {
return nil, common.Address{}, 0, ErrOutOfGas
}
gas = gas - statelessGas
gas = gc.availableGas
}
evm.Context.Transfer(evm.StateDB, caller.Address(), address, value)

Expand Down
4 changes: 2 additions & 2 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
}
pos := scope.Stack.pop()
if !scope.Contract.validJumpdest(&pos) {
if !scope.Contract.UseGas(interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false)) {
if !interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false, scope.Contract.UseGas) {
return nil, ErrOutOfGas
}
return nil, ErrInvalidJump
Expand All @@ -599,7 +599,7 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
pos, cond := scope.Stack.pop(), scope.Stack.pop()
if !cond.IsZero() {
if !scope.Contract.validJumpdest(&pos) {
if !scope.Contract.UseGas(interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false)) {
if !interpreter.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(scope.Contract.CodeAddr[:], pos.Uint64(), 1, uint64(len(scope.Contract.Code)), false, scope.Contract.UseGas) {
return nil, ErrOutOfGas
}
return nil, ErrInvalidJump
Expand Down

0 comments on commit 7aedcc9

Please sign in to comment.