Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump bitcoin version to 0.32.4 #344

Draft
wants to merge 65 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
a0aac98
bump bitcoin version to 0.32.4
maksymar Nov 26, 2024
ba693b5
.
maksymar Nov 26, 2024
2b27d57
unsupported network
maksymar Nov 26, 2024
09bf0d1
.
maksymar Nov 26, 2024
b957b2d
.
maksymar Nov 26, 2024
146fa00
fmt
maksymar Nov 26, 2024
389099f
fix build
maksymar Nov 26, 2024
a3d5d58
types
maksymar Nov 27, 2024
f6d0986
.
maksymar Nov 27, 2024
912c117
is_coinbase
maksymar Nov 27, 2024
d784c7f
.
maksymar Nov 27, 2024
a147c34
map bitcoin error
maksymar Nov 27, 2024
4135d6b
rename BlockHeader to Header
maksymar Nov 27, 2024
9866acd
.
maksymar Nov 27, 2024
7aa92b7
cleanup
maksymar Nov 27, 2024
86aab11
cleanup
maksymar Nov 27, 2024
7dd0388
.
maksymar Nov 27, 2024
ee6b473
.
maksymar Nov 27, 2024
dd7ccc4
.
maksymar Nov 28, 2024
c44ee92
.
maksymar Nov 28, 2024
403d4c2
.
maksymar Nov 28, 2024
34a100e
merge master
maksymar Nov 29, 2024
d7351e7
.
maksymar Nov 29, 2024
caff407
fix state-builder
maksymar Nov 29, 2024
0526496
fix building ic-btc-test-utils
maksymar Dec 6, 2024
ccf2276
fix building e2e-tests
maksymar Dec 6, 2024
1047510
fix build benchmarks
maksymar Dec 6, 2024
f707638
fix test ic-btc-test-utils
maksymar Dec 6, 2024
892d08a
.
maksymar Dec 6, 2024
a56d9f0
.
maksymar Dec 6, 2024
76d0ed0
clippy
maksymar Dec 9, 2024
38431f8
.
maksymar Dec 9, 2024
cdc6359
p2wpkh
maksymar Dec 9, 2024
50af7fa
random_p2wsh_address
maksymar Dec 9, 2024
af3f4d7
cleanup
maksymar Dec 9, 2024
a5df24d
merge master
maksymar Dec 9, 2024
bd783d0
is_op_return
maksymar Dec 9, 2024
60c3037
state-builder
maksymar Dec 9, 2024
b9a1adc
clippy
maksymar Dec 9, 2024
438abc7
fix benchmarks build, getrandom
maksymar Dec 9, 2024
03074ce
.
maksymar Dec 9, 2024
b8c73a4
canbench 0.1.8
maksymar Dec 9, 2024
381ea81
.
maksymar Dec 9, 2024
d5ef6a6
secp256k1 v
maksymar Dec 9, 2024
fb0d81c
update canbench results
maksymar Dec 9, 2024
07e2ebf
pocket-ic
maksymar Dec 9, 2024
766569f
secp256k1 deps
maksymar Dec 9, 2024
eb8a4d2
turn off js
maksymar Dec 9, 2024
197c284
canbench upgrade
maksymar Dec 9, 2024
462eeac
merge master
maksymar Dec 10, 2024
7252aa6
secp256k1
maksymar Dec 10, 2024
e8efc18
tmp skip benchmark
maksymar Dec 10, 2024
64c4ca0
.
maksymar Dec 10, 2024
4171361
fix state-builder build
maksymar Dec 10, 2024
f32b0c7
rand, ic-wasm
maksymar Dec 10, 2024
b790420
fix build
maksymar Dec 10, 2024
ee82875
rm skip ci
maksymar Dec 10, 2024
ae89c5d
cleanup
maksymar Dec 10, 2024
f2102ab
skip ci benchmarks
maksymar Dec 10, 2024
b517fc5
SimpleRng
maksymar Dec 11, 2024
d762547
skip
maksymar Dec 11, 2024
a219306
rm rand
maksymar Dec 11, 2024
d995b06
rm skip
maksymar Dec 11, 2024
a05cc4d
fix bootstrap build
maksymar Dec 11, 2024
f623fb0
cleanup
maksymar Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 78 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ resolver = "2"

[workspace.dependencies]
assert_matches = "1.5.0"
bitcoin = "0.28.1"
bitcoin = "0.32.4"
byteorder = "1.4.3"
canbench-rs = "0.1.8"
candid = "0.10.6"
Expand All @@ -48,6 +48,7 @@ ic-metrics-encoder = "1.0.0"
ic-stable-structures = "0.6.7"
lazy_static = "1.4.0"
pocket-ic = "6.0.0"
secp256k1 = "0.29.1"
serde = "1.0.171"
serde_bytes = "0.11"
serde_json = "1.0.94"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ path = "src/main.rs"
bench = false

[dependencies]
bitcoin = { workspace = true, features = ["use-serde"]}
bitcoin = { workspace = true, features = ["serde"] }
canbench-rs = { workspace = true }
candid = { workspace = true }
hex = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bitcoin::consensus::Decodable;
use bitcoin::{consensus::Encodable, Block as BitcoinBlock, BlockHeader as Header};
use bitcoin::{block::Header, consensus::Encodable, Block as BitcoinBlock};
use canbench_rs::{bench, bench_fn, BenchResult};
use ic_btc_canister::{types::BlockHeaderBlob, with_state_mut};
use ic_btc_interface::{InitConfig, Network};
Expand All @@ -22,7 +22,7 @@ fn init() {
.split('\n')
.map(|block_hex| {
let block_bytes = hex::decode(block_hex).unwrap();
Block::new(BitcoinBlock::consensus_decode(block_bytes.as_slice()).unwrap())
Block::new(BitcoinBlock::consensus_decode(&mut block_bytes.as_slice()).unwrap())
})
.collect(),
);
Expand Down
22 changes: 15 additions & 7 deletions bootstrap/state-builder/src/build_address_utxos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! --network testnet \
//! --output balances.bin \
//! --utxos-dump-path utxos-dump.csv
use bitcoin::{Address as BitcoinAddress, Script, Txid as BitcoinTxid};
use bitcoin::{hashes::Hash, Address as BitcoinAddress, Script, Txid as BitcoinTxid};
use clap::Parser;
use ic_btc_canister::types::{into_bitcoin_network, Address, AddressUtxo};
use ic_btc_interface::Network;
Expand Down Expand Up @@ -49,7 +49,13 @@ fn main() {
let line = line.unwrap();
let parts: Vec<_> = line.split(',').collect();

let txid = Txid::from(BitcoinTxid::from_str(parts[1]).unwrap().to_vec());
let txid = Txid::from(
BitcoinTxid::from_str(parts[1])
.unwrap()
.as_raw_hash()
.as_byte_array()
.to_vec(),
);
let vout: u32 = parts[2].parse().unwrap();
let address_str = parts[5];
let height: u32 = parts[0].parse().unwrap();
Expand All @@ -61,13 +67,15 @@ fn main() {

// Load the address. The UTXO dump tool we use doesn't output all the addresses
// we support, so if parsing the address itself fails, we try parsing the script directly.
let bitcoin_newtork = into_bitcoin_network(args.network);
let address = if let Ok(address) = BitcoinAddress::from_str(address_str) {
Some(address)
let checked_address = address
.require_network(bitcoin_newtork)
.expect("Address must be valid for network");
Some(checked_address)
} else {
BitcoinAddress::from_script(
&Script::from(hex::decode(script).expect("script must be valid hex")),
into_bitcoin_network(args.network),
)
let bytes = hex::decode(script).expect("script must be valid hex");
BitcoinAddress::from_script(Script::from_bytes(&bytes), bitcoin_newtork).ok()
};

if let Some(address) = address {
Expand Down
12 changes: 7 additions & 5 deletions bootstrap/state-builder/src/build_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ fn main() {

// Load the address. The UTXO dump tool we use doesn't output all the addresses
// we support, so if parsing the address itself fails, we try parsing the script directly.
let bitcoin_newtork = into_bitcoin_network(args.network);
let address = if let Ok(address) = BitcoinAddress::from_str(address_str) {
Some(address)
let checked_address = address
.require_network(bitcoin_newtork)
.expect("Address must be valid for network");
Some(checked_address)
} else {
BitcoinAddress::from_script(
&Script::from(hex::decode(script).expect("script must be valid hex")),
into_bitcoin_network(args.network),
)
let bytes = hex::decode(script).expect("script must be valid hex");
BitcoinAddress::from_script(Script::from_bytes(&bytes), bitcoin_newtork).ok()
};

if let Some(address) = address {
Expand Down
20 changes: 16 additions & 4 deletions bootstrap/state-builder/src/build_utxos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
//! --network testnet \
//! --output output-dir \
//! --utxos-dump-path utxos-dump.csv
use bitcoin::{Address, Txid as BitcoinTxid};
use bitcoin::{hashes::Hash, Address, Txid as BitcoinTxid};
use clap::Parser;
use ic_btc_canister::types::into_bitcoin_network;
use ic_btc_canister::{types::TxOut, with_state, with_state_mut};
use ic_btc_interface::{Flag, InitConfig, Network};
use ic_btc_types::{OutPoint, Txid};
Expand Down Expand Up @@ -86,7 +87,13 @@ fn main() {
let line = line.unwrap();
let parts: Vec<_> = line.split(',').collect();

let txid = Txid::from(BitcoinTxid::from_str(parts[1]).unwrap().to_vec());
let txid = Txid::from(
BitcoinTxid::from_str(parts[1])
.unwrap()
.as_raw_hash()
.as_byte_array()
.to_vec(),
);
let vout: u32 = parts[2].parse().unwrap();
let amount: u64 = parts[3].parse().unwrap();
let script = parts[6];
Expand All @@ -101,13 +108,18 @@ fn main() {
// Instead of using the scripts from the database, we can infer the script from the
// address. Otherwise, we use the script in the chainstate database as-is.
let script = match Address::from_str(address_str) {
Ok(address) => address.script_pubkey().as_bytes().to_vec(),
Ok(address) => address
.require_network(into_bitcoin_network(args.network))
.unwrap()
.script_pubkey()
.as_bytes()
.to_vec(),
Err(_) => hex::decode(script).unwrap(),
};

// Insert the UTXO
let outpoint = OutPoint { txid, vout };
if !bitcoin::Script::from(script.clone()).is_provably_unspendable() {
if !bitcoin::Script::from_bytes(&script).is_provably_unspendable() {
let txout = TxOut {
value: amount,
script_pubkey: script,
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/state-builder/src/main_state_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn read_block(reader: &mut BufReader<File>) -> Block {
let mut block = String::new();
reader.read_line(&mut block).unwrap();
let block = hex::decode(block.replace('\n', "")).unwrap();
Block::new(BitcoinBlock::consensus_decode(block.as_slice()).unwrap())
Block::new(BitcoinBlock::consensus_decode(&mut block.as_slice()).unwrap())
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions canister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bitcoin = { workspace = true, features = ["use-serde"] }
bitcoin = { workspace = true, features = ["serde"] }
# An optional dependency to benchmark parts of the code.
canbench-rs = { workspace = true, optional = true }
candid = { workspace = true }
Expand Down Expand Up @@ -35,7 +35,7 @@ bench = false
[dev-dependencies]
assert_matches = { workspace = true }
async-std = { version = "1.12.0", features = ["attributes"] }
bitcoin = { workspace = true, features = ["rand"] } # needed for generating secp256k1 keys.
bitcoin = { workspace = true }
byteorder = { workspace = true }
candid_parser = { workspace = true }
ic-btc-test-utils = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion canister/proptest-regressions/blocktree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
#
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
cc f9ce64e7b8f2ec6d8dd535b56e1aad46443a3e6589852a73a6b2d9778e4e9870 # shrinks to input = _SerializeDeserializeArgs { tree: BlockTree { root: Block { block: Block { header: BlockHeader { version: 1, prev_blockhash: 0000000000000000000000000000000000000000000000000000000000000000, merkle_root: 91ee09dd76d9df4a91913067f13fd47dca48420335cd64ed5ca6262bfe3ecbeb, time: 0, bits: 545259519, nonce: 2 }, txdata: [Transaction { version: 1, lock_time: 0, input: [TxIn { previous_output: OutPoint { txid: 0000000000000000000000000000000000000000000000000000000000000000, vout: 4294967295 }, script_sig: Script(), sequence: 4294967295, witness: Witness { content: [], witness_elements: 0, last: 0, second_to_last: 0 } }], output: [TxOut { value: 5000000000, script_pubkey: Script(OP_DUP OP_HASH160 OP_PUSHBYTES_20 1c06d2ab6d4557646aeda8477edc4143bb728b7f OP_EQUALVERIFY OP_CHECKSIG) }] }] }, transactions: [Transaction { tx: Transaction { version: 1, lock_time: 0, input: [TxIn { previous_output: OutPoint { txid: 0000000000000000000000000000000000000000000000000000000000000000, vout: 4294967295 }, script_sig: Script(), sequence: 4294967295, witness: Witness { content: [], witness_elements: 0, last: 0, second_to_last: 0 } }], output: [TxOut { value: 5000000000, script_pubkey: Script(OP_DUP OP_HASH160 OP_PUSHBYTES_20 1c06d2ab6d4557646aeda8477edc4143bb728b7f OP_EQUALVERIFY OP_CHECKSIG) }] }, txid: RefCell { value: None } }], block_hash: RefCell { value: None }, mock_difficulty: None }, children: [] } }
cc f9ce64e7b8f2ec6d8dd535b56e1aad46443a3e6589852a73a6b2d9778e4e9870 # shrinks to input = _SerializeDeserializeArgs { tree: BlockTree { root: Block { block: Block { header: Header { version: 1, prev_blockhash: 0000000000000000000000000000000000000000000000000000000000000000, merkle_root: 91ee09dd76d9df4a91913067f13fd47dca48420335cd64ed5ca6262bfe3ecbeb, time: 0, bits: 545259519, nonce: 2 }, txdata: [Transaction { version: 1, lock_time: 0, input: [TxIn { previous_output: OutPoint { txid: 0000000000000000000000000000000000000000000000000000000000000000, vout: 4294967295 }, script_sig: Script(), sequence: 4294967295, witness: Witness { content: [], witness_elements: 0, last: 0, second_to_last: 0 } }], output: [TxOut { value: 5000000000, script_pubkey: Script(OP_DUP OP_HASH160 OP_PUSHBYTES_20 1c06d2ab6d4557646aeda8477edc4143bb728b7f OP_EQUALVERIFY OP_CHECKSIG) }] }] }, transactions: [Transaction { tx: Transaction { version: 1, lock_time: 0, input: [TxIn { previous_output: OutPoint { txid: 0000000000000000000000000000000000000000000000000000000000000000, vout: 4294967295 }, script_sig: Script(), sequence: 4294967295, witness: Witness { content: [], witness_elements: 0, last: 0, second_to_last: 0 } }], output: [TxOut { value: 5000000000, script_pubkey: Script(OP_DUP OP_HASH160 OP_PUSHBYTES_20 1c06d2ab6d4557646aeda8477edc4143bb728b7f OP_EQUALVERIFY OP_CHECKSIG) }] }, txid: RefCell { value: None } }], block_hash: RefCell { value: None }, mock_difficulty: None }, children: [] } }
Loading
Loading