-
Notifications
You must be signed in to change notification settings - Fork 212
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
Serve API to return poet registrations state #6266
base: develop
Are you sure you want to change the base?
Changes from 56 commits
726b49d
3f68831
5bba175
8080ed0
7a371a2
89696b1
189aa4c
97aed33
66ea05e
f6f2277
3313ff9
dee9103
4cbafdd
9a5bad8
9ffb962
c4bb081
696e3e3
ace0460
aeb5939
dcda554
d304a1e
0ebdb79
69cfb29
4b12ecb
2c29b49
cadaedc
aa2c4bd
6593496
e00049f
2826b51
bb8fc04
0eacbbe
d7f7f7d
40e3e4b
0a3e5ca
34d118b
b412dfb
66a53c6
9e64d1d
a7b2200
d29238d
f0e13d7
ef2a856
bc36bb2
98aaed4
101bd67
2a4392a
b2a3121
de52ea0
e73e05e
d10d8f0
6d6a4fe
2c41327
5bb7775
e91db30
0400110
fd24c4d
dfedf1c
c74260a
bdb8e52
198fd04
905a669
2b76480
dca792e
729d95d
5b06560
0299474
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 |
---|---|---|
|
@@ -176,14 +176,17 @@ func publishAtx( | |
NumUnits: DefaultPostSetupOpts().NumUnits, | ||
LabelsPerUnit: DefaultPostConfig().LabelsPerUnit, | ||
}, nil).AnyTimes() | ||
|
||
tab.mnipost.EXPECT().BuildNIPost(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn( | ||
func(_ context.Context, _ *signing.EdSigner, _ types.Hash32, _ *types.NIPostChallenge, | ||
) (*nipost.NIPostState, error) { | ||
*currLayer = currLayer.Add(buildNIPostLayerDuration) | ||
return newNIPostWithPoet(tb, types.RandomHash().Bytes()), nil | ||
}) | ||
|
||
ch := make(chan struct{}) | ||
close(ch) | ||
|
||
tab.mclock.EXPECT().AwaitLayer(publishEpoch.FirstLayer()).DoAndReturn( | ||
func(got types.LayerID) <-chan struct{} { | ||
// advance to publish layer | ||
|
@@ -349,7 +352,14 @@ func TestBuilder_StopSmeshing_failsWhenNotStarted(t *testing.T) { | |
} | ||
|
||
func TestBuilder_PublishActivationTx_HappyFlow(t *testing.T) { | ||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration}), | ||
WithIdentityStates(idStates)) | ||
|
||
Comment on lines
-351
to
+361
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. What's the point of adding the "identitystates` in these tests? It doesn't verify anything additionally (compared to the original test) but it complicates the tests. |
||
sig := maps.Values(tab.signers)[0] | ||
|
||
posEpoch := postGenesisEpoch | ||
|
@@ -434,7 +444,13 @@ func TestBuilder_Loop_WaitsOnStaleChallenge(t *testing.T) { | |
} | ||
|
||
func TestBuilder_PublishActivationTx_FaultyNet(t *testing.T) { | ||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4}), | ||
WithIdentityStates(idStates)) | ||
sig := maps.Values(tab.signers)[0] | ||
|
||
posEpoch := postGenesisEpoch | ||
|
@@ -509,7 +525,14 @@ func TestBuilder_PublishActivationTx_UsesExistingChallengeOnLatePublish(t *testi | |
poetCfg := PoetConfig{ | ||
PhaseShift: layerDuration * 4, | ||
} | ||
tab := newTestBuilder(t, 1, WithPoetConfig(poetCfg)) | ||
|
||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(poetCfg), | ||
WithIdentityStates(idStates)) | ||
sig := maps.Values(tab.signers)[0] | ||
|
||
currLayer := (postGenesisEpoch + 1).FirstLayer().Add(5) // late for poet round start | ||
|
@@ -585,7 +608,13 @@ func TestBuilder_PublishActivationTx_UsesExistingChallengeOnLatePublish(t *testi | |
} | ||
|
||
func TestBuilder_PublishActivationTx_RebuildNIPostWhenTargetEpochPassed(t *testing.T) { | ||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4}), | ||
WithIdentityStates(idStates)) | ||
sig := maps.Values(tab.signers)[0] | ||
|
||
posEpoch := types.EpochID(2) | ||
|
@@ -670,7 +699,13 @@ func TestBuilder_PublishActivationTx_RebuildNIPostWhenTargetEpochPassed(t *testi | |
} | ||
|
||
func TestBuilder_PublishActivationTx_NoPrevATX(t *testing.T) { | ||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4}), | ||
WithIdentityStates(idStates)) | ||
sig := maps.Values(tab.signers)[0] | ||
|
||
posEpoch := postGenesisEpoch | ||
|
@@ -784,7 +819,14 @@ func TestBuilder_PublishActivationTx_PrevATXWithoutPrevATX(t *testing.T) { | |
r := require.New(t) | ||
|
||
// Arrange | ||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4}), | ||
WithIdentityStates(idStates), | ||
) | ||
sig := maps.Values(tab.signers)[0] | ||
|
||
otherSigner, err := signing.NewEdSigner() | ||
|
@@ -878,7 +920,14 @@ func TestBuilder_PublishActivationTx_TargetsEpochBasedOnPosAtx(t *testing.T) { | |
r := require.New(t) | ||
|
||
// Arrange | ||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4}), | ||
WithIdentityStates(idStates)) | ||
|
||
sig := maps.Values(tab.signers)[0] | ||
|
||
otherSigner, err := signing.NewEdSigner() | ||
|
@@ -975,7 +1024,14 @@ func TestBuilder_PublishActivationTx_TargetsEpochBasedOnPosAtx(t *testing.T) { | |
} | ||
|
||
func TestBuilder_PublishActivationTx_FailsWhenNIPostBuilderFails(t *testing.T) { | ||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration * 4}), | ||
WithIdentityStates(idStates)) | ||
|
||
sig := maps.Values(tab.signers)[0] | ||
|
||
posEpoch := postGenesisEpoch | ||
|
@@ -1279,10 +1335,14 @@ func TestWaitPositioningAtx(t *testing.T) { | |
{"round started", 0, 0, 3}, | ||
} { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{ | ||
PhaseShift: tc.shift, | ||
GracePeriod: tc.grace, | ||
})) | ||
}), WithIdentityStates(idStates)) | ||
sig := maps.Values(tab.signers)[0] | ||
|
||
tab.mclock.EXPECT().CurrentLayer().Return(types.LayerID(0)).AnyTimes() | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,8 +18,13 @@ import ( | |||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
func TestBuilder_BuildsInitialAtxV2(t *testing.T) { | ||||||||||||||||||||
ctrl := gomock.NewController(t) | ||||||||||||||||||||
idStates := NewMockIdentityStates(ctrl) | ||||||||||||||||||||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||||||||||||||||||||
|
||||||||||||||||||||
tab := newTestBuilder(t, 1, | ||||||||||||||||||||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration}), | ||||||||||||||||||||
WithIdentityStates(idStates), | ||||||||||||||||||||
Comment on lines
+21
to
+27
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. Ditto
Suggested change
|
||||||||||||||||||||
BuilderAtxVersions(AtxVersions{1: types.AtxV2})) | ||||||||||||||||||||
|
||||||||||||||||||||
tab.SetCoinbase(types.Address{1, 2, 3, 4}) | ||||||||||||||||||||
|
@@ -72,8 +77,13 @@ func TestBuilder_BuildsInitialAtxV2(t *testing.T) { | |||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
func TestBuilder_SwitchesToBuildV2(t *testing.T) { | ||||||||||||||||||||
ctrl := gomock.NewController(t) | ||||||||||||||||||||
idStates := NewMockIdentityStates(ctrl) | ||||||||||||||||||||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||||||||||||||||||||
|
||||||||||||||||||||
tab := newTestBuilder(t, 1, | ||||||||||||||||||||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration}), | ||||||||||||||||||||
WithIdentityStates(idStates), | ||||||||||||||||||||
BuilderAtxVersions(AtxVersions{4: types.AtxV2})) | ||||||||||||||||||||
sig := maps.Values(tab.signers)[0] | ||||||||||||||||||||
|
||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about not adding this to the ATX Builder? The builder doesn't need this at all. AFAIR, it's only used in the grpc service, which could do read directly from the "identities state", wdyt?
We don't support unregistering, so the GRPC service could just return all the state of all IDs.