params: define prague block #26481 #26880 (#1836)

This commit is contained in:
Daniel Liu 2025-12-07 18:06:02 +08:00 committed by GitHub
parent e617598d1d
commit c6c5778632
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 87 additions and 18 deletions

View file

@ -64,6 +64,7 @@ type constant struct {
tipEpochHalving *big.Int tipEpochHalving *big.Int
eip1559Block *big.Int eip1559Block *big.Int
cancunBlock *big.Int cancunBlock *big.Int
pragueBlock *big.Int
trc21IssuerSMC Address trc21IssuerSMC Address
xdcxListingSMC Address xdcxListingSMC Address
@ -98,6 +99,7 @@ var (
TIPXDCXReceiverDisable = MainnetConstant.tipXDCXReceiverDisable TIPXDCXReceiverDisable = MainnetConstant.tipXDCXReceiverDisable
Eip1559Block = MainnetConstant.eip1559Block Eip1559Block = MainnetConstant.eip1559Block
CancunBlock = MainnetConstant.cancunBlock CancunBlock = MainnetConstant.cancunBlock
PragueBlock = MainnetConstant.pragueBlock
TIPUpgradeReward = MainnetConstant.tipUpgradeReward TIPUpgradeReward = MainnetConstant.tipUpgradeReward
TipUpgradePenalty = MainnetConstant.tipUpgradePenalty TipUpgradePenalty = MainnetConstant.tipUpgradePenalty
TIPEpochHalving = MainnetConstant.tipEpochHalving TIPEpochHalving = MainnetConstant.tipEpochHalving
@ -160,6 +162,7 @@ func CopyConstants(chainID uint64) {
TIPXDCXReceiverDisable = c.tipXDCXReceiverDisable TIPXDCXReceiverDisable = c.tipXDCXReceiverDisable
Eip1559Block = c.eip1559Block Eip1559Block = c.eip1559Block
CancunBlock = c.cancunBlock CancunBlock = c.cancunBlock
PragueBlock = c.pragueBlock
TIPUpgradeReward = c.tipUpgradeReward TIPUpgradeReward = c.tipUpgradeReward
TipUpgradePenalty = c.tipUpgradePenalty TipUpgradePenalty = c.tipUpgradePenalty
TIPEpochHalving = c.tipEpochHalving TIPEpochHalving = c.tipEpochHalving

View file

@ -1,6 +1,7 @@
package common package common
import ( import (
"math"
"math/big" "math/big"
) )
@ -28,6 +29,7 @@ var DevnetConstant = constant{
tipXDCXReceiverDisable: big.NewInt(0), tipXDCXReceiverDisable: big.NewInt(0),
eip1559Block: big.NewInt(32400), eip1559Block: big.NewInt(32400),
cancunBlock: big.NewInt(43200), cancunBlock: big.NewInt(43200),
pragueBlock: big.NewInt(math.MaxInt64),
tipUpgradeReward: big.NewInt(9999999999), tipUpgradeReward: big.NewInt(9999999999),
tipUpgradePenalty: big.NewInt(9999999999), tipUpgradePenalty: big.NewInt(9999999999),
tipEpochHalving: big.NewInt(9999999999), tipEpochHalving: big.NewInt(9999999999),

View file

@ -1,6 +1,7 @@
package common package common
import ( import (
"math"
"math/big" "math/big"
) )
@ -28,6 +29,7 @@ var localConstant = constant{
tipXDCXReceiverDisable: big.NewInt(0), tipXDCXReceiverDisable: big.NewInt(0),
eip1559Block: big.NewInt(0), eip1559Block: big.NewInt(0),
cancunBlock: big.NewInt(0), cancunBlock: big.NewInt(0),
pragueBlock: big.NewInt(math.MaxInt64),
tipUpgradeReward: big.NewInt(999999999), tipUpgradeReward: big.NewInt(999999999),
tipUpgradePenalty: big.NewInt(999999999), tipUpgradePenalty: big.NewInt(999999999),
tipEpochHalving: big.NewInt(999999999), tipEpochHalving: big.NewInt(999999999),

View file

@ -1,6 +1,7 @@
package common package common
import ( import (
"math"
"math/big" "math/big"
) )
@ -28,6 +29,7 @@ var MainnetConstant = constant{
tipXDCXReceiverDisable: big.NewInt(80370900), // Target 2nd Oct 2024, safer to release after disable miner tipXDCXReceiverDisable: big.NewInt(80370900), // Target 2nd Oct 2024, safer to release after disable miner
eip1559Block: big.NewInt(9999999999), eip1559Block: big.NewInt(9999999999),
cancunBlock: big.NewInt(9999999999), cancunBlock: big.NewInt(9999999999),
pragueBlock: big.NewInt(math.MaxInt64),
tipUpgradeReward: big.NewInt(9999999999), tipUpgradeReward: big.NewInt(9999999999),
tipUpgradePenalty: big.NewInt(9999999999), tipUpgradePenalty: big.NewInt(9999999999),
tipEpochHalving: big.NewInt(9999999999), tipEpochHalving: big.NewInt(9999999999),

View file

@ -1,6 +1,7 @@
package common package common
import ( import (
"math"
"math/big" "math/big"
) )
@ -28,6 +29,7 @@ var TestnetConstant = constant{
tipXDCXReceiverDisable: big.NewInt(66825000), // Target 26 Aug 2024 tipXDCXReceiverDisable: big.NewInt(66825000), // Target 26 Aug 2024
eip1559Block: big.NewInt(71550000), // Target 14th Feb 2025 eip1559Block: big.NewInt(71550000), // Target 14th Feb 2025
cancunBlock: big.NewInt(71551800), cancunBlock: big.NewInt(71551800),
pragueBlock: big.NewInt(math.MaxInt64),
tipUpgradeReward: big.NewInt(9999999999), tipUpgradeReward: big.NewInt(9999999999),
tipUpgradePenalty: big.NewInt(9999999999), tipUpgradePenalty: big.NewInt(9999999999),
tipEpochHalving: big.NewInt(9999999999), tipEpochHalving: big.NewInt(9999999999),

View file

@ -121,15 +121,15 @@ var createGasTests = []struct {
// legacy create(0, 0, 0xc000) _with_ 3860 // legacy create(0, 0, 0xc000) _with_ 3860
{"0x61C00060006000f0" + "600052" + "60206000F3", true, 44309, 44309}, {"0x61C00060006000f0" + "600052" + "60206000F3", true, 44309, 44309},
// create2(0, 0, 0xc001, 0) without 3860 // create2(0, 0, 0xc001, 0) without 3860
{"0x600061C00160006000f5" + "600052" + "60206000F3", false, 50471, 100_000}, {"0x600061C00160006000f5" + "600052" + "60206000F3", false, 50471, 50471},
// create2(0, 0, 0xc001, 0) (too large), with 3860 // create2(0, 0, 0xc001, 0) (too large), with 3860
{"0x600061C00160006000f5" + "600052" + "60206000F3", true, 32012, 100_000}, {"0x600061C00160006000f5" + "600052" + "60206000F3", true, 32012, 100000},
// create2(0, 0, 0xc000, 0) // create2(0, 0, 0xc000, 0)
// This case is trying to deploy code at (within) the limit // This case is trying to deploy code at (within) the limit
{"0x600061C00060006000f5" + "600052" + "60206000F3", true, 53528, 100_000}, {"0x600061C00060006000f5" + "600052" + "60206000F3", true, 53528, 53528},
// create2(0, 0, 0xc001, 0) // create2(0, 0, 0xc001, 0)
// This case is trying to deploy code exceeding the limit // This case is trying to deploy code exceeding the limit
{"0x600061C00160006000f5" + "600052" + "60206000F3", true, 32024, 100_000}} {"0x600061C00160006000f5" + "600052" + "60206000F3", true, 32024, 100000}}
func TestCreateGas(t *testing.T) { func TestCreateGas(t *testing.T) {
for i, tt := range createGasTests { for i, tt := range createGasTests {

View file

@ -17,6 +17,8 @@
package vm package vm
import ( import (
"errors"
"github.com/XinFinOrg/XDPoSChain/params" "github.com/XinFinOrg/XDPoSChain/params"
) )
@ -24,6 +26,8 @@ import (
// the rules. // the rules.
func LookupInstructionSet(rules params.Rules) (JumpTable, error) { func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
switch { switch {
case rules.IsPrague:
return newCancunInstructionSet(), errors.New("prague-fork not defined yet")
case rules.IsCancun: case rules.IsCancun:
return newCancunInstructionSet(), nil return newCancunInstructionSet(), nil
case rules.IsEIP1559: case rules.IsEIP1559:

View file

@ -314,9 +314,6 @@ var (
// AllEthashProtocolChanges contains every protocol change (EIPs) introduced // AllEthashProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Ethash consensus. // and accepted by the Ethereum core developers into the Ethash consensus.
//
// 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{ AllEthashProtocolChanges = &ChainConfig{
ChainID: big.NewInt(1337), ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
@ -326,7 +323,15 @@ var (
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: nil, ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiBlock: big.NewInt(0),
Eip1559Block: nil,
CancunBlock: nil,
PragueBlock: nil,
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
Clique: nil, Clique: nil,
XDPoS: nil, XDPoS: nil,
@ -352,6 +357,8 @@ var (
XDPoS: &XDPoSConfig{Period: 0, Epoch: 900}, XDPoS: &XDPoSConfig{Period: 0, Epoch: 900},
} }
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus.
AllCliqueProtocolChanges = &ChainConfig{ AllCliqueProtocolChanges = &ChainConfig{
ChainID: big.NewInt(1337), ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
@ -361,7 +368,15 @@ var (
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: nil, ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiBlock: big.NewInt(0),
Eip1559Block: nil,
CancunBlock: nil,
PragueBlock: nil,
Ethash: nil, Ethash: nil,
Clique: &CliqueConfig{Period: 0, Epoch: 900}, Clique: &CliqueConfig{Period: 0, Epoch: 900},
XDPoS: nil, XDPoS: nil,
@ -395,6 +410,8 @@ var (
}, },
} }
// TestChainConfig contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers for testing purposes.
TestChainConfig = &ChainConfig{ TestChainConfig = &ChainConfig{
ChainID: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
@ -404,7 +421,15 @@ var (
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: nil, ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiBlock: big.NewInt(0),
Eip1559Block: nil,
CancunBlock: nil,
PragueBlock: nil,
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
Clique: nil, Clique: nil,
XDPoS: nil, XDPoS: nil,
@ -441,6 +466,7 @@ type ChainConfig struct {
ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"`
Eip1559Block *big.Int `json:"eip1559Block,omitempty"` Eip1559Block *big.Int `json:"eip1559Block,omitempty"`
CancunBlock *big.Int `json:"cancunBlock,omitempty"` CancunBlock *big.Int `json:"cancunBlock,omitempty"`
PragueBlock *big.Int `json:"pragueBlock,omitempty"`
// Various consensus engines // Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"` Ethash *EthashConfig `json:"ethash,omitempty"`
@ -761,6 +787,9 @@ func (c *ChainConfig) String() string {
if c.CancunBlock != nil { if c.CancunBlock != nil {
result += fmt.Sprintf(", CancunBlock: %v", c.CancunBlock) result += fmt.Sprintf(", CancunBlock: %v", c.CancunBlock)
} }
if c.PragueBlock != nil {
result += fmt.Sprintf(", PragueBlock: %v", c.PragueBlock)
}
if c.XDPoS != nil { if c.XDPoS != nil {
result += fmt.Sprintf(", %s", c.XDPoS.String()) result += fmt.Sprintf(", %s", c.XDPoS.String())
} }
@ -803,6 +832,10 @@ func (c *ChainConfig) Description() string {
if c.CancunBlock != nil { if c.CancunBlock != nil {
cancunBlock = c.CancunBlock cancunBlock = c.CancunBlock
} }
pragueBlock := common.PragueBlock
if c.PragueBlock != nil {
pragueBlock = c.PragueBlock
}
var banner = "Chain configuration:\n" var banner = "Chain configuration:\n"
banner += fmt.Sprintf(" - ChainID: %-8v\n", c.ChainID) banner += fmt.Sprintf(" - ChainID: %-8v\n", c.ChainID)
@ -821,6 +854,7 @@ func (c *ChainConfig) Description() string {
banner += fmt.Sprintf(" - Shanghai: %-8v\n", shanghaiBlock) banner += fmt.Sprintf(" - Shanghai: %-8v\n", shanghaiBlock)
banner += fmt.Sprintf(" - Eip1559: %-8v\n", eip1559Block) banner += fmt.Sprintf(" - Eip1559: %-8v\n", eip1559Block)
banner += fmt.Sprintf(" - Cancun: %-8v\n", cancunBlock) banner += fmt.Sprintf(" - Cancun: %-8v\n", cancunBlock)
banner += fmt.Sprintf(" - Prague: %-8v\n", pragueBlock)
banner += fmt.Sprintf(" - TIPUpgradeReward: %-8v\n", common.TIPUpgradeReward) banner += fmt.Sprintf(" - TIPUpgradeReward: %-8v\n", common.TIPUpgradeReward)
banner += fmt.Sprintf(" - TIPEpochHalving: %-8v\n", common.TIPEpochHalving) banner += fmt.Sprintf(" - TIPEpochHalving: %-8v\n", common.TIPEpochHalving)
banner += fmt.Sprintf(" - Engine: %v", engine) banner += fmt.Sprintf(" - Engine: %v", engine)
@ -890,14 +924,21 @@ func (c *ChainConfig) IsShanghai(num *big.Int) bool {
return isForked(common.ShanghaiBlock, num) || isForked(c.ShanghaiBlock, num) return isForked(common.ShanghaiBlock, num) || isForked(c.ShanghaiBlock, num)
} }
// IsEIP1559 returns whether num is either equal to the EIP1559 fork block or greater.
func (c *ChainConfig) IsEIP1559(num *big.Int) bool { func (c *ChainConfig) IsEIP1559(num *big.Int) bool {
return isForked(common.Eip1559Block, num) || isForked(c.Eip1559Block, num) return isForked(common.Eip1559Block, num) || isForked(c.Eip1559Block, num)
} }
// IsCancun returns whether num is either equal to the Cancun fork block or greater.
func (c *ChainConfig) IsCancun(num *big.Int) bool { func (c *ChainConfig) IsCancun(num *big.Int) bool {
return isForked(common.CancunBlock, num) || isForked(c.CancunBlock, num) return isForked(common.CancunBlock, num) || isForked(c.CancunBlock, num)
} }
// IsPrague returns whether num is either equal to the Prague fork block or greater.
func (c *ChainConfig) IsPrague(num *big.Int) bool {
return isForked(common.PragueBlock, num) || isForked(c.PragueBlock, num)
}
func (c *ChainConfig) IsTIP2019(num *big.Int) bool { func (c *ChainConfig) IsTIP2019(num *big.Int) bool {
return isForked(common.TIP2019Block, num) return isForked(common.TIP2019Block, num)
} }
@ -1043,6 +1084,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if isForkIncompatible(c.CancunBlock, newcfg.CancunBlock, head) { if isForkIncompatible(c.CancunBlock, newcfg.CancunBlock, head) {
return newCompatError("Cancun fork block", c.CancunBlock, newcfg.CancunBlock) return newCompatError("Cancun fork block", c.CancunBlock, newcfg.CancunBlock)
} }
if isForkIncompatible(c.PragueBlock, newcfg.PragueBlock, head) {
return newCompatError("Prague fork block", c.PragueBlock, newcfg.PragueBlock)
}
if !XDPoSConfigEqual(c.XDPoS, newcfg.XDPoS) { if !XDPoSConfigEqual(c.XDPoS, newcfg.XDPoS) {
storedblock := big.NewInt(1) storedblock := big.NewInt(1)
if c.XDPoS != nil && c.XDPoS.V2 != nil && c.XDPoS.V2.SwitchBlock != nil { if c.XDPoS != nil && c.XDPoS.V2 != nil && c.XDPoS.V2.SwitchBlock != nil {
@ -1118,14 +1162,23 @@ func (err *ConfigCompatError) Error() string {
// Rules is a one time interface meaning that it shouldn't be used in between transition // Rules is a one time interface meaning that it shouldn't be used in between transition
// phases. // phases.
type Rules struct { type Rules struct {
ChainId *big.Int ChainId *big.Int
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool IsHomestead bool
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool IsEIP150 bool
IsBerlin, IsLondon bool IsEIP155 bool
IsMerge, IsShanghai bool IsEIP158 bool
IsXDCxDisable bool IsByzantium bool
IsEIP1559 bool IsConstantinople bool
IsCancun bool IsPetersburg bool
IsIstanbul bool
IsBerlin bool
IsLondon bool
IsMerge bool
IsShanghai bool
IsXDCxDisable bool
IsEIP1559 bool
IsCancun bool
IsPrague bool
} }
func (c *ChainConfig) Rules(num *big.Int) Rules { func (c *ChainConfig) Rules(num *big.Int) Rules {
@ -1150,5 +1203,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
IsXDCxDisable: c.IsXDCxDisable(num), IsXDCxDisable: c.IsXDCxDisable(num),
IsEIP1559: c.IsEIP1559(num), IsEIP1559: c.IsEIP1559(num),
IsCancun: c.IsCancun(num), IsCancun: c.IsCancun(num),
IsPrague: c.IsPrague(num),
} }
} }