Skip to content

Commit 165399f

Browse files
committed
Merge branch 'feat/sip_031_boot_contract' into feat/sip_031_coinbase
2 parents 0789409 + f79b505 commit 165399f

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12639,7 +12639,7 @@ fn write_signer_update(
1263912639
/// Test SIP-031 activation
1264012640
///
1264112641
/// - check epoch 3.2 is active
12642-
/// - check sip031 boot contract has a balance of 200_000_000 STX (TODO)
12642+
/// - check sip031 boot contract has a balance of 200_000_000 STX
1264312643
#[test]
1264412644
#[ignore]
1264512645
fn test_sip_031_activation() {
@@ -12726,7 +12726,29 @@ fn test_sip_031_activation() {
1272612726

1272712727
wait_for_first_naka_block_commit(60, &commits_submitted);
1272812728

12729-
// mine until epooch 3.2 height
12729+
// retrieve current liquidity
12730+
let last_block_id = StacksBlockId::from_hex(
12731+
&test_observer::get_blocks()
12732+
.last()
12733+
.unwrap()
12734+
.get("index_block_hash")
12735+
.unwrap()
12736+
.as_str()
12737+
.unwrap()[2..],
12738+
)
12739+
.unwrap();
12740+
12741+
let sip_031_initial_total_liquid_ustx = chainstate
12742+
.with_read_only_clarity_tx(
12743+
&sortdb
12744+
.index_handle_at_block(&chainstate, &last_block_id)
12745+
.unwrap(),
12746+
&last_block_id,
12747+
|conn| conn.with_clarity_db_readonly(|db| db.get_total_liquid_ustx().unwrap()),
12748+
)
12749+
.unwrap();
12750+
12751+
// mine until epoch 3.2 height
1273012752
loop {
1273112753
let commits_before = commits_submitted.load(Ordering::SeqCst);
1273212754
next_block_and_process_new_stacks_block(&mut btc_regtest_controller, 60, &coord_channel)
@@ -12808,6 +12830,19 @@ fn test_sip_031_activation() {
1280812830
}))
1280912831
);
1281012832

12833+
// check liquidity has been updated accordingly
12834+
let sip_031_total_liquid_ustx = chainstate
12835+
.with_read_only_clarity_tx(
12836+
&sortdb
12837+
.index_handle_at_block(&chainstate, &latest_stacks_block_id)
12838+
.unwrap(),
12839+
&latest_stacks_block_id,
12840+
|conn| conn.with_clarity_db_readonly(|db| db.get_total_liquid_ustx().unwrap()),
12841+
)
12842+
.unwrap();
12843+
12844+
assert!(sip_031_total_liquid_ustx - sip_031_initial_total_liquid_ustx >= SIP_031_INITIAL_MINT);
12845+
1281112846
// check if the coinbase activation block receipt has the mint event
1281212847
let mut mint_event_found: Option<serde_json::Value> = None;
1281312848
let mut coinbase_txid: Option<String> = None;
@@ -12856,7 +12891,7 @@ fn test_sip_031_activation() {
1285612891
.unwrap()
1285712892
.as_str()
1285812893
.unwrap(),
12859-
"200000000000000"
12894+
SIP_031_INITIAL_MINT.to_string()
1286012895
);
1286112896

1286212897
// check the recipient

stackslib/src/clarity_vm/clarity.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ impl<'a> ClarityBlockConnection<'a, '_> {
16351635
};
16361636

16371637
let boot_code_address = boot_code_addr(mainnet);
1638-
let boot_code_auth = boot_code_tx_auth(boot_code_address.clone());
1638+
let boot_code_auth = boot_code_tx_auth(boot_code_address);
16391639

16401640
// SIP-031 setup (deploy of the boot contract, minting and transfer to the boot contract)
16411641
let sip_031_contract_id = boot_code_id(SIP_031_NAME, mainnet);
@@ -1654,28 +1654,28 @@ impl<'a> ClarityBlockConnection<'a, '_> {
16541654

16551655
let mut sip_031_initialization_receipt = self.as_transaction(|tx_conn| {
16561656
// initialize with a synthetic transaction
1657-
debug!("Instantiate {} contract", &sip_031_contract_id);
1657+
info!("Instantiate {} contract", &sip_031_contract_id);
16581658
let receipt = StacksChainState::process_transaction_payload(
16591659
tx_conn,
16601660
&sip_031_contract_tx,
16611661
&boot_code_account,
16621662
ASTRules::PrecheckSize,
16631663
None,
16641664
)
1665-
.expect("FATAL: Failed to process .sip031 contract initialization");
1665+
.expect("FATAL: Failed to process .sip-031 contract initialization");
16661666
receipt
16671667
});
16681668

16691669
if sip_031_initialization_receipt.result != Value::okay_true()
16701670
|| sip_031_initialization_receipt.post_condition_aborted
16711671
{
16721672
panic!(
1673-
"FATAL: Failure processing sip031 contract initialization: {:#?}",
1673+
"FATAL: Failure processing sip-031 contract initialization: {:#?}",
16741674
&sip_031_initialization_receipt
16751675
);
16761676
}
16771677

1678-
let recipient = PrincipalData::Contract(boot_code_id(SIP_031_NAME, mainnet));
1678+
let recipient = PrincipalData::Contract(sip_031_contract_id);
16791679

16801680
self.as_transaction(|tx_conn| {
16811681
tx_conn

0 commit comments

Comments
 (0)