Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type EVMConfig struct {
StartingPeriod uint64 `required:"true" split_words:"true"`
ForcePeriod bool `default:"false" split_words:"true"`
FinalityThreshold uint64 `default:"342" split_words:"true"`
SlotsPerEpoch uint64 `default:"32" split_words:"true"`
}

// LoadEVMConfig loads EVM config from the environment and validates the fields
Expand Down
3 changes: 3 additions & 0 deletions chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (s *EVMConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad_DefaultValues() {
StartingPeriod: 500,
ForcePeriod: false,
FinalityThreshold: 342,
SlotsPerEpoch: 32,
})
}

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

c, err := config.LoadEVMConfig(1)

Expand All @@ -106,5 +108,6 @@ func (s *EVMConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad() {
StartingPeriod: 500,
ForcePeriod: true,
FinalityThreshold: 382,
SlotsPerEpoch: 16,
})
}
7 changes: 5 additions & 2 deletions chains/evm/prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Prover struct {
proverClient ProverClient

spec Spec
slotsPerEpoch uint64
finalityThreshold uint64
}

Expand All @@ -68,13 +69,15 @@ func NewProver(
lightClient LightClient,
spec Spec,
finalityTreshold uint64,
slotsPerEpoch uint64,
) *Prover {
return &Prover{
proverClient: proverClient,
spec: spec,
beaconClient: beaconClient,
lightClient: lightClient,
finalityThreshold: finalityTreshold,
slotsPerEpoch: slotsPerEpoch,
}
}

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

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

domain, err := p.beaconClient.Domain(context.Background(), SYNC_COMMITTEE_DOMAIN, phase0.Epoch(update.FinalizedHeader.Header.Slot/32))
domain, err := p.beaconClient.Domain(context.Background(), SYNC_COMMITTEE_DOMAIN, phase0.Epoch(update.FinalizedHeader.Header.Slot/p.slotsPerEpoch))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func main() {
}

lightClient := lightclient.NewLightClient(config.BeaconEndpoint)
p := prover.NewProver(proverClient, beaconProvider, lightClient, prover.Spec(config.Spec), config.FinalityThreshold)
p := prover.NewProver(proverClient, beaconProvider, lightClient, prover.Spec(config.Spec), config.FinalityThreshold, config.SlotsPerEpoch)
routerAddress := common.HexToAddress(config.Router)
stepHandler := handlers.NewStepEventHandler(msgChan, client, beaconProvider, p, routerAddress, id, domains)
rotateHandler := handlers.NewRotateHandler(msgChan, periodStore, p, id, domains, config.CommitteePeriodLength, latestPeriod)
Expand Down