diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 796e64d747..e6f1246d85 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -58,6 +58,7 @@ func TestStateProcessorErrors(t *testing.T) { ShanghaiBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), + DescartesBlock: big.NewInt(0), Ethash: new(params.EthashConfig), } signer = types.LatestSigner(config) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 9e1f47f125..5dd26061aa 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -74,6 +74,8 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter { if cfg.JumpTable[STOP] == nil { var jt JumpTable switch { + case evm.chainRules.IsDescartes: + jt = descartesInstructionSet case evm.chainRules.IsCurie: jt = curieInstructionSet case evm.chainRules.IsShanghai: diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index b499ffad2c..55e739f098 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -60,11 +60,20 @@ var ( londonInstructionSet = newLondonInstructionSet() shanghaiInstructionSet = newShanghaiInstructionSet() curieInstructionSet = newCurieInstructionSet() + descartesInstructionSet = newDescartesInstructionSet() ) // JumpTable contains the EVM opcodes supported at a given fork. type JumpTable [256]*operation +// newDescartesInstructionSet returns the frontier, homestead, byzantium, +// contantinople, istanbul, petersburg, berlin, london, shanghai, curie, and descartes instructions. +func newDescartesInstructionSet() JumpTable { + instructionSet := newCurieInstructionSet() + + return instructionSet +} + // newCurieInstructionSet returns the frontier, homestead, byzantium, // contantinople, istanbul, petersburg, berlin, london, shanghai, and curie instructions. func newCurieInstructionSet() JumpTable { diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 6fe50e0aa5..a27bfbe1bd 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -72,6 +72,7 @@ func setDefaults(cfg *Config) { ShanghaiBlock: new(big.Int), BernoulliBlock: new(big.Int), CurieBlock: new(big.Int), + DescartesBlock: new(big.Int), } } diff --git a/params/config.go b/params/config.go index 2e3efc4151..e0e3b41473 100644 --- a/params/config.go +++ b/params/config.go @@ -281,6 +281,7 @@ var ( ShanghaiBlock: nil, BernoulliBlock: nil, CurieBlock: nil, + DescartesBlock: nil, Clique: &CliqueConfig{ Period: 3, Epoch: 30000, @@ -319,6 +320,7 @@ var ( ShanghaiBlock: big.NewInt(0), BernoulliBlock: big.NewInt(3747132), CurieBlock: nil, + DescartesBlock: nil, Clique: &CliqueConfig{ Period: 3, Epoch: 30000, @@ -357,6 +359,7 @@ var ( ShanghaiBlock: big.NewInt(0), BernoulliBlock: big.NewInt(5220340), CurieBlock: nil, + DescartesBlock: nil, Clique: &CliqueConfig{ Period: 3, Epoch: 30000, @@ -380,7 +383,7 @@ var ( // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, + AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, ScrollConfig{ UseZktrie: false, FeeVaultAddress: nil, @@ -394,7 +397,7 @@ var ( // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, + AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, ScrollConfig{ UseZktrie: false, FeeVaultAddress: nil, @@ -403,7 +406,7 @@ var ( L1Config: &L1Config{5, common.HexToAddress("0x0000000000000000000000000000000000000000"), 0, common.HexToAddress("0x0000000000000000000000000000000000000000")}, }} - TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, + TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, ScrollConfig{ UseZktrie: false, FeeVaultAddress: &common.Address{123}, @@ -413,7 +416,7 @@ var ( }} TestRules = TestChainConfig.Rules(new(big.Int)) - TestNoL1DataFeeChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, + TestNoL1DataFeeChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, ScrollConfig{ UseZktrie: false, FeeVaultAddress: nil, @@ -503,6 +506,7 @@ type ChainConfig struct { ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch block (nil = no fork, 0 = already on shanghai) BernoulliBlock *big.Int `json:"bernoulliBlock,omitempty"` // Bernoulli switch block (nil = no fork, 0 = already on bernoulli) CurieBlock *big.Int `json:"curieBlock,omitempty"` // Curie switch block (nil = no fork, 0 = already on curie) + DescartesBlock *big.Int `json:"descartesBlock,omitempty"` // Descartes switch block (nil = no fork, 0 = already on descartes) // TerminalTotalDifficulty is the amount of total difficulty reached by // the network that triggers the consensus upgrade. @@ -618,7 +622,7 @@ func (c *ChainConfig) String() string { default: engine = "unknown" } - return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Archimedes: %v, Shanghai: %v, Bernoulli: %v, Curie: %v, Engine: %v, Scroll config: %v}", + return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Archimedes: %v, Shanghai: %v, Bernoulli: %v, Curie: %v, Descartes: %v, Engine: %v, Scroll config: %v}", c.ChainID, c.HomesteadBlock, c.DAOForkBlock, @@ -638,6 +642,7 @@ func (c *ChainConfig) String() string { c.ShanghaiBlock, c.BernoulliBlock, c.CurieBlock, + c.DescartesBlock, engine, c.Scroll, ) @@ -730,6 +735,11 @@ func (c *ChainConfig) IsCurie(num *big.Int) bool { return isForked(c.CurieBlock, num) } +// IsDescartes returns whether num is either equal to the Descartes fork block or greater. +func (c *ChainConfig) IsDescartes(num *big.Int) bool { + return isForked(c.DescartesBlock, num) +} + // IsTerminalPoWBlock returns whether the given block is the last block of PoW stage. func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *big.Int) bool { if c.TerminalTotalDifficulty == nil { @@ -783,6 +793,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "shanghaiBlock", block: c.ShanghaiBlock, optional: true}, {name: "bernoulliBlock", block: c.BernoulliBlock, optional: true}, {name: "curieBlock", block: c.CurieBlock, optional: true}, + {name: "descartesBlock", block: c.DescartesBlock, optional: true}, } { if lastFork.name != "" { // Next one must be higher number @@ -867,6 +878,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi if isForkIncompatible(c.CurieBlock, newcfg.CurieBlock, head) { return newCompatError("Curie fork block", c.CurieBlock, newcfg.CurieBlock) } + if isForkIncompatible(c.DescartesBlock, newcfg.DescartesBlock, head) { + return newCompatError("Descartes fork block", c.DescartesBlock, newcfg.DescartesBlock) + } return nil } @@ -935,7 +949,7 @@ type Rules struct { IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool IsBerlin, IsLondon, IsArchimedes, IsShanghai bool - IsBernoulli, IsCurie bool + IsBernoulli, IsCurie, IsDescartes bool } // Rules ensures c's ChainID is not nil. @@ -960,5 +974,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules { IsShanghai: c.IsShanghai(num), IsBernoulli: c.IsBernoulli(num), IsCurie: c.IsCurie(num), + IsDescartes: c.IsDescartes(num), } } diff --git a/params/version.go b/params/version.go index 0662000f69..807e341306 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 4 // Patch version component of the current release + VersionPatch = 5 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )