Skip to content

Commit

Permalink
Merge branch 'develop' into long-block-proposal-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
obycode authored Feb 5, 2025
2 parents 8641730 + 9b48330 commit f465d80
Show file tree
Hide file tree
Showing 22 changed files with 384 additions and 211 deletions.
243 changes: 93 additions & 150 deletions .github/workflows/bitcoin-tests.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE

### Fixed

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

## [3.1.0.0.5]

### Added
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion docs/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ The timing of the next Stacking cycle can be found [here](https://stx.eco/dao/to
- Add cherry-picked commits to the `feat/X.Y.Z.A.n-pr_number` branch
- Merge `feat/X.Y.Z.A.n-pr_number` into `release/X.Y.Z.A.n`.

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

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

- 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).

Expand Down
8 changes: 7 additions & 1 deletion libsigner/src/libsigner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use blockstack_lib::version_string;
use clarity::codec::StacksMessageCodec;
use clarity::vm::types::QualifiedContractIdentifier;
use lazy_static::lazy_static;
use stacks_common::versions::STACKS_SIGNER_VERSION;

pub use crate::error::{EventError, RPCError};
pub use crate::events::{
Expand Down Expand Up @@ -80,7 +81,12 @@ pub trait SignerMessage<T: MessageSlotID>: StacksMessageCodec {
lazy_static! {
/// The version string for the signer
pub static ref VERSION_STRING: String = {
let pkg_version = option_env!("STACKS_NODE_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"));
let pkg_version = option_env!("STACKS_NODE_VERSION").or(Some(STACKS_SIGNER_VERSION));
version_string("stacks-signer", pkg_version)
};
}

#[test]
fn test_version_string() {
assert!(VERSION_STRING.contains(format!("stacks-signer {}", STACKS_SIGNER_VERSION).as_str()));
}
4 changes: 4 additions & 0 deletions stacks-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ keywords = [ "stacks", "stx", "bitcoin", "crypto", "blockstack", "decentralized"
readme = "README.md"
resolver = "2"
edition = "2021"
build = "build.rs"

[lib]
name = "stacks_common"
Expand Down Expand Up @@ -73,6 +74,9 @@ serde = []
bech32_std = []
bech32_strict = []

[build-dependencies]
toml = "0.5.6"

[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies]
sha2 = { version = "0.10", features = ["asm"] }

Expand Down
33 changes: 33 additions & 0 deletions stacks-common/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use std::path::Path;
use std::{env, fs};

use toml::Value;

fn main() {
let toml_file = "../versions.toml";
let toml_content = fs::read_to_string(toml_file).expect("Failed to read versions.toml");

let config: Value = toml::from_str(&toml_content).expect("Failed to parse TOML");

let mut rust_code = String::from("// Auto-generated code from versions.toml\n\n");

let Value::Table(table) = config else {
panic!("Invalid value type in versions.toml: {config:?}");
};
for (key, val) in table {
let Value::String(s) = val else {
panic!("Invalid value type in versions.toml: {val:?}");
};
rust_code.push_str(&format!(
"pub const {}: &str = {s:?};\n",
key.to_uppercase()
));
}

let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("versions.rs");
fs::write(&dest_path, rust_code).expect("Failed to write generated code");

// Tell Cargo to rerun this script if the TOML file changes
println!("cargo:rerun-if-changed={toml_file}");
}
4 changes: 4 additions & 0 deletions stacks-common/src/libcommon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pub mod consts {
pub const MICROSTACKS_PER_STACKS: u32 = 1_000_000;
}

pub mod versions {
include!(concat!(env!("OUT_DIR"), "/versions.rs"));
}

/// This test asserts that the constant above doesn't change.
/// This exists because the constant above is used by Epoch 2.5 instantiation code.
///
Expand Down
3 changes: 2 additions & 1 deletion stacks-signer/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ The timing of the next Stacking cycle can be found [here](https://stx.eco/dao/to
- Add cherry-picked commits to the `feat/signer-X.Y.Z.A.n.x-pr_number` branch
- Merge `feat/signer-X.Y.Z.A.n.x-pr_number` into `release/signer-X.Y.Z.A.n.x`.

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

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

- 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).

Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/cost_estimates/tests/fee_rate_fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::cost_estimates::fee_rate_fuzzer::FeeRateFuzzer;
use crate::cost_estimates::tests::common::make_block_receipt;
use crate::cost_estimates::{EstimatorError, FeeEstimator, FeeRateEstimate};

struct ConstantFeeEstimator {}
pub struct ConstantFeeEstimator {}

/// Returns a constant fee rate estimate.
impl FeeEstimator for ConstantFeeEstimator {
Expand Down
8 changes: 5 additions & 3 deletions stackslib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern crate stacks_common;
#[macro_use]
pub extern crate clarity;

use stacks_common::versions::STACKS_NODE_VERSION;
pub use stacks_common::{address, codec, types, util};

#[macro_use]
Expand Down Expand Up @@ -79,16 +80,17 @@ const BUILD_TYPE: &str = "debug";
#[cfg(not(debug_assertions))]
const BUILD_TYPE: &str = "release";

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

format!(
"{} {} ({}:{}{}, {} build, {} [{}])",
pkg_name,
pkg_version,
&git_branch,
git_branch,
git_commit,
git_tree_clean,
BUILD_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ fn main() {
"{}",
&blockstack_lib::version_string(
option_env!("CARGO_PKG_NAME").unwrap_or(&argv[0]),
option_env!("CARGO_PKG_VERSION").unwrap_or("0.0.0.0")
option_env!("STACKS_NODE_VERSION")
)
);
process::exit(0);
Expand Down
7 changes: 1 addition & 6 deletions stackslib/src/net/api/getinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@ impl RPCPeerInfoData {
coinbase_height: u64,
ibd: bool,
) -> RPCPeerInfoData {
let server_version = version_string(
"stacks-node",
option_env!("STACKS_NODE_VERSION")
.or(option_env!("CARGO_PKG_VERSION"))
.unwrap_or("0.0.0.0"),
);
let server_version = version_string("stacks-node", option_env!("STACKS_NODE_VERSION"));
let (unconfirmed_tip, unconfirmed_seq) = match chainstate.unconfirmed_state {
Some(ref unconfirmed) => {
if unconfirmed.num_mined_txs() > 0 {
Expand Down
1 change: 0 additions & 1 deletion stackslib/src/net/api/getstxtransfercost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use crate::net::httpcore::{
};
use crate::net::p2p::PeerNetwork;
use crate::net::{Error as NetError, HttpServerError, StacksNodeState};
use crate::version_string;

pub(crate) const SINGLESIG_TX_TRANSFER_LEN: u64 = 180;

Expand Down
21 changes: 6 additions & 15 deletions stackslib/src/net/api/postfeerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::io::{Read, Write};

use clarity::vm::costs::ExecutionCost;
use regex::{Captures, Regex};
use serde_json::json;
use stacks_common::codec::{StacksMessageCodec, MAX_PAYLOAD_LEN};
use stacks_common::types::chainstate::{
BlockHeaderHash, ConsensusHash, StacksBlockId, StacksPublicKey,
Expand Down Expand Up @@ -118,13 +119,7 @@ impl RPCPostFeeRateRequestHandler {
let scalar_cost =
metric.from_cost_and_len(&estimated_cost, &stacks_epoch.block_limit, estimated_len);
let fee_rates = fee_estimator.get_rate_estimates().map_err(|e| {
StacksHttpResponse::new_error(
preamble,
&HttpBadRequest::new(format!(
"Estimator RPC endpoint failed to estimate fees for tx: {:?}",
&e
)),
)
StacksHttpResponse::new_error(preamble, &HttpBadRequest::new_json(e.into_json()))
})?;

let mut estimations = RPCFeeEstimate::estimate_fees(scalar_cost, fee_rates).to_vec();
Expand Down Expand Up @@ -243,11 +238,7 @@ impl RPCRequestHandler for RPCPostFeeRateRequestHandler {
.map_err(|e| {
StacksHttpResponse::new_error(
&preamble,
&HttpBadRequest::new(format!(
"Estimator RPC endpoint failed to estimate tx {}: {:?}",
&tx.name(),
&e
)),
&HttpBadRequest::new_json(e.into_json()),
)
})?;

Expand All @@ -263,9 +254,9 @@ impl RPCRequestHandler for RPCPostFeeRateRequestHandler {
debug!("Fee and cost estimation not configured on this stacks node");
Err(StacksHttpResponse::new_error(
&preamble,
&HttpBadRequest::new(
"Fee estimation not supported on this node".to_string(),
),
&HttpBadRequest::new_json(json!(
"Fee estimation not supported on this node"
)),
))
}
});
Expand Down
46 changes: 40 additions & 6 deletions stackslib/src/net/api/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use std::net::SocketAddr;
use std::sync::{Arc, Mutex};

use clarity::vm::costs::ExecutionCost;
use clarity::vm::types::{QualifiedContractIdentifier, StacksAddressExtensions};
Expand Down Expand Up @@ -46,7 +47,7 @@ use crate::net::db::PeerDB;
use crate::net::httpcore::{StacksHttpRequest, StacksHttpResponse};
use crate::net::relay::Relayer;
use crate::net::rpc::ConversationHttp;
use crate::net::test::{TestEventObserver, TestPeer, TestPeerConfig};
use crate::net::test::{RPCHandlerArgsType, TestEventObserver, TestPeer, TestPeerConfig};
use crate::net::tests::inv::nakamoto::make_nakamoto_peers_from_invs_ext;
use crate::net::{
Attachment, AttachmentInstance, MemPoolEventDispatcher, RPCHandlerArgs, StackerDBConfig,
Expand Down Expand Up @@ -226,10 +227,28 @@ pub struct TestRPC<'a> {

impl<'a> TestRPC<'a> {
pub fn setup(test_name: &str) -> TestRPC<'a> {
Self::setup_ex(test_name, true)
Self::setup_ex(test_name, true, None, None)
}

pub fn setup_ex(test_name: &str, process_microblock: bool) -> TestRPC<'a> {
pub fn setup_with_rpc_args(
test_name: &str,
rpc_handler_args_opt_1: Option<RPCHandlerArgsType>,
rpc_handler_args_opt_2: Option<RPCHandlerArgsType>,
) -> TestRPC<'a> {
Self::setup_ex(
test_name,
true,
rpc_handler_args_opt_1,
rpc_handler_args_opt_2,
)
}

pub fn setup_ex(
test_name: &str,
process_microblock: bool,
rpc_handler_args_opt_1: Option<RPCHandlerArgsType>,
rpc_handler_args_opt_2: Option<RPCHandlerArgsType>,
) -> TestRPC<'a> {
// ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R
let privk1 = StacksPrivateKey::from_hex(
"9f1f85a512a96a244e4c0d762788500687feb97481639572e3bffbd6860e6ab001",
Expand Down Expand Up @@ -317,6 +336,9 @@ impl<'a> TestRPC<'a> {
let mut peer_1 = TestPeer::new(peer_1_config);
let mut peer_2 = TestPeer::new(peer_2_config);

peer_1.rpc_handler_args = rpc_handler_args_opt_1;
peer_2.rpc_handler_args = rpc_handler_args_opt_2;

// mine one block with a contract in it
// first the coinbase
// make a coinbase for this miner
Expand Down Expand Up @@ -976,7 +998,11 @@ impl<'a> TestRPC<'a> {
}

{
let mut rpc_args = RPCHandlerArgs::default();
let mut rpc_args = peer_1
.rpc_handler_args
.as_ref()
.map(|args_type| args_type.instantiate())
.unwrap_or(RPCHandlerArgsType::make_default());
rpc_args.event_observer = event_observer;
let mut node_state = StacksNodeState::new(
&mut peer_1.network,
Expand Down Expand Up @@ -1020,7 +1046,11 @@ impl<'a> TestRPC<'a> {
}

{
let mut rpc_args = RPCHandlerArgs::default();
let mut rpc_args = peer_2
.rpc_handler_args
.as_ref()
.map(|args_type| args_type.instantiate())
.unwrap_or(RPCHandlerArgsType::make_default());
rpc_args.event_observer = event_observer;
let mut node_state = StacksNodeState::new(
&mut peer_2.network,
Expand Down Expand Up @@ -1076,7 +1106,11 @@ impl<'a> TestRPC<'a> {
let mut peer_1_stacks_node = peer_1.stacks_node.take().unwrap();
let mut peer_1_mempool = peer_1.mempool.take().unwrap();

let rpc_args = RPCHandlerArgs::default();
let rpc_args = peer_1
.rpc_handler_args
.as_ref()
.map(|args_type| args_type.instantiate())
.unwrap_or(RPCHandlerArgsType::make_default());
let mut node_state = StacksNodeState::new(
&mut peer_1.network,
&peer_1_sortdb,
Expand Down
Loading

0 comments on commit f465d80

Please sign in to comment.