Update interop genesis for Electra (#13991)

This commit is contained in:
terence
2024-05-12 09:34:02 -07:00
committed by GitHub
parent d71079e1d8
commit e4310aef73
2 changed files with 22 additions and 1 deletions

View File

@@ -273,6 +273,7 @@ func generateGenesis(ctx context.Context) (state.BeaconState, error) {
gen.Timestamp = f.GenesisTime
gen.Config.ShanghaiTime = interop.GethShanghaiTime(f.GenesisTime, params.BeaconConfig())
gen.Config.CancunTime = interop.GethCancunTime(f.GenesisTime, params.BeaconConfig())
gen.Config.PragueTime = interop.GethPragueTime(f.GenesisTime, params.BeaconConfig())
fields := logrus.Fields{}
if gen.Config.ShanghaiTime != nil {
@@ -281,6 +282,9 @@ func generateGenesis(ctx context.Context) (state.BeaconState, error) {
if gen.Config.CancunTime != nil {
fields["cancun"] = fmt.Sprintf("%d", *gen.Config.CancunTime)
}
if gen.Config.PragueTime != nil {
fields["prague"] = fmt.Sprintf("%d", *gen.Config.PragueTime)
}
log.WithFields(fields).Info("Setting fork geth times")
if v > version.Altair {
// set ttd to zero so EL goes post-merge immediately

View File

@@ -92,7 +92,7 @@ func GethShanghaiTime(genesisTime uint64, cfg *clparams.BeaconChainConfig) *uint
return shanghaiTime
}
// GethCancunTime calculates the absolute time of the shanghai (aka capella) fork block
// GethCancunTime calculates the absolute time of the cancun (aka deneb) fork block
// by adding the relative time of the capella the fork epoch to the given genesis timestamp.
func GethCancunTime(genesisTime uint64, cfg *clparams.BeaconChainConfig) *uint64 {
var cancunTime *uint64
@@ -107,6 +107,21 @@ func GethCancunTime(genesisTime uint64, cfg *clparams.BeaconChainConfig) *uint64
return cancunTime
}
// GethPragueTime calculates the absolute time of the prague (aka electra) fork block
// by adding the relative time of the capella the fork epoch to the given genesis timestamp.
func GethPragueTime(genesisTime uint64, cfg *clparams.BeaconChainConfig) *uint64 {
var pragueTime *uint64
if cfg.ElectraForkEpoch != math.MaxUint64 {
startSlot, err := slots.EpochStart(cfg.ElectraForkEpoch)
if err == nil {
startTime := slots.StartTime(genesisTime, startSlot)
newTime := uint64(startTime.Unix())
pragueTime = &newTime
}
}
return pragueTime
}
// GethTestnetGenesis creates a genesis.json for eth1 clients with a set of defaults suitable for ephemeral testnets,
// like in an e2e test. The parameters are minimal but the full value is returned unmarshaled so that it can be
// customized as desired.
@@ -118,6 +133,7 @@ func GethTestnetGenesis(genesisTime uint64, cfg *clparams.BeaconChainConfig) *co
shanghaiTime := GethShanghaiTime(genesisTime, cfg)
cancunTime := GethCancunTime(genesisTime, cfg)
pragueTime := GethPragueTime(genesisTime, cfg)
cc := &params.ChainConfig{
ChainID: big.NewInt(defaultTestChainId),
HomesteadBlock: bigz,
@@ -143,6 +159,7 @@ func GethTestnetGenesis(genesisTime uint64, cfg *clparams.BeaconChainConfig) *co
},
ShanghaiTime: shanghaiTime,
CancunTime: cancunTime,
PragueTime: pragueTime,
}
da := defaultDepositContractAllocation(cfg.DepositContractAddress)
ma := minerAllocation()