Skip to content

[Breaking Change] Add --multisig-code-hash flag to specify MultisigScript::V2 or MultisigScript::Legacy #631

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

Merged

Conversation

eval-exec
Copy link
Collaborator

@eval-exec eval-exec commented Apr 21, 2025

❯ ./target/release/ckb-cli tx add-multisig-config --multisig-code-hash v2 --sighash-address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqtnx6ct4yqxsn9nevq0p4rdfajvpx222cspfkcrt ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2hynq78yj62grfgnt48fhnakhdl9mawlclnt69d --tx-file tx.json --threshold 2
status: success
ckb-cli on  exec/upgrade-multisig is 📦 v1.14.0 via 🦀 v1.85.0 via ❄️  impure (nix-shell) on ☁️
❯ cat tx.json
{
  "transaction": {
    "version": "0x0",
    "cell_deps": [],
    "header_deps": [],
    "inputs": [],
    "outputs": [],
    "outputs_data": [],
    "witnesses": []
  },
  "multisig_configs": {
    "0xbc9818d8a149cfc0cd0323386c46ba07920a037f": {
      "lock_code_hash": "0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29", // New field !
      "sighash_addresses": [
        "ckt1qyq8xd4sh2gqdpxt8jcq7r2x6nmyczv5543qzt67fa",
        "ckt1qyq9wfxpuwf955sxj3xh2wn08mdwm7th6alsyagdcv"
      ],
      "require_first_n": 0,
      "threshold": 2
    }
  },
  "signatures": {}
}
  • Add --multisig-code-hash arg to some commands, the --multisig-code-hash flag help message is
❯ ./target/release/ckb-cli tx build-multisig-address -h

USAGE:
    ckb-cli tx build-multisig-address [FLAGS] [OPTIONS] --sighash-address <sighash-address>... --multisig-code-hash <multisig-code-hash>
....
OPTIONS:
...
        --multisig-code-hash <multisig-code-hash>
            Specifies the multisig code hash to use:
                - v2(default): `0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29`.
                - legacy(deprecated): `0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8` is NOT
            recommended for use.

             [possible values: v2, legacy, 0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8,
            0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29]
........
  1. ckb-cli util to-multisig-addr --multisig-code-hash v2 ...
❯ ./target/release/ckb-cli util to-multisig-addr --multisig-code-hash v2 --sighash-address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdfq3kxc87y7nq00c3mmxhy3yfzj7fpdzcktzr39 --locktime 2014-11-28T21:00:00+00:00
address:
  mainnet: ckb1qqmvjudc6s0mm992hjnhm367sfnjntycg3a5d7g7qpukz4wamvxjjq4jqqem772qpur6jw9vt59stawchrflq4s09vqgkpggqusqvm04rr
  testnet: ckt1qqmvjudc6s0mm992hjnhm367sfnjntycg3a5d7g7qpukz4wamvxjjq4jqqem772qpur6jw9vt59stawchrflq4s09vqgkpggqusqq3h6mr
target_epoch: "Epoch { number: 11023, index: 1419, length: 1800 }"
  1. ckb-cli tx build-multisig-address --multisig-code-hash v2 ...
❯ ./target/release/ckb-cli tx build-multisig-address --multisig-code-hash v2 --sighash-address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqtnx6ct4yqxsn9nevq0p4rdfajvpx222cspfkcrt --sighash-address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2hynq78yj62grfgnt48fhnakhdl9mawlclnt69d --threshold 2
lock-arg: 0xbc9818d8a149cfc0cd0323386c46ba07920a037f
lock-hash: 0xd2193fe59a656476b44f69e0048e734f34834679460ac9830fa6cb90c19d1191
mainnet: ckb1qqmvjudc6s0mm992hjnhm367sfnjntycg3a5d7g7qpukz4wamvxjjq4unqvd3g2felqv6qer8pkydws8jg9qxlcl3vrlh
testnet: ckt1qqmvjudc6s0mm992hjnhm367sfnjntycg3a5d7g7qpukz4wamvxjjq4unqvd3g2felqv6qer8pkydws8jg9qxlc3r8v40
  1. ckb-cli tx add-multisig-config --multisig-code-hash v2 ...
❯ ./target/release/ckb-cli tx add-multisig-config --multisig-code-hash v2 --sighash-address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqtnx6ct4yqxsn9nevq0p4rdfajvpx222cspfkcrt ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2hynq78yj62grfgnt48fhnakhdl9mawlclnt69d --tx-file tx.json --threshold 2
status: success

@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch 8 times, most recently from d8901d3 to e83c169 Compare April 22, 2025 09:40
@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch 2 times, most recently from eee67fe to 64047ae Compare April 23, 2025 08:58
@eval-exec eval-exec changed the title Upgrade multisig [Break Change] Upgrade multisig Apr 28, 2025
@eval-exec eval-exec changed the title [Break Change] Upgrade multisig [Breaking Change] Upgrade multisig Apr 28, 2025
@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch 4 times, most recently from d4857cb to 1346b72 Compare April 28, 2025 07:06
@doitian doitian requested a review from Copilot April 28, 2025 07:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch 10 times, most recently from 51da577 to ae0f57f Compare May 22, 2025 03:54
@eval-exec eval-exec requested a review from Copilot May 22, 2025 06:28
@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch 2 times, most recently from 6c92435 to d361b08 Compare May 30, 2025 10:12
@eval-exec eval-exec requested a review from Copilot May 30, 2025 10:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades multisig support by replacing the old MULTISIG_TYPE_HASH constant with a new MultisigScript enum, adds a --multisig-code-hash flag to relevant CLI commands, and bumps ckb-sdk to v4.0.0.

  • Swap out MULTISIG_TYPE_HASH for MultisigScript::{Legacy, V2} checks across code paths.
  • Introduce arg_multisig_code_hash parser and require --multisig-code-hash in wallet, tx, and util subcommands.
  • Update all ckb-sdk dependencies from 3.7.0 to 4.0.0.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/src/spec/wallet.rs Adjusted multisig address test to include --multisig-code-hash legacy.
Cargo.toml (root, test, signer) Bumped ckb-sdk versions to 4.0.0.
src/utils/tx_helper.rs Replaced constant checks with MultisigScript-based lookups.
src/subcommands/mod.rs Added definition of arg_multisig_code_hash.
src/subcommands/tx.rs Wired --multisig-code-hash into tx subcommands and parsing.
src/subcommands/util.rs Integrated code-hash flag into util commands and gen_multisig_addr.
Comments suppressed due to low confidence (2)

test/src/spec/wallet.rs:221

  • [nitpick] This test only covers the legacy script variant. Consider adding a case for the default V2 code hash to ensure both variants are exercised.
r#"util to-multisig-addr --sighash-address {} --locktime "2020-01-02T21:00:00+08:00" --multisig-code-hash legacy"#

src/subcommands/mod.rs:115

  • The help text mentions a 'default' v2 code hash, but the flag is marked required, so there's no actual default. Consider either removing the default note or adding .default_value("v2") to the argument definition.
.about("Specifies the multisig code hash to use:\n    - v2(default): ...")

@eval-exec eval-exec changed the title [Breaking Change] Upgrade multisig [Breaking Change] Add MultisigScript::V2 and MultisigScript::Legacy May 30, 2025
@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch from d361b08 to 12f3142 Compare May 30, 2025 14:11
Copilot

This comment was marked as outdated.

@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch 2 times, most recently from 52553f1 to ba5e678 Compare June 3, 2025 02:34
@eval-exec eval-exec requested a review from driftluo June 4, 2025 11:35
@eval-exec
Copy link
Collaborator Author

Invite @quake @doitian @driftluo @zhangsoledad to review again.

@eval-exec eval-exec requested a review from Copilot June 4, 2025 11:35
@eval-exec eval-exec changed the title [Breaking Change] Add MultisigScript::V2 and MultisigScript::Legacy [Breaking Change] Add --multisig-code-hash arg to specify MultisigScript::V2 or MultisigScript::Legacy Jun 4, 2025
@eval-exec eval-exec changed the title [Breaking Change] Add --multisig-code-hash arg to specify MultisigScript::V2 or MultisigScript::Legacy [Breaking Change] Add --multisig-code-hash argument to specify MultisigScript::V2 or MultisigScript::Legacy Jun 4, 2025
Copilot

This comment was marked as outdated.

@eval-exec eval-exec changed the title [Breaking Change] Add --multisig-code-hash argument to specify MultisigScript::V2 or MultisigScript::Legacy [Breaking Change] Add --multisig-code-hash flag to specify MultisigScript::V2 or MultisigScript::Legacy Jun 4, 2025
@zhangsoledad zhangsoledad requested a review from Copilot June 5, 2025 13:57
Copilot

This comment was marked as outdated.

@zhangsoledad zhangsoledad self-requested a review June 5, 2025 13:58
@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch from ba5e678 to 03d7dc3 Compare June 5, 2025 14:03
Signed-off-by: Eval EXEC <execvy@gmail.com>
@eval-exec eval-exec force-pushed the exec/upgrade-multisig branch from 03d7dc3 to 90c2ec0 Compare June 5, 2025 14:04
@zhangsoledad zhangsoledad requested a review from Copilot June 5, 2025 14:36
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a --multisig-code-hash flag to allow choosing between legacy and V2 multisig script hashes, updates configuration formats to include the new code hash field (defaulting to legacy for compatibility), and upgrades ckb-sdk to v4.0.0.

  • Upgraded ckb-sdk dependency and replaced MULTISIG_TYPE_HASH constant with MultisigScript enum usage.
  • Added lock_code_hash to multisig configs with backward-compat defaults.
  • Extended CLI and util commands to accept and propagate the new --multisig-code-hash flag.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/src/spec/wallet.rs Updated test command to pass legacy code-hash flag
test/Cargo.toml Bumped ckb-sdk to v4.0.0
src/utils/tx_helper.rs Handled both legacy and V2 multisig code hashes
src/utils/rpc/types.rs Adjusted script serialization suffixes for legacy/V2
src/utils/genesis_info.rs Changed multisig_dep() to take a MultisigScript parameter
src/utils/arg_parser.rs Extended new_multisig() to accept script version
src/subcommands/wallet.rs Detected and matched legacy/V2 multisig configs
src/subcommands/util.rs Added flag but initial to-multisig-addr branch still hardcodes legacy
src/subcommands/tx.rs Integrated flag into tx subcommands and validators
src/subcommands/mod.rs Introduced arg_multisig_code_hash and parser helper
src/subcommands/deploy/tx_builder.rs Refactored deploy builder for versioned multisig deps
ckb-signer/Cargo.toml Bumped ckb-sdk to v4.0.0
Cargo.toml Bumped ckb-sdk to v4.0.0
Comments suppressed due to low confidence (2)

src/subcommands/util.rs:691

  • The util to-multisig-addr command always uses MultisigScript::Legacy, ignoring the --multisig-code-hash flag; parse the selected script via arg_get_multisig_code_hash(m) and pass it to gen_multisig_addr.
let (epoch_fraction, addr_payload) = gen_multisig_addr(MultisigScript::Legacy, address.payload(), None, elapsed);

test/src/spec/wallet.rs:221

  • This spec only tests the legacy multisig code hash path; consider adding a test case for --multisig-code-hash v2 to ensure V2 behavior is also validated.
r#"util to-multisig-addr --sighash-address {} --locktime "2020-01-02T21:00:00+08:00" --multisig-code-hash legacy"#

@zhangsoledad zhangsoledad merged commit dfbd7f4 into nervosnetwork:develop Jun 5, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants