chore: use restricted access keys instead of full access keys for MPC nodes#2773
chore: use restricted access keys instead of full access keys for MPC nodes#2773barakeinav1 wants to merge 3 commits intomainfrom
Conversation
…odes Node account keys should only be able to call node-facing methods on the MPC contract, not have full access to the account. This updates all scripts and documentation to use grant-function-call-access with the specific method list instead of grant-full-access. Closes #2543
|
PR title type suggestion: This PR changes only deployment scripts and documentation, so the type prefix should probably be Suggested title: |
Code ReviewVerified the method list against Checked quoting across all scripts: the comma-separated method list contains no whitespace so word-splitting is not a concern, even in Good security improvement — replacing full-access keys with restricted function-call access keys limits blast radius if a node key is compromised. ✅ Approved — clean, consistent change across all scripts and docs. |
|
PR title type suggestion: This PR changes only deployment scripts and documentation, so the type prefix should probably be Suggested title: |
There was a problem hiding this comment.
Pull request overview
This PR updates localnet/testnet deployment scripts and documentation to add MPC node public keys as restricted function-call access keys (instead of full-access keys), limiting what node keys can do on the MPC contract and setting a 1 NEAR allowance.
Changes:
- Replace
grant-full-accesswithgrant-function-call-accessfor adding node signer/responder keys. - Restrict allowed contract methods to the node-facing transaction methods (respond/vote/start/TEE/migration-related).
- Update localnet/testnet docs to reflect the restricted-key CLI commands.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/launch-localnet.sh | Adds node keys as function-call-only keys scoped to mpc-contract.test.near with 1 NEAR allowance. |
| localnet/tee/scripts/rust-launcher/deploy-tee-localnet.sh | Updates near_add_key_skip_if_exists to create restricted function-call keys for node signer/responder keys. |
| localnet/tee/scripts/deploy-tee-localnet.sh | Same restricted-key change for the non-rust-launcher localnet TEE deploy script. |
| deployment/testnet/scripts/scale-testnet-tee.sh | Same restricted-key change for scaling TEE nodes on testnet. |
| docs/localnet/localnet.md | Updates localnet instructions to add restricted function-call keys (with method allowlist). |
| docs/localnet/tee-localnet.md | Updates TEE localnet instructions to add restricted function-call keys (with method allowlist). |
| docs/testnet/setup-guide-for-testnet-with-tee-support.md | Updates testnet setup instructions to add restricted function-call keys (with method allowlist). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ```bash | ||
| near account add-key $SAM_ACCOUNT grant-full-access \ | ||
| near account add-key $SAM_ACCOUNT grant-function-call-access \ | ||
| --allowance '1 NEAR' --contract-account-id $MPC_CONTRACT_ACCOUNT --function-names "$NODE_METHODS" \ | ||
| use-manually-provided-public-key "$SAM_PUBKEY" network-config testnet sign-with-keychain send | ||
|
|
||
| near account add-key $SAM_ACCOUNT grant-full-access \ | ||
| near account add-key $SAM_ACCOUNT grant-function-call-access \ | ||
| --allowance '1 NEAR' --contract-account-id $MPC_CONTRACT_ACCOUNT --function-names "$NODE_METHODS" \ |
There was a problem hiding this comment.
NODE_METHODS is defined in the previous fenced code block, but the $SAM_ACCOUNT add-key commands are in a separate code block. If a reader copies only the SAM block, $NODE_METHODS will be undefined and near account add-key will fail. Consider either repeating the NODE_METHODS=... line in the second block or merging both Frodo/Sam commands into a single code block.
- Merge Frodo/Sam code blocks so NODE_METHODS is always defined - Quote variable expansions in launch-localnet.sh
Summary
grant-full-accesswithgrant-function-call-accessin all scripts and docs that add node account keysrespond,respond_ckd,respond_verify_foreign_tx,vote_pk,start_keygen_instance,vote_reshared,vote_foreign_chain_policy,start_reshare_instance,vote_abort_key_event_instance,verify_tee,submit_participant_info,conclude_node_migrationFiles changed
Scripts (4):
localnet/tee/scripts/rust-launcher/deploy-tee-localnet.shlocalnet/tee/scripts/deploy-tee-localnet.shdeployment/testnet/scripts/scale-testnet-tee.shscripts/launch-localnet.shDocs (3):
docs/localnet/localnet.mddocs/localnet/tee-localnet.mddocs/testnet/setup-guide-for-testnet-with-tee-support.mdThe method list was verified against
crates/near-mpc-contract-interface/src/method_names.rsand theChainSendTransactionRequestenum incrates/node/src/indexer/types.rs.Closes #2543
Test plan