Skip to content

Commit

Permalink
Remove 1920000 from forkid list for Ethereum Classic
Browse files Browse the repository at this point in the history
  • Loading branch information
sorpaas committed Mar 24, 2020
1 parent acf1132 commit 269fdfe
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 9 deletions.
2 changes: 1 addition & 1 deletion consensus/ethash/consensus_classic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func accumulateECIP1017Rewards(config *params.ChainConfig, state *state.StateDB,
blockReward := FrontierBlockReward

// Ensure value 'era' is configured.
eraLen := config.ECIP1017EraRounds
eraLen := config.ECIP1017EraBlock
era := getBlockEra(header.Number, eraLen)
wr := getBlockWinnerRewardByEra(era, blockReward) // wr "winner reward". 5, 4, 3.2, 2.56, ...
wurs := getBlockWinnerRewardForUnclesByEra(era, uncles, blockReward) // wurs "winner uncle rewards"
Expand Down
3 changes: 3 additions & 0 deletions core/forkid/forkid.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func gatherForks(config *params.ChainConfig) []uint64 {
for i := 0; i < kind.NumField(); i++ {
// Fetch the next field and skip non-fork rules
field := kind.Field(i)
if field.Name == "DAOForkBlock" && !config.DAOForkSupport {
continue
}
if !strings.HasSuffix(field.Name, "Block") {
continue
}
Expand Down
109 changes: 109 additions & 0 deletions core/forkid/forkid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,115 @@ func TestCreation(t *testing.T) {
{2000000, ID{Hash: checksumToBytes(0xc25efa5c), Next: 0}}, // Future Istanbul block
},
},
// Classic test cases
{
params.ClassicChainConfig,
params.MainnetGenesisHash,
[]testcase{
{0, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}},
{1, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}},
{2, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}},
{3, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}},
{9, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}},
{10, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}},
{1149999, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}},
{1150000, ID{Hash: checksumToBytes(0x97c2c34c), Next: 2500000}},
{1150001, ID{Hash: checksumToBytes(0x97c2c34c), Next: 2500000}},
{2499999, ID{Hash: checksumToBytes(0x97c2c34c), Next: 2500000}},
{2500000, ID{Hash: checksumToBytes(0xdb06803f), Next: 3000000}},
{2500001, ID{Hash: checksumToBytes(0xdb06803f), Next: 3000000}},
{2999999, ID{Hash: checksumToBytes(0xdb06803f), Next: 3000000}},
{3000000, ID{Hash: checksumToBytes(0xaff4bed4), Next: 5000000}},
{3000001, ID{Hash: checksumToBytes(0xaff4bed4), Next: 5000000}},
{4999999, ID{Hash: checksumToBytes(0xaff4bed4), Next: 5000000}},
{5000000, ID{Hash: checksumToBytes(0xf79a63c0), Next: 5900000}},
{5000001, ID{Hash: checksumToBytes(0xf79a63c0), Next: 5900000}},
{5899999, ID{Hash: checksumToBytes(0xf79a63c0), Next: 5900000}},
{5900000, ID{Hash: checksumToBytes(0x744899d6), Next: 8772000}},
{5900001, ID{Hash: checksumToBytes(0x744899d6), Next: 8772000}},
{8771999, ID{Hash: checksumToBytes(0x744899d6), Next: 8772000}},
{8772000, ID{Hash: checksumToBytes(0x518b59c6), Next: 9573000}},
{8772001, ID{Hash: checksumToBytes(0x518b59c6), Next: 9573000}},
{9572999, ID{Hash: checksumToBytes(0x518b59c6), Next: 9573000}},
{9573000, ID{Hash: checksumToBytes(0x7ba22882), Next: 0}},
{9573001, ID{Hash: checksumToBytes(0x7ba22882), Next: 0}},
{10500838, ID{Hash: checksumToBytes(0x7ba22882), Next: 0}},
},
},
// Kotti test cases
{
params.KottiChainConfig,
params.KottiGenesisHash,
[]testcase{
{0, ID{Hash: checksumToBytes(0x0550152e), Next: 716617}},
{1, ID{Hash: checksumToBytes(0x0550152e), Next: 716617}},
{2, ID{Hash: checksumToBytes(0x0550152e), Next: 716617}},
{3, ID{Hash: checksumToBytes(0x0550152e), Next: 716617}},
{9, ID{Hash: checksumToBytes(0x0550152e), Next: 716617}},
{10, ID{Hash: checksumToBytes(0x0550152e), Next: 716617}},
{1149999, ID{Hash: checksumToBytes(0xa3270822), Next: 1705549}},
{1150000, ID{Hash: checksumToBytes(0xa3270822), Next: 1705549}},
{1150001, ID{Hash: checksumToBytes(0xa3270822), Next: 1705549}},
{2499999, ID{Hash: checksumToBytes(0x6f402821), Next: 5000000}},
{2500000, ID{Hash: checksumToBytes(0x6f402821), Next: 5000000}},
{2500001, ID{Hash: checksumToBytes(0x6f402821), Next: 5000000}},
{2999999, ID{Hash: checksumToBytes(0x6f402821), Next: 5000000}},
{3000000, ID{Hash: checksumToBytes(0x6f402821), Next: 5000000}},
{3000001, ID{Hash: checksumToBytes(0x6f402821), Next: 5000000}},
{4999999, ID{Hash: checksumToBytes(0x6f402821), Next: 5000000}},
{5000000, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{5000001, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{5899999, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{5900000, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{5900001, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{8771999, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{8772000, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{8772001, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{9572999, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{9573000, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{9573001, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{10500838, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{10500839, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
{10500840, ID{Hash: checksumToBytes(0xa4478350), Next: 0}},
},
},
// Mordor test cases
{
params.MordorChainConfig,
params.MordorGenesisHash,
[]testcase{
{0, ID{Hash: checksumToBytes(0x175782aa), Next: 301243}},
{1, ID{Hash: checksumToBytes(0x175782aa), Next: 301243}},
{2, ID{Hash: checksumToBytes(0x175782aa), Next: 301243}},
{3, ID{Hash: checksumToBytes(0x175782aa), Next: 301243}},
{9, ID{Hash: checksumToBytes(0x175782aa), Next: 301243}},
{10, ID{Hash: checksumToBytes(0x175782aa), Next: 301243}},
{1149999, ID{Hash: checksumToBytes(0xf42f5539), Next: 2000000}},
{1150000, ID{Hash: checksumToBytes(0xf42f5539), Next: 2000000}},
{1150001, ID{Hash: checksumToBytes(0xf42f5539), Next: 2000000}},
{2499999, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{2500000, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{2500001, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{2999999, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{3000000, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{3000001, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{4999999, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{5000000, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{5000001, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{5899999, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{5900000, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{5900001, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{8771999, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{8772000, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{8772001, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{9572999, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{9573000, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{9573001, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{10500838, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{10500839, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
{10500840, ID{Hash: checksumToBytes(0x61ec4044), Next: 0}},
},
},
}
for i, tt := range tests {
for j, ttt := range tt.cases {
Expand Down
10 changes: 5 additions & 5 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ var (
nil, // EIP160Block
nil, // ECIP1010PauseBlock
nil, // ECIP1010Length
nil, // ECIP1017EraRounds
nil, // ECIP1017EraBlock
nil, // DisposalBlock

nil, // MCIP0Block
Expand Down Expand Up @@ -259,7 +259,7 @@ var (
nil, // EIP160Block
nil, // ECIP1010PauseBlock
nil, // ECIP1010Length
nil, // ECIP1017EraRounds
nil, // ECIP1017EraBlock
nil, // DisposalBlock

nil, // MCIP0Block
Expand Down Expand Up @@ -296,7 +296,7 @@ var (
nil, // EIP160Block
nil, // ECIP1010PauseBlock
nil, // ECIP1010Length
nil, // ECIP1017EraRounds
nil, // ECIP1017EraBlock
nil, // DisposalBlock

nil, // MCIP0Block
Expand Down Expand Up @@ -388,7 +388,7 @@ type ChainConfig struct {
EIP160Block *big.Int `json:"eip160Block,omitempty"`
ECIP1010PauseBlock *big.Int `json:"ecip1010PauseBlock,omitempty"` // ECIP1010 pause HF block
ECIP1010Length *big.Int `json:"ecip1010Length,omitempty"` // ECIP1010 length
ECIP1017EraRounds *big.Int `json:"ecip1017EraRounds,omitempty"` // ECIP1017 era rounds
ECIP1017EraBlock *big.Int `json:"ecip1017EraBlock,omitempty"` // ECIP1017 era rounds
DisposalBlock *big.Int `json:"disposalBlock,omitempty"` // Bomb disposal HF block

MCIP0Block *big.Int `json:"mcip0Block,omitempty"` // Musicoin default block; no MCIP, just denotes chain pref
Expand Down Expand Up @@ -506,7 +506,7 @@ func (c *ChainConfig) IsEWASM(num *big.Int) bool {

// HasECIP1017 returns whether the chain is configured with ECIP1017.
func (c *ChainConfig) HasECIP1017() bool {
if c.ECIP1017EraRounds == nil {
if c.ECIP1017EraBlock == nil {
return false
} else {
return true
Expand Down
2 changes: 1 addition & 1 deletion params/config_classic.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
DisposalBlock: big.NewInt(5900000),
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
ECIP1017EraRounds: big.NewInt(5000000),
ECIP1017EraBlock: big.NewInt(5000000),
EIP160Block: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Expand Down
2 changes: 1 addition & 1 deletion params/config_kotti.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
PetersburgBlock: big.NewInt(1705549),
IstanbulBlock: big.NewInt(2200013),
DisposalBlock: big.NewInt(0),
ECIP1017EraRounds: big.NewInt(5000000),
ECIP1017EraBlock: big.NewInt(5000000),
EIP160Block: big.NewInt(0),
ECIP1010PauseBlock: big.NewInt(0),
ECIP1010Length: big.NewInt(2000000),
Expand Down
2 changes: 1 addition & 1 deletion params/config_mordor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (
PetersburgBlock: big.NewInt(301243),
IstanbulBlock: big.NewInt(999983),
DisposalBlock: big.NewInt(0),
ECIP1017EraRounds: big.NewInt(2000000),
ECIP1017EraBlock: big.NewInt(2000000),
EIP160Block: big.NewInt(0),
ECIP1010PauseBlock: big.NewInt(0),
ECIP1010Length: big.NewInt(2000000),
Expand Down

0 comments on commit 269fdfe

Please sign in to comment.