Skip to content

Commit 9d30fa5

Browse files
authored
Node split poc cache hare weights (#6697)
1 parent 7365a96 commit 9d30fa5

20 files changed

+1281
-949
lines changed

api/node/client/client.gen.go

Lines changed: 162 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/node/client/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (s *NodeService) HareRoundTemplate(
187187
}
188188

189189
func (s *NodeService) TotalWeight(ctx context.Context, epoch types.EpochID) (uint64, error) {
190-
resp, err := s.client.GetHareTotalWeightEpochWithResponse(ctx, epoch.Uint32())
190+
resp, err := s.client.GetWeightsTotalEpochWithResponse(ctx, epoch.Uint32())
191191
if err != nil {
192192
return 0, fmt.Errorf("get total weight: %w", err)
193193
}
@@ -200,7 +200,7 @@ func (s *NodeService) TotalWeight(ctx context.Context, epoch types.EpochID) (uin
200200
}
201201

202202
func (s *NodeService) MinerWeight(ctx context.Context, epoch types.EpochID, node types.NodeID) (uint64, error) {
203-
resp, err := s.client.GetHareWeightNodeIdEpochWithResponse(ctx, hex.EncodeToString(node.Bytes()), epoch.Uint32())
203+
resp, err := s.client.GetWeightsMinerNodeIdEpochWithResponse(ctx, hex.EncodeToString(node.Bytes()), epoch.Uint32())
204204
if err != nil {
205205
return 0, fmt.Errorf("get miner weight: %w", err)
206206
}
@@ -213,7 +213,7 @@ func (s *NodeService) MinerWeight(ctx context.Context, epoch types.EpochID, node
213213
}
214214

215215
func (s *NodeService) Beacon(ctx context.Context, epoch types.EpochID) (types.Beacon, error) {
216-
resp, err := s.client.GetHareBeaconEpochWithResponse(ctx, epoch.Uint32())
216+
resp, err := s.client.GetBeaconEpochWithResponse(ctx, epoch.Uint32())
217217
if err != nil {
218218
return types.Beacon{}, fmt.Errorf("get hare beacon: %w", err)
219219
}

api/node/client/client_e2e_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type mocks struct {
2828
beacons *server.MockbeaconService
2929
poetDb *server.MockpoetDB
3030
hare *server.Mockhare
31+
weights *server.Mockweights
3132
publisher *pubsubMocks.MockPublisher
3233
proposals *server.MockproposalBuilder
3334
}
@@ -41,6 +42,7 @@ func setupE2E(t *testing.T) (*client.NodeService, *mocks) {
4142
beacons: server.NewMockbeaconService(ctrl),
4243
poetDb: server.NewMockpoetDB(ctrl),
4344
hare: server.NewMockhare(ctrl),
45+
weights: server.NewMockweights(ctrl),
4446
publisher: pubsubMocks.NewMockPublisher(ctrl),
4547
proposals: server.NewMockproposalBuilder(ctrl),
4648
}
@@ -50,6 +52,7 @@ func setupE2E(t *testing.T) (*client.NodeService, *mocks) {
5052
m.publisher,
5153
m.poetDb,
5254
m.hare,
55+
m.weights,
5356
m.proposals,
5457
log.Named("server"))
5558

@@ -206,15 +209,16 @@ func Test_Hare(t *testing.T) {
206209
svc, mock := setupE2E(t)
207210
t.Run("total weight", func(t *testing.T) {
208211
val := uint64(11)
209-
mock.hare.EXPECT().TotalWeight(gomock.Any(), types.EpochID(112)).Return(val, nil)
212+
mock.weights.EXPECT().TotalWeight(gomock.Any(), types.EpochID(112)).Return(val, nil)
210213
v, err := svc.TotalWeight(context.Background(), 112)
211214
require.NoError(t, err)
212215
require.Equal(t, v, val)
213216
})
214217
t.Run("miner weight", func(t *testing.T) {
215218
val := uint64(101)
216-
mock.hare.EXPECT().MinerWeight(gomock.Any(), gomock.Any(), types.EpochID(113)).Return(val, nil)
217-
v, err := svc.MinerWeight(context.Background(), 113, types.NodeID{})
219+
nodeID := types.RandomNodeID()
220+
mock.weights.EXPECT().MinerWeight(gomock.Any(), types.EpochID(113), nodeID).Return(val, nil)
221+
v, err := svc.MinerWeight(context.Background(), 113, nodeID)
218222
require.NoError(t, err)
219223
require.Equal(t, v, val)
220224
})

api/node/node_service.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ paths:
167167
$ref: "models/components.yaml#/components/schemas/HareRoundTemplate"
168168
"204":
169169
description: did not find a message to retrieve
170-
/hare/total_weight/{epoch}:
170+
/weights/total/{epoch}:
171171
get:
172172
summary: Get the total weight for epoch
173173
tags:
174-
- "hare"
174+
- "weights"
175175
parameters:
176176
- in: path
177177
name: epoch
@@ -191,13 +191,11 @@ paths:
191191
format: uint64
192192
required:
193193
- weight
194-
"204":
195-
description: did not find a message to retrieve
196-
/hare/weight/{node_id}/{epoch}:
194+
/weights/miner/{node_id}/{epoch}:
197195
get:
198196
summary: Get the miner weight in epoch
199197
tags:
200-
- "hare"
198+
- "weights"
201199
parameters:
202200
- in: path
203201
name: node_id
@@ -222,19 +220,17 @@ paths:
222220
format: uint64
223221
required:
224222
- weight
225-
"204":
226-
description: did not find a message to retrieve
227223
"400":
228224
description: Bad request
229225
content:
230226
plain/text:
231227
schema:
232228
type: string
233-
/hare/beacon/{epoch}:
229+
/beacon/{epoch}:
234230
get:
235231
summary: Get the beacon value for an epoch
236232
tags:
237-
- "hare"
233+
- "beacon"
238234
parameters:
239235
- in: path
240236
name: epoch

api/node/server/mocks.go

Lines changed: 64 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)