diff --git a/chains/evm/config/config.go b/chains/evm/config/config.go index 4b317b7..ff7a431 100644 --- a/chains/evm/config/config.go +++ b/chains/evm/config/config.go @@ -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 diff --git a/chains/evm/config/config_test.go b/chains/evm/config/config_test.go index c72ad0c..471c7a8 100644 --- a/chains/evm/config/config_test.go +++ b/chains/evm/config/config_test.go @@ -65,6 +65,7 @@ func (s *EVMConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad_DefaultValues() { StartingPeriod: 500, ForcePeriod: false, FinalityThreshold: 342, + SlotsPerEpoch: 32, }) } @@ -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) @@ -106,5 +108,6 @@ func (s *EVMConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad() { StartingPeriod: 500, ForcePeriod: true, FinalityThreshold: 382, + SlotsPerEpoch: 16, }) } diff --git a/chains/evm/prover/prover.go b/chains/evm/prover/prover.go index 73fbb12..26bd8d1 100644 --- a/chains/evm/prover/prover.go +++ b/chains/evm/prover/prover.go @@ -59,6 +59,7 @@ type Prover struct { proverClient ProverClient spec Spec + slotsPerEpoch uint64 finalityThreshold uint64 } @@ -68,6 +69,7 @@ func NewProver( lightClient LightClient, spec Spec, finalityTreshold uint64, + slotsPerEpoch uint64, ) *Prover { return &Prover{ proverClient: proverClient, @@ -75,6 +77,7 @@ func NewProver( beaconClient: beaconClient, lightClient: lightClient, finalityThreshold: finalityTreshold, + slotsPerEpoch: slotsPerEpoch, } } @@ -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 } @@ -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 } diff --git a/main.go b/main.go index dec14a0..82d3f0b 100644 --- a/main.go +++ b/main.go @@ -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)