Skip to content

Commit

Permalink
fix genesis EthUpgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Oct 3, 2024
1 parent 8e223b9 commit 43dde81
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func SetupGenesisBlock(
rawdb.WriteChainConfig(db, stored, newcfg)
return newcfg, stored, nil
}
params.SetEthUpgrades(storedcfg)
storedData, _ := json.Marshal(storedcfg)
// Check config compatibility and write the config. Compatibility errors
// are returned to the caller unless we're already at block zero.
Expand Down
42 changes: 21 additions & 21 deletions params/config_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,30 @@ type AvalancheContext struct {
// code in place of their Ethereum counterparts. The original Ethereum names
// should be restored for maintainability.
func SetEthUpgrades(c *ChainConfig) {
if c.ChainID != nil && AvalancheFujiChainID.Cmp(c.ChainID) == 0 {
c.BerlinBlock = big.NewInt(184985) // https://testnet.snowtrace.io/block/184985?chainid=43113, AP2 activation block
c.LondonBlock = big.NewInt(805078) // https://testnet.snowtrace.io/block/805078?chainid=43113, AP3 activation block
} else if c.ChainID != nil && AvalancheMainnetChainID.Cmp(c.ChainID) == 0 {
c.BerlinBlock = big.NewInt(1640340) // https://snowtrace.io/block/1640340?chainid=43114, AP2 activation block
c.LondonBlock = big.NewInt(3308552) // https://snowtrace.io/block/3308552?chainid=43114, AP3 activation block
} else {
// In testing or local networks, we only support enabling Berlin and London prior
// to the initially active time. This is likely to correspond to an intended block
// number of 0 as well.
initiallyActive := uint64(upgrade.InitiallyActiveTime.Unix())
extra := GetExtra(c)
if extra != nil && extra.ApricotPhase2BlockTimestamp != nil && *extra.ApricotPhase2BlockTimestamp <= initiallyActive && c.BerlinBlock == nil {
c.BerlinBlock = big.NewInt(0)
}
if extra != nil && extra.ApricotPhase3BlockTimestamp != nil && *extra.ApricotPhase3BlockTimestamp <= initiallyActive && c.LondonBlock == nil {
c.LondonBlock = big.NewInt(0)
}
}
extra := GetExtra(c)
if extra.DurangoBlockTimestamp != nil {
if extra != nil && extra.DurangoBlockTimestamp != nil {
c.ShanghaiTime = utils.NewUint64(*extra.DurangoBlockTimestamp)
}
if extra.EtnaTimestamp != nil {
if extra != nil && extra.EtnaTimestamp != nil {
c.CancunTime = utils.NewUint64(*extra.EtnaTimestamp)
}
}
Expand Down Expand Up @@ -184,25 +203,6 @@ func GetChainConfig(agoUpgrade upgrade.Config, chainID *big.Int) *ChainConfig {
NetworkUpgrades: getNetworkUpgrades(agoUpgrade),
},
)
if AvalancheFujiChainID.Cmp(c.ChainID) == 0 {
c.BerlinBlock = big.NewInt(184985) // https://testnet.snowtrace.io/block/184985?chainid=43113, AP2 activation block
c.LondonBlock = big.NewInt(805078) // https://testnet.snowtrace.io/block/805078?chainid=43113, AP3 activation block
} else if AvalancheMainnetChainID.Cmp(c.ChainID) == 0 {
c.BerlinBlock = big.NewInt(1640340) // https://snowtrace.io/block/1640340?chainid=43114, AP2 activation block
c.LondonBlock = big.NewInt(3308552) // https://snowtrace.io/block/3308552?chainid=43114, AP3 activation block
} else {
// In testing or local networks, we only support enabling Berlin and London prior
// to the initially active time. This is likely to correspond to an intended block
// number of 0 as well.
initiallyActive := uint64(upgrade.InitiallyActiveTime.Unix())
extra := GetExtra(c)
if extra.ApricotPhase2BlockTimestamp != nil && *extra.ApricotPhase2BlockTimestamp <= initiallyActive && c.BerlinBlock == nil {
c.BerlinBlock = big.NewInt(0)
}
if extra.ApricotPhase3BlockTimestamp != nil && *extra.ApricotPhase3BlockTimestamp <= initiallyActive && c.LondonBlock == nil {
c.LondonBlock = big.NewInt(0)
}
}
return c
}

Expand Down

0 comments on commit 43dde81

Please sign in to comment.