Skip to content

Commit df5431e

Browse files
committed
Merge branch 'develop' into debug/dkg-results
2 parents 344388b + 8874fd2 commit df5431e

File tree

22 files changed

+757
-258
lines changed

22 files changed

+757
-258
lines changed

.cargo/config

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
stacks-node = "run --package stacks-node --"
33
fmt-stacks = "fmt -- --config group_imports=StdExternalCrate,imports_granularity=Module"
44

5-
# Default to `native`
6-
# This makes it slightly faster for running tests and locally built binaries.
7-
# This can cause trouble when building "portable" binaries, such as for docker,
8-
# so disable it with the "portable" feature.
9-
[target.'cfg(not(feature = "portable"))']
10-
rustflags = ["-Ctarget-cpu=native"]
5+
# Uncomment to improve performance slightly, at the cost of portability
6+
# * Note that native binaries may not run on CPUs that are different from the build machine
7+
# [build]
8+
# rustflags = ["-Ctarget-cpu=native"]
119

1210
# Needed by perf to generate flamegraphs.
1311
#[target.x86_64-unknown-linux-gnu]

.github/actions/dockerfiles/Dockerfile.debian-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \
1919
&& cd ${BUILD_DIR} \
2020
&& rustup target add ${TARGET} \
2121
&& rustup component add rustfmt \
22-
&& cargo build --features monitoring_prom,slog_json,portable --release --workspace --target ${TARGET} \
22+
&& cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} \
2323
&& mkdir -p /out \
2424
&& cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out
2525

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN apk add --no-cache musl-dev
1212

1313
RUN mkdir /out
1414

15-
RUN cd testnet/stacks-node && cargo build --features monitoring_prom,slog_json,portable --release
15+
RUN cd testnet/stacks-node && cargo build --features monitoring_prom,slog_json --release
1616

1717
RUN cp target/release/stacks-node /out
1818

Dockerfile.debian

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY . .
1010

1111
RUN mkdir /out
1212

13-
RUN cd testnet/stacks-node && cargo build --features monitoring_prom,slog_json,portable --release
13+
RUN cd testnet/stacks-node && cargo build --features monitoring_prom,slog_json --release
1414

1515
RUN cp target/release/stacks-node /out
1616

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ cargo build --release
4949
cargo build --profile release-lite
5050
```
5151

52+
_Note on building_: you may set `RUSTFLAGS` to build binaries for your native cpu:
53+
54+
```
55+
RUSTFLAGS="-Ctarget-cpu=native"
56+
```
57+
58+
or uncomment these lines in `./cargo/config`:
59+
60+
```
61+
# [build]
62+
# rustflags = ["-Ctarget-cpu=native"]
63+
```
64+
5265
## Testing
5366

5467
**Run the tests:**

stacks-signer/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,3 @@ features = ["arbitrary_precision", "unbounded_depth"]
6060
[dependencies.secp256k1]
6161
version = "0.24.3"
6262
features = ["serde", "recovery"]
63-
64-
[features]
65-
portable = []

stacks-signer/src/cli.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ pub struct Cli {
4444
/// Subcommands for the stacks signer binary
4545
#[derive(clap::Subcommand, Debug)]
4646
pub enum Command {
47-
/// Get a chunk from the stacker-db instance
47+
/// Get a chunk from the stacker-db instance in hex encoding
4848
GetChunk(GetChunkArgs),
49-
/// Get the latest chunk from the stacker-db instance
49+
/// Get the latest chunk from the stacker-db instance in hex encoding
5050
GetLatestChunk(GetLatestChunkArgs),
51-
/// List chunks from the stacker-db instance
51+
/// List chunks from the stacker-db instance in hex encoding
5252
ListChunks(StackerDBArgs),
5353
/// Upload a chunk to the stacker-db instance
5454
PutChunk(PutChunkArgs),
@@ -64,6 +64,8 @@ pub enum Command {
6464
GenerateFiles(GenerateFilesArgs),
6565
/// Generate a signature for Stacking transactions
6666
GenerateStackingSignature(GenerateStackingSignatureArgs),
67+
/// Check a configuration file and output config information
68+
CheckConfig(RunSignerArgs),
6769
}
6870

6971
/// Basic arguments for all cyrptographic and stacker-db functionality
@@ -349,17 +351,16 @@ mod tests {
349351
}
350352

351353
fn clarity_tuple_version(pox_addr: &PoxAddress) -> u8 {
352-
pox_addr
354+
*pox_addr
353355
.as_clarity_tuple()
354356
.expect("Failed to generate clarity tuple for pox address")
355357
.get("version")
356358
.expect("Expected version in clarity tuple")
357359
.clone()
358360
.expect_buff(1)
359361
.expect("Expected version to be a u128")
360-
.get(0)
362+
.first()
361363
.expect("Expected version to be a uint")
362-
.clone()
363364
}
364365

365366
#[test]

stacks-signer/src/client/mod.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pub(crate) mod tests {
116116
use blockstack_lib::net::api::getpoxinfo::{
117117
RPCPoxCurrentCycleInfo, RPCPoxEpoch, RPCPoxInfoData, RPCPoxNextCycleInfo,
118118
};
119+
use blockstack_lib::net::api::postfeerate::{RPCFeeEstimate, RPCFeeEstimateResponse};
119120
use blockstack_lib::util_lib::boot::boot_code_id;
120121
use clarity::vm::costs::ExecutionCost;
121122
use clarity::vm::types::TupleData;
@@ -398,6 +399,44 @@ pub(crate) mod tests {
398399
format!("HTTP/1.1 200 OK\n\n{{\"okay\":true,\"result\":\"{hex}\"}}")
399400
}
400401

402+
/// Build a response for the get_medium_estimated_fee_ustx_response request with a specific medium estimate
403+
pub fn build_get_medium_estimated_fee_ustx_response(
404+
medium_estimate: u64,
405+
) -> (String, RPCFeeEstimateResponse) {
406+
// Generate some random info
407+
let fee_response = RPCFeeEstimateResponse {
408+
estimated_cost: ExecutionCost {
409+
write_length: thread_rng().next_u64(),
410+
write_count: thread_rng().next_u64(),
411+
read_length: thread_rng().next_u64(),
412+
read_count: thread_rng().next_u64(),
413+
runtime: thread_rng().next_u64(),
414+
},
415+
estimated_cost_scalar: thread_rng().next_u64(),
416+
cost_scalar_change_by_byte: thread_rng().next_u32() as f64,
417+
estimations: vec![
418+
RPCFeeEstimate {
419+
fee_rate: thread_rng().next_u32() as f64,
420+
fee: thread_rng().next_u64(),
421+
},
422+
RPCFeeEstimate {
423+
fee_rate: thread_rng().next_u32() as f64,
424+
fee: medium_estimate,
425+
},
426+
RPCFeeEstimate {
427+
fee_rate: thread_rng().next_u32() as f64,
428+
fee: thread_rng().next_u64(),
429+
},
430+
],
431+
};
432+
let fee_response_json = serde_json::to_string(&fee_response)
433+
.expect("Failed to serialize fee estimate response");
434+
(
435+
format!("HTTP/1.1 200 OK\n\n{fee_response_json}"),
436+
fee_response,
437+
)
438+
}
439+
401440
/// Generate a signer config with the given number of signers and keys where the first signer is
402441
/// obtained from the provided global config
403442
pub fn generate_signer_config(
@@ -515,6 +554,7 @@ pub(crate) mod tests {
515554
nonce_timeout: config.nonce_timeout,
516555
sign_timeout: config.sign_timeout,
517556
tx_fee_ustx: config.tx_fee_ustx,
557+
max_tx_fee_ustx: config.max_tx_fee_ustx,
518558
db_path: config.db_path.clone(),
519559
}
520560
}

stacks-signer/src/client/stackerdb.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl StackerDB {
100100
}
101101

102102
/// Sends message (as a raw msg ID and bytes) to the .signers stacker-db with an
103-
/// exponential backoff retry
103+
/// exponential backoff retry
104104
pub fn send_message_bytes_with_retry(
105105
&mut self,
106106
msg_id: &MessageSlotID,
@@ -224,9 +224,7 @@ impl StackerDB {
224224
}
225225

226226
/// Get this signer's latest transactions from stackerdb
227-
pub fn get_current_transactions_with_retry(
228-
&mut self,
229-
) -> Result<Vec<StacksTransaction>, ClientError> {
227+
pub fn get_current_transactions(&mut self) -> Result<Vec<StacksTransaction>, ClientError> {
230228
let Some(transactions_session) = self
231229
.signers_message_stackerdb_sessions
232230
.get_mut(&MessageSlotID::Transactions)
@@ -237,7 +235,7 @@ impl StackerDB {
237235
}
238236

239237
/// Get the latest signer transactions from signer ids for the next reward cycle
240-
pub fn get_next_transactions_with_retry(
238+
pub fn get_next_transactions(
241239
&mut self,
242240
signer_ids: &[SignerSlotID],
243241
) -> Result<Vec<StacksTransaction>, ClientError> {
@@ -272,7 +270,7 @@ mod tests {
272270
use crate::config::GlobalConfig;
273271

274272
#[test]
275-
fn get_signer_transactions_with_retry_should_succeed() {
273+
fn get_signer_transactions_should_succeed() {
276274
let config = GlobalConfig::load_from_file("./src/tests/conf/signer-0.toml").unwrap();
277275
let signer_config = generate_signer_config(&config, 5, 20);
278276
let mut stackerdb = StackerDB::from(&signer_config);
@@ -297,7 +295,7 @@ mod tests {
297295
let message = signer_message.serialize_to_vec();
298296

299297
let signer_slot_ids = vec![SignerSlotID(0), SignerSlotID(1)];
300-
let h = spawn(move || stackerdb.get_next_transactions_with_retry(&signer_slot_ids));
298+
let h = spawn(move || stackerdb.get_next_transactions(&signer_slot_ids));
301299
let mut response_bytes = b"HTTP/1.1 200 OK\n\n".to_vec();
302300
response_bytes.extend(message);
303301
let mock_server = mock_server_from_config(&config);
@@ -315,7 +313,7 @@ mod tests {
315313
}
316314

317315
#[test]
318-
fn send_signer_message_with_retry_should_succeed() {
316+
fn send_signer_message_should_succeed() {
319317
let config = GlobalConfig::load_from_file("./src/tests/conf/signer-1.toml").unwrap();
320318
let signer_config = generate_signer_config(&config, 5, 20);
321319
let mut stackerdb = StackerDB::from(&signer_config);

0 commit comments

Comments
 (0)