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

Update interop genesis for Electra #13991

Merged
merged 1 commit into from
May 12, 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
4 changes: 4 additions & 0 deletions cmd/prysmctl/testnet/generate_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
19 changes: 18 additions & 1 deletion runtime/interop/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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,
Expand All @@ -143,6 +159,7 @@ func GethTestnetGenesis(genesisTime uint64, cfg *clparams.BeaconChainConfig) *co
},
ShanghaiTime: shanghaiTime,
CancunTime: cancunTime,
PragueTime: pragueTime,
}
da := defaultDepositContractAllocation(cfg.DepositContractAddress)
ma := minerAllocation()
Expand Down
Loading