Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 5c81f6e

Browse files
authored
fix: setup slot number per network (#43)
1 parent 1c1a02b commit 5c81f6e

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

chains/evm/config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type EVMConfig struct {
2424
StartingPeriod uint64 `required:"true" split_words:"true"`
2525
ForcePeriod bool `default:"false" split_words:"true"`
2626
FinalityThreshold uint64 `default:"342" split_words:"true"`
27+
SlotsPerEpoch uint64 `default:"32" split_words:"true"`
2728
}
2829

2930
// LoadEVMConfig loads EVM config from the environment and validates the fields

chains/evm/config/config_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (s *EVMConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad_DefaultValues() {
6565
StartingPeriod: 500,
6666
ForcePeriod: false,
6767
FinalityThreshold: 342,
68+
SlotsPerEpoch: 32,
6869
})
6970
}
7071

@@ -85,6 +86,7 @@ func (s *EVMConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad() {
8586
os.Setenv("SPECTRE_DOMAINS_1_STARTING_PERIOD", "500")
8687
os.Setenv("SPECTRE_DOMAINS_1_FORCE_PERIOD", "true")
8788
os.Setenv("SPECTRE_DOMAINS_1_FINALITY_THRESHOLD", "382")
89+
os.Setenv("SPECTRE_DOMAINS_1_SLOTS_PER_EPOCH", "16")
8890

8991
c, err := config.LoadEVMConfig(1)
9092

@@ -106,5 +108,6 @@ func (s *EVMConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad() {
106108
StartingPeriod: 500,
107109
ForcePeriod: true,
108110
FinalityThreshold: 382,
111+
SlotsPerEpoch: 16,
109112
})
110113
}

chains/evm/prover/prover.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type Prover struct {
5959
proverClient ProverClient
6060

6161
spec Spec
62+
slotsPerEpoch uint64
6263
finalityThreshold uint64
6364
}
6465

@@ -68,13 +69,15 @@ func NewProver(
6869
lightClient LightClient,
6970
spec Spec,
7071
finalityTreshold uint64,
72+
slotsPerEpoch uint64,
7173
) *Prover {
7274
return &Prover{
7375
proverClient: proverClient,
7476
spec: spec,
7577
beaconClient: beaconClient,
7678
lightClient: lightClient,
7779
finalityThreshold: finalityTreshold,
80+
slotsPerEpoch: slotsPerEpoch,
7881
}
7982
}
8083

@@ -174,7 +177,7 @@ func (p *Prover) StepArgs() (*StepArgs, error) {
174177
}
175178
pubkeys := bootstrap.CurrentSyncCommittee.PubKeys
176179

177-
domain, err := p.beaconClient.Domain(context.Background(), SYNC_COMMITTEE_DOMAIN, phase0.Epoch(update.FinalizedHeader.Header.Slot/32))
180+
domain, err := p.beaconClient.Domain(context.Background(), SYNC_COMMITTEE_DOMAIN, phase0.Epoch(update.FinalizedHeader.Header.Slot/p.slotsPerEpoch))
178181
if err != nil {
179182
return nil, err
180183
}
@@ -213,7 +216,7 @@ func (p *Prover) RotateArgs(period uint64) (*RotateArgs, error) {
213216
finalizedNextSyncCommitteeBranch[0] = update.NextSyncCommitteeBranch[0]
214217
update.NextSyncCommitteeBranch = finalizedNextSyncCommitteeBranch
215218

216-
domain, err := p.beaconClient.Domain(context.Background(), SYNC_COMMITTEE_DOMAIN, phase0.Epoch(update.FinalizedHeader.Header.Slot/32))
219+
domain, err := p.beaconClient.Domain(context.Background(), SYNC_COMMITTEE_DOMAIN, phase0.Epoch(update.FinalizedHeader.Header.Slot/p.slotsPerEpoch))
217220
if err != nil {
218221
return nil, err
219222
}

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func main() {
128128
}
129129

130130
lightClient := lightclient.NewLightClient(config.BeaconEndpoint)
131-
p := prover.NewProver(proverClient, beaconProvider, lightClient, prover.Spec(config.Spec), config.FinalityThreshold)
131+
p := prover.NewProver(proverClient, beaconProvider, lightClient, prover.Spec(config.Spec), config.FinalityThreshold, config.SlotsPerEpoch)
132132
routerAddress := common.HexToAddress(config.Router)
133133
stepHandler := handlers.NewStepEventHandler(msgChan, client, beaconProvider, p, routerAddress, id, domains)
134134
rotateHandler := handlers.NewRotateHandler(msgChan, periodStore, p, id, domains, config.CommitteePeriodLength, latestPeriod)

0 commit comments

Comments
 (0)