Skip to content

Commit

Permalink
fix: advance burn chain tip
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Jan 31, 2025
1 parent e3ef08e commit f2406a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 0 additions & 2 deletions components/clarinet-sdk-wasm/src/test_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ async fn it_can_call_remote_data() {
"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM".into(),
));

uprint!("tx: {:?}", tx);

let expected = format!("0x{}", ClarityValue::UInt(0).serialize_to_hex().unwrap());
assert_eq!(tx.unwrap().result, expected);
}
1 change: 1 addition & 0 deletions components/clarinet-sdk/node/tests/simnet-usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe("basic simnet interactions", () => {
simnet.mineEmptyBlocks(4);
expect(simnet.blockHeight).toBe(blockHeight + 5);
});

it("can not mine empty stacks block in pre-3.0", () => {
expect(() => simnet.mineEmptyStacksBlock()).toThrowError(
"use mineEmptyBurnBlock in epoch lower than 3.0",
Expand Down
24 changes: 11 additions & 13 deletions components/clarity-repl/src/repl/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,9 @@ impl Datastore {
fn build_next_stacks_block(&self, clarity_datastore: &ClarityDatastore) -> StacksBlockInfo {
let stacks_block_height = self.stacks_chain_height;

let current_chain_tip = clarity_datastore.current_chain_tip.read().unwrap();
let previous_stacks_block = self
.stacks_blocks
.get(&current_chain_tip)
.get(&clarity_datastore.open_chain_tip)
.expect("current chain tip missing in stacks block table");
let last_burn_block = self
.burn_blocks
Expand Down Expand Up @@ -702,16 +701,15 @@ impl Datastore {
) -> u32 {
for _ in 1..=count {
let next_burn_block_time = {
let current_chain_tip = clarity_datastore.current_chain_tip.read().unwrap();
let last_stacks_block =
self.stacks_blocks
.get(&current_chain_tip)
.unwrap_or_else(|| {
panic!(
"current chain tip missing in stacks_blocks table: {}",
current_chain_tip
)
});
let last_stacks_block = self
.stacks_blocks
.get(&clarity_datastore.open_chain_tip)
.unwrap_or_else(|| {
panic!(
"current chain tip missing in stacks_blocks table: {}",
clarity_datastore.open_chain_tip
)
});
let last_burn_block =
self.burn_blocks
.get(&self.burn_chain_tip)
Expand Down Expand Up @@ -868,7 +866,7 @@ impl HeadersDB for Datastore {
}

fn get_burn_block_height_for_block(&self, id_bhh: &StacksBlockId) -> Option<u32> {
self.get_burn_header_hash_for_block(dbg!(id_bhh))
self.get_burn_header_hash_for_block(id_bhh)
.and_then(|hash| self.burn_blocks.get(&hash))
.map(|b| b.burn_chain_height)
}
Expand Down

0 comments on commit f2406a0

Please sign in to comment.