Repository navigation
Check node ID matching in addNodeObject - #620
Merged
vishalchangrani merged 2 commits intoNov 19, 2026
Merged
Conversation
Validate that the nodeID of the MachineAccountInfo passed to addNodeObject matches the ID of the node being added. This ports the fix already deployed via onflow/flow-core-contracts-internal#5.
vishalchangrani
left a comment
Contributor
There was a problem hiding this comment.
Review
Verdict: matches mainnet, small/surgical, well-tested.
What it changes
contracts/FlowStakingCollection.cdc— adds an 11-line guard insideaddNodeObjectassertingmachineAccountInfo.nodeID == node.id.lib/go/contracts/internal/assets/assets.go— regenerated blob (62.869kB → 63.54kB), consistent with the 11-line Cadence addition.lib/go/test/flow_stakingcollection_security_test.go— new file, two tests:TestAddNodeObjectRejectsMismatchedMachineAccountInfo— negative: account2's node + account1'sMachineAccountInfomust be rejected.TestAddNodeObjectAcceptsMatchingMachineAccountInfo— positive: usestransfer_node.cdc, confirms the receiver can withdraw from the machine account after transfer.
Does the branch match mainnet?
Yes. I fetched the live mainnet contract at 0x8d0e87b65159ae63 (per flow.json) via the access-node REST API and diffed it against this PR's head (beba069c):
- Mainnet already contains the exact
assert(info.nodeID == id, …)block with an identical error message — the internal hotfix (onflow/flow-core-contracts-internal#5) is already live on Mainnet. - After stripping (a) imports — the PR uses
import \"FungibleToken\"resolved viaflow.jsonaliases, Mainnet has concretefrom 0x…addresses — and (b) trailing whitespace, the files are identical except for one trailing blank line at EOF on Mainnet. No semantic drift.
So the public repo was lagging Mainnet; this PR closes that gap. The PR body's claim ("apart from import addresses and whitespace, identical to Mainnet and Testnet") is accurate.
Nits (non-blocking)
assets.gois auto-generated; size delta matches, somake generatewas run correctly.- The negative test uses
shouldFail=true, which only checks that the tx errored — not that it errored for this reason. Tightening it to assert the error message contains\"does not match the node's ID\"would make the test future-proof against unrelated regressions that also happen to fail the tx. Not a blocker since this is the onlyassertadded inaddNodeObject.
vishalchangrani
approved these changes
Nov 19, 2026
vishalchangrani
deleted the
bastian/port-add-node-object-nodeid-check
branch
November 19, 2026 21:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Validate in
FlowStakingCollection.StakingCollection.addNodeObjectthat thenodeIDof the providedMachineAccountInfomatches the ID of the node being added, so a node can no longer be associated with a machine account record that belongs to a different node.This ports the fix already deployed via onflow/flow-core-contracts-internal#5 (authored by Leo Zhang). Apart from import addresses and whitespace,
FlowStakingCollection.cdcon this branch is identical to the contract currently deployed on Mainnet and Testnet.Changes
info.nodeID == node.idinaddNodeObjectwhen aMachineAccountInfois providedlib/go/contracts/internal/assets/assets.goTestAddNodeObjectRejectsMismatchedMachineAccountInfo(verified to fail against the pre-fix contract) andTestAddNodeObjectAcceptsMatchingMachineAccountInfo(node transfer viatransfer_node.cdcwith a matching record still works)Testing
go test ./...inlib/go/testandlib/go/contractspassRelated: onflow/flow-core-contracts-internal#5