-
Notifications
You must be signed in to change notification settings - Fork 150
boole-convergence polish: gating docs, startup fork validation, spectest bound (#2968 items 4, 6, 7) #2973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: stage
Are you sure you want to change the base?
boole-convergence polish: gating docs, startup fork validation, spectest bound (#2968 items 4, 6, 7) #2973
Changes from all commits
0c04f7e
b8a834b
c0411b7
8e85bcc
0a6d483
4b8bf87
0fe941f
dc125fa
49c4927
7c32997
401a1cc
699a9a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,6 +202,131 @@ func TestBooleForkAtSlot(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestNetworkValidate(t *testing.T) { | ||
|
iurii-ssv marked this conversation as resolved.
|
||
| domainAlan := spectypes.DomainType{0x01, 0x02, 0x03, 0x04} | ||
| domainBoole := spectypes.DomainType{0x05, 0x06, 0x07, 0x08} | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| boole phase0.Epoch | ||
| currentEpoch phase0.Epoch // wall-clock epoch the config is validated at | ||
| preGenesis bool // put GenesisTime in the future (overrides currentEpoch) | ||
| slotsPerEpoch uint64 | ||
| domainType spectypes.DomainType | ||
| nextDomainType spectypes.DomainType | ||
| expectErr bool | ||
| }{ | ||
| { | ||
| name: "hard_error_zero_slots_per_epoch", | ||
| boole: 10, | ||
| slotsPerEpoch: 0, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainBoole, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "hard_error_zero_slots_per_epoch_unscheduled", | ||
| boole: phase0.Epoch(math.MaxUint64), | ||
| slotsPerEpoch: 0, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainAlan, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "hard_error_overflow", | ||
| boole: phase0.Epoch(math.MaxUint64/32) + 1, | ||
| slotsPerEpoch: 32, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainBoole, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "hard_error_next_domain_equals_domain_before_fork", | ||
| boole: 10, | ||
| currentEpoch: 5, | ||
| slotsPerEpoch: 32, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainAlan, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| // The unchanged-domain check must not panic on EstimatedCurrentSlot when the | ||
| // clock is still before genesis; pre-genesis the fork is not yet active, so the | ||
| // misconfiguration is still reported as an error. | ||
| name: "hard_error_next_domain_equals_domain_pre_genesis", | ||
| boole: 10, | ||
| preGenesis: true, | ||
| slotsPerEpoch: 32, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainAlan, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "clean_next_domain_equals_domain_after_fork", | ||
| boole: 10, | ||
| currentEpoch: 20, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (optional, coverage) — non-blocking: the domain-equality cases cover |
||
| slotsPerEpoch: 32, | ||
| domainType: domainBoole, | ||
| nextDomainType: domainBoole, | ||
| }, | ||
| { | ||
| name: "clean_scheduled", | ||
| boole: 10, | ||
| slotsPerEpoch: 32, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainBoole, | ||
| }, | ||
| { | ||
| name: "clean_genesis_fork", | ||
| boole: 0, | ||
| slotsPerEpoch: 32, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainBoole, | ||
| }, | ||
| { | ||
| name: "clean_at_max_epoch_boundary", | ||
| boole: phase0.Epoch(math.MaxUint64 / 32), | ||
| slotsPerEpoch: 32, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainBoole, | ||
| }, | ||
| { | ||
| name: "clean_unscheduled", | ||
| boole: phase0.Epoch(math.MaxUint64), | ||
| slotsPerEpoch: 32, | ||
| domainType: domainAlan, | ||
| nextDomainType: domainAlan, | ||
| }, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| t.Run(test.name, func(t *testing.T) { | ||
| beacon := *TestNetwork.Beacon | ||
| beacon.SlotsPerEpoch = test.slotsPerEpoch | ||
| slotsSinceGenesis := uint64(test.currentEpoch) * test.slotsPerEpoch | ||
| beacon.GenesisTime = time.Now().Add(-time.Duration(slotsSinceGenesis) * beacon.SlotDuration) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (optional, maintainability) — non-blocking: this per-case beacon setup duplicates |
||
| if test.preGenesis { | ||
| beacon.GenesisTime = time.Now().Add(time.Hour) | ||
| } | ||
| netCfg := Network{ | ||
| Beacon: &beacon, | ||
| SSV: &SSV{ | ||
| DomainType: test.domainType, | ||
| NextDomainType: test.nextDomainType, | ||
| Forks: SSVForks{Boole: test.boole}, | ||
| }, | ||
| } | ||
|
|
||
| err := netCfg.Validate() | ||
| if test.expectErr { | ||
| require.Error(t, err) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func beaconAtEpoch(epoch phase0.Epoch) *Beacon { | ||
| beacon := *TestNetwork.Beacon | ||
| slotsSinceGenesis := uint64(epoch) * beacon.SlotsPerEpoch | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.