Skip to content

Commit

Permalink
feat: use assert safe from utu
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Nov 1, 2024
1 parent 1e2a8fa commit d35cc2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2023_11"

[dependencies]
starknet = "2.8.4"
utils = { git = "https://github.com/keep-starknet-strange/raito.git" }
consensus = { git = "https://github.com/keep-starknet-strange/raito.git" }
utu_relay = { git = "https://github.com/lfglabs-dev/utu_relay.git" }
utils = { git = "https://github.com/keep-starknet-strange/raito.git", rev = "02a13045b7074ae2b3247431cd91f1ad76263fb2" }
consensus = { git = "https://github.com/keep-starknet-strange/raito.git", rev = "02a13045b7074ae2b3247431cd91f1ad76263fb2" }
utu_relay = { git = "https://github.com/lfglabs-dev/utu_relay.git", rev = "80dd830" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.31.0" }
Expand Down
10 changes: 4 additions & 6 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ mod BitcoinDepositor {
assert(
block_header.merkle_root_hash.value == merkle_root.value, 'invalid inclusion proof'
);
// we verify this block is part of the canonical chain
let utu = IUtuRelayDispatcher { contract_address: self.utu_address.read() };
let canonical_block_digest = utu.get_block(block_height);
assert(canonical_block_digest == block_header.hash(), 'invalid block digest');

// in case we want to check the status
// let block_status = utu.get_status(canonical_block_digest);
// we verify this block is safe to use (part of the canonical chain & sufficient pow)
// sufficient pow for our usecase: 100 sextillion expected hashes
let utu = IUtuRelayDispatcher { contract_address: self.utu_address.read() };
utu.assert_safe(block_height, block_header.hash(), 100_000_000_000_000_000_000_000, 0);

// if all good, we update the receiver
self.depositor.write(get_caller_address());
Expand Down

0 comments on commit d35cc2c

Please sign in to comment.