mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
feat: setup configuration for upcoming hard fork and re-enable sha256 precompile (#562)
* setup configuration for upcoming hard fork * bump version * bump version * enable sha256 * rename to kepler * update * update lint * rename Kepler to Banach * goimports * reorder precompile forks * typo --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
parent
7e3a7ae744
commit
ee381b2451
6 changed files with 66 additions and 9 deletions
|
|
@ -111,6 +111,20 @@ var PrecompiledContractsArchimedes = map[common.Address]PrecompiledContract{
|
||||||
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
|
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PrecompiledContractsBanach contains the default set of pre-compiled Ethereum
|
||||||
|
// contracts used in the Banach release. Same as Archimedes but with sha256hash enabled again
|
||||||
|
var PrecompiledContractsBanach = map[common.Address]PrecompiledContract{
|
||||||
|
common.BytesToAddress([]byte{1}): &ecrecover{},
|
||||||
|
common.BytesToAddress([]byte{2}): &sha256hash{},
|
||||||
|
common.BytesToAddress([]byte{3}): &ripemd160hashDisabled{},
|
||||||
|
common.BytesToAddress([]byte{4}): &dataCopy{},
|
||||||
|
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: true},
|
||||||
|
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
|
||||||
|
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
|
||||||
|
}
|
||||||
|
|
||||||
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
|
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
|
||||||
// contracts specified in EIP-2537. These are exported for testing purposes.
|
// contracts specified in EIP-2537. These are exported for testing purposes.
|
||||||
var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
|
var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
|
||||||
|
|
@ -126,6 +140,7 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
PrecompiledAddressesBanach []common.Address
|
||||||
PrecompiledAddressesArchimedes []common.Address
|
PrecompiledAddressesArchimedes []common.Address
|
||||||
PrecompiledAddressesBerlin []common.Address
|
PrecompiledAddressesBerlin []common.Address
|
||||||
PrecompiledAddressesIstanbul []common.Address
|
PrecompiledAddressesIstanbul []common.Address
|
||||||
|
|
@ -149,11 +164,16 @@ func init() {
|
||||||
for k := range PrecompiledContractsArchimedes {
|
for k := range PrecompiledContractsArchimedes {
|
||||||
PrecompiledAddressesArchimedes = append(PrecompiledAddressesArchimedes, k)
|
PrecompiledAddressesArchimedes = append(PrecompiledAddressesArchimedes, k)
|
||||||
}
|
}
|
||||||
|
for k := range PrecompiledContractsBanach {
|
||||||
|
PrecompiledAddressesBanach = append(PrecompiledAddressesBanach, k)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivePrecompiles returns the precompiles enabled with the current configuration.
|
// ActivePrecompiles returns the precompiles enabled with the current configuration.
|
||||||
func ActivePrecompiles(rules params.Rules) []common.Address {
|
func ActivePrecompiles(rules params.Rules) []common.Address {
|
||||||
switch {
|
switch {
|
||||||
|
case rules.IsBanach:
|
||||||
|
return PrecompiledAddressesBanach
|
||||||
case rules.IsArchimedes:
|
case rules.IsArchimedes:
|
||||||
return PrecompiledAddressesArchimedes
|
return PrecompiledAddressesArchimedes
|
||||||
case rules.IsBerlin:
|
case rules.IsBerlin:
|
||||||
|
|
@ -309,6 +329,7 @@ var (
|
||||||
// modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198
|
// modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198
|
||||||
//
|
//
|
||||||
// def mult_complexity(x):
|
// def mult_complexity(x):
|
||||||
|
//
|
||||||
// if x <= 64: return x ** 2
|
// if x <= 64: return x ** 2
|
||||||
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
|
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
|
||||||
// else: return x ** 2 // 16 + 480 * x - 199680
|
// else: return x ** 2 // 16 + 480 * x - 199680
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ type (
|
||||||
func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
|
func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
|
||||||
var precompiles map[common.Address]PrecompiledContract
|
var precompiles map[common.Address]PrecompiledContract
|
||||||
switch {
|
switch {
|
||||||
|
case evm.chainRules.IsBanach:
|
||||||
|
precompiles = PrecompiledContractsBanach
|
||||||
case evm.chainRules.IsArchimedes:
|
case evm.chainRules.IsArchimedes:
|
||||||
precompiles = PrecompiledContractsArchimedes
|
precompiles = PrecompiledContractsArchimedes
|
||||||
case evm.chainRules.IsBerlin:
|
case evm.chainRules.IsBerlin:
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ func setDefaults(cfg *Config) {
|
||||||
BerlinBlock: new(big.Int),
|
BerlinBlock: new(big.Int),
|
||||||
LondonBlock: new(big.Int),
|
LondonBlock: new(big.Int),
|
||||||
ArchimedesBlock: new(big.Int),
|
ArchimedesBlock: new(big.Int),
|
||||||
|
BanachBlock: new(big.Int),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,6 +279,7 @@ var (
|
||||||
ArrowGlacierBlock: nil,
|
ArrowGlacierBlock: nil,
|
||||||
ArchimedesBlock: big.NewInt(2646311),
|
ArchimedesBlock: big.NewInt(2646311),
|
||||||
ShanghaiBlock: nil,
|
ShanghaiBlock: nil,
|
||||||
|
BanachBlock: nil,
|
||||||
Clique: &CliqueConfig{
|
Clique: &CliqueConfig{
|
||||||
Period: 3,
|
Period: 3,
|
||||||
Epoch: 30000,
|
Epoch: 30000,
|
||||||
|
|
@ -317,6 +318,7 @@ var (
|
||||||
ArrowGlacierBlock: nil,
|
ArrowGlacierBlock: nil,
|
||||||
ArchimedesBlock: big.NewInt(0),
|
ArchimedesBlock: big.NewInt(0),
|
||||||
ShanghaiBlock: big.NewInt(0),
|
ShanghaiBlock: big.NewInt(0),
|
||||||
|
BanachBlock: nil,
|
||||||
Clique: &CliqueConfig{
|
Clique: &CliqueConfig{
|
||||||
Period: 3,
|
Period: 3,
|
||||||
Epoch: 30000,
|
Epoch: 30000,
|
||||||
|
|
@ -355,6 +357,7 @@ var (
|
||||||
ArrowGlacierBlock: nil,
|
ArrowGlacierBlock: nil,
|
||||||
ArchimedesBlock: big.NewInt(0),
|
ArchimedesBlock: big.NewInt(0),
|
||||||
ShanghaiBlock: big.NewInt(0),
|
ShanghaiBlock: big.NewInt(0),
|
||||||
|
BanachBlock: nil,
|
||||||
Clique: &CliqueConfig{
|
Clique: &CliqueConfig{
|
||||||
Period: 3,
|
Period: 3,
|
||||||
Epoch: 30000,
|
Epoch: 30000,
|
||||||
|
|
@ -380,7 +383,7 @@ var (
|
||||||
//
|
//
|
||||||
// This configuration is intentionally not using keyed fields to force anyone
|
// This configuration is intentionally not using keyed fields to force anyone
|
||||||
// adding flags to the config to also have to set these fields.
|
// 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), nil, 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), nil, nil, nil, new(EthashConfig), nil,
|
||||||
ScrollConfig{
|
ScrollConfig{
|
||||||
UseZktrie: false,
|
UseZktrie: false,
|
||||||
FeeVaultAddress: nil,
|
FeeVaultAddress: nil,
|
||||||
|
|
@ -396,7 +399,7 @@ var (
|
||||||
//
|
//
|
||||||
// This configuration is intentionally not using keyed fields to force anyone
|
// This configuration is intentionally not using keyed fields to force anyone
|
||||||
// adding flags to the config to also have to set these fields.
|
// 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), nil, nil, 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), nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000},
|
||||||
ScrollConfig{
|
ScrollConfig{
|
||||||
UseZktrie: false,
|
UseZktrie: false,
|
||||||
FeeVaultAddress: nil,
|
FeeVaultAddress: nil,
|
||||||
|
|
@ -407,7 +410,7 @@ var (
|
||||||
L1Config: &L1Config{5, common.HexToAddress("0x0000000000000000000000000000000000000000"), 0, common.HexToAddress("0x0000000000000000000000000000000000000000")},
|
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), nil, 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), nil, nil, nil, new(EthashConfig), nil,
|
||||||
ScrollConfig{
|
ScrollConfig{
|
||||||
UseZktrie: false,
|
UseZktrie: false,
|
||||||
FeeVaultAddress: &common.Address{123},
|
FeeVaultAddress: &common.Address{123},
|
||||||
|
|
@ -419,7 +422,7 @@ var (
|
||||||
}}
|
}}
|
||||||
TestRules = TestChainConfig.Rules(new(big.Int))
|
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), nil, 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), nil, nil, nil, new(EthashConfig), nil,
|
||||||
ScrollConfig{
|
ScrollConfig{
|
||||||
UseZktrie: false,
|
UseZktrie: false,
|
||||||
FeeVaultAddress: nil,
|
FeeVaultAddress: nil,
|
||||||
|
|
@ -509,6 +512,7 @@ type ChainConfig struct {
|
||||||
ArrowGlacierBlock *big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
ArrowGlacierBlock *big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
||||||
ArchimedesBlock *big.Int `json:"archimedesBlock,omitempty"` // Archimedes switch block (nil = no fork, 0 = already on archimedes)
|
ArchimedesBlock *big.Int `json:"archimedesBlock,omitempty"` // Archimedes switch block (nil = no fork, 0 = already on archimedes)
|
||||||
ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch block (nil = no fork, 0 = already on shanghai)
|
ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch block (nil = no fork, 0 = already on shanghai)
|
||||||
|
BanachBlock *big.Int `json:"banachBlock,omitempty"` // Banach switch block (nil = no fork, 0 = already on banach)
|
||||||
|
|
||||||
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
||||||
// the network that triggers the consensus upgrade.
|
// the network that triggers the consensus upgrade.
|
||||||
|
|
@ -634,7 +638,7 @@ func (c *ChainConfig) String() string {
|
||||||
default:
|
default:
|
||||||
engine = "unknown"
|
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, 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, Banach: %v, Engine: %v, Scroll config: %v}",
|
||||||
c.ChainID,
|
c.ChainID,
|
||||||
c.HomesteadBlock,
|
c.HomesteadBlock,
|
||||||
c.DAOForkBlock,
|
c.DAOForkBlock,
|
||||||
|
|
@ -652,6 +656,7 @@ func (c *ChainConfig) String() string {
|
||||||
c.ArrowGlacierBlock,
|
c.ArrowGlacierBlock,
|
||||||
c.ArchimedesBlock,
|
c.ArchimedesBlock,
|
||||||
c.ShanghaiBlock,
|
c.ShanghaiBlock,
|
||||||
|
c.BanachBlock,
|
||||||
engine,
|
engine,
|
||||||
c.Scroll,
|
c.Scroll,
|
||||||
)
|
)
|
||||||
|
|
@ -734,6 +739,11 @@ func (c *ChainConfig) IsShanghai(num *big.Int) bool {
|
||||||
return isForked(c.ShanghaiBlock, num)
|
return isForked(c.ShanghaiBlock, num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsBanach returns whether num is either equal to the Banach fork block or greater.
|
||||||
|
func (c *ChainConfig) IsBanach(num *big.Int) bool {
|
||||||
|
return isForked(c.BanachBlock, num)
|
||||||
|
}
|
||||||
|
|
||||||
// IsTerminalPoWBlock returns whether the given block is the last block of PoW stage.
|
// IsTerminalPoWBlock returns whether the given block is the last block of PoW stage.
|
||||||
func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *big.Int) bool {
|
func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *big.Int) bool {
|
||||||
if c.TerminalTotalDifficulty == nil {
|
if c.TerminalTotalDifficulty == nil {
|
||||||
|
|
@ -785,6 +795,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||||
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
|
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
|
||||||
{name: "archimedesBlock", block: c.ArchimedesBlock, optional: true},
|
{name: "archimedesBlock", block: c.ArchimedesBlock, optional: true},
|
||||||
{name: "shanghaiBlock", block: c.ShanghaiBlock, optional: true},
|
{name: "shanghaiBlock", block: c.ShanghaiBlock, optional: true},
|
||||||
|
{name: "banachBlock", block: c.BanachBlock, optional: true},
|
||||||
} {
|
} {
|
||||||
if lastFork.name != "" {
|
if lastFork.name != "" {
|
||||||
// Next one must be higher number
|
// Next one must be higher number
|
||||||
|
|
@ -863,6 +874,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
|
||||||
if isForkIncompatible(c.ShanghaiBlock, newcfg.ShanghaiBlock, head) {
|
if isForkIncompatible(c.ShanghaiBlock, newcfg.ShanghaiBlock, head) {
|
||||||
return newCompatError("Shanghai fork block", c.ShanghaiBlock, newcfg.ShanghaiBlock)
|
return newCompatError("Shanghai fork block", c.ShanghaiBlock, newcfg.ShanghaiBlock)
|
||||||
}
|
}
|
||||||
|
if isForkIncompatible(c.BanachBlock, newcfg.BanachBlock, head) {
|
||||||
|
return newCompatError("Hard fork block", c.BanachBlock, newcfg.BanachBlock)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -931,6 +945,7 @@ type Rules struct {
|
||||||
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
|
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
|
||||||
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
||||||
IsBerlin, IsLondon, IsArchimedes, IsShanghai bool
|
IsBerlin, IsLondon, IsArchimedes, IsShanghai bool
|
||||||
|
IsBanach bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rules ensures c's ChainID is not nil.
|
// Rules ensures c's ChainID is not nil.
|
||||||
|
|
@ -953,5 +968,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
|
||||||
IsLondon: c.IsLondon(num),
|
IsLondon: c.IsLondon(num),
|
||||||
IsArchimedes: c.IsArchimedes(num),
|
IsArchimedes: c.IsArchimedes(num),
|
||||||
IsShanghai: c.IsShanghai(num),
|
IsShanghai: c.IsShanghai(num),
|
||||||
|
IsBanach: c.IsBanach(num),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 5 // Major version component of the current release
|
VersionMajor = 5 // Major version component of the current release
|
||||||
VersionMinor = 1 // Minor version component of the current release
|
VersionMinor = 1 // Minor version component of the current release
|
||||||
VersionPatch = 15 // Patch version component of the current release
|
VersionPatch = 16 // Patch version component of the current release
|
||||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,23 @@ var Forks = map[string]*params.ChainConfig{
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: big.NewInt(0),
|
||||||
ArchimedesBlock: big.NewInt(0),
|
ArchimedesBlock: big.NewInt(0),
|
||||||
},
|
},
|
||||||
|
"Banach": {
|
||||||
|
ChainID: big.NewInt(1),
|
||||||
|
HomesteadBlock: big.NewInt(0),
|
||||||
|
EIP150Block: big.NewInt(0),
|
||||||
|
EIP155Block: big.NewInt(0),
|
||||||
|
EIP158Block: big.NewInt(0),
|
||||||
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
|
PetersburgBlock: big.NewInt(0),
|
||||||
|
IstanbulBlock: big.NewInt(0),
|
||||||
|
MuirGlacierBlock: big.NewInt(0),
|
||||||
|
BerlinBlock: big.NewInt(0),
|
||||||
|
LondonBlock: big.NewInt(0),
|
||||||
|
ArrowGlacierBlock: big.NewInt(0),
|
||||||
|
ArchimedesBlock: big.NewInt(0),
|
||||||
|
BanachBlock: big.NewInt(0),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the set of defined fork names
|
// Returns the set of defined fork names
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue