Repository navigation
Add multisig actions and tests - #45
Conversation
341855d to
32336ec
Compare
|
@paulgnz can you review it please? |
paulgnz
left a comment
There was a problem hiding this comment.
Looks good, thanks Blas. Checked it out and ran it locally:
tsc -bbuilds clean.- 19/19 tests pass on Node 18. (The boilerplate test takes ~6s, so it needs a longer mocha timeout than the default 2s.)
- All six actions match the live
eosio.msigABI on XPR mainnet, including theproposal_hashbinary extension onapproveandinvalidate. - The requested-signer dedupe by
actor@permissionfixes a real bug: the old code dropped a second required permission from the same account.
Two small things before merging:
msig approvelink: "View Proposal" uses the approver (authorization.actor) instead of the proposer, so it points at the wrong proposal page. It was already like that before this PR, but it's a one-word fix while you're in there:args.proposer.test/commands/network.test.ts: it now asserts"chain": "proton", which depends on whatever network is saved in the local config. It fails on any machine set toproton-test. Could you stub the config or just assert onCurrent Network:?
FYI, not from this PR: @oclif/test crashes on load under Node 22 (Cannot read properties of undefined (reading 'filename')), so the suite only runs on Node ≤20.
Happy to approve after 1 and 2.
|
Addressed both review comments: fixed the approve proposal link to use the proposer and made the network test independent of local config. @paulgnz |
acfc4ab to
45186af
Compare
|
Thanks! Both fixes look right. One catch: the new assertion in Adding test
.stub(network, 'transact', capture(transaction))
.stdout()
.command(['msig:approve', 'proposer', 'proposal', 'signer'])I'll approve once that's in. |
|
Added |
paulgnz
left a comment
There was a problem hiding this comment.
Approving. Thanks, the .stdout() fix did it.
Verified on a fresh checkout of 6c883e1 with Node 18:
tsc -bbuilds.- 19/19 tests pass (
mocha --require ts-node/register "test/**/*.test.ts"). - eslint is clean on all changed files.
approve,cancel,execandproposetake the same arguments as on master, so existing usage doesn't break.
Two things for a follow-up, both already on master and not caused by this PR:
npm testdoesn't run the suite. Current mocha ignorestest/mocha.opts, so the.tsfiles never load (ERR_UNKNOWN_FILE_EXTENSION). Moving those options into a.mocharc.json(withrequire: ts-node/register) should fix it.engines.nodesays>=14.0.0, but the code usesnode:imports, which need 16+. On very new Node (26)@oclif/testalso fails to load, so for now we should document Node 18/20 as the tested versions.
|
Nice addition of functionality and tests. This should clear one item in the TODO file. That being said, I've run this through Gemini 3.8 Flash (via Cursor) which has feedback I'm posting below. I understand that AI model output is not always on point, so please take a look and let me know what you think: Must Be Addressed in This Branch Before MergingThese are critical correctness bugs, protocol-level consensus constraints, and regressions that directly affect the code modified in this branch. If merged as-is, they will cause transactions to fail on-chain or degrade production operations. 1. Canonical Sorting of
|
149af68 to
87cb842
Compare
87cb842 to
8419426
Compare
|
Thanks for the detailed review, @squdgy . I went through all five points and addressed them in commit 8419426:
I added regression coverage for sorting, fallback resolution, hash normalization and validation, formatted errors, and the exec transaction URL. I also rebuilt the branch from Verification on Node 18.20.8:
The repository’s older oclif test stack still does not load under Node 26, so Node 18 is the runtime used for the full test run. |
Code review findings (commit 8419426)Static review only. Tests, lint and scans were not run. Only finding 1 was checked against the code by hand; the rest are reviewer-reported and unverified. 1. Failed msig commands exit 0 (confirmed by code read)
2. Approvers sorted with
|
- msig catch handlers log via parseDetailsError then this.error(exit 1) - propose: code-unit sort, fail fast on unresolvable required accounts - parseActions requires object data; exec tx-id shape guard - document --proposal-hash; cover link, hash, data and exit-code paths - migrate test/mocha.opts to .mocharc.json so mocha 9 picks it up
|
@squdgy Thanks for the thorough review. Addressed in d2d7638: Fixed
Left as-is, open to pushback Verification: 24/24 green on Node 20 ( |
|
Review of d2d7638 (static read plus a local run on Node 20:
|
eosio.msig approve and unapprove call require_auth(level), so the approval level must be the action's declared authorization. The separate --level flag could build transactions the chain rejects whenever it differed from auth; drop it and always approve/unapprove with the signing authorization. invalidate calls require_auth(account), so derive the account from auth and simplify the signature to msig:invalidate AUTH, matching cancel/exec/propose. Update payload tests to assert level equals the signing authorization, add regression tests that --level is rejected, and refresh the README command reference.
|
Confirmed and fixed — thanks @squdgy. I checked the eosio.msig source directly (eosio.msig.cpp in EOSIO/eosio.contracts): Fixed in feb6892 by taking your first suggested option:
Tests: the payload tests now assert What I have not done, flagging honestly: your suggested testnet confirmation. The tests stub Unrelated finding while verifying: the test suite currently only runs on Node 20 — it crashes inside |
squdgy
left a comment
There was a problem hiding this comment.
Thanks for all the updates @blasrodri. I approve the changes.
* Add msig:propose-updateauth for WA keys under multisig New msig:propose-updateauth wraps eosio::updateauth in an eosio.msig propose, with early PUB_WA_/PUB_K1_/PUB_R1_ validation, threshold/weight checks, and chain-order sorting. Covers the WebAuthn-under-multisig case PR #45 left without a dedicated flow. * Fix serializeActions stub typing in propose-updateauth test * Harden updateauth validation: permission names, 13-char accounts Validate the permission side of --accounts entries, accept 13-character EOSIO names with a restricted final character, and pin the key-sort test to an explicit order. * Rename updateauth builders to remove auth stutter buildUpdateauthAuth -> buildRequiredAuth (matches RpcInterfaces.RequiredAuth return type); buildUpdateauthAction -> buildUpdateAuthAction (camelCase fix). Update caller and tests. * Address review: canonical sorting, range and duplicate validation, safer parent and auth defaults Fix waits crash (numeric compare), sort accounts by (actor, permission) and keys by (type, bytes) with compareNames. Reject weights above uint16, delays and thresholds above uint32, zero waits, and duplicate keys, accounts, and waits. Require explicit --parent for custom permissions and default to the on-chain parent otherwise. Authorize new permissions with the parent authority, require --yes to replace owner, reject empty --permission, print old and proposed authorities, and share signer resolution between msig:propose and msig:propose-updateauth. Cover all of it with tests and sync the README flags. * Harden propose-updateauth: early name validation, parent existence, decode-once key sort Validate proposal name, account, permission, and authorization before any chain call. Reject a parent permission that does not exist on the account. Make the new-permission authorization rule explicit via buildUpdateAuthAction actionPermission instead of mutating the built action. Decode authority keys once when sorting instead of per comparison. Rename argument parameters to flagName/label and validName to isValidEosioName. Add tests for all of it. * Harden updateauth against chain-invalid and unsafe authorities Match Leap updateauth rules: canonical EOSIO names without trailing-dot aliases, reserved eosio. permissions, immutable parents, active parent owner, existing account authorities, chain maximum delay, the 2^16 authority entry cap, and field-wise WebAuthn key ordering. Reject waits-only satisfaction, self-referential and otherwise invalid direct authorities, and malformed WebAuthn payloads without echoing mistakenly supplied private keys. Dedupe and validate multisig approver resolution, add ABI serialization coverage, and rename sortRequiredAuth to kebab case so touched files pass lint. * Address follow-up review: sort coverage and RPC error mapping Add save-path regression tests for permission and contract:enableinline now that they share canonical authority sorting. Only map genuine account-not-found RPC failures to the missing-account message, document the propose-time chain snapshot caveat, and state the waits-alone threshold policy in help and README.
Summary
Verification