mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
params: fix fork ordering, add missing chain compatibility check
This commit is contained in:
parent
8dca6f1760
commit
c384f0216e
2 changed files with 25 additions and 23 deletions
|
|
@ -62,10 +62,10 @@ var (
|
|||
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
|
||||
EIP155Block: big.NewInt(2675000),
|
||||
EIP158Block: big.NewInt(2675000),
|
||||
IstanbulBlock: nil,
|
||||
ByzantiumBlock: big.NewInt(4370000),
|
||||
ConstantinopleBlock: big.NewInt(7280000),
|
||||
PetersburgBlock: big.NewInt(7280000),
|
||||
IstanbulBlock: nil,
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
||||
|
|
@ -100,10 +100,10 @@ var (
|
|||
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
|
||||
EIP155Block: big.NewInt(10),
|
||||
EIP158Block: big.NewInt(10),
|
||||
IstanbulBlock: nil,
|
||||
ByzantiumBlock: big.NewInt(1700000),
|
||||
ConstantinopleBlock: big.NewInt(4230000),
|
||||
PetersburgBlock: big.NewInt(4939394),
|
||||
IstanbulBlock: nil,
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
||||
|
|
@ -138,10 +138,10 @@ var (
|
|||
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
|
||||
EIP155Block: big.NewInt(3),
|
||||
EIP158Block: big.NewInt(3),
|
||||
IstanbulBlock: nil,
|
||||
ByzantiumBlock: big.NewInt(1035301),
|
||||
ConstantinopleBlock: big.NewInt(3660663),
|
||||
PetersburgBlock: big.NewInt(4321234),
|
||||
IstanbulBlock: nil,
|
||||
Clique: &CliqueConfig{
|
||||
Period: 15,
|
||||
Epoch: 30000,
|
||||
|
|
@ -177,10 +177,10 @@ var (
|
|||
EIP150Block: big.NewInt(0),
|
||||
EIP155Block: big.NewInt(0),
|
||||
EIP158Block: big.NewInt(0),
|
||||
IstanbulBlock: nil,
|
||||
ByzantiumBlock: big.NewInt(0),
|
||||
ConstantinopleBlock: big.NewInt(0),
|
||||
PetersburgBlock: big.NewInt(0),
|
||||
IstanbulBlock: nil,
|
||||
Clique: &CliqueConfig{
|
||||
Period: 15,
|
||||
Epoch: 30000,
|
||||
|
|
@ -213,16 +213,16 @@ 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), nil, 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), nil, nil, new(EthashConfig), nil}
|
||||
|
||||
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
|
||||
// and accepted by the Ethereum core developers into the Clique consensus.
|
||||
//
|
||||
// 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), nil, 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), nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}}
|
||||
|
||||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), nil, 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), nil, nil, new(EthashConfig), nil}
|
||||
TestRules = TestChainConfig.Rules(new(big.Int))
|
||||
)
|
||||
|
||||
|
|
@ -288,10 +288,10 @@ type ChainConfig struct {
|
|||
EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
|
||||
EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block
|
||||
|
||||
IstanbulBlock *big.Int `json:"istanbulBlock,omitempty"` // Istanbul switch block (nil = no fork, 0 = already on istanbul)
|
||||
ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
|
||||
ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
|
||||
PetersburgBlock *big.Int `json:"petersburgBlock,omitempty"` // Petersburg switch block (nil = same as Constantinople)
|
||||
IstanbulBlock *big.Int `json:"istanbulBlock,omitempty"` // Istanbul switch block (nil = no fork, 0 = already on istanbul)
|
||||
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)
|
||||
|
||||
// Various consensus engines
|
||||
|
|
@ -329,7 +329,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 Engine: %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 Engine: %v}",
|
||||
c.ChainID,
|
||||
c.HomesteadBlock,
|
||||
c.DAOForkBlock,
|
||||
|
|
@ -337,10 +337,10 @@ func (c *ChainConfig) String() string {
|
|||
c.EIP150Block,
|
||||
c.EIP155Block,
|
||||
c.EIP158Block,
|
||||
c.IstanbulBlock,
|
||||
c.ByzantiumBlock,
|
||||
c.ConstantinopleBlock,
|
||||
c.PetersburgBlock,
|
||||
c.IstanbulBlock,
|
||||
engine,
|
||||
)
|
||||
}
|
||||
|
|
@ -370,11 +370,6 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
|
|||
return isForked(c.EIP158Block, num)
|
||||
}
|
||||
|
||||
// IsIstanbul returns whether num is either equal to the Istanbul fork block or greater.
|
||||
func (c *ChainConfig) IsIstanbul(num *big.Int) bool {
|
||||
return isForked(c.IstanbulBlock, num)
|
||||
}
|
||||
|
||||
// IsByzantium returns whether num is either equal to the Byzantium fork block or greater.
|
||||
func (c *ChainConfig) IsByzantium(num *big.Int) bool {
|
||||
return isForked(c.ByzantiumBlock, num)
|
||||
|
|
@ -392,6 +387,11 @@ func (c *ChainConfig) IsPetersburg(num *big.Int) bool {
|
|||
return isForked(c.PetersburgBlock, num) || c.PetersburgBlock == nil && isForked(c.ConstantinopleBlock, num)
|
||||
}
|
||||
|
||||
// IsIstanbul returns whether num is either equal to the Istanbul fork block or greater.
|
||||
func (c *ChainConfig) IsIstanbul(num *big.Int) bool {
|
||||
return isForked(c.IstanbulBlock, num)
|
||||
}
|
||||
|
||||
// IsEWASM returns whether num represents a block number after the EWASM fork
|
||||
func (c *ChainConfig) IsEWASM(num *big.Int) bool {
|
||||
return isForked(c.EWASMBlock, num)
|
||||
|
|
@ -446,6 +446,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
|
|||
if isForkIncompatible(c.PetersburgBlock, newcfg.PetersburgBlock, head) {
|
||||
return newCompatError("Petersburg fork block", c.PetersburgBlock, newcfg.PetersburgBlock)
|
||||
}
|
||||
if isForkIncompatible(c.IstanbulBlock, newcfg.IstanbulBlock, head) {
|
||||
return newCompatError("Istanbul fork block", c.IstanbulBlock, newcfg.IstanbulBlock)
|
||||
}
|
||||
if isForkIncompatible(c.EWASMBlock, newcfg.EWASMBlock, head) {
|
||||
return newCompatError("ewasm fork block", c.EWASMBlock, newcfg.EWASMBlock)
|
||||
}
|
||||
|
|
@ -515,7 +518,7 @@ func (err *ConfigCompatError) Error() string {
|
|||
type Rules struct {
|
||||
ChainID *big.Int
|
||||
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
|
||||
IsIstanbul, IsByzantium, IsConstantinople, IsPetersburg bool
|
||||
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
||||
}
|
||||
|
||||
// Rules ensures c's ChainID is not nil.
|
||||
|
|
@ -530,9 +533,9 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
|
|||
IsEIP150: c.IsEIP150(num),
|
||||
IsEIP155: c.IsEIP155(num),
|
||||
IsEIP158: c.IsEIP158(num),
|
||||
IsIstanbul: c.IsIstanbul(num),
|
||||
IsByzantium: c.IsByzantium(num),
|
||||
IsConstantinople: c.IsConstantinople(num),
|
||||
IsPetersburg: c.IsPetersburg(num),
|
||||
IsIstanbul: c.IsIstanbul(num),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,15 +107,14 @@ const (
|
|||
IdentityBaseGas uint64 = 15 // Base price for a data copy operation
|
||||
IdentityPerWordGas uint64 = 3 // Per-work price for a data copy operation
|
||||
ModExpQuadCoeffDiv uint64 = 20 // Divisor for the quadratic particle of the big int modular exponentiation
|
||||
// Byzantium precompiled elliptic curve contract gas prices
|
||||
|
||||
Bn256AddGasByzantium uint64 = 500 // Byzantium gas needed for an elliptic curve addition
|
||||
Bn256ScalarMulGasByzantium uint64 = 40000 // Byzantium gas needed for an elliptic curve scalar multiplication
|
||||
Bn256PairingBaseGasByzantium uint64 = 100000 // Byzantium base price for an elliptic curve pairing check
|
||||
Bn256PairingPerPointGasByzantium uint64 = 80000 // Byzantium per-point price for an elliptic curve pairing check
|
||||
// Precompiled elliptic curve contract gas prices were reduced in Istanbul via EIP-1108
|
||||
Bn256AddGasIstanbul uint64 = 150 // Gas needed for an elliptic curve addition
|
||||
Bn256ScalarMulGasByzantium uint64 = 40000 // Byzantium gas needed for an elliptic curve scalar multiplication
|
||||
Bn256ScalarMulGasIstanbul uint64 = 6000 // Gas needed for an elliptic curve scalar multiplication
|
||||
Bn256PairingBaseGasByzantium uint64 = 100000 // Byzantium base price for an elliptic curve pairing check
|
||||
Bn256PairingBaseGasIstanbul uint64 = 45000 // Base price for an elliptic curve pairing check
|
||||
Bn256PairingPerPointGasByzantium uint64 = 80000 // Byzantium per-point price for an elliptic curve pairing check
|
||||
Bn256PairingPerPointGasIstanbul uint64 = 34000 // Per-point price for an elliptic curve pairing check
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue