Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
eip-4844: NewEVMBlockContext now expects excessDataGas (erigontech#7203)
Browse files Browse the repository at this point in the history
Small change in core.NewEVMBlockContext and now it expects
excessDataGas. This will be used in state transition to compute data fee
for eip-4844 data blobs. The logic that computes it will be added in the
next PRs.
  • Loading branch information
racytech authored and gladcow committed May 4, 2023
1 parent ff14bb6 commit 51b2e18
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg

txContext := core.NewEVMTxContext(msg)
header := block.Header()
evmContext := core.NewEVMBlockContext(header, core.GetHashFn(header, b.getHeader), b.m.Engine, nil)
evmContext := core.NewEVMBlockContext(header, core.GetHashFn(header, b.getHeader), b.m.Engine, nil, nil /*excessDataGas*/)
// Create a new environment which holds all relevant information
// about the transaction and calling mechanisms.
vmEnv := vm.NewEVM(evmContext, txContext, statedb, b.m.ChainConfig, vm.Config{})
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/otterscan_generic_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (api *OtterscanAPIImpl) genericTracer(dbtx kv.Tx, ctx context.Context, bloc

msg, _ := tx.AsMessage(*signer, header.BaseFee, rules)

BlockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, getHeader), engine, nil)
BlockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, getHeader), engine, nil, nil /*excessDataGas*/)
TxContext := core.NewEVMTxContext(msg)

vmenv := vm.NewEVM(BlockContext, TxContext, ibs, chainConfig, vm.Config{Debug: true, Tracer: tracer})
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/otterscan_search_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (api *OtterscanAPIImpl) traceBlock(dbtx kv.Tx, ctx context.Context, blockNu
msg, _ := tx.AsMessage(*signer, header.BaseFee, rules)

tracer := NewTouchTracer(searchAddr)
BlockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, getHeader), engine, nil)
BlockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, getHeader), engine, nil, nil /*excessDataGas*/)
TxContext := core.NewEVMTxContext(msg)

vmenv := vm.NewEVM(BlockContext, TxContext, ibs, chainConfig, vm.Config{Debug: true, Tracer: tracer})
Expand Down
2 changes: 1 addition & 1 deletion cmd/state/exec3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (rw *Worker) RunTxTaskNoLock(txTask *exec22.TxTask) {
blockContext := txTask.EvmBlockContext
if !rw.background {
getHashFn := core.GetHashFn(header, rw.getHeader)
blockContext = core.NewEVMBlockContext(header, getHashFn, rw.engine, nil /* author */)
blockContext = core.NewEVMBlockContext(header, getHashFn, rw.engine, nil /* author */, nil /*excessDataGas*/)
}
rw.evm.ResetBetweenBlocks(blockContext, core.NewEVMTxContext(msg), ibs, vmConfig, rules)
vmenv := rw.evm
Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ func (p *Parlia) systemCall(from, contract libcommon.Address, data []byte, ibs *
)
vmConfig := vm.Config{NoReceipts: true}
// Create a new context to be used in the EVM environment
blockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, nil), p, &from)
blockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, nil), p, &from, nil /*excessDataGas*/)
evm := vm.NewEVM(blockContext, core.NewEVMTxContext(msg), ibs, chainConfig, vmConfig)
ret, leftOverGas, err := evm.Call(
vm.AccountRef(msg.From()),
Expand Down
4 changes: 2 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func SysCallContract(contract libcommon.Address, data []byte, chainConfig chain.
author = &state.SystemAddress
txContext = NewEVMTxContext(msg)
}
blockContext := NewEVMBlockContext(header, GetHashFn(header, nil), engine, author)
blockContext := NewEVMBlockContext(header, GetHashFn(header, nil), engine, author, nil /*excessDataGas*/)
evm := vm.NewEVM(blockContext, txContext, ibs, &chainConfig, vmConfig)

ret, _, err := evm.Call(
Expand Down Expand Up @@ -529,7 +529,7 @@ func SysCreate(contract libcommon.Address, data []byte, chainConfig chain.Config
// Create a new context to be used in the EVM environment
author := &contract
txContext := NewEVMTxContext(msg)
blockContext := NewEVMBlockContext(header, GetHashFn(header, nil), nil, author)
blockContext := NewEVMBlockContext(header, GetHashFn(header, nil), nil, author, nil /*excessDataGas*/)
evm := vm.NewEVM(blockContext, txContext, ibs, &chainConfig, vmConfig)

ret, _, err := evm.SysCreate(
Expand Down
2 changes: 1 addition & 1 deletion core/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

// NewEVMBlockContext creates a new context for use in the EVM.
func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libcommon.Hash, engine consensus.EngineReader, author *libcommon.Address) evmtypes.BlockContext {
func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libcommon.Hash, engine consensus.EngineReader, author *libcommon.Address, excessDataGas *big.Int) evmtypes.BlockContext {
// If we don't have an explicit author (i.e. not mining), extract from the header
var beneficiary libcommon.Address
if author == nil {
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func ApplyTransaction(config *chain.Config, blockHashFunc func(n uint64) libcomm
// about the transaction and calling mechanisms.
cfg.SkipAnalysis = SkipAnalysis(config, header.Number.Uint64())

blockContext := NewEVMBlockContext(header, blockHashFunc, engine, author)
blockContext := NewEVMBlockContext(header, blockHashFunc, engine, author, nil /*excessDataGas*/)
vmenv := vm.NewEVM(blockContext, evmtypes.TxContext{}, ibs, config, cfg)

return applyTransaction(config, engine, gp, ibs, stateWriter, header, tx, usedGas, vmenv, cfg)
Expand Down
4 changes: 2 additions & 2 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ Loop:
defer getHashFnMute.Unlock()
return f(n)
}
blockContext := core.NewEVMBlockContext(header, getHashFn, engine, nil /* author */)
blockContext := core.NewEVMBlockContext(header, getHashFn, engine, nil /* author */, nil /*excessDataGas*/)

if parallel {
select {
Expand Down Expand Up @@ -1057,7 +1057,7 @@ func reconstituteStep(last bool,
defer getHashFnMute.Unlock()
return f(n)
}
blockContext := core.NewEVMBlockContext(header, getHashFn, engine, nil /* author */)
blockContext := core.NewEVMBlockContext(header, getHashFn, engine, nil /* author */, nil /*excessDataGas*/)
rules := chainConfig.Rules(bn, b.Time())

for txIndex := -1; txIndex <= len(txs); txIndex++ {
Expand Down
2 changes: 1 addition & 1 deletion tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (t *StateTest) RunNoVerify(tx kv.RwTx, subtest StateSubtest, vmconfig vm.Co
// Prepare the EVM.
txContext := core.NewEVMTxContext(msg)
header := block.Header()
context := core.NewEVMBlockContext(header, core.GetHashFn(header, nil), nil, &t.json.Env.Coinbase)
context := core.NewEVMBlockContext(header, core.GetHashFn(header, nil), nil, &t.json.Env.Coinbase, nil /*excessDataGas*/)
context.GetHash = vmTestBlockHash
if baseFee != nil {
context.BaseFee = new(uint256.Int)
Expand Down
2 changes: 1 addition & 1 deletion turbo/transactions/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func DoCall(
}

func NewEVMBlockContext(engine consensus.EngineReader, header *types.Header, requireCanonical bool, tx kv.Tx, headerReader services.HeaderReader) evmtypes.BlockContext {
return core.NewEVMBlockContext(header, MakeHeaderGetter(requireCanonical, tx, headerReader), engine, nil /* author */)
return core.NewEVMBlockContext(header, MakeHeaderGetter(requireCanonical, tx, headerReader), engine, nil /* author */, nil /*excessDataGas*/)
}

func MakeHeaderGetter(requireCanonical bool, tx kv.Tx, headerReader services.HeaderReader) func(uint64) libcommon.Hash {
Expand Down
2 changes: 1 addition & 1 deletion turbo/transactions/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ComputeTxEnv(ctx context.Context, engine consensus.EngineReader, block *typ
return h
}
header := block.HeaderNoCopy()
BlockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, getHeader), engine, nil)
BlockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, getHeader), engine, nil, nil /*excessDataGas*/)

// Recompute transactions up to the target index.
signer := types.MakeSigner(cfg, block.NumberU64())
Expand Down

0 comments on commit 51b2e18

Please sign in to comment.