Skip to content

Commit 66f99d8

Browse files
committed
ci: add check for consts and stacks-inspect command to dump constants
1 parent 85e8f29 commit 66f99d8

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,38 @@ jobs:
164164
- check-release
165165
uses: ./.github/workflows/stacks-core-tests.yml
166166

167+
## Checks to run on built binaries
168+
##
169+
## Runs when:
170+
## - it is a release run
171+
## or:
172+
## - it is not a release run
173+
## and any of:
174+
## - this workflow is called manually
175+
## - PR is opened
176+
## - PR added to merge queue
177+
## - commit to either (development, next, master) branch
178+
stacks-core-build-tests:
179+
if: |
180+
needs.check-release.outputs.is_release == 'true' || (
181+
github.event_name == 'workflow_dispatch' ||
182+
github.event_name == 'pull_request' ||
183+
github.event_name == 'merge_group' ||
184+
(
185+
contains('
186+
refs/heads/master
187+
refs/heads/develop
188+
refs/heads/next
189+
', github.event.pull_request.head.ref) &&
190+
github.event_name == 'push'
191+
)
192+
)
193+
name: Stacks Core Build Tests
194+
needs:
195+
- rustfmt
196+
- check-release
197+
uses: ./.github/workflows/core-build-tests.yml
198+
167199
bitcoin-tests:
168200
if: |
169201
needs.check-release.outputs.is_release == 'true' || (
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Core build tests
2+
3+
# Only run when:
4+
# - PRs are (re)opened against develop branch
5+
on:
6+
workflow_call:
7+
8+
jobs:
9+
check-consts:
10+
name: Check the constants from stacks-inspect
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout the latest code
14+
id: git_checkout
15+
uses: actions/checkout@v3
16+
- name: Define Rust Toolchain
17+
id: define_rust_toolchain
18+
run: echo "RUST_TOOLCHAIN=$(cat ./rust-toolchain)" >> $GITHUB_ENV
19+
- name: Setup Rust Toolchain
20+
id: setup_rust_toolchain
21+
uses: actions-rust-lang/setup-rust-toolchain@v1
22+
with:
23+
toolchain: ${{ env.RUST_TOOLCHAIN }}
24+
- name: Build the binaries
25+
id: build
26+
run: |
27+
cargo build
28+
- name: Dump constants JSON
29+
id: consts-dump
30+
run: cargo run --bin stacks-inspect -- dump-consts | tee out.json
31+
- name: Set expected constants JSON
32+
id: expects-json
33+
run: diff out.json ./sample/expected_consts.json

sample/expected_consts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"chain_id_mainnet": 1,
3+
"chain_id_testnet": 2147483648,
4+
"microstacks_per_stacks": 1000000,
5+
"miner_reward_maturity": 100,
6+
"network_id_mainnet": 385875968,
7+
"network_id_testnet": 4278190080,
8+
"peer_version_mainnet_major": 402653184,
9+
"peer_version_testnet_major": 4207599104,
10+
"signer_slots_per_user": 13,
11+
"stacks_epoch_max": 9223372036854775807
12+
}

stackslib/src/main.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,12 +1614,35 @@ check if the associated microblocks can be downloaded
16141614
process::exit(0);
16151615
}
16161616

1617+
if argv[1] == "dump-consts" {
1618+
dump_consts();
1619+
}
1620+
16171621
if argv.len() < 4 {
16181622
eprintln!("Usage: {} blockchain network working_dir", argv[0]);
16191623
process::exit(1);
16201624
}
16211625
}
16221626

1627+
#[cfg_attr(test, mutants::skip)]
1628+
pub fn dump_consts() {
1629+
use stacks_common::consts;
1630+
let json_out = json!({
1631+
"miner_reward_maturity": consts::MINER_REWARD_MATURITY,
1632+
"chain_id_mainnet": consts::CHAIN_ID_MAINNET,
1633+
"chain_id_testnet": consts::CHAIN_ID_TESTNET,
1634+
"signer_slots_per_user": consts::SIGNER_SLOTS_PER_USER,
1635+
"network_id_mainnet": consts::NETWORK_ID_MAINNET,
1636+
"network_id_testnet": consts::NETWORK_ID_TESTNET,
1637+
"microstacks_per_stacks": consts::MICROSTACKS_PER_STACKS,
1638+
"stacks_epoch_max": consts::STACKS_EPOCH_MAX,
1639+
"peer_version_mainnet_major": consts::PEER_VERSION_MAINNET_MAJOR,
1640+
"peer_version_testnet_major": consts::PEER_VERSION_TESTNET_MAJOR,
1641+
});
1642+
println!("{}", serde_json::to_string_pretty(&json_out).unwrap());
1643+
process::exit(0);
1644+
}
1645+
16231646
#[cfg_attr(test, mutants::skip)]
16241647
pub fn tip_mine() {
16251648
let argv: Vec<String> = env::args().collect();

0 commit comments

Comments
 (0)