Skip to content
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

Node split poc cache hare weights #6697

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
324 changes: 162 additions & 162 deletions api/node/client/client.gen.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions api/node/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (s *NodeService) HareRoundTemplate(
}

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

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

func (s *NodeService) Beacon(ctx context.Context, epoch types.EpochID) (types.Beacon, error) {
resp, err := s.client.GetHareBeaconEpochWithResponse(ctx, epoch.Uint32())
resp, err := s.client.GetBeaconEpochWithResponse(ctx, epoch.Uint32())
if err != nil {
return types.Beacon{}, fmt.Errorf("get hare beacon: %w", err)
}
Expand Down
10 changes: 7 additions & 3 deletions api/node/client/client_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type mocks struct {
beacons *server.MockbeaconService
poetDb *server.MockpoetDB
hare *server.Mockhare
weights *server.Mockweights
publisher *pubsubMocks.MockPublisher
proposals *server.MockproposalBuilder
}
Expand All @@ -41,6 +42,7 @@ func setupE2E(t *testing.T) (*client.NodeService, *mocks) {
beacons: server.NewMockbeaconService(ctrl),
poetDb: server.NewMockpoetDB(ctrl),
hare: server.NewMockhare(ctrl),
weights: server.NewMockweights(ctrl),
publisher: pubsubMocks.NewMockPublisher(ctrl),
proposals: server.NewMockproposalBuilder(ctrl),
}
Expand All @@ -50,6 +52,7 @@ func setupE2E(t *testing.T) (*client.NodeService, *mocks) {
m.publisher,
m.poetDb,
m.hare,
m.weights,
m.proposals,
log.Named("server"))

Expand Down Expand Up @@ -204,15 +207,16 @@ func Test_Hare(t *testing.T) {
svc, mock := setupE2E(t)
t.Run("total weight", func(t *testing.T) {
val := uint64(11)
mock.hare.EXPECT().TotalWeight(gomock.Any(), types.EpochID(112)).Return(val, nil)
mock.weights.EXPECT().TotalWeight(gomock.Any(), types.EpochID(112)).Return(val, nil)
v, err := svc.TotalWeight(context.Background(), 112)
require.NoError(t, err)
require.Equal(t, v, val)
})
t.Run("miner weight", func(t *testing.T) {
val := uint64(101)
mock.hare.EXPECT().MinerWeight(gomock.Any(), gomock.Any(), types.EpochID(113)).Return(val, nil)
v, err := svc.MinerWeight(context.Background(), 113, types.NodeID{})
nodeID := types.RandomNodeID()
mock.weights.EXPECT().MinerWeight(gomock.Any(), types.EpochID(113), nodeID).Return(val, nil)
v, err := svc.MinerWeight(context.Background(), 113, nodeID)
require.NoError(t, err)
require.Equal(t, v, val)
})
Expand Down
16 changes: 6 additions & 10 deletions api/node/node_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ paths:
$ref: "models/components.yaml#/components/schemas/HareRoundTemplate"
"204":
description: did not find a message to retrieve
/hare/total_weight/{epoch}:
/weights/total/{epoch}:
get:
summary: Get the total weight for epoch
tags:
- "hare"
- "weights"
parameters:
- in: path
name: epoch
Expand All @@ -191,13 +191,11 @@ paths:
format: uint64
required:
- weight
"204":
description: did not find a message to retrieve
/hare/weight/{node_id}/{epoch}:
/weights/miner/{node_id}/{epoch}:
get:
summary: Get the miner weight in epoch
tags:
- "hare"
- "weights"
parameters:
- in: path
name: node_id
Expand All @@ -222,19 +220,17 @@ paths:
format: uint64
required:
- weight
"204":
description: did not find a message to retrieve
"400":
description: Bad request
content:
plain/text:
schema:
type: string
/hare/beacon/{epoch}:
/beacon/{epoch}:
get:
summary: Get the beacon value for an epoch
tags:
- "hare"
- "beacon"
parameters:
- in: path
name: epoch
Expand Down
104 changes: 64 additions & 40 deletions api/node/server/mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading