Skip to content

Commit 04c6c8a

Browse files
committed
Remove stale functions and config options left over from v1 signer and update the README file
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 81a09c2 commit 04c6c8a

File tree

8 files changed

+85
-712
lines changed

8 files changed

+85
-712
lines changed

stacks-signer/README.md

Lines changed: 77 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stacks-signer: Stacks Signer CLI
22

3-
stacks-signer is a command-line interface (CLI) for executing DKG (Distributed Key Generation) rounds, signing transactions and blocks, and more within the Stacks blockchain ecosystem. This tool provides various subcommands to interact with the StackerDB contract, perform cryptographic operations, and run a Stacks compliant signer.
3+
stacks-signer is a command-line interface (CLI) for operating a Stacks compliant signer. This tool provides various subcommands to interact with the StackerDB contract, generate SIP voting and stacking signatures, and monitoring the Signer network for expected behaviour.
44

55
## Installation
66

@@ -25,18 +25,92 @@ To use stacks-signer, you need to build and install the Rust program. You can do
2525
./target/release/stacks-signer --help
2626
```
2727

28+
4. **Build with Prometheus Metrics Enabled**: You can optionally build and run the stacks-signer with monitoring metrics enabled.
29+
30+
```bash
31+
cd stacks-signer
32+
cargo build --release --features "monitoring_prom"
33+
cargo run --features "monitoring_prom" -p stacks-signer run --config <config_file>
34+
```
35+
36+
You must specify the "metrics_endpoint" option in the config file to serve these metrics.
37+
See [metrics documentation](TODO) for a complete breakdown of the available metrics.
38+
2839
## Usage
2940

3041
The stacks-signer CLI provides the following subcommands:
3142

43+
### `run`
44+
45+
Start the signer and handle requests to sign Stacks block proposals.
46+
47+
```bash
48+
./stacks-signer run --config <config_file>
49+
50+
```
51+
52+
### `monitor-signers`
53+
54+
Periodically query the current reward cycle's signers' StackerDB slots to verify their operation.
55+
56+
```bash
57+
./stacks-signer monitor-signers --host <host> --interval <interval> --max-age <max_age>
58+
59+
```
60+
- `--host`: The Stacks node to connect to.
61+
- `--interval`: The polling interval in seconds for querying stackerDB.
62+
- `--max-age`: The max age in seconds before a signer message is considered stale.
63+
64+
### `generate-stacking-signature`
65+
66+
Generate a signature for stacking.
67+
68+
```bash
69+
./stacks-signer generate-stacking-signature --config <config_file> --pox-address <address> --reward-cycle <cycle> --period <period> --max-amount <max_amount> --auth-id <auth_id>
70+
71+
```
72+
- `--config`: The path to the signer configuration file.
73+
- `--pox-address`: The BTC address used to receive rewards
74+
- `--reward-cycle`: The reward cycle during which this signature is used
75+
- `--method`: Stacking metod that can be used
76+
- `--period`: Number of cycles used as a lock period. Use `1` for stack-aggregation-commit method
77+
- `--max-amount`: The max amount of uSTX that can be used in this unique transaction
78+
- `--auth-id`: A unique identifier to prevent re-using this authorization
79+
- `--json`: Output information in JSON format
80+
81+
### `generate-vote`
82+
83+
Generate a vote signature for a specific SIP
84+
85+
```bash
86+
./stacks-signer generate-vote --config <config_file> --vote <yes|no> --sip <sip_number>
87+
88+
```
89+
- `--config`: The path to the signer configuration file.
90+
- `--vote`: The vote (YES or NO)
91+
- `--sip`: the number of the SIP being voted on
92+
93+
### `verify-vote`
94+
95+
Verify the validity of a vote signature for a specific SIP.
96+
97+
```bash
98+
./stacks-signer verify-vote --public-key <public_key> --signature <signature> --vote <yes|no> --sip <sip_number>
99+
100+
```
101+
- `--public-key`: The stacks public key to verify against in hexadecimal format
102+
- `--signature`: The message signature in hexadecimal format
103+
- `--vote`: The vote (YES or NO)
104+
- `--sip`: the number of the SIP being voted on
105+
32106
### `get-chunk`
33107

34108
Retrieve a chunk from the StackerDB instance.
35109

36110
```bash
37111
./stacks-signer get-chunk --host <host> --contract <contract> --slot_id <slot_id> --slot_version <slot_version>
38-
```
39112

113+
```
40114
- `--host`: The stacks node host to connect to.
41115
- `--contract`: The contract ID of the StackerDB instance.
42116
- `--slot-id`: The slot ID to get.
@@ -49,7 +123,6 @@ Retrieve the latest chunk from the StackerDB instance.
49123
```bash
50124
./stacks-signer get-latest-chunk --host <host> --contract <contract> --slot-id <slot_id>
51125
```
52-
53126
- `--host`: The stacks node host to connect to.
54127
- `--contract`: The contract ID of the StackerDB instance.
55128
- `--slot-id`: The slot ID to get.
@@ -71,72 +144,17 @@ Upload a chunk to the StackerDB instance.
71144
```bash
72145
./stacks-signer put-chunk --host <host> --contract <contract> --private_key <private_key> --slot-id <slot_id> --slot-version <slot_version> [--data <data>]
73146
```
74-
75147
- `--host`: The stacks node host to connect to.
76148
- `--contract`: The contract ID of the StackerDB instance.
77149
- `--private_key`: The Stacks private key to use in hexademical format.
78150
- `--slot-id`: The slot ID to get.
79151
- `--slot-version`: The slot version to get.
80152
- `--data`: The data to upload. If you wish to pipe data using STDIN, use with '-'.
81153

82-
### `dkg`
83-
84-
Run a distributed key generation round through stacker-db.
85-
86-
```bash
87-
./stacks-signer dkg --config <config_file>
88-
```
89-
90-
- `--config`: The path to the signer configuration file.
91-
92-
### `dkg-sign`
93-
94-
Run a distributed key generation round and sign a given message through stacker-db.
95-
96-
```bash
97-
./stacks-signer dkg-sign --config <config_file> [--data <data>]
98-
```
99-
- `--config`: The path to the signer configuration file.
100-
- `--data`: The data to sign. If you wish to pipe data using STDIN, use with '-'.
101-
102-
103-
### `dkg-sign`
104-
105-
Sign a given message through stacker-db.
106-
107-
```bash
108-
./stacks-signer sign --config <config_file> [--data <data>]
109-
```
110-
- `--config`: The path to the signer configuration file.
111-
- `--data`: The data to sign. If you wish to pipe data using STDIN, use with '-'.
112-
113-
### `run`
114-
115-
Start the signer and handle requests to sign messages and participate in DKG rounds via stacker-db.
116-
```bash
117-
./stacks-signer run --config <config_file>
118-
```
119-
- `--config`: The path to the signer configuration file.
120-
121-
### `generate-files`
122-
123-
Generate the necessary files to run a collection of signers to communicate via stacker-db.
124-
125-
```bash
126-
./stacks-signer generate-files --host <host> --contract <contract> --num-signers <num_signers> --num-keys <num_keys> --network <network> --dir <dir>
127-
```
128-
- `--host`: The stacks node host to connect to.
129-
- `--contract`: The contract ID of the StackerDB signer contract.
130-
- `--num-signers`: The number of signers to generate configuration files for.
131-
- `--num-keys`: The total number of key ids to distribute among the signers.
132-
- `--private-keys:` A path to a file containing a list of hexadecimal representations of Stacks private keys. Required if `--num-keys` is not set.
133-
- `--network`: The network to use. One of "mainnet" or "testnet".
134-
- `--dir`: The directory to write files to. Defaults to the current directory.
135-
- `--timeout`: Optional timeout in milliseconds to use when polling for updates in the StackerDB runloop.
136-
137154
## Contributing
138155

139156
To contribute to the stacks-signer project, please read the [Contributing Guidelines](../CONTRIBUTING.md).
157+
140158
## License
141159

142160
This program is open-source software released under the terms of the GNU General Public License (GPL). You should have received a copy of the GNU General Public License along with this program.

stacks-signer/src/client/mod.rs

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,12 @@ pub(crate) mod tests {
129129

130130
use blockstack_lib::chainstate::stacks::boot::POX_4_NAME;
131131
use blockstack_lib::chainstate::stacks::db::StacksBlockHeaderTypes;
132-
use blockstack_lib::net::api::getaccount::AccountEntryResponse;
133132
use blockstack_lib::net::api::getinfo::RPCPeerInfoData;
134133
use blockstack_lib::net::api::getpoxinfo::{
135134
RPCPoxCurrentCycleInfo, RPCPoxEpoch, RPCPoxInfoData, RPCPoxNextCycleInfo,
136135
};
137-
use blockstack_lib::net::api::postfeerate::{RPCFeeEstimate, RPCFeeEstimateResponse};
138136
use blockstack_lib::util_lib::boot::boot_code_id;
139137
use clarity::vm::costs::ExecutionCost;
140-
use clarity::vm::types::TupleData;
141138
use clarity::vm::Value as ClarityValue;
142139
use libsigner::SignerEntries;
143140
use rand::distributions::Standard;
@@ -221,28 +218,6 @@ pub(crate) mod tests {
221218
ConsensusHash(hash)
222219
}
223220

224-
/// Build a response for the get_last_round request
225-
pub fn build_get_last_round_response(round: u64) -> String {
226-
let value = ClarityValue::some(ClarityValue::UInt(round as u128))
227-
.expect("Failed to create response");
228-
build_read_only_response(&value)
229-
}
230-
231-
/// Build a response for the get_account_nonce request
232-
pub fn build_account_nonce_response(nonce: u64) -> String {
233-
let account_nonce_entry = AccountEntryResponse {
234-
nonce,
235-
balance: "0x00000000000000000000000000000000".to_string(),
236-
locked: "0x00000000000000000000000000000000".to_string(),
237-
unlock_height: thread_rng().next_u64(),
238-
balance_proof: None,
239-
nonce_proof: None,
240-
};
241-
let account_nonce_entry_json = serde_json::to_string(&account_nonce_entry)
242-
.expect("Failed to serialize account nonce entry");
243-
format!("HTTP/1.1 200 OK\n\n{account_nonce_entry_json}")
244-
}
245-
246221
/// Build a response to get_pox_data_with_retry where it returns a specific reward cycle id and block height
247222
pub fn build_get_pox_data_response(
248223
reward_cycle: Option<u64>,
@@ -377,44 +352,6 @@ pub(crate) mod tests {
377352
format!("HTTP/1.1 200 OK\n\n{{\"okay\":true,\"result\":\"{hex}\"}}")
378353
}
379354

380-
/// Build a response for the get_medium_estimated_fee_ustx_response request with a specific medium estimate
381-
pub fn build_get_medium_estimated_fee_ustx_response(
382-
medium_estimate: u64,
383-
) -> (String, RPCFeeEstimateResponse) {
384-
// Generate some random info
385-
let fee_response = RPCFeeEstimateResponse {
386-
estimated_cost: ExecutionCost {
387-
write_length: thread_rng().next_u64(),
388-
write_count: thread_rng().next_u64(),
389-
read_length: thread_rng().next_u64(),
390-
read_count: thread_rng().next_u64(),
391-
runtime: thread_rng().next_u64(),
392-
},
393-
estimated_cost_scalar: thread_rng().next_u64(),
394-
cost_scalar_change_by_byte: thread_rng().next_u32() as f64,
395-
estimations: vec![
396-
RPCFeeEstimate {
397-
fee_rate: thread_rng().next_u32() as f64,
398-
fee: thread_rng().next_u64(),
399-
},
400-
RPCFeeEstimate {
401-
fee_rate: thread_rng().next_u32() as f64,
402-
fee: medium_estimate,
403-
},
404-
RPCFeeEstimate {
405-
fee_rate: thread_rng().next_u32() as f64,
406-
fee: thread_rng().next_u64(),
407-
},
408-
],
409-
};
410-
let fee_response_json = serde_json::to_string(&fee_response)
411-
.expect("Failed to serialize fee estimate response");
412-
(
413-
format!("HTTP/1.1 200 OK\n\n{fee_response_json}"),
414-
fee_response,
415-
)
416-
}
417-
418355
/// Generate a signer config with the given number of signers and keys where the first signer is
419356
/// obtained from the provided global config
420357
pub fn generate_signer_config(config: &GlobalConfig, num_signers: u32) -> SignerConfig {
@@ -473,43 +410,12 @@ pub(crate) mod tests {
473410
stacks_private_key: config.stacks_private_key,
474411
node_host: config.node_host.to_string(),
475412
mainnet: config.network.is_mainnet(),
476-
dkg_end_timeout: config.dkg_end_timeout,
477-
dkg_private_timeout: config.dkg_private_timeout,
478-
dkg_public_timeout: config.dkg_public_timeout,
479-
nonce_timeout: config.nonce_timeout,
480-
sign_timeout: config.sign_timeout,
481-
tx_fee_ustx: config.tx_fee_ustx,
482-
max_tx_fee_ustx: config.max_tx_fee_ustx,
483413
db_path: config.db_path.clone(),
484414
first_proposal_burn_block_timing: config.first_proposal_burn_block_timing,
485415
block_proposal_timeout: config.block_proposal_timeout,
486416
}
487417
}
488418

489-
pub fn build_get_round_info_response(info: Option<(u64, u64)>) -> String {
490-
let clarity_value = if let Some((vote_count, vote_weight)) = info {
491-
ClarityValue::some(ClarityValue::Tuple(
492-
TupleData::from_data(vec![
493-
("votes-count".into(), ClarityValue::UInt(vote_count as u128)),
494-
(
495-
"votes-weight".into(),
496-
ClarityValue::UInt(vote_weight as u128),
497-
),
498-
])
499-
.expect("BUG: Failed to create clarity value from tuple data"),
500-
))
501-
.expect("BUG: Failed to create clarity value from tuple data")
502-
} else {
503-
ClarityValue::none()
504-
};
505-
build_read_only_response(&clarity_value)
506-
}
507-
508-
pub fn build_get_weight_threshold_response(threshold: u64) -> String {
509-
let clarity_value = ClarityValue::UInt(threshold as u128);
510-
build_read_only_response(&clarity_value)
511-
}
512-
513419
pub fn build_get_tenure_tip_response(header_types: &StacksBlockHeaderTypes) -> String {
514420
let response_json =
515421
serde_json::to_string(header_types).expect("Failed to serialize tenure tip info");

0 commit comments

Comments
 (0)