-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
chore(cre-deployment): refactor register nodes; add better test #16212
base: develop
Are you sure you want to change the base?
Conversation
@@ -615,19 +604,15 @@ func RegisterNodes(lggr logger.Logger, req *RegisterNodesRequest) (*RegisterNode | |||
params, ok := nodeIDToParams[n.NodeID] | |||
|
|||
if !ok { | |||
evmCC, exists := n.SelToOCRConfig[registryChainDetails] |
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.
this was the only call site of registryChainDetails; mv'd to helper
42bf97a
to
b7282ba
Compare
params = capabilities_registry.CapabilitiesRegistryNodeParams{ | ||
NodeOperatorId: nop.NodeOperatorId, | ||
Signer: signer, | ||
P2pId: n.PeerID, | ||
EncryptionPublicKey: csakey, |
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.
csakey was a misleading var name
}, nil | ||
} | ||
|
||
tx, err := registry.AddNodes(registryChain.DeployerKey, nodes2Add) | ||
tx, err := registry.AddNodes(req.RegistryChain.DeployerKey, nodes2Add) | ||
if err != nil { | ||
err = deployment.DecodeErr(capabilities_registry.CapabilitiesRegistryABI, err) | ||
// no typed errors in the abi, so we have to do string matching |
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.
this was unneeded b/c getNodesToRegistry already dedups
AER Report: CI Core ran successfully ✅AER Report: Operator UI CI ran successfully ✅ |
Flakeguard SummaryRan new or updated tests between View Flaky Detector Details | Compare Changes Found Flaky Tests ❌2 Results
ArtifactsFor detailed logs of the failed tests, please refer to the artifact failed-test-results-with-logs.json. |
|
||
var _ deployment.ChangeSet[*AddNodesRequest] = AddNodes | ||
|
||
func AddNodes(env deployment.Environment, req *AddNodesRequest) (deployment.ChangesetOutput, error) { |
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.
this is the new changeset; follow up will be to use in CLD instead of this https://github.com/smartcontractkit/chainlink-deployments/blob/badb8425d61c3079a0df23e59b78fbfd44a95fff/keystone/shared/changeset_registry.go#L108
checkErr func(t *testing.T, useMCMS bool, err error) | ||
} | ||
//run the same tests for both mcms and non-mcms | ||
var mcmsConfigs = []*changeset.MCMSConfig{nil, {MinDuration: 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.
this is a nice evolution of the test convention; run all the tests for the both mcms & non mcms and ensure they do the same thing, up to much poorer mcms error handling
checkErr: func(t *testing.T, useMCMS bool, err error) { | ||
require.NotNil(t, err) | ||
if useMCMS { | ||
assert.ErrorContains(t, err, "underlying transaction reverted") |
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.
notice the loss of info when using mcms wrt contract errors
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.
out of scope for this PR, but just out of curiosity: is there a way to bubble a more specific error up?
} | ||
} | ||
addResp, err := AddNodes(lggr, &AddNodesRequest{ |
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.
this is the refactored, shareable code that is leveraged in the new changeset
t: t, | ||
nameToId: make(map[string][32]byte), | ||
} | ||
caps, err := registry.GetCapabilities(nil) | ||
require.NoError(t, err) | ||
for _, capb := range caps { |
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.
populate the cache with onchain state
6b8c4de
to
bb63ef9
Compare
Flakeguard SummaryRan new or updated tests between View Flaky Detector Details | Compare Changes Found Flaky Tests ❌2 Results
ArtifactsFor detailed logs of the failed tests, please refer to the artifact failed-test-results-with-logs.json. |
c7733ff
to
6b16dad
Compare
Quality Gate passedIssues Measures |
// NOPIdentity is a node operator identity | ||
// | ||
// either by operator or registration ID must be non empty | ||
// it is an error to have both set |
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.
/nit both set is an error: [why]
} | ||
|
||
func (i NOPIdentity) Validate() error { | ||
dflt := kcr.CapabilitiesRegistryNodeOperator{} |
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.
/nit dflt stands for what?
MCMSConfig *MCMSConfig | ||
} | ||
|
||
func (r *AddNodesRequest) Validate() error { |
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.
Should this also run Validate on each CreateNodeRequest
in CreateNodeRequests
?
if err != nil { | ||
return deployment.ChangesetOutput{}, fmt.Errorf("failed to resolve node params for node %s: %w", nodeName, err) | ||
} | ||
p2p := string(p.P2pId[:]) |
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.
/nit, could the array to slice conversion happen in Resolve
?
checkErr: func(t *testing.T, useMCMS bool, err error) { | ||
require.NotNil(t, err) | ||
if useMCMS { | ||
assert.ErrorContains(t, err, "underlying transaction reverted") |
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.
out of scope for this PR, but just out of curiosity: is there a way to bubble a more specific error up?
NOPIdentity: changeset.NOPIdentity{ | ||
RegistrationID: te.Nops()[0].NodeOperatorId, | ||
}, | ||
Signer: test32byte(t, "dupe signer"), |
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.
Signer, EncryptionPublicKey, and P2PID are all duplicated. Would it be valuable to test each duplicate individually?
CRE-236
Add the AddNodes changeset
refactor RegisterNodes to seperate out reuseable logic
add lots of tests
Requires
Supports