mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core: implement blobfee opcode
This commit is contained in:
parent
545f4c5547
commit
eeff9fef8a
4 changed files with 24 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
|
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
)
|
)
|
||||||
|
|
@ -40,6 +41,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
|
||||||
var (
|
var (
|
||||||
beneficiary common.Address
|
beneficiary common.Address
|
||||||
baseFee *big.Int
|
baseFee *big.Int
|
||||||
|
blobFee *big.Int
|
||||||
random *common.Hash
|
random *common.Hash
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -52,6 +54,9 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
|
||||||
if header.BaseFee != nil {
|
if header.BaseFee != nil {
|
||||||
baseFee = new(big.Int).Set(header.BaseFee)
|
baseFee = new(big.Int).Set(header.BaseFee)
|
||||||
}
|
}
|
||||||
|
if header.ExcessBlobGas != nil {
|
||||||
|
blobFee = eip4844.CalcBlobFee(*header.ExcessBlobGas)
|
||||||
|
}
|
||||||
if header.Difficulty.Cmp(common.Big0) == 0 {
|
if header.Difficulty.Cmp(common.Big0) == 0 {
|
||||||
random = &header.MixDigest
|
random = &header.MixDigest
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +69,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
|
||||||
Time: header.Time,
|
Time: header.Time,
|
||||||
Difficulty: new(big.Int).Set(header.Difficulty),
|
Difficulty: new(big.Int).Set(header.Difficulty),
|
||||||
BaseFee: baseFee,
|
BaseFee: baseFee,
|
||||||
|
BlobFee: blobFee,
|
||||||
GasLimit: header.GasLimit,
|
GasLimit: header.GasLimit,
|
||||||
Random: random,
|
Random: random,
|
||||||
ExcessBlobGas: header.ExcessBlobGas,
|
ExcessBlobGas: header.ExcessBlobGas,
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,13 @@ func opBlobHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// opBlobfee implements BLOBFEE 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
|
||||||
|
}
|
||||||
|
|
||||||
// enable4844 applies EIP-4844 (DATAHASH opcode)
|
// enable4844 applies EIP-4844 (DATAHASH opcode)
|
||||||
func enable4844(jt *JumpTable) {
|
func enable4844(jt *JumpTable) {
|
||||||
// New opcode
|
// New opcode
|
||||||
|
|
@ -291,6 +298,13 @@ func enable4844(jt *JumpTable) {
|
||||||
minStack: minStack(1, 1),
|
minStack: minStack(1, 1),
|
||||||
maxStack: maxStack(1, 1),
|
maxStack: maxStack(1, 1),
|
||||||
}
|
}
|
||||||
|
jt[BLOBFEE] = &operation{
|
||||||
|
execute: opSelfdestruct6780,
|
||||||
|
dynamicGas: gasSelfdestructEIP3529,
|
||||||
|
constantGas: params.SelfdestructGasEIP150,
|
||||||
|
minStack: minStack(1, 0),
|
||||||
|
maxStack: maxStack(1, 0),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable6780 applies EIP-6780 (deactivate SELFDESTRUCT)
|
// enable6780 applies EIP-6780 (deactivate SELFDESTRUCT)
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ type BlockContext struct {
|
||||||
Time uint64 // Provides information for TIME
|
Time uint64 // Provides information for TIME
|
||||||
Difficulty *big.Int // Provides information for DIFFICULTY
|
Difficulty *big.Int // Provides information for DIFFICULTY
|
||||||
BaseFee *big.Int // Provides information for BASEFEE
|
BaseFee *big.Int // Provides information for BASEFEE
|
||||||
|
BlobFee *big.Int // Provides information for BLOBFEE
|
||||||
Random *common.Hash // Provides information for PREVRANDAO
|
Random *common.Hash // Provides information for PREVRANDAO
|
||||||
ExcessBlobGas *uint64 // ExcessBlobGas field in the header, needed to compute the data
|
ExcessBlobGas *uint64 // ExcessBlobGas field in the header, needed to compute the data
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ const (
|
||||||
SELFBALANCE OpCode = 0x47
|
SELFBALANCE OpCode = 0x47
|
||||||
BASEFEE OpCode = 0x48
|
BASEFEE OpCode = 0x48
|
||||||
BLOBHASH OpCode = 0x49
|
BLOBHASH OpCode = 0x49
|
||||||
|
BLOBFEE OpCode = 0x4a
|
||||||
)
|
)
|
||||||
|
|
||||||
// 0x50 range - 'storage' and execution.
|
// 0x50 range - 'storage' and execution.
|
||||||
|
|
@ -287,6 +288,7 @@ var opCodeToString = map[OpCode]string{
|
||||||
SELFBALANCE: "SELFBALANCE",
|
SELFBALANCE: "SELFBALANCE",
|
||||||
BASEFEE: "BASEFEE",
|
BASEFEE: "BASEFEE",
|
||||||
BLOBHASH: "BLOBHASH",
|
BLOBHASH: "BLOBHASH",
|
||||||
|
BLOBFEE: "BLOBFEE",
|
||||||
|
|
||||||
// 0x50 range - 'storage' and execution.
|
// 0x50 range - 'storage' and execution.
|
||||||
POP: "POP",
|
POP: "POP",
|
||||||
|
|
@ -444,6 +446,7 @@ var stringToOp = map[string]OpCode{
|
||||||
"CHAINID": CHAINID,
|
"CHAINID": CHAINID,
|
||||||
"BASEFEE": BASEFEE,
|
"BASEFEE": BASEFEE,
|
||||||
"BLOBHASH": BLOBHASH,
|
"BLOBHASH": BLOBHASH,
|
||||||
|
"BLOBFEE": BLOBFEE,
|
||||||
"DELEGATECALL": DELEGATECALL,
|
"DELEGATECALL": DELEGATECALL,
|
||||||
"STATICCALL": STATICCALL,
|
"STATICCALL": STATICCALL,
|
||||||
"CODESIZE": CODESIZE,
|
"CODESIZE": CODESIZE,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue