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

[Keystone][Deployment] Dedup NOPs #15175

Merged
merged 1 commit into from
Nov 9, 2024
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
10 changes: 7 additions & 3 deletions deployment/keystone/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,18 @@ func ConfigureRegistry(ctx context.Context, lggr logger.Logger, req ConfigureCon
lggr.Infow("registered capabilities", "capabilities", capabilitiesResp.donToCapabilities)

// register node operators
var nops []kcr.CapabilitiesRegistryNodeOperator
dedupedNops := make(map[kcr.CapabilitiesRegistryNodeOperator]struct{})
var nopsList []kcr.CapabilitiesRegistryNodeOperator
for _, nop := range nodeIdToNop {
nops = append(nops, nop)
dedupedNops[nop] = struct{}{}
}
for nop := range dedupedNops {
nopsList = append(nopsList, nop)
}
nopsResp, err := RegisterNOPS(ctx, lggr, RegisterNOPSRequest{
Chain: registryChain,
Registry: registry,
Nops: nops,
Nops: nopsList,
})
if err != nil {
return nil, fmt.Errorf("failed to register node operators: %w", err)
Expand Down
12 changes: 10 additions & 2 deletions deployment/keystone/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,22 @@ func TestDeploy(t *testing.T) {
require.True(t, ok)
gotRegistry := regChainContracts.CapabilitiesRegistry
require.NotNil(t, gotRegistry)
// contract reads
// check DONs
gotDons, err := gotRegistry.GetDONs(&bind.CallOpts{})
if err != nil {
err = keystone.DecodeErr(kcr.CapabilitiesRegistryABI, err)
require.Fail(t, fmt.Sprintf("failed to get Dons from registry at %s: %s", gotRegistry.Address().String(), err))
require.Fail(t, fmt.Sprintf("failed to get DONs from registry at %s: %s", gotRegistry.Address().String(), err))
}
require.NoError(t, err)
assert.Len(t, gotDons, len(deployReq.Dons))
// check NOPs
nops, err := gotRegistry.GetNodeOperators(&bind.CallOpts{})
if err != nil {
err = keystone.DecodeErr(kcr.CapabilitiesRegistryABI, err)
require.Fail(t, fmt.Sprintf("failed to get NOPs from registry at %s: %s", gotRegistry.Address().String(), err))
}
require.NoError(t, err)
assert.Len(t, nops, 26) // 10 NOPs owning workflow & writer DONs + 16 NOPs owning Asset DON

for n, info := range deployResp.DonInfos {
found := false
Expand Down
Loading