Skip to content

Commit

Permalink
[Keystone][Deployment] Dedup NOPs (#15175)
Browse files Browse the repository at this point in the history
  • Loading branch information
bolekk authored Nov 9, 2024
1 parent 1e84f96 commit 8104c49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
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

0 comments on commit 8104c49

Please sign in to comment.