Skip to content

Commit

Permalink
Rename Grace Period
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Sep 11, 2023
1 parent 61d308f commit 74b6fc4
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ See [RELEASE](./RELEASE.md) for workflow instructions.

### Upgrade information

A new config `poet-request-timeout` has been added, that defines the timeout for PoET requests. It defaults to 10 seconds.

### Highlights

### Features
Expand Down
7 changes: 4 additions & 3 deletions activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type PoetConfig struct {
PhaseShift time.Duration `mapstructure:"phase-shift"`
CycleGap time.Duration `mapstructure:"cycle-gap"`
GracePeriod time.Duration `mapstructure:"grace-period"`
RequestTimeout time.Duration `mapstructure:"poet-request-timeout"`
RequestRetryDelay time.Duration `mapstructure:"retry-delay"`
MaxRequestRetries int `mapstructure:"retry-max"`
}
Expand All @@ -50,7 +51,7 @@ const (
defaultPoetRetryInterval = 5 * time.Second

// Jitter added to the wait time before building a nipost challenge.
// It's expressed as % of poet grace period which translates to:
// It is expressed as % of poet grace period which translates to:
// mainnet (grace period 1h) -> 36s
// systest (grace period 10s) -> 0.1s
maxNipostChallengeBuildJitter = 1.0
Expand Down Expand Up @@ -727,6 +728,6 @@ func SignAndFinalizeAtx(signer *signing.EdSigner, atx *types.ActivationTx) error
}

func timeToWaitToBuildNipostChallenge(untilRoundStart, gracePeriod time.Duration) time.Duration {
jitter := randomDurationInRange(time.Duration(0), gracePeriod*maxNipostChallengeBuildJitter/100.0)
return untilRoundStart + jitter - gracePeriod
jitter := randomDurationInRange(time.Duration(0), gracePeriod * maxNipostChallengeBuildJitter/100.0)
return untilRoundStart + jitter
}
4 changes: 1 addition & 3 deletions activation/nipost.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,7 @@ func (nb *NIPostBuilder) getBestProof(ctx context.Context, challenge types.Hash3
case <-time.After(time.Until(waitDeadline)):
}

// TODO(mafa): this should be renamed from GracePeriod to something like RequestTimeout
// and should be much shorter (e.g. 10 seconds instead of 1 hour on mainnet)
getProofsCtx, cancel := context.WithTimeout(ctx, nb.poetCfg.GracePeriod)
getProofsCtx, cancel := context.WithTimeout(ctx, nb.poetCfg.RequestTimeout)
defer cancel()

proof, members, err := client.Proof(getProofsCtx, round)
Expand Down
2 changes: 2 additions & 0 deletions activation/nipost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func buildNIPost(tb testing.TB, postProvider *testPostManager, nipostChallenge t
PhaseShift: epoch / 5,
CycleGap: epoch / 10,
GracePeriod: epoch / 10,
RequestTimeout: epoch / 20,
RequestRetryDelay: epoch / 100,
MaxRequestRetries: 10,
}
Expand Down Expand Up @@ -244,6 +245,7 @@ func TestNewNIPostBuilderNotInitialized(t *testing.T) {
PhaseShift: epoch / 5,
CycleGap: epoch / 10,
GracePeriod: epoch / 10,
RequestTimeout: epoch / 20,
RequestRetryDelay: epoch / 100,
MaxRequestRetries: 10,
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ func AddCommands(cmd *cobra.Command) {
cmd.PersistentFlags().DurationVar(&cfg.POET.CycleGap, "cycle-gap",
cfg.POET.CycleGap, "cycle gap of poet server")
cmd.PersistentFlags().DurationVar(&cfg.POET.GracePeriod, "grace-period",
cfg.POET.GracePeriod, "propagation time for ATXs in the network")
cfg.POET.GracePeriod, "time before PoET round starts when the node builds and submits a challenge")
cmd.PersistentFlags().DurationVar(&cfg.POET.RequestTimeout, "poet-request-timeout",
cfg.POET.RequestTimeout, "timeout for poet requests")

/**======================== bootstrap data updater Flags ========================== **/
cmd.PersistentFlags().StringVar(&cfg.Bootstrap.URL, "bootstrap-url",
Expand Down
1 change: 1 addition & 0 deletions config/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func MainnetConfig() Config {
PhaseShift: 240 * time.Hour,
CycleGap: 12 * time.Hour,
GracePeriod: 1 * time.Hour,
RequestTimeout: 10 * time.Second,
RequestRetryDelay: 10 * time.Second,
MaxRequestRetries: 10,
},
Expand Down
1 change: 1 addition & 0 deletions config/presets/fastnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func fastnet() config.Config {
conf.Beacon.VotesLimit = 100

conf.POET.GracePeriod = 10 * time.Second
conf.POET.RequestTimeout = 3 * time.Second
conf.POET.CycleGap = 30 * time.Second
conf.POET.PhaseShift = 30 * time.Second

Expand Down
3 changes: 2 additions & 1 deletion config/presets/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ func standalone() config.Config {
conf.Beacon.VotesLimit = 100

conf.PoETServers = []string{"http://0.0.0.0:10010"}
conf.POET.GracePeriod = 5 * time.Second
conf.POET.GracePeriod = 10 * time.Second
conf.POET.RequestTimeout = 3 * time.Second
conf.POET.CycleGap = 30 * time.Second
conf.POET.PhaseShift = 30 * time.Second

Expand Down

0 comments on commit 74b6fc4

Please sign in to comment.