From bf36e967aae58f5cf12db317002bb8fefc0c6c39 Mon Sep 17 00:00:00 2001 From: Jacinta Ferrant Date: Thu, 14 Sep 2023 09:31:14 -0700 Subject: [PATCH] CRC: Update host port and make contract ID into CLI arg instead of just name Signed-off-by: Jacinta Ferrant --- stacks-signer/README.md | 6 +++--- stacks-signer/src/cli.rs | 11 ++++------- stacks-signer/src/main.rs | 10 ++-------- stacks-signer/src/tests/conf/signer-0.toml | 18 +++++++++--------- stacks-signer/src/tests/conf/signer-1.toml | 18 +++++++++--------- stacks-signer/src/tests/conf/signer-2.toml | 18 +++++++++--------- stacks-signer/src/tests/conf/signer-3.toml | 18 +++++++++--------- stacks-signer/src/tests/conf/signer-4.toml | 18 +++++++++--------- .../src/tests/contracts/signers-stackerdb.clar | 10 +++++----- 9 files changed, 59 insertions(+), 68 deletions(-) diff --git a/stacks-signer/README.md b/stacks-signer/README.md index 73cd9554f51..e8d4d719f44 100644 --- a/stacks-signer/README.md +++ b/stacks-signer/README.md @@ -123,14 +123,14 @@ Start the signer and handle requests to sign messages and participate in DKG rou Generate the necessary files to run a collection of signers to communicate via stacker-db. ```bash -./stacks-signer generate-files --num-signers --num-keys --network --contract-name --host --dir +./stacks-signer generate-files --host --contract --num-signers --num-keys --network --dir ``` +- `--host`: The stacks node host to connect to. +- `--contract`: The contract ID of the StackerDB signer contract. - `--num-signers`: The number of signers to generate configuration files for. - `--num-keys`: The total number of key ids to distribute among the signers. - `--private-keys:` A path to a file containing a list of hexadecimal representations of Stacks private keys. Required if `--num-keys` is not set. - `--network`: The network to use. One of "mainnet" or "testnet". -- `--contract-name`: The contract name to give the generated stacker-db contract. -- `--host`: The stacks node host to connect to. - `--dir`: The directory to write files to. Defaults to the current directory. ## Contributing diff --git a/stacks-signer/src/cli.rs b/stacks-signer/src/cli.rs index b403d72d751..7409edc7ad0 100644 --- a/stacks-signer/src/cli.rs +++ b/stacks-signer/src/cli.rs @@ -48,7 +48,7 @@ pub struct StackerDBArgs { /// The Stacks node to connect to #[arg(long)] pub host: SocketAddr, - /// The stacker-db contract to use + /// The stacker-db contract to use. Must be in the format of "STACKS_ADDRESS.CONTRACT_NAME" #[arg(short, long, value_parser = parse_contract)] pub contract: QualifiedContractIdentifier, } @@ -120,6 +120,9 @@ pub struct RunDkgArgs { #[derive(Parser, Debug, Clone)] /// Arguments for the generate-files command pub struct GenerateFilesArgs { + /// The base arguments + #[clap(flatten)] + pub db_args: StackerDBArgs, #[arg( long, required_unless_present = "private_keys", @@ -136,12 +139,6 @@ pub struct GenerateFilesArgs { #[arg(long, value_parser = parse_network)] /// The network to use. One of "mainnet" or "testnet". pub network: Network, - #[arg(long)] - /// The name of the contract to use - pub contract_name: String, - #[arg(long)] - /// The stacks node host to use - pub host: SocketAddr, /// The directory to write the test data files to #[arg(long, default_value = ".")] pub dir: PathBuf, diff --git a/stacks-signer/src/main.rs b/stacks-signer/src/main.rs index 80b60304d97..ff9d7840dae 100644 --- a/stacks-signer/src/main.rs +++ b/stacks-signer/src/main.rs @@ -157,17 +157,11 @@ fn handle_generate_files(args: GenerateFilesArgs) { .collect::>(); // Build the stackerdb contract let stackerdb_contract = build_stackerdb_contract(&signer_stacks_addresses); - debug!("Stacker DB Contract: {}", &stackerdb_contract); - let contract_id = QualifiedContractIdentifier::new( - signer_stacks_addresses[0].into(), - args.contract_name.as_str().into(), - ); - debug!("Contract ID: {}", contract_id); let signer_config_tomls = build_signer_config_tomls( &signer_stacks_private_keys, args.num_keys, - &args.host.to_string(), - &contract_id.to_string(), + &args.db_args.host.to_string(), + &args.db_args.contract.to_string(), ); debug!("Built {:?} signer config tomls.", signer_config_tomls.len()); for (i, file_contents) in signer_config_tomls.iter().enumerate() { diff --git a/stacks-signer/src/tests/conf/signer-0.toml b/stacks-signer/src/tests/conf/signer-0.toml index d97d2501647..ee510d563e0 100644 --- a/stacks-signer/src/tests/conf/signer-0.toml +++ b/stacks-signer/src/tests/conf/signer-0.toml @@ -1,19 +1,19 @@ -message_private_key = "CosqumxnRfykP24DdUCDEEMZ2qCwHPUyBy21Qf55EPKJ" -stacks_private_key = "8a99f02ddede302a0e9fbb4eb4ef1bd587a9c076f67230c3e7a62a9d78d34d0401" -node_host = "127.0.0.1:20444" +message_private_key = "2ZCxUV9BAKJrGnTPaamKHb4HVgj9ArQgEhowuTe7uRt3" +stacks_private_key = "69be0e68947fa7128702761151dc8d9b39ee1401e547781bb2ec3e5b4eb1b36f01" +node_host = "127.0.0.1:20443" endpoint = "localhost:30000" network = "testnet" -stackerdb_contract_id = "ST1RER7KAS4Q81ZTCA025SVSNZ73444NHG4D7BKWC.signers-stackerdb" +stackerdb_contract_id = "ST11Z60137Y96MF89K1KKRTA3CR6B25WY1Y931668.signers-stackerdb" signer_id = 0 signers = [ - {public_key = "y2ZGH2FdFYXCP5Tm2y8yGAR6LB2j3yVUTaV4QpbtC7xm", key_ids = [1, 2, 3, 4]} + {public_key = "swBaKxfzs4pQne7spxhrkF6AtB34WEcreAkJ8mPcqx3t", key_ids = [1, 2, 3, 4]} , - {public_key = "24z7XAnx99SAbeQekcoAM5jQvDyvErF7pSGxNJ9Mqu5uy", key_ids = [5, 6, 7, 8]} + {public_key = "yDJhntuJczbss1XGDmyWtG9Wpw5NDqoBBnedxmyhKiFN", key_ids = [5, 6, 7, 8]} , - {public_key = "eAsVpTz66qN687yzRPrVosyWhMxewd6rfCC2tt4fDGDf", key_ids = [9, 10, 11, 12]} + {public_key = "xNVCph6zd7HLLJcuwrWz1gNbFoPHjXxn7cyRvvTYhP3U", key_ids = [9, 10, 11, 12]} , - {public_key = "2BYKuG6a2jizKaoJJFvdyJc8WFqhBu3oZYuxGHCAt8Pgd", key_ids = [13, 14, 15, 16]} + {public_key = "p2wFfLEbwGCmxCR5eGa46Ct6i3BVjFrvBixRn7FnCQjA", key_ids = [13, 14, 15, 16]} , - {public_key = "cHMPeNTruE17rvvQ1LhD7m9QCna4KZZCYgsAUbkrWHU4", key_ids = [17, 18, 19, 20]} + {public_key = "26jpUNnJPvzDJRJg3hfBn5s5MR4eQ4LLTokjrSDzByh4i", key_ids = [17, 18, 19, 20]} ] diff --git a/stacks-signer/src/tests/conf/signer-1.toml b/stacks-signer/src/tests/conf/signer-1.toml index f4cf9d0021c..73d5cb6a692 100644 --- a/stacks-signer/src/tests/conf/signer-1.toml +++ b/stacks-signer/src/tests/conf/signer-1.toml @@ -1,19 +1,19 @@ -message_private_key = "2KA3ArTdW8NhqMzaZUG5RXo5RgPWx5PRwuLdiZamZ6du" -stacks_private_key = "2136d9374c3aff76808be7917a8c66a30b07d7d5a56a42fedb23cb90c038114e01" -node_host = "127.0.0.1:20444" +message_private_key = "vZTMaCTufQ9YtZPUcqqKRgbxWWkLTxU5iySooPw81D1" +stacks_private_key = "fd5a538e8548e9d6a4a4060a43d0142356df022a4b8fd8ed4a7d0663825f8d2c01" +node_host = "127.0.0.1:20443" endpoint = "localhost:30001" network = "testnet" -stackerdb_contract_id = "ST1RER7KAS4Q81ZTCA025SVSNZ73444NHG4D7BKWC.signers-stackerdb" +stackerdb_contract_id = "ST11Z60137Y96MF89K1KKRTA3CR6B25WY1Y931668.signers-stackerdb" signer_id = 1 signers = [ - {public_key = "y2ZGH2FdFYXCP5Tm2y8yGAR6LB2j3yVUTaV4QpbtC7xm", key_ids = [1, 2, 3, 4]} + {public_key = "swBaKxfzs4pQne7spxhrkF6AtB34WEcreAkJ8mPcqx3t", key_ids = [1, 2, 3, 4]} , - {public_key = "24z7XAnx99SAbeQekcoAM5jQvDyvErF7pSGxNJ9Mqu5uy", key_ids = [5, 6, 7, 8]} + {public_key = "yDJhntuJczbss1XGDmyWtG9Wpw5NDqoBBnedxmyhKiFN", key_ids = [5, 6, 7, 8]} , - {public_key = "eAsVpTz66qN687yzRPrVosyWhMxewd6rfCC2tt4fDGDf", key_ids = [9, 10, 11, 12]} + {public_key = "xNVCph6zd7HLLJcuwrWz1gNbFoPHjXxn7cyRvvTYhP3U", key_ids = [9, 10, 11, 12]} , - {public_key = "2BYKuG6a2jizKaoJJFvdyJc8WFqhBu3oZYuxGHCAt8Pgd", key_ids = [13, 14, 15, 16]} + {public_key = "p2wFfLEbwGCmxCR5eGa46Ct6i3BVjFrvBixRn7FnCQjA", key_ids = [13, 14, 15, 16]} , - {public_key = "cHMPeNTruE17rvvQ1LhD7m9QCna4KZZCYgsAUbkrWHU4", key_ids = [17, 18, 19, 20]} + {public_key = "26jpUNnJPvzDJRJg3hfBn5s5MR4eQ4LLTokjrSDzByh4i", key_ids = [17, 18, 19, 20]} ] diff --git a/stacks-signer/src/tests/conf/signer-2.toml b/stacks-signer/src/tests/conf/signer-2.toml index e96e1cf42f9..7ff263940d1 100644 --- a/stacks-signer/src/tests/conf/signer-2.toml +++ b/stacks-signer/src/tests/conf/signer-2.toml @@ -1,19 +1,19 @@ -message_private_key = "5PsUp2Sn21DeXNH45eUiUsea6Abne7xcBzSM1PCVZzLf" -stacks_private_key = "e7db7cb2e44693041ce195b37cc77d2373f957fd505f769cb26465cd91a518d801" -node_host = "127.0.0.1:20444" +message_private_key = "BZNqcMp82XykQ2z6NLc2h5cTJpPcLQ9AuKVtG4Ut7FY3" +stacks_private_key = "74e8e8550a5210b89461128c600e4bf611d1553e6809308bc012dbb0fbb4818d01" +node_host = "127.0.0.1:20443" endpoint = "localhost:30002" network = "testnet" -stackerdb_contract_id = "ST1RER7KAS4Q81ZTCA025SVSNZ73444NHG4D7BKWC.signers-stackerdb" +stackerdb_contract_id = "ST11Z60137Y96MF89K1KKRTA3CR6B25WY1Y931668.signers-stackerdb" signer_id = 2 signers = [ - {public_key = "y2ZGH2FdFYXCP5Tm2y8yGAR6LB2j3yVUTaV4QpbtC7xm", key_ids = [1, 2, 3, 4]} + {public_key = "swBaKxfzs4pQne7spxhrkF6AtB34WEcreAkJ8mPcqx3t", key_ids = [1, 2, 3, 4]} , - {public_key = "24z7XAnx99SAbeQekcoAM5jQvDyvErF7pSGxNJ9Mqu5uy", key_ids = [5, 6, 7, 8]} + {public_key = "yDJhntuJczbss1XGDmyWtG9Wpw5NDqoBBnedxmyhKiFN", key_ids = [5, 6, 7, 8]} , - {public_key = "eAsVpTz66qN687yzRPrVosyWhMxewd6rfCC2tt4fDGDf", key_ids = [9, 10, 11, 12]} + {public_key = "xNVCph6zd7HLLJcuwrWz1gNbFoPHjXxn7cyRvvTYhP3U", key_ids = [9, 10, 11, 12]} , - {public_key = "2BYKuG6a2jizKaoJJFvdyJc8WFqhBu3oZYuxGHCAt8Pgd", key_ids = [13, 14, 15, 16]} + {public_key = "p2wFfLEbwGCmxCR5eGa46Ct6i3BVjFrvBixRn7FnCQjA", key_ids = [13, 14, 15, 16]} , - {public_key = "cHMPeNTruE17rvvQ1LhD7m9QCna4KZZCYgsAUbkrWHU4", key_ids = [17, 18, 19, 20]} + {public_key = "26jpUNnJPvzDJRJg3hfBn5s5MR4eQ4LLTokjrSDzByh4i", key_ids = [17, 18, 19, 20]} ] diff --git a/stacks-signer/src/tests/conf/signer-3.toml b/stacks-signer/src/tests/conf/signer-3.toml index 3b90338af3a..e7ac219a40d 100644 --- a/stacks-signer/src/tests/conf/signer-3.toml +++ b/stacks-signer/src/tests/conf/signer-3.toml @@ -1,19 +1,19 @@ -message_private_key = "78WZR12DxgbtCpTr7cUYFL1mWnVNJrwG8hWTvAMa1tHQ" -stacks_private_key = "a7ade2a5189f79161e02a6c2f4dab325fef2a5a74890d4ff0c0d1721786f920e01" -node_host = "127.0.0.1:20444" +message_private_key = "3fMkii13QRwRqrwgcLtxmAAcqCfGwpY3ANZLYMWD8qUj" +stacks_private_key = "803fa7b9c8a39ed368f160b3dcbfaa8f677fc157ffbccb46ee3e4a32a37f12d201" +node_host = "127.0.0.1:20443" endpoint = "localhost:30003" network = "testnet" -stackerdb_contract_id = "ST1RER7KAS4Q81ZTCA025SVSNZ73444NHG4D7BKWC.signers-stackerdb" +stackerdb_contract_id = "ST11Z60137Y96MF89K1KKRTA3CR6B25WY1Y931668.signers-stackerdb" signer_id = 3 signers = [ - {public_key = "y2ZGH2FdFYXCP5Tm2y8yGAR6LB2j3yVUTaV4QpbtC7xm", key_ids = [1, 2, 3, 4]} + {public_key = "swBaKxfzs4pQne7spxhrkF6AtB34WEcreAkJ8mPcqx3t", key_ids = [1, 2, 3, 4]} , - {public_key = "24z7XAnx99SAbeQekcoAM5jQvDyvErF7pSGxNJ9Mqu5uy", key_ids = [5, 6, 7, 8]} + {public_key = "yDJhntuJczbss1XGDmyWtG9Wpw5NDqoBBnedxmyhKiFN", key_ids = [5, 6, 7, 8]} , - {public_key = "eAsVpTz66qN687yzRPrVosyWhMxewd6rfCC2tt4fDGDf", key_ids = [9, 10, 11, 12]} + {public_key = "xNVCph6zd7HLLJcuwrWz1gNbFoPHjXxn7cyRvvTYhP3U", key_ids = [9, 10, 11, 12]} , - {public_key = "2BYKuG6a2jizKaoJJFvdyJc8WFqhBu3oZYuxGHCAt8Pgd", key_ids = [13, 14, 15, 16]} + {public_key = "p2wFfLEbwGCmxCR5eGa46Ct6i3BVjFrvBixRn7FnCQjA", key_ids = [13, 14, 15, 16]} , - {public_key = "cHMPeNTruE17rvvQ1LhD7m9QCna4KZZCYgsAUbkrWHU4", key_ids = [17, 18, 19, 20]} + {public_key = "26jpUNnJPvzDJRJg3hfBn5s5MR4eQ4LLTokjrSDzByh4i", key_ids = [17, 18, 19, 20]} ] diff --git a/stacks-signer/src/tests/conf/signer-4.toml b/stacks-signer/src/tests/conf/signer-4.toml index 49833e9dfe6..c2eb3f37d00 100644 --- a/stacks-signer/src/tests/conf/signer-4.toml +++ b/stacks-signer/src/tests/conf/signer-4.toml @@ -1,19 +1,19 @@ -message_private_key = "25sCKA2hhrbYLR9U7RfKtL4hWQiY9cdmntCDww5SB9HA" -stacks_private_key = "61a2e31072a9cec9b1e5950d7d63e69a8b0e049a7eab43bc5918f7bb1bed8aa601" -node_host = "127.0.0.1:20444" +message_private_key = "9hn4j7pm37WyG6WMX25dn8j8v8E2uyTCDRPNrucjDWn1" +stacks_private_key = "1bfdf386114aacf355fe018a1ec7ac728fa05ca20a6131a70f686291bb9b31ca01" +node_host = "127.0.0.1:20443" endpoint = "localhost:30004" network = "testnet" -stackerdb_contract_id = "ST1RER7KAS4Q81ZTCA025SVSNZ73444NHG4D7BKWC.signers-stackerdb" +stackerdb_contract_id = "ST11Z60137Y96MF89K1KKRTA3CR6B25WY1Y931668.signers-stackerdb" signer_id = 4 signers = [ - {public_key = "y2ZGH2FdFYXCP5Tm2y8yGAR6LB2j3yVUTaV4QpbtC7xm", key_ids = [1, 2, 3, 4]} + {public_key = "swBaKxfzs4pQne7spxhrkF6AtB34WEcreAkJ8mPcqx3t", key_ids = [1, 2, 3, 4]} , - {public_key = "24z7XAnx99SAbeQekcoAM5jQvDyvErF7pSGxNJ9Mqu5uy", key_ids = [5, 6, 7, 8]} + {public_key = "yDJhntuJczbss1XGDmyWtG9Wpw5NDqoBBnedxmyhKiFN", key_ids = [5, 6, 7, 8]} , - {public_key = "eAsVpTz66qN687yzRPrVosyWhMxewd6rfCC2tt4fDGDf", key_ids = [9, 10, 11, 12]} + {public_key = "xNVCph6zd7HLLJcuwrWz1gNbFoPHjXxn7cyRvvTYhP3U", key_ids = [9, 10, 11, 12]} , - {public_key = "2BYKuG6a2jizKaoJJFvdyJc8WFqhBu3oZYuxGHCAt8Pgd", key_ids = [13, 14, 15, 16]} + {public_key = "p2wFfLEbwGCmxCR5eGa46Ct6i3BVjFrvBixRn7FnCQjA", key_ids = [13, 14, 15, 16]} , - {public_key = "cHMPeNTruE17rvvQ1LhD7m9QCna4KZZCYgsAUbkrWHU4", key_ids = [17, 18, 19, 20]} + {public_key = "26jpUNnJPvzDJRJg3hfBn5s5MR4eQ4LLTokjrSDzByh4i", key_ids = [17, 18, 19, 20]} ] diff --git a/stacks-signer/src/tests/contracts/signers-stackerdb.clar b/stacks-signer/src/tests/contracts/signers-stackerdb.clar index 64fe1ae8a10..81493284874 100644 --- a/stacks-signer/src/tests/contracts/signers-stackerdb.clar +++ b/stacks-signer/src/tests/contracts/signers-stackerdb.clar @@ -2,23 +2,23 @@ (define-read-only (stackerdb-get-signer-slots) (ok (list { - signer: 'ST1RER7KAS4Q81ZTCA025SVSNZ73444NHG4D7BKWC, + signer: 'ST24GDPTR7D9G3GFRR233JMWSD9HA296EXXG5XVGA, num-slots: u10 } { - signer: 'ST3WM0P0EWTVRA1EDWS9YFGDKV2A6A8N9TFANTSV9, + signer: 'ST1MR26HR7MMDE847BE2QC1CTNQY4WKN9XDKNPEP3, num-slots: u10 } { - signer: 'ST2411R5HEBCKFQ8YKRANVFAJ8B6QNPEG9WHHP5TX, + signer: 'ST110M4DRDXX2RF3W8EY1HCRQ25CS24PGY22DZ004, num-slots: u10 } { - signer: 'ST3N2XTMKWPWCGE3MC8EMDEP0C9CRB728M4EDZDNZ, + signer: 'ST69990VH3BVCV39QWT6CJAVVA9QPB1715HTSN75, num-slots: u10 } { - signer: 'ST2NHTSBDFQRJSCBKHFRWG5C0DS22G357CNQE1ZQ, + signer: 'STCZSBZJK6C3MMAAW9N9RHSDKRKB9AKGJ2JMVDKN, num-slots: u10 } )))