Skip to content

Commit 0f96d8c

Browse files
committed
simulators/eth2/engine: Fix merge time prediction
1 parent 0dba5de commit 0f96d8c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

simulators/eth2/engine/helper.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ func combine(a, b *proxy.Spoof) *proxy.Spoof {
684684
// This function is used to calculate timeouts, so it will always return a pessimistic value.
685685
func SlotsUntilMerge(t *Testnet, c *Config) beacon.Slot {
686686
l := make([]beacon.Slot, 0)
687-
// TODO: Simply return zero to allow unlimited time
688687
l = append(l, SlotsUntilBellatrix(t.genesisTime, t.spec))
689688

690689
for i, e := range t.eth1 {
@@ -714,6 +713,7 @@ func SlotsUntilBellatrix(genesisTime beacon.Timestamp, spec *beacon.Spec) beacon
714713
if currentTimestamp >= bellatrixTime {
715714
return beacon.Slot(0)
716715
}
716+
fmt.Printf("INFO: bellatrixTime:%d, currentTimestamp:%d\n", bellatrixTime, currentTimestamp)
717717
return beacon.Slot((bellatrixTime-currentTimestamp)/spec.SECONDS_PER_SLOT) + 1
718718
}
719719

@@ -738,6 +738,7 @@ func TimeUntilTerminalBlock(e *Eth1Node, c setup.Eth1Consensus, defaultTTD *big.
738738
// TTD already reached
739739
return 0
740740
}
741+
fmt.Printf("INFO: ttd:%d, td:%d, diffPerBlock:%d, secondsPerBlock:%d\n", ttd, td, c.DifficultyPerBlock(), c.SecondsPerBlock())
741742
td.Sub(ttd, td).Div(td, c.DifficultyPerBlock()).Mul(td, big.NewInt(int64(c.SecondsPerBlock())))
742743
return td.Uint64()
743744
}

simulators/eth2/engine/setup/eth1config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ func (c Eth1CliqueConsensus) DifficultyPerBlock() *big.Int {
141141
}
142142

143143
func (c Eth1CliqueConsensus) SecondsPerBlock() uint64 {
144+
if c.CliquePeriod == 0 {
145+
return CLIQUE_PERIOD_DEFAULT
146+
}
144147
return c.CliquePeriod
145148
}
146149

0 commit comments

Comments
 (0)