Skip to content

Commit 0985e6f

Browse files
committed
core/vm: don't include contract deployer bytecode in AccessWitness or charge witness access costs for it
1 parent 99f3c92 commit 0985e6f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

core/vm/contract.go

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ type Contract struct {
5858
CodeAddr *common.Address
5959
Input []byte
6060

61+
// is the execution frame represented by this object a contract deployment
62+
IsDeployment bool
63+
6164
Gas uint64
6265
value *big.Int
6366
}

core/vm/evm.go

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
260260
// The depth-check is already done, and precompiles handled above
261261
contract := NewContract(caller, AccountRef(addrCopy), value, gas)
262262
contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), code)
263+
contract.IsDeployment = true
263264
ret, err = evm.interpreter.Run(contract, input, false)
264265
gas = contract.Gas
265266
}
@@ -483,6 +484,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
483484
// The contract is a scoped environment for this execution context only.
484485
contract := NewContract(caller, AccountRef(address), value, gas)
485486
contract.SetCodeOptionalHash(&address, codeAndHash)
487+
contract.IsDeployment = true
486488

487489
if evm.Config.NoRecursion && evm.depth > 0 {
488490
return nil, address, gas, nil

core/vm/interpreter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
191191
logged, pcCopy, gasCopy = false, pc, contract.Gas
192192
}
193193

194-
if in.evm.TxContext.Accesses != nil {
194+
if in.evm.TxContext.Accesses != nil && !contract.IsDeployment {
195195
// if the PC ends up in a new "page" of verkleized code, charge the
196196
// associated witness costs.
197197
contract.Gas -= touchEachChunksAndChargeGas(pc, 1, contract.Address().Bytes()[:], contract, in.evm.TxContext.Accesses)

0 commit comments

Comments
 (0)