mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd: core: apply review comments, fix t8n tool
This commit is contained in:
parent
44d6276f37
commit
a09c7f1f06
8 changed files with 22 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue