diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c59f23e8d..661f2e3746 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,6 +164,38 @@ jobs: - check-release uses: ./.github/workflows/stacks-core-tests.yml + ## Checks to run on built binaries + ## + ## Runs when: + ## - it is a release run + ## or: + ## - it is not a release run + ## and any of: + ## - this workflow is called manually + ## - PR is opened + ## - PR added to merge queue + ## - commit to either (development, next, master) branch + stacks-core-build-tests: + if: | + needs.check-release.outputs.is_release == 'true' || ( + github.event_name == 'workflow_dispatch' || + github.event_name == 'pull_request' || + github.event_name == 'merge_group' || + ( + contains(' + refs/heads/master + refs/heads/develop + refs/heads/next + ', github.event.pull_request.head.ref) && + github.event_name == 'push' + ) + ) + name: Stacks Core Build Tests + needs: + - rustfmt + - check-release + uses: ./.github/workflows/core-build-tests.yml + bitcoin-tests: if: | needs.check-release.outputs.is_release == 'true' || ( diff --git a/.github/workflows/core-build-tests.yml b/.github/workflows/core-build-tests.yml new file mode 100644 index 0000000000..393e2ff6b0 --- /dev/null +++ b/.github/workflows/core-build-tests.yml @@ -0,0 +1,33 @@ +name: Core build tests + +# Only run when: +# - PRs are (re)opened against develop branch +on: + workflow_call: + +jobs: + check-consts: + name: Check the constants from stacks-inspect + runs-on: ubuntu-latest + steps: + - name: Checkout the latest code + id: git_checkout + uses: actions/checkout@v3 + - name: Define Rust Toolchain + id: define_rust_toolchain + run: echo "RUST_TOOLCHAIN=$(cat ./rust-toolchain)" >> $GITHUB_ENV + - name: Setup Rust Toolchain + id: setup_rust_toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + - name: Build the binaries + id: build + run: | + cargo build + - name: Dump constants JSON + id: consts-dump + run: cargo run --bin stacks-inspect -- dump-consts | tee out.json + - name: Set expected constants JSON + id: expects-json + run: diff out.json ./sample/expected_consts.json diff --git a/pox-locking/Cargo.toml b/pox-locking/Cargo.toml index 4fbc9885dc..2ebca921d9 100644 --- a/pox-locking/Cargo.toml +++ b/pox-locking/Cargo.toml @@ -28,3 +28,4 @@ mutants = "0.0.3" [features] slog_json = ["stacks_common/slog_json", "clarity/slog_json"] +testing = [] diff --git a/sample/expected_consts.json b/sample/expected_consts.json new file mode 100644 index 0000000000..2c6da73a25 --- /dev/null +++ b/sample/expected_consts.json @@ -0,0 +1,12 @@ +{ + "chain_id_mainnet": 1, + "chain_id_testnet": 2147483648, + "microstacks_per_stacks": 1000000, + "miner_reward_maturity": 100, + "network_id_mainnet": 385875968, + "network_id_testnet": 4278190080, + "peer_version_mainnet_major": 402653184, + "peer_version_testnet_major": 4207599104, + "signer_slots_per_user": 13, + "stacks_epoch_max": 9223372036854775807 +} diff --git a/stacks-common/src/util/mod.rs b/stacks-common/src/util/mod.rs index 8fc9499b2f..95ca7eeec0 100644 --- a/stacks-common/src/util/mod.rs +++ b/stacks-common/src/util/mod.rs @@ -36,7 +36,6 @@ use std::time::{SystemTime, UNIX_EPOCH}; use std::{error, fmt, thread, time}; /// Given a relative path inside the Cargo workspace, return the absolute path -#[cfg(any(test, feature = "testing"))] pub fn cargo_workspace

(relative_path: P) -> PathBuf where P: AsRef, diff --git a/stacks-signer/Cargo.toml b/stacks-signer/Cargo.toml index 9e63365d39..eb58164a6e 100644 --- a/stacks-signer/Cargo.toml +++ b/stacks-signer/Cargo.toml @@ -36,7 +36,7 @@ serde_stacker = "0.1" slog = { version = "2.5.2", features = [ "max_level_trace" ] } slog-json = { version = "2.3.0", optional = true } slog-term = "2.6.0" -stacks-common = { path = "../stacks-common", features = ["testing"] } +stacks-common = { path = "../stacks-common" } stackslib = { path = "../stackslib" } thiserror = { workspace = true } tiny_http = { version = "0.12", optional = true } @@ -49,6 +49,7 @@ rusqlite = { workspace = true, features = ["functions"] } [dev-dependencies] clarity = { path = "../clarity", features = ["testing"] } +stacks-common = { path = "../stacks-common", features = ["testing"] } num-traits = "0.2.18" [dependencies.serde_json] diff --git a/stackslib/src/main.rs b/stackslib/src/main.rs index 730303cbd2..af597808c0 100644 --- a/stackslib/src/main.rs +++ b/stackslib/src/main.rs @@ -1614,12 +1614,35 @@ check if the associated microblocks can be downloaded process::exit(0); } + if argv[1] == "dump-consts" { + dump_consts(); + } + if argv.len() < 4 { eprintln!("Usage: {} blockchain network working_dir", argv[0]); process::exit(1); } } +#[cfg_attr(test, mutants::skip)] +pub fn dump_consts() { + use stacks_common::consts; + let json_out = json!({ + "miner_reward_maturity": consts::MINER_REWARD_MATURITY, + "chain_id_mainnet": consts::CHAIN_ID_MAINNET, + "chain_id_testnet": consts::CHAIN_ID_TESTNET, + "signer_slots_per_user": consts::SIGNER_SLOTS_PER_USER, + "network_id_mainnet": consts::NETWORK_ID_MAINNET, + "network_id_testnet": consts::NETWORK_ID_TESTNET, + "microstacks_per_stacks": consts::MICROSTACKS_PER_STACKS, + "stacks_epoch_max": consts::STACKS_EPOCH_MAX, + "peer_version_mainnet_major": consts::PEER_VERSION_MAINNET_MAJOR, + "peer_version_testnet_major": consts::PEER_VERSION_TESTNET_MAJOR, + }); + println!("{}", serde_json::to_string_pretty(&json_out).unwrap()); + process::exit(0); +} + #[cfg_attr(test, mutants::skip)] pub fn tip_mine() { let argv: Vec = env::args().collect();