Skip to content

Commit d4f2768

Browse files
committed
review feedback from @holiman
1 parent 811ebfe commit d4f2768

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

cmd/evm/internal/t8ntool/execution.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
194194
}
195195
if beaconRoot := pre.Env.ParentBeaconBlockRoot; beaconRoot != nil {
196196
evm := vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vmConfig)
197-
core.ProcessBeaconBlockRoot(*beaconRoot, evm, statedb, big.NewInt(int64(pre.Env.Number)), pre.Env.Timestamp)
197+
core.ProcessBeaconBlockRoot(*beaconRoot, evm, statedb)
198198
}
199199

200200
for i := 0; txIt.Next(); i++ {

core/chain_makers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (b *BlockGen) SetParentBeaconRoot(root common.Hash) {
102102
blockContext = NewEVMBlockContext(b.header, b.cm, &b.header.Coinbase)
103103
vmenv = vm.NewEVM(blockContext, vm.TxContext{}, b.statedb, b.cm.config, vm.Config{})
104104
)
105-
ProcessBeaconBlockRoot(root, vmenv, b.statedb, b.Number(), b.Timestamp())
105+
ProcessBeaconBlockRoot(root, vmenv, b.statedb)
106106
}
107107

108108
// addTx adds a transaction to the generated block. If no coinbase has

core/state_processor.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
7878
signer = types.MakeSigner(p.config, header.Number, header.Time)
7979
)
8080
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
81-
ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb, header.Number, header.Time)
81+
ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
8282
}
8383
// Iterate over and process the individual transactions
8484
for i, tx := range block.Transactions() {
@@ -190,7 +190,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
190190

191191
// ProcessBeaconBlockRoot applies the EIP-4788 system call to the beacon block root
192192
// contract. This method is exported to be used in tests.
193-
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB, num *big.Int, time uint64) {
193+
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB) {
194194
// If EIP-4788 is enabled, we need to invoke the beaconroot storage contract with
195195
// the new root
196196
msg := &Message{
@@ -204,11 +204,11 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat
204204
}
205205
txctx := NewEVMTxContext(msg)
206206
vmenv.Reset(txctx, statedb)
207-
if vmenv.ChainConfig().Rules(num, true, time).IsEIP2929 {
207+
if vmenv.ChainConfig().Rules(vmenv.Context.BlockNumber, true, vmenv.Context.Time).IsEIP2929 {
208208
statedb.AddAddressToAccessList(params.BeaconRootsAddress)
209209
}
210210
_, _, _ = vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560)
211-
if vmenv.ChainConfig().Rules(num, true, time).IsEIP4762 {
211+
if vmenv.ChainConfig().Rules(vmenv.Context.BlockNumber, true, vmenv.Context.Time).IsEIP4762 {
212212
statedb.Witness().Merge(txctx.Accesses)
213213
}
214214
statedb.Finalise(true)

eth/state_accessor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
237237
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
238238
context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil)
239239
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, eth.blockchain.Config(), vm.Config{})
240-
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb, block.Number(), block.Time())
240+
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
241241
}
242242
if txIndex == 0 && len(block.Transactions()) == 0 {
243243
return nil, vm.BlockContext{}, statedb, release, nil

eth/tracers/api.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
381381
if beaconRoot := next.BeaconRoot(); beaconRoot != nil {
382382
context := core.NewEVMBlockContext(next.Header(), api.chainContext(ctx), nil)
383383
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
384-
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb, vmenv.Context.BlockNumber, vmenv.Context.Time)
384+
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
385385
}
386386
// Clean out any pending release functions of trace state. Note this
387387
// step must be done after constructing tracing state, because the
@@ -533,7 +533,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
533533
)
534534
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
535535
vmenv := vm.NewEVM(vmctx, vm.TxContext{}, statedb, chainConfig, vm.Config{})
536-
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb, vmenv.Context.BlockNumber, vmenv.Context.Time)
536+
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
537537
}
538538
for i, tx := range block.Transactions() {
539539
if err := ctx.Err(); err != nil {
@@ -612,7 +612,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
612612
)
613613
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
614614
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
615-
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb, vmenv.Context.BlockNumber, vmenv.Context.Time)
615+
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
616616
}
617617
for i, tx := range txs {
618618
// Generate the next state snapshot fast without tracing
@@ -770,7 +770,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
770770
}
771771
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
772772
vmenv := vm.NewEVM(vmctx, vm.TxContext{}, statedb, chainConfig, vm.Config{})
773-
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb, vmenv.Context.BlockNumber, vmenv.Context.Time)
773+
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
774774
}
775775
for i, tx := range block.Transactions() {
776776
// Prepare the transaction for un-traced execution

miner/worker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error)
198198
if header.ParentBeaconRoot != nil {
199199
context := core.NewEVMBlockContext(header, miner.chain, nil)
200200
vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, miner.chainConfig, vm.Config{})
201-
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state, env.header.Number, env.header.Time)
201+
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state)
202202
}
203203
return env, nil
204204
}

params/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,8 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
932932
IsPetersburg: c.IsPetersburg(num),
933933
IsIstanbul: c.IsIstanbul(num),
934934
IsBerlin: c.IsBerlin(num),
935-
IsEIP2929: c.IsBerlin(num) && !c.IsPrague(num, timestamp),
936-
IsEIP4762: c.IsPrague(num, timestamp),
935+
IsEIP2929: c.IsBerlin(num) && !c.IsVerkle(num, timestamp),
936+
IsEIP4762: c.IsVerkle(num, timestamp),
937937
IsLondon: c.IsLondon(num),
938938
IsMerge: isMerge,
939939
IsShanghai: isMerge && c.IsShanghai(num, timestamp),

0 commit comments

Comments
 (0)