Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support haber fix #420

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/system_contract_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func init() {
addCodeRecords(systemcontracts.FeynmanFixUpgrade[chainName], 0, blockTime, byChain)
}
}
if chainConfig.HaberFixTime != nil {
blockTime := chainConfig.HaberFixTime.Uint64()
if blockTime != 0 {
addCodeRecords(systemcontracts.HaberFixUpgrade[chainName], 0, blockTime, byChain)
}
}
}

addGnosisSpecialCase()
Expand Down
51 changes: 47 additions & 4 deletions core/systemcontracts/upgrade.go

Large diffs are not rendered by default.

29 changes: 23 additions & 6 deletions erigon-lib/chain/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type Config struct {
FeynmanFixTime *big.Int `json:"feynmanFixTime,omitempty"`
CancunTime *big.Int `json:"cancunTime,omitempty"`
HaberTime *big.Int `json:"haberTime,omitempty"`
HaberFixTime *big.Int `json:"haberFixTime,omitempty"`
BohrTime *big.Int `json:"bohrTime,omitempty"`
PragueTime *big.Int `json:"pragueTime,omitempty"`
OsakaTime *big.Int `json:"osakaTime,omitempty"`

Expand Down Expand Up @@ -124,7 +126,7 @@ func (c *Config) String() string {
engine := c.getEngine()

if c.Consensus == ParliaConsensus {
return fmt.Sprintf("{ChainID: %v Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v, Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, ShanghaiTime: %v, KeplerTime %v, FeynmanTime %v, FeynmanFixTime %v, CancunTime %v, HaberTime %v, Engine: %v}",
return fmt.Sprintf("{ChainID: %v Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v, Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, ShanghaiTime: %v, KeplerTime %v, FeynmanTime %v, FeynmanFixTime %v, CancunTime %v, HaberTime %v, HaberFixTime %v, Engine: %v}",
c.ChainID,
c.RamanujanBlock,
c.NielsBlock,
Expand All @@ -145,6 +147,7 @@ func (c *Config) String() string {
c.FeynmanFixTime,
c.CancunTime,
c.HaberTime,
c.HaberFixTime,
engine,
)
}
Expand Down Expand Up @@ -282,11 +285,6 @@ func (c *Config) IsCancun(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.CancunTime, time)
}

// IsHaber returns whether time is either equal to the Haber fork time or greater.
func (c *Config) IsHaber(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.HaberTime, time)
}

// IsPrague returns whether time is either equal to the Prague fork time or greater.
func (c *Config) IsPrague(time uint64) bool {
return isForked(c.PragueTime, time)
Expand Down Expand Up @@ -493,6 +491,25 @@ func (c *Config) IsOnFeynmanFix(currentBlockNumber *big.Int, lastBlockTime uint6
return !c.IsFeynmanFix(lastBlockNumber.Uint64(), lastBlockTime) && c.IsFeynmanFix(currentBlockNumber.Uint64(), currentBlockTime)
}

// IsHaber returns whether time is either equal to the Haber fork time or greater.
func (c *Config) IsHaber(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.HaberTime, time)
}

// IsHaber returns whether time is either equal to the Haber fork time or greater.
func (c *Config) IsHaberFix(num uint64, time uint64) bool {
return c.IsLondon(num) && isForked(c.HaberFixTime, time)
}

// IsOnHaberFix returns whether currentBlockTime is either equal to the HaberFix fork time or greater firstly.
func (c *Config) IsOnHaberFix(currentBlockNumber *big.Int, lastBlockTime uint64, currentBlockTime uint64) bool {
lastBlockNumber := new(big.Int)
if currentBlockNumber.Cmp(big.NewInt(1)) >= 0 {
lastBlockNumber.Sub(currentBlockNumber, big.NewInt(1))
}
return !c.IsHaberFix(lastBlockNumber.Uint64(), lastBlockTime) && c.IsHaberFix(currentBlockNumber.Uint64(), currentBlockTime)
}

// CheckCompatible checks whether scheduled fork transitions have been imported
// with a mismatching chain configuration.
func (c *Config) CheckCompatible(newcfg *Config, height uint64) *ConfigCompatError {
Expand Down
1 change: 1 addition & 0 deletions params/chainspecs/bsc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"feynmanFixTime": 1713419340,
"cancunTime": 1718863500,
"haberTime": 1718863500,
"haberFixTime": 1720591588,
"parlia": {
"DBPath": "",
"InMemory": false,
Expand Down
1 change: 1 addition & 0 deletions params/chainspecs/chapel.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"feynmanFixTime": 1711342800,
"cancunTime": 1713330442,
"haberTime": 1716962820,
"haberFixTime": 1719986788,
"parlia": {
"DBPath": "",
"InMemory": false,
Expand Down
1 change: 1 addition & 0 deletions params/chainspecs/rialto.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"feynmanFixTime":0,
"cancunTime": 0,
"haberTime": 0,
"haberFixTime": 0,
"parlia": {
"DBPath": "",
"InMemory": false,
Expand Down
Loading