Skip to content

Commit f465d80

Browse files
authored
Merge branch 'develop' into long-block-proposal-timeout
2 parents 8641730 + 9b48330 commit f465d80

File tree

22 files changed

+384
-211
lines changed

22 files changed

+384
-211
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 93 additions & 150 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1313

1414
### Fixed
1515

16+
- Error responses to /v2/transactions/fees are once again expressed as JSON ([#4145](https://github.com/stacks-network/stacks-core/issues/4145)).
17+
1618
## [3.1.0.0.5]
1719

1820
### Added

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/release-process.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ The timing of the next Stacking cycle can be found [here](https://stx.eco/dao/to
6464
- Add cherry-picked commits to the `feat/X.Y.Z.A.n-pr_number` branch
6565
- Merge `feat/X.Y.Z.A.n-pr_number` into `release/X.Y.Z.A.n`.
6666

67-
4. Open a PR to update the [CHANGELOG](../CHANGELOG.md) file in the `release/X.Y.Z.A.n` branch.
67+
4. Open a PR to update the [CHANGELOG](../CHANGELOG.md) in the `release/X.Y.Z.A.n` branch.
6868

6969
- Create a chore branch from `release/X.Y.Z.A.n`, ex: `chore/X.Y.Z.A.n-changelog`.
7070
- Add summaries of all Pull Requests to the `Added`, `Changed` and `Fixed` sections.
71+
- Update the `stacks_node_version` string in [versions.toml](../versions.toml) to match this release.
7172

7273
- Pull requests merged into `develop` can be found [here](https://github.com/stacks-network/stacks-core/pulls?q=is%3Apr+is%3Aclosed+base%3Adevelop+sort%3Aupdated-desc).
7374

libsigner/src/libsigner.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use blockstack_lib::version_string;
5353
use clarity::codec::StacksMessageCodec;
5454
use clarity::vm::types::QualifiedContractIdentifier;
5555
use lazy_static::lazy_static;
56+
use stacks_common::versions::STACKS_SIGNER_VERSION;
5657

5758
pub use crate::error::{EventError, RPCError};
5859
pub use crate::events::{
@@ -80,7 +81,12 @@ pub trait SignerMessage<T: MessageSlotID>: StacksMessageCodec {
8081
lazy_static! {
8182
/// The version string for the signer
8283
pub static ref VERSION_STRING: String = {
83-
let pkg_version = option_env!("STACKS_NODE_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"));
84+
let pkg_version = option_env!("STACKS_NODE_VERSION").or(Some(STACKS_SIGNER_VERSION));
8485
version_string("stacks-signer", pkg_version)
8586
};
8687
}
88+
89+
#[test]
90+
fn test_version_string() {
91+
assert!(VERSION_STRING.contains(format!("stacks-signer {}", STACKS_SIGNER_VERSION).as_str()));
92+
}

stacks-common/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ keywords = [ "stacks", "stx", "bitcoin", "crypto", "blockstack", "decentralized"
1212
readme = "README.md"
1313
resolver = "2"
1414
edition = "2021"
15+
build = "build.rs"
1516

1617
[lib]
1718
name = "stacks_common"
@@ -73,6 +74,9 @@ serde = []
7374
bech32_std = []
7475
bech32_strict = []
7576

77+
[build-dependencies]
78+
toml = "0.5.6"
79+
7680
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies]
7781
sha2 = { version = "0.10", features = ["asm"] }
7882

stacks-common/build.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use std::path::Path;
2+
use std::{env, fs};
3+
4+
use toml::Value;
5+
6+
fn main() {
7+
let toml_file = "../versions.toml";
8+
let toml_content = fs::read_to_string(toml_file).expect("Failed to read versions.toml");
9+
10+
let config: Value = toml::from_str(&toml_content).expect("Failed to parse TOML");
11+
12+
let mut rust_code = String::from("// Auto-generated code from versions.toml\n\n");
13+
14+
let Value::Table(table) = config else {
15+
panic!("Invalid value type in versions.toml: {config:?}");
16+
};
17+
for (key, val) in table {
18+
let Value::String(s) = val else {
19+
panic!("Invalid value type in versions.toml: {val:?}");
20+
};
21+
rust_code.push_str(&format!(
22+
"pub const {}: &str = {s:?};\n",
23+
key.to_uppercase()
24+
));
25+
}
26+
27+
let out_dir = env::var_os("OUT_DIR").unwrap();
28+
let dest_path = Path::new(&out_dir).join("versions.rs");
29+
fs::write(&dest_path, rust_code).expect("Failed to write generated code");
30+
31+
// Tell Cargo to rerun this script if the TOML file changes
32+
println!("cargo:rerun-if-changed={toml_file}");
33+
}

stacks-common/src/libcommon.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ pub mod consts {
9797
pub const MICROSTACKS_PER_STACKS: u32 = 1_000_000;
9898
}
9999

100+
pub mod versions {
101+
include!(concat!(env!("OUT_DIR"), "/versions.rs"));
102+
}
103+
100104
/// This test asserts that the constant above doesn't change.
101105
/// This exists because the constant above is used by Epoch 2.5 instantiation code.
102106
///

stacks-signer/release-process.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ The timing of the next Stacking cycle can be found [here](https://stx.eco/dao/to
6363
- Add cherry-picked commits to the `feat/signer-X.Y.Z.A.n.x-pr_number` branch
6464
- Merge `feat/signer-X.Y.Z.A.n.x-pr_number` into `release/signer-X.Y.Z.A.n.x`.
6565

66-
4. Open a PR to update the [CHANGELOG](./CHANGELOG.md) file in the `release/signer-X.Y.Z.A.n.x` branch.
66+
4. Open a PR to update the [CHANGELOG](./CHANGELOG.md) in the `release/signer-X.Y.Z.A.n.x` branch.
6767

6868
- Create a chore branch from `release/signer-X.Y.Z.A.n.x`, ex: `chore/signer-X.Y.Z.A.n.x-changelog`.
6969
- Add summaries of all Pull Requests to the `Added`, `Changed` and `Fixed` sections.
70+
- Update the `stacks_signer_version` string in [versions.toml](../versions.toml) to match this release.
7071

7172
- Pull requests merged into `develop` can be found [here](https://github.com/stacks-network/stacks-core/pulls?q=is%3Apr+is%3Aclosed+base%3Adevelop+sort%3Aupdated-desc).
7273

stackslib/src/cost_estimates/tests/fee_rate_fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::cost_estimates::fee_rate_fuzzer::FeeRateFuzzer;
1515
use crate::cost_estimates::tests::common::make_block_receipt;
1616
use crate::cost_estimates::{EstimatorError, FeeEstimator, FeeRateEstimate};
1717

18-
struct ConstantFeeEstimator {}
18+
pub struct ConstantFeeEstimator {}
1919

2020
/// Returns a constant fee rate estimate.
2121
impl FeeEstimator for ConstantFeeEstimator {

stackslib/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern crate stacks_common;
4545
#[macro_use]
4646
pub extern crate clarity;
4747

48+
use stacks_common::versions::STACKS_NODE_VERSION;
4849
pub use stacks_common::{address, codec, types, util};
4950

5051
#[macro_use]
@@ -79,16 +80,17 @@ const BUILD_TYPE: &str = "debug";
7980
#[cfg(not(debug_assertions))]
8081
const BUILD_TYPE: &str = "release";
8182

82-
pub fn version_string(pkg_name: &str, pkg_version: &str) -> String {
83-
let git_branch = GIT_BRANCH.map(String::from).unwrap_or("".to_string());
83+
pub fn version_string(pkg_name: &str, pkg_version: Option<&str>) -> String {
84+
let pkg_version = pkg_version.unwrap_or(STACKS_NODE_VERSION);
85+
let git_branch = GIT_BRANCH.unwrap_or("");
8486
let git_commit = GIT_COMMIT.unwrap_or("");
8587
let git_tree_clean = GIT_TREE_CLEAN.unwrap_or("");
8688

8789
format!(
8890
"{} {} ({}:{}{}, {} build, {} [{}])",
8991
pkg_name,
9092
pkg_version,
91-
&git_branch,
93+
git_branch,
9294
git_commit,
9395
git_tree_clean,
9496
BUILD_TYPE,

stackslib/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ fn main() {
316316
"{}",
317317
&blockstack_lib::version_string(
318318
option_env!("CARGO_PKG_NAME").unwrap_or(&argv[0]),
319-
option_env!("CARGO_PKG_VERSION").unwrap_or("0.0.0.0")
319+
option_env!("STACKS_NODE_VERSION")
320320
)
321321
);
322322
process::exit(0);

stackslib/src/net/api/getinfo.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,7 @@ impl RPCPeerInfoData {
111111
coinbase_height: u64,
112112
ibd: bool,
113113
) -> RPCPeerInfoData {
114-
let server_version = version_string(
115-
"stacks-node",
116-
option_env!("STACKS_NODE_VERSION")
117-
.or(option_env!("CARGO_PKG_VERSION"))
118-
.unwrap_or("0.0.0.0"),
119-
);
114+
let server_version = version_string("stacks-node", option_env!("STACKS_NODE_VERSION"));
120115
let (unconfirmed_tip, unconfirmed_seq) = match chainstate.unconfirmed_state {
121116
Some(ref unconfirmed) => {
122117
if unconfirmed.num_mined_txs() > 0 {

stackslib/src/net/api/getstxtransfercost.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use crate::net::httpcore::{
4242
};
4343
use crate::net::p2p::PeerNetwork;
4444
use crate::net::{Error as NetError, HttpServerError, StacksNodeState};
45-
use crate::version_string;
4645

4746
pub(crate) const SINGLESIG_TX_TRANSFER_LEN: u64 = 180;
4847

stackslib/src/net/api/postfeerate.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::io::{Read, Write};
1818

1919
use clarity::vm::costs::ExecutionCost;
2020
use regex::{Captures, Regex};
21+
use serde_json::json;
2122
use stacks_common::codec::{StacksMessageCodec, MAX_PAYLOAD_LEN};
2223
use stacks_common::types::chainstate::{
2324
BlockHeaderHash, ConsensusHash, StacksBlockId, StacksPublicKey,
@@ -118,13 +119,7 @@ impl RPCPostFeeRateRequestHandler {
118119
let scalar_cost =
119120
metric.from_cost_and_len(&estimated_cost, &stacks_epoch.block_limit, estimated_len);
120121
let fee_rates = fee_estimator.get_rate_estimates().map_err(|e| {
121-
StacksHttpResponse::new_error(
122-
preamble,
123-
&HttpBadRequest::new(format!(
124-
"Estimator RPC endpoint failed to estimate fees for tx: {:?}",
125-
&e
126-
)),
127-
)
122+
StacksHttpResponse::new_error(preamble, &HttpBadRequest::new_json(e.into_json()))
128123
})?;
129124

130125
let mut estimations = RPCFeeEstimate::estimate_fees(scalar_cost, fee_rates).to_vec();
@@ -243,11 +238,7 @@ impl RPCRequestHandler for RPCPostFeeRateRequestHandler {
243238
.map_err(|e| {
244239
StacksHttpResponse::new_error(
245240
&preamble,
246-
&HttpBadRequest::new(format!(
247-
"Estimator RPC endpoint failed to estimate tx {}: {:?}",
248-
&tx.name(),
249-
&e
250-
)),
241+
&HttpBadRequest::new_json(e.into_json()),
251242
)
252243
})?;
253244

@@ -263,9 +254,9 @@ impl RPCRequestHandler for RPCPostFeeRateRequestHandler {
263254
debug!("Fee and cost estimation not configured on this stacks node");
264255
Err(StacksHttpResponse::new_error(
265256
&preamble,
266-
&HttpBadRequest::new(
267-
"Fee estimation not supported on this node".to_string(),
268-
),
257+
&HttpBadRequest::new_json(json!(
258+
"Fee estimation not supported on this node"
259+
)),
269260
))
270261
}
271262
});

stackslib/src/net/api/tests/mod.rs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use std::net::SocketAddr;
18+
use std::sync::{Arc, Mutex};
1819

1920
use clarity::vm::costs::ExecutionCost;
2021
use clarity::vm::types::{QualifiedContractIdentifier, StacksAddressExtensions};
@@ -46,7 +47,7 @@ use crate::net::db::PeerDB;
4647
use crate::net::httpcore::{StacksHttpRequest, StacksHttpResponse};
4748
use crate::net::relay::Relayer;
4849
use crate::net::rpc::ConversationHttp;
49-
use crate::net::test::{TestEventObserver, TestPeer, TestPeerConfig};
50+
use crate::net::test::{RPCHandlerArgsType, TestEventObserver, TestPeer, TestPeerConfig};
5051
use crate::net::tests::inv::nakamoto::make_nakamoto_peers_from_invs_ext;
5152
use crate::net::{
5253
Attachment, AttachmentInstance, MemPoolEventDispatcher, RPCHandlerArgs, StackerDBConfig,
@@ -226,10 +227,28 @@ pub struct TestRPC<'a> {
226227

227228
impl<'a> TestRPC<'a> {
228229
pub fn setup(test_name: &str) -> TestRPC<'a> {
229-
Self::setup_ex(test_name, true)
230+
Self::setup_ex(test_name, true, None, None)
230231
}
231232

232-
pub fn setup_ex(test_name: &str, process_microblock: bool) -> TestRPC<'a> {
233+
pub fn setup_with_rpc_args(
234+
test_name: &str,
235+
rpc_handler_args_opt_1: Option<RPCHandlerArgsType>,
236+
rpc_handler_args_opt_2: Option<RPCHandlerArgsType>,
237+
) -> TestRPC<'a> {
238+
Self::setup_ex(
239+
test_name,
240+
true,
241+
rpc_handler_args_opt_1,
242+
rpc_handler_args_opt_2,
243+
)
244+
}
245+
246+
pub fn setup_ex(
247+
test_name: &str,
248+
process_microblock: bool,
249+
rpc_handler_args_opt_1: Option<RPCHandlerArgsType>,
250+
rpc_handler_args_opt_2: Option<RPCHandlerArgsType>,
251+
) -> TestRPC<'a> {
233252
// ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R
234253
let privk1 = StacksPrivateKey::from_hex(
235254
"9f1f85a512a96a244e4c0d762788500687feb97481639572e3bffbd6860e6ab001",
@@ -317,6 +336,9 @@ impl<'a> TestRPC<'a> {
317336
let mut peer_1 = TestPeer::new(peer_1_config);
318337
let mut peer_2 = TestPeer::new(peer_2_config);
319338

339+
peer_1.rpc_handler_args = rpc_handler_args_opt_1;
340+
peer_2.rpc_handler_args = rpc_handler_args_opt_2;
341+
320342
// mine one block with a contract in it
321343
// first the coinbase
322344
// make a coinbase for this miner
@@ -976,7 +998,11 @@ impl<'a> TestRPC<'a> {
976998
}
977999

9781000
{
979-
let mut rpc_args = RPCHandlerArgs::default();
1001+
let mut rpc_args = peer_1
1002+
.rpc_handler_args
1003+
.as_ref()
1004+
.map(|args_type| args_type.instantiate())
1005+
.unwrap_or(RPCHandlerArgsType::make_default());
9801006
rpc_args.event_observer = event_observer;
9811007
let mut node_state = StacksNodeState::new(
9821008
&mut peer_1.network,
@@ -1020,7 +1046,11 @@ impl<'a> TestRPC<'a> {
10201046
}
10211047

10221048
{
1023-
let mut rpc_args = RPCHandlerArgs::default();
1049+
let mut rpc_args = peer_2
1050+
.rpc_handler_args
1051+
.as_ref()
1052+
.map(|args_type| args_type.instantiate())
1053+
.unwrap_or(RPCHandlerArgsType::make_default());
10241054
rpc_args.event_observer = event_observer;
10251055
let mut node_state = StacksNodeState::new(
10261056
&mut peer_2.network,
@@ -1076,7 +1106,11 @@ impl<'a> TestRPC<'a> {
10761106
let mut peer_1_stacks_node = peer_1.stacks_node.take().unwrap();
10771107
let mut peer_1_mempool = peer_1.mempool.take().unwrap();
10781108

1079-
let rpc_args = RPCHandlerArgs::default();
1109+
let rpc_args = peer_1
1110+
.rpc_handler_args
1111+
.as_ref()
1112+
.map(|args_type| args_type.instantiate())
1113+
.unwrap_or(RPCHandlerArgsType::make_default());
10801114
let mut node_state = StacksNodeState::new(
10811115
&mut peer_1.network,
10821116
&peer_1_sortdb,

0 commit comments

Comments
 (0)