Skip to content

Commit 3e59974

Browse files
committed
fix panic
1 parent e0aaf1d commit 3e59974

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

cl/phase1/forkchoice/forkchoice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func NewForkChoiceStore(
297297
f.highestSeen.Store(anchorState.Slot())
298298
f.time.Store(anchorState.GenesisTime() + anchorState.BeaconConfig().SecondsPerSlot*anchorState.Slot())
299299

300-
f.ptcVote.Store(anchorRoot, [clparams.PtcSize]bool{})
300+
f.ptcVote.Store(common.Hash(anchorRoot), [clparams.PtcSize]bool{})
301301

302302
// [New in Gloas:EIP7732] Initialize indexed weight store
303303
f.indexedWeightStore = NewIndexedWeightStore(f)

cl/phase1/forkchoice/on_block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (f *ForkChoiceStore) OnBlock(ctx context.Context, block *cltypes.SignedBeac
265265
// [New in Gloas:EIP7732] GLOAS-specific on_block logic (post state transition)
266266
if isGloas {
267267
// Initialize PTC vote for this block
268-
f.ptcVote.Store(blockRoot, [clparams.PtcSize]bool{})
268+
f.ptcVote.Store(common.Hash(blockRoot), [clparams.PtcSize]bool{})
269269

270270
// Notify PTC messages from payload attestations in the block
271271
if block.Block.Body.PayloadAttestations != nil {

cl/phase1/forkchoice/utils.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,17 @@ func (f *ForkChoiceStore) onNewFinalized(newFinalized solid.Checkpoint) {
8080

8181
// [New in Gloas:EIP7732] Clean up ptcVote for finalized blocks
8282
// Note: envelope files are cleaned up in forkGraph.Prune()
83-
finalizedSlot := newFinalized.Epoch * f.beaconCfg.SlotsPerEpoch
84-
f.ptcVote.Range(func(k, v any) bool {
85-
root := k.(common.Hash)
86-
if header, has := f.forkGraph.GetHeader(root); !has || header.Slot <= finalizedSlot {
87-
f.ptcVote.Delete(k)
88-
}
89-
return true
90-
})
83+
if newFinalized.Epoch >= f.beaconCfg.GloasForkEpoch {
84+
finalizedSlot := newFinalized.Epoch * f.beaconCfg.SlotsPerEpoch
85+
f.ptcVote.Range(func(k, v any) bool {
86+
// Key is stored as common.Hash
87+
root := k.(common.Hash)
88+
if header, has := f.forkGraph.GetHeader(root); !has || header.Slot <= finalizedSlot {
89+
f.ptcVote.Delete(k)
90+
}
91+
return true
92+
})
93+
}
9194

9295
slotToPrune := ((newFinalized.Epoch - 3) * f.beaconCfg.SlotsPerEpoch) - 1
9396
f.forkGraph.Prune(slotToPrune)

0 commit comments

Comments
 (0)