From a82097c14300b37c233e298012d87cca1d5bcc90 Mon Sep 17 00:00:00 2001 From: Jeason Date: Thu, 9 May 2024 17:04:41 +0800 Subject: [PATCH 1/2] Fix fuzzers --- fuzz/fuzz_targets/runestone_decipher.rs | 2 +- fuzz/fuzz_targets/transaction_builder.rs | 30 ++++++++++++------------ fuzz/fuzz_targets/varint_decode.rs | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fuzz/fuzz_targets/runestone_decipher.rs b/fuzz/fuzz_targets/runestone_decipher.rs index 4895530074..9422221e29 100644 --- a/fuzz/fuzz_targets/runestone_decipher.rs +++ b/fuzz/fuzz_targets/runestone_decipher.rs @@ -32,5 +32,5 @@ fuzz_target!(|input: Vec>| { version: 2, }; - Runestone::from_transaction(&tx); + Runestone::decipher(&tx); }); diff --git a/fuzz/fuzz_targets/transaction_builder.rs b/fuzz/fuzz_targets/transaction_builder.rs index 41948b559e..ecdccb0cac 100644 --- a/fuzz/fuzz_targets/transaction_builder.rs +++ b/fuzz/fuzz_targets/transaction_builder.rs @@ -4,10 +4,10 @@ use { arbitrary::Arbitrary, bitcoin::{ address::{Address, NetworkUnchecked}, - Amount, OutPoint, + Amount, OutPoint, TxOut, }, libfuzzer_sys::fuzz_target, - ord::{FeeRate, Target, TransactionBuilder}, + ord::{FeeRate, InscriptionId, Target, TransactionBuilder}, ordinals::SatPoint, std::collections::{BTreeMap, BTreeSet}, }; @@ -16,7 +16,6 @@ use { struct Input { output_value: Option, fee_rate: f64, - utxos: Vec, } fuzz_target!(|input: Input| { @@ -29,23 +28,24 @@ fuzz_target!(|input: Input| { .unwrap(); let inscription_id = "1111111111111111111111111111111111111111111111111111111111111111i1" - .parse() + .parse::() .unwrap(); let mut inscriptions = BTreeMap::new(); - inscriptions.insert(satpoint, inscription_id); + inscriptions.insert(satpoint, vec![inscription_id]); + let address = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4" + .parse::>() + .unwrap() + .assume_checked(); let mut amounts = BTreeMap::new(); - amounts.insert(outpoint, Amount::from_sat(1_000_000)); - - for (i, value) in input.utxos.into_iter().enumerate() { - amounts.insert( - format!("0000000000000000000000000000000000000000000000000000000000000000:{i}",) - .parse() - .unwrap(), - Amount::from_sat(value), - ); - } + amounts.insert( + outpoint, + TxOut { + value: 50_000, + script_pubkey: address.script_pubkey(), + }, + ); let recipient = "bc1pdqrcrxa8vx6gy75mfdfj84puhxffh4fq46h3gkp6jxdd0vjcsdyspfxcv6" .parse::>() diff --git a/fuzz/fuzz_targets/varint_decode.rs b/fuzz/fuzz_targets/varint_decode.rs index cd54a8712e..5ca215465d 100644 --- a/fuzz/fuzz_targets/varint_decode.rs +++ b/fuzz/fuzz_targets/varint_decode.rs @@ -6,7 +6,7 @@ fuzz_target!(|input: &[u8]| { let mut i = 0; while i < input.len() { - let Some((decoded, length)) = varint::decode(&input[i..]) else { + let Ok((decoded, length)) = varint::decode(&input[i..]) else { break; }; let mut encoded = Vec::new(); From a413292d1ea23c503b18f7819b2cb41c4b92304c Mon Sep 17 00:00:00 2001 From: raphjaph Date: Fri, 17 May 2024 16:45:11 +0200 Subject: [PATCH 2/2] Amend --- fuzz/Cargo.lock | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 4d7c65be2c..1961c66a03 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -195,7 +195,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" dependencies = [ - "brotli", + "brotli 3.5.0", "flate2", "futures-core", "memchr", @@ -574,7 +574,18 @@ checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", - "brotli-decompressor", + "brotli-decompressor 2.5.1", +] + +[[package]] +name = "brotli" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19483b140a7ac7174d34b5a581b406c64f84da5409d3e09cf4fff604f9270e67" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor 4.0.0", ] [[package]] @@ -587,6 +598,16 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "brotli-decompressor" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6221fe77a248b9117d431ad93761222e1cf8ff282d9d1d5d9f53d6299a1cf76" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bumpalo" version = "3.15.4" @@ -2075,7 +2096,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ord" -version = "0.16.0" +version = "0.18.5" dependencies = [ "anyhow", "async-trait", @@ -2086,7 +2107,7 @@ dependencies = [ "bip39", "bitcoin", "boilerplate", - "brotli", + "brotli 5.0.0", "chrono", "ciborium", "clap", @@ -2160,7 +2181,7 @@ dependencies = [ [[package]] name = "ordinals" -version = "0.0.4" +version = "0.0.8" dependencies = [ "bitcoin", "derive_more",