diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index bb14ac63ca..5d11240c14 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -166,6 +166,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, // If excessBlobGas is defined, add it to the vmContext. if pre.Env.ExcessBlobGas != nil { vmContext.ExcessBlobGas = pre.Env.ExcessBlobGas + vmContext.BlobFee = eip4844.CalcBlobFee(*pre.Env.ExcessBlobGas) } else { // If it is not explicitly defined, but we have the parent values, we try // to calculate it ourselves. @@ -174,6 +175,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, if parentExcessBlobGas != nil && parentBlobGasUsed != nil { excessBlobGas := eip4844.CalcExcessBlobGas(*parentExcessBlobGas, *parentBlobGasUsed) vmContext.ExcessBlobGas = &excessBlobGas + vmContext.BlobFee = eip4844.CalcBlobFee(excessBlobGas) } } // If DAO is supported/enabled, we need to handle it here. In geth 'proper', it's diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 017388efb5..4539089884 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -123,7 +123,8 @@ func runCmd(ctx *cli.Context) error { sender = common.BytesToAddress([]byte("sender")) receiver = common.BytesToAddress([]byte("receiver")) preimages = ctx.Bool(DumpFlag.Name) - blobHashes []common.Hash // TODO (MariusVanDerWijden) implement blob hashes in state tests + blobHashes []common.Hash // TODO (MariusVanDerWijden) implement blob hashes in state tests + blobFee = new(big.Int) // TODO (MariusVanDerWijden) implement blob fee in state tests ) if ctx.Bool(MachineFlag.Name) { tracer = logger.NewJSONLogger(logconfig, os.Stdout) @@ -221,6 +222,7 @@ func runCmd(ctx *cli.Context) error { Coinbase: genesisConfig.Coinbase, BlockNumber: new(big.Int).SetUint64(genesisConfig.Number), BlobHashes: blobHashes, + BlobFee: blobFee, EVMConfig: vm.Config{ Tracer: tracer, }, diff --git a/core/vm/eips.go b/core/vm/eips.go index 6104c66968..827c69ba72 100644 --- a/core/vm/eips.go +++ b/core/vm/eips.go @@ -282,8 +282,8 @@ func opBlobHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([ return nil, nil } -// opBlobfee implements BLOBFEE opcode -func opBlobfee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { +// opBlobFee implements BLOBBASEFEE opcode +func opBlobFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { blobFee, _ := uint256.FromBig(interpreter.evm.Context.BlobFee) scope.Stack.push(blobFee) return nil, nil @@ -298,8 +298,8 @@ func enable4844(jt *JumpTable) { minStack: minStack(1, 1), maxStack: maxStack(1, 1), } - jt[BLOBFEE] = &operation{ - execute: opBlobfee, + jt[BLOBBASEFEE] = &operation{ + execute: opBlobFee, constantGas: GasQuickStep, minStack: minStack(0, 1), maxStack: maxStack(0, 1), diff --git a/core/vm/evm.go b/core/vm/evm.go index 3ed8b19aa9..c20460a5c5 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -73,7 +73,7 @@ type BlockContext struct { Time uint64 // Provides information for TIME Difficulty *big.Int // Provides information for DIFFICULTY BaseFee *big.Int // Provides information for BASEFEE - BlobFee *big.Int // Provides information for BLOBFEE + BlobFee *big.Int // Provides information for BLOBBASEFEE Random *common.Hash // Provides information for PREVRANDAO ExcessBlobGas *uint64 // ExcessBlobGas field in the header, needed to compute the data } diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go index 6c570c10eb..a11cf05a15 100644 --- a/core/vm/opcodes.go +++ b/core/vm/opcodes.go @@ -101,7 +101,7 @@ const ( SELFBALANCE OpCode = 0x47 BASEFEE OpCode = 0x48 BLOBHASH OpCode = 0x49 - BLOBFEE OpCode = 0x4a + BLOBBASEFEE OpCode = 0x4a ) // 0x50 range - 'storage' and execution. @@ -288,7 +288,7 @@ var opCodeToString = map[OpCode]string{ SELFBALANCE: "SELFBALANCE", BASEFEE: "BASEFEE", BLOBHASH: "BLOBHASH", - BLOBFEE: "BLOBFEE", + BLOBBASEFEE: "BLOBBASEFEE", // 0x50 range - 'storage' and execution. POP: "POP", @@ -446,7 +446,7 @@ var stringToOp = map[string]OpCode{ "CHAINID": CHAINID, "BASEFEE": BASEFEE, "BLOBHASH": BLOBHASH, - "BLOBFEE": BLOBFEE, + "BLOBBASEFEE": BLOBBASEFEE, "DELEGATECALL": DELEGATECALL, "STATICCALL": STATICCALL, "CODESIZE": CODESIZE, diff --git a/core/vm/runtime/env.go b/core/vm/runtime/env.go index 7e330e0732..ce44d4d24d 100644 --- a/core/vm/runtime/env.go +++ b/core/vm/runtime/env.go @@ -37,6 +37,7 @@ func NewEnv(cfg *Config) *vm.EVM { Difficulty: cfg.Difficulty, GasLimit: cfg.GasLimit, BaseFee: cfg.BaseFee, + BlobFee: cfg.BlobFee, Random: cfg.Random, } diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 480e5cec67..0f4a27d04e 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -44,6 +44,7 @@ type Config struct { Debug bool EVMConfig vm.Config BaseFee *big.Int + BlobFee *big.Int BlobHashes []common.Hash Random *common.Hash @@ -95,6 +96,9 @@ func setDefaults(cfg *Config) { if cfg.BaseFee == nil { cfg.BaseFee = big.NewInt(params.InitialBaseFee) } + if cfg.BlobFee == nil { + cfg.BlobFee = new(big.Int) + } } // Execute executes the code using the input as call data during the execution. diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 733e671e0a..13ec5058c2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -998,6 +998,7 @@ type BlockOverrides struct { Coinbase *common.Address Random *common.Hash BaseFee *hexutil.Big + BlobFee *hexutil.Big } // Apply overrides the given header fields into the given block context. @@ -1026,6 +1027,9 @@ func (diff *BlockOverrides) Apply(blockCtx *vm.BlockContext) { if diff.BaseFee != nil { blockCtx.BaseFee = diff.BaseFee.ToInt() } + if diff.BlobFee != nil { + blockCtx.BlobFee = diff.BlobFee.ToInt() + } } // ChainContextBackend provides methods required to implement ChainContext.