add amsterdam instruction set etc.

This commit is contained in:
Felix H 2026-01-19 15:49:28 +00:00
parent 6133de443d
commit def5237da5
4 changed files with 14 additions and 4 deletions

View file

@ -35,7 +35,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
BlockAccessListHash *common.Hash `json:"blockAccessListHash,omitempty"` BlockAccessListHash *common.Hash `json:"blockAccessListHash,omitempty"`
SlotNumber *uint64 `json:"slotNumber"` SlotNumber *math.HexOrDecimal64 `json:"slotNumber"`
} }
var enc Genesis var enc Genesis
enc.Config = g.Config enc.Config = g.Config
@ -59,7 +59,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas) enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas)
enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed) enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed)
enc.BlockAccessListHash = g.BlockAccessListHash enc.BlockAccessListHash = g.BlockAccessListHash
enc.SlotNumber = g.SlotNumber enc.SlotNumber = (*math.HexOrDecimal64)(g.SlotNumber)
return json.Marshal(&enc) return json.Marshal(&enc)
} }
@ -82,7 +82,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
BlockAccessListHash *common.Hash `json:"blockAccessListHash,omitempty"` BlockAccessListHash *common.Hash `json:"blockAccessListHash,omitempty"`
SlotNumber *uint64 `json:"slotNumber"` SlotNumber *math.HexOrDecimal64 `json:"slotNumber"`
} }
var dec Genesis var dec Genesis
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
@ -143,7 +143,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
g.BlockAccessListHash = dec.BlockAccessListHash g.BlockAccessListHash = dec.BlockAccessListHash
} }
if dec.SlotNumber != nil { if dec.SlotNumber != nil {
g.SlotNumber = dec.SlotNumber g.SlotNumber = (*uint64)(dec.SlotNumber)
} }
return nil return nil
} }

View file

@ -264,6 +264,7 @@ type genesisSpecMarshaling struct {
BaseFee *math.HexOrDecimal256 BaseFee *math.HexOrDecimal256
ExcessBlobGas *math.HexOrDecimal64 ExcessBlobGas *math.HexOrDecimal64
BlobGasUsed *math.HexOrDecimal64 BlobGasUsed *math.HexOrDecimal64
SlotNumber *math.HexOrDecimal64
} }
// GenesisMismatchError is raised when trying to overwrite an existing // GenesisMismatchError is raised when trying to overwrite an existing

View file

@ -150,6 +150,8 @@ func NewEVM(blockCtx BlockContext, statedb StateDB, chainConfig *params.ChainCon
evm.precompiles = activePrecompiledContracts(evm.chainRules) evm.precompiles = activePrecompiledContracts(evm.chainRules)
switch { switch {
case evm.chainRules.IsAmsterdam:
evm.table = &amsterdamInstructionSet
case evm.chainRules.IsOsaka: case evm.chainRules.IsOsaka:
evm.table = &osakaInstructionSet evm.table = &osakaInstructionSet
case evm.chainRules.IsVerkle: case evm.chainRules.IsVerkle:

View file

@ -63,6 +63,7 @@ var (
verkleInstructionSet = newVerkleInstructionSet() verkleInstructionSet = newVerkleInstructionSet()
pragueInstructionSet = newPragueInstructionSet() pragueInstructionSet = newPragueInstructionSet()
osakaInstructionSet = newOsakaInstructionSet() osakaInstructionSet = newOsakaInstructionSet()
amsterdamInstructionSet = newAmsterdamInstructionSet()
) )
// JumpTable contains the EVM opcodes supported at a given fork. // JumpTable contains the EVM opcodes supported at a given fork.
@ -92,6 +93,12 @@ func newVerkleInstructionSet() JumpTable {
return validate(instructionSet) return validate(instructionSet)
} }
func newAmsterdamInstructionSet() JumpTable {
instructionSet := newOsakaInstructionSet()
enable7843(&instructionSet) // EIP-7843 (SLOTNUM opcode)
return validate(instructionSet)
}
func newOsakaInstructionSet() JumpTable { func newOsakaInstructionSet() JumpTable {
instructionSet := newPragueInstructionSet() instructionSet := newPragueInstructionSet()
enable7939(&instructionSet) // EIP-7939 (CLZ opcode) enable7939(&instructionSet) // EIP-7939 (CLZ opcode)