From 15bdc41ff432b99905796b927b867a7b7c62ca11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 26 Jun 2024 12:22:25 +0100 Subject: [PATCH 01/30] init a fuzz target with cargo-fuzz --- Cargo.lock | 39 +++++++++++++++++++++++++++ Cargo.toml | 2 ++ fuzz/.gitignore | 4 +++ fuzz/Cargo.toml | 20 ++++++++++++++ fuzz/fuzz_targets/fuzz_txs_mempool.rs | 7 +++++ 5 files changed, 72 insertions(+) create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/fuzz_txs_mempool.rs diff --git a/Cargo.lock b/Cargo.lock index 67366f9653..0e220c5141 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,6 +162,15 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "ark-bls12-381" version = "0.3.0" @@ -1695,6 +1704,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "derive_builder" version = "0.12.0" @@ -4185,6 +4205,17 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libfuzzer-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +dependencies = [ + "arbitrary", + "cc", + "once_cell", +] + [[package]] name = "libgit2-sys" version = "0.16.2+1.7.2" @@ -4832,6 +4863,14 @@ dependencies = [ "tokio", ] +[[package]] +name = "namada_fuzz" +version = "0.0.0" +dependencies = [ + "libfuzzer-sys", + "namada_node", +] + [[package]] name = "namada_gas" version = "0.42.0" diff --git a/Cargo.toml b/Cargo.toml index 2e3f8a0cd3..965831d98c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ members = [ "crates/vp_env", "crates/vp_prelude", "examples", + "fuzz", ] # wasm packages have to be built separately @@ -62,6 +63,7 @@ repository = "https://github.com/anoma/namada" version = "0.42.0" [workspace.dependencies] +arbitrary = {version = "1.3", features = ["derive"]} ark-bls12-381 = {version = "0.3"} ark-serialize = {version = "0.3"} ark-std = "0.3.0" diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000000..1a45eee776 --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,4 @@ +target +corpus +artifacts +coverage diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000000..9645a559fa --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "namada_fuzz" +version = "0.0.0" +publish = false +edition = "2021" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +namada_node = { path = "../crates/node" } + +libfuzzer-sys = "0.4" + +[[bin]] +name = "fuzz_txs_mempool" +path = "fuzz_targets/fuzz_txs_mempool.rs" +test = false +doc = false +bench = false diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/fuzz_txs_mempool.rs new file mode 100644 index 0000000000..43a88c14f3 --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_txs_mempool.rs @@ -0,0 +1,7 @@ +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + // fuzzed code goes here +}); From 9ed51c10822051c8023c3803cb45877f60852330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 26 Jun 2024 15:27:58 +0100 Subject: [PATCH 02/30] tx: impl Arbitrary for Tx --- Cargo.lock | 6 +- crates/core/Cargo.toml | 2 + crates/core/src/address.rs | 4 + crates/core/src/chain.rs | 1 + crates/core/src/ethereum_events.rs | 1 + crates/core/src/hash.rs | 1 + crates/core/src/ibc.rs | 1 + crates/core/src/key/common.rs | 2 + crates/core/src/key/ed25519.rs | 25 +++++ crates/core/src/key/mod.rs | 1 + crates/core/src/key/secp256k1.rs | 26 +++++ crates/core/src/time.rs | 1 + crates/core/src/token.rs | 3 + crates/core/src/uint.rs | 1 + crates/tx/Cargo.toml | 2 + crates/tx/src/data/mod.rs | 1 + crates/tx/src/data/protocol.rs | 2 + crates/tx/src/data/wrapper.rs | 3 + crates/tx/src/types.rs | 159 ++++++++++++++++++++++++++++- 19 files changed, 240 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e220c5141..f881514a08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -921,6 +921,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", + "arbitrary", "iana-time-zone", "js-sys", "num-traits 0.2.17", @@ -3844,7 +3845,7 @@ name = "indexmap" version = "2.2.4" source = "git+https://github.com/heliaxdev/indexmap?tag=2.2.4-heliax-1#b5b5b547bd6ab04bbb16e060326a50ddaeb6c909" dependencies = [ - "borsh", + "arbitrary", "equivalent", "hashbrown 0.14.3", "serde", @@ -4721,6 +4722,7 @@ dependencies = [ name = "namada_core" version = "0.42.0" dependencies = [ + "arbitrary", "assert_matches", "bech32 0.8.1", "borsh", @@ -4869,6 +4871,7 @@ version = "0.0.0" dependencies = [ "libfuzzer-sys", "namada_node", + "namada_tx", ] [[package]] @@ -5412,6 +5415,7 @@ dependencies = [ name = "namada_tx" version = "0.42.0" dependencies = [ + "arbitrary", "ark-bls12-381", "assert_matches", "bitflags 2.5.0", diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index fa821140a5..fa1fb3c665 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -30,11 +30,13 @@ migrations = [ ] benches = ["proptest"] control_flow = ["futures", "lazy_static", "tokio", "wasmtimer"] +arbitrary = ["dep:arbitrary", "chrono/arbitrary", "indexmap/arbitrary"] [dependencies] namada_macros = {path = "../macros"} namada_migrations = {path = "../migrations", optional = true} +arbitrary = { workspace = true, optional = true } arse-merkle-tree.workspace = true bech32.workspace = true borsh.workspace = true diff --git a/crates/core/src/address.rs b/crates/core/src/address.rs index a2035c5fb9..38bd439846 100644 --- a/crates/core/src/address.rs +++ b/crates/core/src/address.rs @@ -79,6 +79,7 @@ pub type DecodeError = string_encoding::DecodeError; pub type Result = std::result::Result; /// An account's address +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, BorshSerialize, @@ -412,6 +413,7 @@ impl TryFrom for Address { } /// An established address is generated on-chain +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -512,6 +514,7 @@ impl EstablishedAddressGen { } /// An implicit address is derived from a cryptographic key +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -543,6 +546,7 @@ impl From<&key::common::PublicKey> for Address { } /// An internal address represents a module with a native VP +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/core/src/chain.rs b/crates/core/src/chain.rs index e6c75e539b..5e93db551f 100644 --- a/crates/core/src/chain.rs +++ b/crates/core/src/chain.rs @@ -205,6 +205,7 @@ impl ProposalBytes { pub const DEFAULT_CHAIN_ID: &str = "namada-internal.00000000000000"; /// Chain ID +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/core/src/ethereum_events.rs b/crates/core/src/ethereum_events.rs index 0a8de94ba8..63afa38589 100644 --- a/crates/core/src/ethereum_events.rs +++ b/crates/core/src/ethereum_events.rs @@ -112,6 +112,7 @@ impl From for Uint { /// Representation of address on Ethereum. The inner value is the last 20 bytes /// of the public key that controls the account. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Copy, Clone, diff --git a/crates/core/src/hash.rs b/crates/core/src/hash.rs index 8caea1bc4b..a2cfa4112c 100644 --- a/crates/core/src/hash.rs +++ b/crates/core/src/hash.rs @@ -36,6 +36,7 @@ pub enum Error { /// Result for functions that may fail pub type HashResult = std::result::Result; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, diff --git a/crates/core/src/ibc.rs b/crates/core/src/ibc.rs index 39a4b505d8..8473095275 100644 --- a/crates/core/src/ibc.rs +++ b/crates/core/src/ibc.rs @@ -18,6 +18,7 @@ use crate::hash::Hash; use crate::token; /// IBC token hash derived from a denomination. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/core/src/key/common.rs b/crates/core/src/key/common.rs index 5a758f4b07..4c6788237a 100644 --- a/crates/core/src/key/common.rs +++ b/crates/core/src/key/common.rs @@ -23,6 +23,7 @@ use crate::key::{SignableBytes, StorageHasher}; use crate::{impl_display_and_from_str_via_format, string_encoding}; /// Public key +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -299,6 +300,7 @@ impl FromStr for SecretKey { } /// Signature +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, diff --git a/crates/core/src/key/ed25519.rs b/crates/core/src/key/ed25519.rs index d746f16179..03997f4dd8 100644 --- a/crates/core/src/key/ed25519.rs +++ b/crates/core/src/key/ed25519.rs @@ -394,3 +394,28 @@ impl super::SigScheme for SigScheme { .map_err(|err| VerifySigError::SigVerifyError(err.to_string())) } } + +#[cfg(feature = "arbitrary")] +impl arbitrary::Arbitrary<'_> for PublicKey { + fn arbitrary( + _: &mut arbitrary::Unstructured<'_>, + ) -> arbitrary::Result { + Ok(Self( + ed25519_consensus::VerificationKey::try_from( + [0_u8; PUBLIC_KEY_LENGTH], + ) + .unwrap(), + )) + } +} + +#[cfg(feature = "arbitrary")] +impl arbitrary::Arbitrary<'_> for Signature { + fn arbitrary( + _: &mut arbitrary::Unstructured<'_>, + ) -> arbitrary::Result { + Ok(Self(ed25519_consensus::Signature::from( + [0_u8; SIGNATURE_LENGTH], + ))) + } +} diff --git a/crates/core/src/key/mod.rs b/crates/core/src/key/mod.rs index fdfe0195d5..970164f97e 100644 --- a/crates/core/src/key/mod.rs +++ b/crates/core/src/key/mod.rs @@ -276,6 +276,7 @@ pub trait SigScheme: Eq + Ord + Debug + Serialize + Default { /// Public key hash derived from `common::Key` borsh encoded bytes (hex string /// of the first 40 chars of sha256 hash) +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/core/src/key/secp256k1.rs b/crates/core/src/key/secp256k1.rs index 441d30beac..2211305480 100644 --- a/crates/core/src/key/secp256k1.rs +++ b/crates/core/src/key/secp256k1.rs @@ -599,6 +599,32 @@ impl super::SigScheme for SigScheme { } } +#[cfg(feature = "arbitrary")] +impl arbitrary::Arbitrary<'_> for PublicKey { + fn arbitrary( + _: &mut arbitrary::Unstructured<'_>, + ) -> arbitrary::Result { + Ok(Self( + k256::PublicKey::from_sec1_bytes( + &[0_u8; COMPRESSED_PUBLIC_KEY_SIZE], + ) + .unwrap(), + )) + } +} + +#[cfg(feature = "arbitrary")] +impl arbitrary::Arbitrary<'_> for Signature { + fn arbitrary( + _: &mut arbitrary::Unstructured<'_>, + ) -> arbitrary::Result { + Ok(Self( + k256::ecdsa::Signature::from_slice(&[0_u8; 64]).unwrap(), + RecoveryId::from_byte(0).unwrap(), + )) + } +} + #[cfg(test)] mod test { diff --git a/crates/core/src/time.rs b/crates/core/src/time.rs index 16970916ec..fd27aa31aa 100644 --- a/crates/core/src/time.rs +++ b/crates/core/src/time.rs @@ -127,6 +127,7 @@ impl From for std::time::Duration { pub struct Rfc3339String(pub String); /// A duration in seconds precision. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, diff --git a/crates/core/src/token.rs b/crates/core/src/token.rs index 70cdeff7dc..8347c5871b 100644 --- a/crates/core/src/token.rs +++ b/crates/core/src/token.rs @@ -22,6 +22,7 @@ use crate::uint::{self, Uint, I256}; /// Amount in micro units. For different granularity another representation /// might be more appropriate. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, @@ -381,6 +382,7 @@ impl Display for Amount { /// Given a number represented as `M*B^D`, then /// `M` is the matissa, `B` is the base and `D` /// is the denomination, represented by this struct. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Copy, @@ -413,6 +415,7 @@ impl From for u8 { } /// An amount with its denomination. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Copy, diff --git a/crates/core/src/uint.rs b/crates/core/src/uint.rs index 8736379e9b..14a361f871 100644 --- a/crates/core/src/uint.rs +++ b/crates/core/src/uint.rs @@ -294,6 +294,7 @@ impl Uint { construct_uint! { /// Namada native type to replace for unsigned 256 bit /// integers. + #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( BorshSerialize, BorshDeserialize, diff --git a/crates/tx/Cargo.toml b/crates/tx/Cargo.toml index 7a967104ec..43331561c7 100644 --- a/crates/tx/Cargo.toml +++ b/crates/tx/Cargo.toml @@ -20,6 +20,7 @@ migrations = [ "namada_migrations", "linkme", ] +arbitrary = ["dep:arbitrary", "namada_core/arbitrary"] [dependencies] namada_core = { path = "../core" } @@ -28,6 +29,7 @@ namada_gas = { path = "../gas" } namada_macros = { path = "../macros" } namada_migrations = {path = "../migrations", optional = true } +arbitrary = { workspace = true, optional = true } ark-bls12-381.workspace = true bitflags.workspace = true borsh.workspace = true diff --git a/crates/tx/src/data/mod.rs b/crates/tx/src/data/mod.rs index ea73b8ed70..c180d30537 100644 --- a/crates/tx/src/data/mod.rs +++ b/crates/tx/src/data/mod.rs @@ -573,6 +573,7 @@ fn iterable_to_string( /// Struct that classifies that kind of Tx /// based on the contents of its data. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, diff --git a/crates/tx/src/data/protocol.rs b/crates/tx/src/data/protocol.rs index fd994cb47c..e52e24e422 100644 --- a/crates/tx/src/data/protocol.rs +++ b/crates/tx/src/data/protocol.rs @@ -13,6 +13,7 @@ use sha2::{Digest, Sha256}; use crate::TxError; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -55,6 +56,7 @@ impl ProtocolTx { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Copy, Clone, diff --git a/crates/tx/src/data/wrapper.rs b/crates/tx/src/data/wrapper.rs index 137054ed5a..eaaffbca84 100644 --- a/crates/tx/src/data/wrapper.rs +++ b/crates/tx/src/data/wrapper.rs @@ -40,6 +40,7 @@ pub enum WrapperTxErr { } /// Amount of some specified token to pay for fees. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -60,6 +61,7 @@ pub struct Fee { } /// Gas limit of a transaction +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -138,6 +140,7 @@ impl GasLimit { /// A transaction with an encrypted payload, an optional shielded pool /// unshielding tx for fee payment and some non-encrypted metadata for /// inclusion and / or verification purposes +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 51830063d5..cddbd64f0f 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -219,6 +219,7 @@ pub fn verify_standalone_sig>( } /// A section representing transaction data +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -268,6 +269,7 @@ impl Data { pub struct CommitmentError; /// Represents either some code bytes or their SHA-256 hash +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -334,6 +336,7 @@ impl Commitment { } /// A section representing transaction code +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -406,6 +409,7 @@ impl Code { pub type Memo = Vec; /// Indicates the list of public keys against which signatures will be verified +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -425,6 +429,7 @@ pub enum Signer { } /// A section representing a multisig over another section +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -758,6 +763,7 @@ impl MaspBuilder { /// A section of a transaction. Carries an independent piece of information /// necessary for the processing of a transaction. +// #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -791,6 +797,154 @@ pub enum Section { Header(Header), } +#[cfg(feature = "arbitrary")] +std::thread_local! { + #[allow(non_upper_case_globals)] + static RECURSIVE_COUNT_Section: ::core::cell::Cell = ::core::cell::Cell::new(0); +} + +#[cfg(feature = "arbitrary")] +impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { + fn arbitrary( + u: &mut arbitrary::Unstructured<'arbitrary>, + ) -> arbitrary::Result { + let guard_against_recursion = u.is_empty(); + if guard_against_recursion { + RECURSIVE_COUNT_Section.with(|count| { + if count.get() > 0 { + return Err(arbitrary::Error::NotEnoughData); + } + count.set(count.get() + 1); + Ok(()) + })?; + } + let result = (|| { + Ok( + match (u64::from(::arbitrary(u)?) + * 7u64) + >> 32 + { + 0u64 => Section::Data(arbitrary::Arbitrary::arbitrary(u)?), + 1u64 => { + Section::ExtraData(arbitrary::Arbitrary::arbitrary(u)?) + } + 2u64 => Section::Code(arbitrary::Arbitrary::arbitrary(u)?), + 3u64 => Section::Authorization( + arbitrary::Arbitrary::arbitrary(u)?, + ), + // 4u64 => Section::MaspTx(arbitrary::Arbitrary::arbitrary(u)?), + // 5u64 => { + // Section::MaspBuilder(arbitrary::Arbitrary::arbitrary(u)?) + // } + 4u64 => { + Section::Header(arbitrary::Arbitrary::arbitrary(u)?) + } + _ => panic!("internal error: entered unreachable code",), + }, + ) + })(); + if guard_against_recursion { + RECURSIVE_COUNT_Section.with(|count| { + count.set(count.get() - 1); + }); + } + result + } + + fn arbitrary_take_rest( + mut u: arbitrary::Unstructured<'arbitrary>, + ) -> arbitrary::Result { + let guard_against_recursion = u.is_empty(); + if guard_against_recursion { + RECURSIVE_COUNT_Section.with(|count| { + if count.get() > 0 { + return Err(arbitrary::Error::NotEnoughData); + } + count.set(count.get() + 1); + Ok(()) + })?; + } + let result = (|| { + Ok( + match (u64::from(::arbitrary( + &mut u, + )?) * 7u64) + >> 32 + { + 0u64 => Section::Data( + arbitrary::Arbitrary::arbitrary_take_rest(u)?, + ), + 1u64 => Section::ExtraData( + arbitrary::Arbitrary::arbitrary_take_rest(u)?, + ), + 2u64 => Section::Code( + arbitrary::Arbitrary::arbitrary_take_rest(u)?, + ), + 3u64 => Section::Authorization( + arbitrary::Arbitrary::arbitrary_take_rest(u)?, + ), + // 4u64 => { + // Section::MaspTx( + // arbitrary::Arbitrary::arbitrary_take_rest(u)?, + // ) + // } + // 5u64 => { + // Section::MaspBuilder( + // arbitrary::Arbitrary::arbitrary_take_rest(u)?, + // ) + // } + 4u64 => Section::Header( + arbitrary::Arbitrary::arbitrary_take_rest(u)?, + ), + _ => panic!("internal error: entered unreachable code",), + }, + ) + })(); + if guard_against_recursion { + RECURSIVE_COUNT_Section.with(|count| { + count.set(count.get() - 1); + }); + } + result + } + + #[inline] + fn size_hint(depth: usize) -> (usize, Option) { + arbitrary::size_hint::and( + ::size_hint(depth), + arbitrary::size_hint::recursion_guard(depth, |depth| { + arbitrary::size_hint::or_all(&[ + arbitrary::size_hint::and_all(&[ + ::size_hint(depth), + ]), + arbitrary::size_hint::and_all(&[ + ::size_hint(depth), + ]), + arbitrary::size_hint::and_all(&[ + ::size_hint(depth), + ]), + arbitrary::size_hint::and_all(&[ + ::size_hint( + depth, + ), + ]), + // arbitrary::size_hint::and_all( + // &[::size_hint(depth)], + // ), + // arbitrary::size_hint::and_all( + // &[::size_hint(depth)], + // ), + arbitrary::size_hint::and_all(&[ +
::size_hint(depth), + ]), + ]) + }), + ) + } +} + impl Section { /// Hash this section. Section hashes are useful for signatures and also for /// allowing transaction sections to cross reference. @@ -895,6 +1049,7 @@ impl Section { /// An inner transaction of the batch, represented by its commitments to the /// [`Code`], [`Data`] and [`Memo`] sections +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -955,6 +1110,7 @@ impl TxCommitments { /// A Namada transaction header indicating where transaction subcomponents can /// be found +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -1034,7 +1190,8 @@ pub enum TxError { } /// A Namada transaction is represented as a header followed by a series of -/// seections providing additional details. +/// sections providing additional details. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, From 49fcca7b4421dc8cfe9d0e80b1f9f21fbe5cdfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 26 Jun 2024 16:14:38 +0100 Subject: [PATCH 03/30] fuzz mempool with arb txs --- crates/node/Cargo.toml | 2 ++ crates/node/src/shell/init_chain.rs | 6 +++--- crates/node/src/shell/mod.rs | 24 ++++++++++++------------ fuzz/Cargo.toml | 3 ++- fuzz/fuzz_targets/fuzz_txs_mempool.rs | 8 ++++++-- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index ec0d6ffbac..0074bcbe1a 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -23,6 +23,7 @@ testing = [ "namada_test_utils", "clap", "lazy_static", + "rand", ] benches = [ "namada_apps_lib/benches", @@ -80,6 +81,7 @@ num-rational.workspace = true num-traits.workspace = true once_cell.workspace = true prost.workspace = true +rand = { workspace = true, features = ["std"], optional = true } rand_core = { workspace = true, optional = true, features = ["std"] } rayon.workspace = true regex.workspace = true diff --git a/crates/node/src/shell/init_chain.rs b/crates/node/src/shell/init_chain.rs index 74d324aba3..f17feae89a 100644 --- a/crates/node/src/shell/init_chain.rs +++ b/crates/node/src/shell/init_chain.rs @@ -132,7 +132,7 @@ where // Read the genesis files #[cfg(any( feature = "integration", - not(any(test, feature = "benches")) + not(any(test, fuzzing, feature = "benches")) ))] let genesis = { let chain_dir = self.base_dir.join(chain_id); @@ -140,7 +140,7 @@ where .expect("Missing genesis files") }; #[cfg(all( - any(test, feature = "benches"), + any(test, fuzzing, feature = "benches"), not(feature = "integration") ))] let genesis = { @@ -148,7 +148,7 @@ where genesis::make_dev_genesis(_num_validators, &chain_dir) }; #[cfg(all( - any(test, feature = "benches"), + any(test, fuzzing, feature = "benches"), not(feature = "integration") ))] { diff --git a/crates/node/src/shell/mod.rs b/crates/node/src/shell/mod.rs index cb5c486cea..3474aada63 100644 --- a/crates/node/src/shell/mod.rs +++ b/crates/node/src/shell/mod.rs @@ -440,13 +440,13 @@ where // For all tests except integration use hard-coded native token addr ... #[cfg(all( - any(test, feature = "testing", feature = "benches"), + any(test, fuzzing, feature = "testing", feature = "benches"), not(feature = "integration"), ))] let native_token = namada_sdk::address::testing::nam(); // ... Otherwise, look it up from the genesis file #[cfg(not(all( - any(test, feature = "testing", feature = "benches"), + any(test, fuzzing, feature = "testing", feature = "benches"), not(feature = "integration"), )))] let native_token = { @@ -473,7 +473,7 @@ where // load in keys and address from wallet if mode is set to `Validator` let mode = match mode { TendermintMode::Validator => { - #[cfg(not(test))] + #[cfg(not(any(test, fuzzing)))] { let wallet_path = &base_dir.join(chain_id.as_str()); tracing::debug!( @@ -526,7 +526,7 @@ where wallet", ) } - #[cfg(test)] + #[cfg(any(test, fuzzing))] { let (protocol_keypair, eth_bridge_keypair) = wallet::defaults::validator_keys(); @@ -1031,6 +1031,7 @@ where } // Tx signature check + #[cfg(not(fuzzing))] let tx_type = match tx.validate_tx() { Ok(_) => tx.header(), Err(msg) => { @@ -1039,6 +1040,8 @@ where return response; } }; + #[cfg(fuzzing)] + let tx_type = tx.header(); // try to parse a vote extension protocol tx from // the provided tx data @@ -1447,8 +1450,8 @@ where /// for the shell #[allow(clippy::arithmetic_side_effects, clippy::cast_possible_wrap)] -#[cfg(test)] -mod test_utils { +#[cfg(any(test, feature = "testing"))] +pub mod test_utils { use std::ops::{Deref, DerefMut}; use data_encoding::HEXUPPER; @@ -1491,12 +1494,9 @@ mod test_utils { .expect("Current directory should exist") .canonicalize() .expect("Current directory should exist"); - while current_path.file_name().unwrap() != "node" { + while !current_path.join("rust-toolchain.toml").exists() { current_path.pop(); } - // Two-dirs up to root - current_path.pop(); - current_path.pop(); current_path } @@ -1573,7 +1573,7 @@ mod test_utils { /// Drop so as to clean up the files that it /// generates. Also allows illegal state /// modifications for testing purposes - pub(super) struct TestShell { + pub struct TestShell { pub shell: Shell, } @@ -1894,7 +1894,7 @@ mod test_utils { /// Same as [`setup_with_cfg`], but returns a shell at block height 0, /// with a single validator. #[inline] - pub(super) fn setup() -> ( + pub fn setup() -> ( TestShell, UnboundedReceiver>, Sender, diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 9645a559fa..dc7944175a 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -8,7 +8,8 @@ edition = "2021" cargo-fuzz = true [dependencies] -namada_node = { path = "../crates/node" } +namada_node = { path = "../crates/node", features = ["testing"] } +namada_tx = { path = "../crates/tx", features = ["arbitrary"] } libfuzzer-sys = "0.4" diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/fuzz_txs_mempool.rs index 43a88c14f3..5edf712aa7 100644 --- a/fuzz/fuzz_targets/fuzz_txs_mempool.rs +++ b/fuzz/fuzz_targets/fuzz_txs_mempool.rs @@ -1,7 +1,11 @@ #![no_main] use libfuzzer_sys::fuzz_target; +use namada_node::shell; +use namada_node::shell::MempoolTxType; +use namada_tx::Tx; -fuzz_target!(|data: &[u8]| { - // fuzzed code goes here +fuzz_target!(|tx: Tx| { + let (shell, _recv, _, _) = shell::test_utils::setup(); + shell.mempool_validate(&tx.to_bytes(), MempoolTxType::NewTransaction); }); From b226786dd3ddade198a50d972060a9725c2c52ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 28 Jun 2024 08:48:52 +0100 Subject: [PATCH 04/30] Makefile: add `cargo-fuzz` dep and `fuzz-txs-mempool` recipe --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7ba72ab8f1..d589cf5867 100644 --- a/Makefile +++ b/Makefile @@ -273,6 +273,9 @@ clean: bench: $(cargo) bench --package namada_benchmarks +fuzz-txs-mempool: + $(cargo) +$(nightly) fuzz run fuzz_txs_mempool + build-doc: $(cargo) doc --no-deps @@ -351,7 +354,7 @@ dev-deps: $(rustup) toolchain install $(nightly) $(rustup) target add wasm32-unknown-unknown $(rustup) component add rustfmt clippy miri --toolchain $(nightly) - $(cargo) install cargo-watch unclog wasm-opt + $(cargo) install cargo-watch unclog wasm-opt cargo-fuzz test-miri: $(cargo) +$(nightly) miri setup From a04b45fd42a118b016110b070ab983a27ea6b623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 1 Jul 2024 15:35:22 +0100 Subject: [PATCH 05/30] node/init_chain: no wasm pre-compile for fuzzing --- crates/node/src/shell/init_chain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/node/src/shell/init_chain.rs b/crates/node/src/shell/init_chain.rs index f17feae89a..40ab7a6921 100644 --- a/crates/node/src/shell/init_chain.rs +++ b/crates/node/src/shell/init_chain.rs @@ -418,7 +418,7 @@ where ) .or_placeholder(None)?; - #[cfg(not(test))] + #[cfg(not(any(test, fuzzing)))] if name.starts_with("tx_") { self.tx_wasm_cache.pre_compile(&code); } else if name.starts_with("vp_") { From 44c1d71b28b66a406bb362260670f77b8fb78c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 1 Jul 2024 16:05:00 +0100 Subject: [PATCH 06/30] fuzz: set dev opt-level = 3 --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 965831d98c..11393a0ccc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -223,3 +223,6 @@ lto = true opt-level = 3 panic = "unwind" overflow-checks = true + +[profile.dev.package.namada_fuzz] +opt-level = 3 From b5c0a2cc3349672f6ce1692f0ed681a09ac89565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 1 Jul 2024 16:09:58 +0100 Subject: [PATCH 07/30] fuzz_txs_mempool: re-use TestShell between runs --- Cargo.lock | 1 + fuzz/Cargo.toml | 1 + fuzz/fuzz_targets/fuzz_txs_mempool.rs | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f881514a08..3e374055ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4869,6 +4869,7 @@ dependencies = [ name = "namada_fuzz" version = "0.0.0" dependencies = [ + "lazy_static", "libfuzzer-sys", "namada_node", "namada_tx", diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index dc7944175a..7305115186 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -11,6 +11,7 @@ cargo-fuzz = true namada_node = { path = "../crates/node", features = ["testing"] } namada_tx = { path = "../crates/tx", features = ["arbitrary"] } +lazy_static.workspace = true libfuzzer-sys = "0.4" [[bin]] diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/fuzz_txs_mempool.rs index 5edf712aa7..309c7d575d 100644 --- a/fuzz/fuzz_targets/fuzz_txs_mempool.rs +++ b/fuzz/fuzz_targets/fuzz_txs_mempool.rs @@ -1,11 +1,19 @@ #![no_main] +use lazy_static::lazy_static; use libfuzzer_sys::fuzz_target; use namada_node::shell; +use namada_node::shell::test_utils::TestShell; use namada_node::shell::MempoolTxType; use namada_tx::Tx; +lazy_static! { + static ref SHELL: TestShell = { + let (shell, _recv, _, _) = shell::test_utils::setup(); + shell + }; +} + fuzz_target!(|tx: Tx| { - let (shell, _recv, _, _) = shell::test_utils::setup(); - shell.mempool_validate(&tx.to_bytes(), MempoolTxType::NewTransaction); + SHELL.mempool_validate(&tx.to_bytes(), MempoolTxType::NewTransaction); }); From 0c5e9cbbc89efba87a7df9b7f84cb552a82b132c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 2 Jul 2024 09:03:08 +0100 Subject: [PATCH 08/30] core/key: fix arbitrary impls --- crates/core/src/key/ed25519.rs | 29 ++++++++++++++++---------- crates/core/src/key/secp256k1.rs | 35 +++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/crates/core/src/key/ed25519.rs b/crates/core/src/key/ed25519.rs index 03997f4dd8..31efebe94f 100644 --- a/crates/core/src/key/ed25519.rs +++ b/crates/core/src/key/ed25519.rs @@ -398,24 +398,31 @@ impl super::SigScheme for SigScheme { #[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for PublicKey { fn arbitrary( - _: &mut arbitrary::Unstructured<'_>, + u: &mut arbitrary::Unstructured<'_>, ) -> arbitrary::Result { - Ok(Self( - ed25519_consensus::VerificationKey::try_from( - [0_u8; PUBLIC_KEY_LENGTH], - ) - .unwrap(), - )) + let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?; + let sk = ed25519_consensus::SigningKey::from(seed); + Ok(Self(sk.verification_key())) + } + + fn size_hint(_depth: usize) -> (usize, Option) { + // Signing key seed size + (32, Some(32)) } } #[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for Signature { fn arbitrary( - _: &mut arbitrary::Unstructured<'_>, + u: &mut arbitrary::Unstructured<'_>, ) -> arbitrary::Result { - Ok(Self(ed25519_consensus::Signature::from( - [0_u8; SIGNATURE_LENGTH], - ))) + let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?; + let sk = ed25519_consensus::SigningKey::from(seed); + Ok(Self(sk.sign(&[0_u8]))) + } + + fn size_hint(_depth: usize) -> (usize, Option) { + // Signing key seed size + (32, Some(32)) } } diff --git a/crates/core/src/key/secp256k1.rs b/crates/core/src/key/secp256k1.rs index 2211305480..619d7ec08f 100644 --- a/crates/core/src/key/secp256k1.rs +++ b/crates/core/src/key/secp256k1.rs @@ -602,26 +602,41 @@ impl super::SigScheme for SigScheme { #[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for PublicKey { fn arbitrary( - _: &mut arbitrary::Unstructured<'_>, + u: &mut arbitrary::Unstructured<'_>, ) -> arbitrary::Result { + use rand::SeedableRng; + let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?; Ok(Self( - k256::PublicKey::from_sec1_bytes( - &[0_u8; COMPRESSED_PUBLIC_KEY_SIZE], - ) - .unwrap(), + k256::SecretKey::random(&mut rand::rngs::StdRng::from_seed(seed)) + .public_key(), )) } + + fn size_hint(_depth: usize) -> (usize, Option) { + // StdRng seed len + (32, Some(32)) + } } #[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for Signature { fn arbitrary( - _: &mut arbitrary::Unstructured<'_>, + u: &mut arbitrary::Unstructured<'_>, ) -> arbitrary::Result { - Ok(Self( - k256::ecdsa::Signature::from_slice(&[0_u8; 64]).unwrap(), - RecoveryId::from_byte(0).unwrap(), - )) + use rand::SeedableRng; + let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?; + let sk = + k256::SecretKey::random(&mut rand::rngs::StdRng::from_seed(seed)); + let sig_key = k256::ecdsa::SigningKey::from(&sk); + let (sig, recovery_id) = sig_key + .sign_prehash_recoverable(&[0_u8; 32]) + .expect("Must be able to sign"); + Ok(Self(sig, recovery_id)) + } + + fn size_hint(_depth: usize) -> (usize, Option) { + // StdRng seed len + (32, Some(32)) } } From 3206ad747fda297fc1456eaa037b66135823cff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 2 Jul 2024 09:18:12 +0100 Subject: [PATCH 09/30] tx: fix manual impl Arbitrary for Section --- crates/tx/src/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index cddbd64f0f..3946fcea74 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -821,7 +821,7 @@ impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { let result = (|| { Ok( match (u64::from(::arbitrary(u)?) - * 7u64) + * 5u64) >> 32 { 0u64 => Section::Data(arbitrary::Arbitrary::arbitrary(u)?), @@ -868,7 +868,7 @@ impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { Ok( match (u64::from(::arbitrary( &mut u, - )?) * 7u64) + )?) * 5u64) >> 32 { 0u64 => Section::Data( From 4a57fffc3e068b47bc93c7eb1301210a7bf52661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 3 Jul 2024 09:02:45 +0100 Subject: [PATCH 10/30] shell/mempool: skip chain ID check for fuzzing --- crates/node/src/shell/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/node/src/shell/mod.rs b/crates/node/src/shell/mod.rs index 3474aada63..e91efd95bf 100644 --- a/crates/node/src/shell/mod.rs +++ b/crates/node/src/shell/mod.rs @@ -1003,6 +1003,7 @@ where }; // Tx chain id + #[cfg(not(fuzzing))] if tx.header.chain_id != self.chain_id { response.code = ResultCode::InvalidChainId.into(); response.log = format!( From 6bfa43ca3bdd1d9c7f0e728eb3edd9c9aa2e8681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 12 Jul 2024 11:14:02 +0100 Subject: [PATCH 11/30] make/fuzz-txs-mempool: run with `--dev` to avoid OOM --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d589cf5867..3fbc68ac4a 100644 --- a/Makefile +++ b/Makefile @@ -273,8 +273,10 @@ clean: bench: $(cargo) bench --package namada_benchmarks +# NOTE: running in `--dev` as release build takes over 64GB memory, but +# dev is still configured for opt-level=3 fuzz-txs-mempool: - $(cargo) +$(nightly) fuzz run fuzz_txs_mempool + $(cargo) +$(nightly) fuzz run fuzz_txs_mempool --dev build-doc: $(cargo) doc --no-deps From 864a7bd1c55ef6201ebfc5fb4e81dadab1fe5bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 12 Jul 2024 11:19:38 +0100 Subject: [PATCH 12/30] tx: add arbitrary masp tx section --- Cargo.lock | 49 +++++++++++++++++++++++++++++++-------- Cargo.toml | 9 +++---- crates/tx/src/types.rs | 20 ++++++++-------- fuzz/Cargo.toml | 1 + wasm/Cargo.lock | 43 ++++++++++++++++++++++++++-------- wasm_for_tests/Cargo.lock | 43 ++++++++++++++++++++++++++-------- 6 files changed, 121 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e374055ba..350a052e18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -673,6 +673,17 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838#d3ebe9dd6488fac1923db120a7498079e55dd838" +dependencies = [ + "arbitrary", "ff", "group", "pairing", @@ -3846,6 +3857,7 @@ version = "2.2.4" source = "git+https://github.com/heliaxdev/indexmap?tag=2.2.4-heliax-1#b5b5b547bd6ab04bbb16e060326a50ddaeb6c909" dependencies = [ "arbitrary", + "borsh", "equivalent", "hashbrown 0.14.3", "serde", @@ -4024,7 +4036,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8499f7a74008aafbecb2a2e608a3e13e4dd3e84df198b604451efe93f2de6e61" dependencies = [ "bitvec", - "bls12_381", + "bls12_381 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ff", + "group", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "jubjub" +version = "0.10.0" +source = "git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19#e887d6964985f267a1085d480756f20d9eaceb19" +dependencies = [ + "arbitrary", + "bitvec", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "ff", "group", "rand_core 0.6.4", @@ -4366,8 +4392,9 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ + "arbitrary", "borsh", "chacha20", "chacha20poly1305", @@ -4379,14 +4406,15 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "aes", + "arbitrary", "bip0039", "bitvec", "blake2b_simd", "blake2s_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "borsh", "byteorder", "ff", @@ -4394,7 +4422,7 @@ dependencies = [ "group", "hex", "incrementalmerkletree", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_note_encryption", "memuse", @@ -4411,16 +4439,16 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "bellman", "blake2b_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "directories", "getrandom 0.2.15", "group", "itertools 0.11.0", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_primitives", "minreq", @@ -4871,6 +4899,7 @@ version = "0.0.0" dependencies = [ "lazy_static", "libfuzzer-sys", + "masp_primitives", "namada_node", "namada_tx", ] @@ -5165,7 +5194,7 @@ dependencies = [ "futures", "init-once", "itertools 0.12.1", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "kdam", "lazy_static", "linkme", @@ -6729,7 +6758,7 @@ dependencies = [ "frost-rerandomized", "group", "hex", - "jubjub", + "jubjub 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "pasta_curves", "rand_core 0.6.4", "serde", diff --git a/Cargo.toml b/Cargo.toml index 11393a0ccc..112e37e17d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,7 +123,8 @@ index-set = { git = "https://github.com/heliaxdev/index-set", tag = "v0.8.1", fe indexmap = { git = "https://github.com/heliaxdev/indexmap", tag = "2.2.4-heliax-1", features = ["borsh-schema", "serde"] } init-once = "0.6.0" itertools = "0.12.1" -jubjub = "0.10" +# branch "tomas/arbitrary" +jubjub = { git = "https://github.com/heliaxdev/jubjub.git", rev = "e887d6964985f267a1085d480756f20d9eaceb19" } k256 = { version = "0.13.0", default-features = false, features = ["ecdsa", "pkcs8", "precomputed-tables", "serde", "std"]} kdam = "0.5.2" konst = { version = "0.3.8", default-features = false } @@ -136,9 +137,9 @@ ledger-transport-hid = "0.10.0" libc = "0.2.97" libloading = "0.7.2" linkme = "0.3.24" -# branch = "main" -masp_primitives = { git = "https://github.com/anoma/masp", rev = "8d83b172698098fba393006016072bc201ed9ab7" } -masp_proofs = { git = "https://github.com/anoma/masp", rev = "8d83b172698098fba393006016072bc201ed9ab7", default-features = false, features = ["local-prover"] } +# branch = "tomas/arbitrary" +masp_primitives = { git = "https://github.com/anoma/masp", rev = "9c5e3ad500066668fb253dcaac56f56c68c7bbc6" } +masp_proofs = { git = "https://github.com/anoma/masp", rev = "9c5e3ad500066668fb253dcaac56f56c68c7bbc6", default-features = false, features = ["local-prover"] } num256 = "0.3.5" num_cpus = "1.13.0" num-derive = "0.4" diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 3946fcea74..624c28cd60 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -821,7 +821,7 @@ impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { let result = (|| { Ok( match (u64::from(::arbitrary(u)?) - * 5u64) + * 6u64) >> 32 { 0u64 => Section::Data(arbitrary::Arbitrary::arbitrary(u)?), @@ -832,11 +832,13 @@ impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { 3u64 => Section::Authorization( arbitrary::Arbitrary::arbitrary(u)?, ), - // 4u64 => Section::MaspTx(arbitrary::Arbitrary::arbitrary(u)?), + 4u64 => { + Section::MaspTx(arbitrary::Arbitrary::arbitrary(u)?) + } // 5u64 => { // Section::MaspBuilder(arbitrary::Arbitrary::arbitrary(u)?) // } - 4u64 => { + 5u64 => { Section::Header(arbitrary::Arbitrary::arbitrary(u)?) } _ => panic!("internal error: entered unreachable code",), @@ -868,7 +870,7 @@ impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { Ok( match (u64::from(::arbitrary( &mut u, - )?) * 5u64) + )?) * 6u64) >> 32 { 0u64 => Section::Data( @@ -883,17 +885,15 @@ impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { 3u64 => Section::Authorization( arbitrary::Arbitrary::arbitrary_take_rest(u)?, ), - // 4u64 => { - // Section::MaspTx( - // arbitrary::Arbitrary::arbitrary_take_rest(u)?, - // ) - // } + 4u64 => Section::MaspTx( + arbitrary::Arbitrary::arbitrary_take_rest(u)?, + ), // 5u64 => { // Section::MaspBuilder( // arbitrary::Arbitrary::arbitrary_take_rest(u)?, // ) // } - 4u64 => Section::Header( + 5u64 => Section::Header( arbitrary::Arbitrary::arbitrary_take_rest(u)?, ), _ => panic!("internal error: entered unreachable code",), diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 7305115186..1539112ded 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -10,6 +10,7 @@ cargo-fuzz = true [dependencies] namada_node = { path = "../crates/node", features = ["testing"] } namada_tx = { path = "../crates/tx", features = ["arbitrary"] } +masp_primitives = { workspace = true, features = ["arbitrary"] } lazy_static.workspace = true libfuzzer-sys = "0.4" diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index d1afa43ba1..172d4b85c3 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -517,6 +517,16 @@ name = "bls12_381" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838#d3ebe9dd6488fac1923db120a7498079e55dd838" dependencies = [ "ff", "group", @@ -3197,7 +3207,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8499f7a74008aafbecb2a2e608a3e13e4dd3e84df198b604451efe93f2de6e61" dependencies = [ "bitvec", - "bls12_381", + "bls12_381 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ff", + "group", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "jubjub" +version = "0.10.0" +source = "git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19#e887d6964985f267a1085d480756f20d9eaceb19" +dependencies = [ + "bitvec", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "ff", "group", "rand_core 0.6.4", @@ -3333,7 +3356,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "borsh", "chacha20", @@ -3346,14 +3369,14 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "aes", "bip0039", "bitvec", "blake2b_simd", "blake2s_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "borsh", "byteorder", "ff", @@ -3361,7 +3384,7 @@ dependencies = [ "group", "hex", "incrementalmerkletree", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_note_encryption", "memuse", @@ -3378,16 +3401,16 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "bellman", "blake2b_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "directories", "getrandom 0.2.15", "group", "itertools 0.11.0", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_primitives", "minreq", @@ -3781,7 +3804,7 @@ dependencies = [ "futures", "init-once", "itertools 0.12.1", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "kdam", "lazy_static", "masp_primitives", @@ -5014,7 +5037,7 @@ dependencies = [ "byteorder", "group", "hex", - "jubjub", + "jubjub 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "pasta_curves", "rand_core 0.6.4", "serde", diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index 5194c4dc82..3281a9f6c4 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -517,6 +517,16 @@ name = "bls12_381" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838#d3ebe9dd6488fac1923db120a7498079e55dd838" dependencies = [ "ff", "group", @@ -3197,7 +3207,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8499f7a74008aafbecb2a2e608a3e13e4dd3e84df198b604451efe93f2de6e61" dependencies = [ "bitvec", - "bls12_381", + "bls12_381 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ff", + "group", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "jubjub" +version = "0.10.0" +source = "git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19#e887d6964985f267a1085d480756f20d9eaceb19" +dependencies = [ + "bitvec", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "ff", "group", "rand_core 0.6.4", @@ -3333,7 +3356,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "borsh", "chacha20", @@ -3346,14 +3369,14 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "aes", "bip0039", "bitvec", "blake2b_simd", "blake2s_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "borsh", "byteorder", "ff", @@ -3361,7 +3384,7 @@ dependencies = [ "group", "hex", "incrementalmerkletree", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_note_encryption", "memuse", @@ -3378,16 +3401,16 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" +source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" dependencies = [ "bellman", "blake2b_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "directories", "getrandom 0.2.15", "group", "itertools 0.11.0", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_primitives", "minreq", @@ -3781,7 +3804,7 @@ dependencies = [ "futures", "init-once", "itertools 0.12.1", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "kdam", "lazy_static", "masp_primitives", @@ -5014,7 +5037,7 @@ dependencies = [ "byteorder", "group", "hex", - "jubjub", + "jubjub 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "pasta_curves", "rand_core 0.6.4", "serde", From 2f1818e2aea0c61c9a28042555c54911672afec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 12 Jul 2024 12:25:11 +0100 Subject: [PATCH 13/30] tx: add non-panicking serialization method --- crates/tx/src/types.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 624c28cd60..2b8788e2da 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -14,7 +14,7 @@ use namada_core::account::AccountPublicKeysMap; use namada_core::address::Address; use namada_core::borsh::schema::{add_definition, Declaration, Definition}; use namada_core::borsh::{ - BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, + self, BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, }; use namada_core::chain::ChainId; use namada_core::collections::{HashMap, HashSet}; @@ -1486,6 +1486,20 @@ impl Tx { bytes } + /// Convert this transaction into protobufs bytes + pub fn try_to_bytes(&self) -> std::io::Result> { + use prost::Message; + + let mut bytes = vec![]; + let tx: proto::Tx = proto::Tx { + data: borsh::to_vec(self)?, + }; + tx.encode(&mut bytes).map_err(|e| { + std::io::Error::new(std::io::ErrorKind::InvalidData, e) + })?; + Ok(bytes) + } + /// Verify that the section with the given hash has been signed by the given /// public key pub fn verify_signatures( From 6eae64ce8b6629f232168dc99bad9fcb87cef752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 12 Jul 2024 12:25:35 +0100 Subject: [PATCH 14/30] fuzz_txs_mempool: use non-panicking tx serialization method --- fuzz/fuzz_targets/fuzz_txs_mempool.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/fuzz_txs_mempool.rs index 309c7d575d..86b0e337a5 100644 --- a/fuzz/fuzz_targets/fuzz_txs_mempool.rs +++ b/fuzz/fuzz_targets/fuzz_txs_mempool.rs @@ -15,5 +15,10 @@ lazy_static! { } fuzz_target!(|tx: Tx| { - SHELL.mempool_validate(&tx.to_bytes(), MempoolTxType::NewTransaction); + // Sometimes the generated `Tx` cannot be serialized (due to e.g. broken + // invariants in the `Section::MaspTx`) so we have to use the non-panicking + // serialization + if let Ok(tx_bytes) = tx.try_to_bytes() { + SHELL.mempool_validate(&tx_bytes, MempoolTxType::NewTransaction); + } }); From 0bbfef3a42abe571876ba88fee19a595bcb19d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 12 Jul 2024 12:53:51 +0100 Subject: [PATCH 15/30] fuzz_txs_mempool: catch panics in serialization --- fuzz/fuzz_targets/fuzz_txs_mempool.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/fuzz_txs_mempool.rs index 86b0e337a5..6798e1af83 100644 --- a/fuzz/fuzz_targets/fuzz_txs_mempool.rs +++ b/fuzz/fuzz_targets/fuzz_txs_mempool.rs @@ -16,9 +16,8 @@ lazy_static! { fuzz_target!(|tx: Tx| { // Sometimes the generated `Tx` cannot be serialized (due to e.g. broken - // invariants in the `Section::MaspTx`) so we have to use the non-panicking - // serialization - if let Ok(tx_bytes) = tx.try_to_bytes() { + // invariants in the `Section::MaspTx`) and it may also panic + if let Ok(Ok(tx_bytes)) = std::panic::catch_unwind(|| tx.try_to_bytes()) { SHELL.mempool_validate(&tx_bytes, MempoolTxType::NewTransaction); } }); From 2aa37ae39c3a3efc991620e2b86fd1913cafc3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 12 Jul 2024 14:42:06 +0100 Subject: [PATCH 16/30] use updated jubjub that prevents invalid arb ExtendedPoint --- Cargo.lock | 12 ++++++------ Cargo.toml | 6 +++--- fuzz/fuzz_targets/fuzz_txs_mempool.rs | 6 ++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 350a052e18..2f90e8976a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4046,7 +4046,7 @@ dependencies = [ [[package]] name = "jubjub" version = "0.10.0" -source = "git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19#e887d6964985f267a1085d480756f20d9eaceb19" +source = "git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c#a373686962f4e9d0edb3b4716f86ff6bbd9aa86c" dependencies = [ "arbitrary", "bitvec", @@ -4392,7 +4392,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "arbitrary", "borsh", @@ -4406,7 +4406,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "aes", "arbitrary", @@ -4422,7 +4422,7 @@ dependencies = [ "group", "hex", "incrementalmerkletree", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "lazy_static", "masp_note_encryption", "memuse", @@ -4439,7 +4439,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "bellman", "blake2b_simd", @@ -4448,7 +4448,7 @@ dependencies = [ "getrandom 0.2.15", "group", "itertools 0.11.0", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "lazy_static", "masp_primitives", "minreq", diff --git a/Cargo.toml b/Cargo.toml index 112e37e17d..646138be2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,7 +124,7 @@ indexmap = { git = "https://github.com/heliaxdev/indexmap", tag = "2.2.4-heliax- init-once = "0.6.0" itertools = "0.12.1" # branch "tomas/arbitrary" -jubjub = { git = "https://github.com/heliaxdev/jubjub.git", rev = "e887d6964985f267a1085d480756f20d9eaceb19" } +jubjub = { git = "https://github.com/heliaxdev/jubjub.git", rev = "a373686962f4e9d0edb3b4716f86ff6bbd9aa86c" } k256 = { version = "0.13.0", default-features = false, features = ["ecdsa", "pkcs8", "precomputed-tables", "serde", "std"]} kdam = "0.5.2" konst = { version = "0.3.8", default-features = false } @@ -138,8 +138,8 @@ libc = "0.2.97" libloading = "0.7.2" linkme = "0.3.24" # branch = "tomas/arbitrary" -masp_primitives = { git = "https://github.com/anoma/masp", rev = "9c5e3ad500066668fb253dcaac56f56c68c7bbc6" } -masp_proofs = { git = "https://github.com/anoma/masp", rev = "9c5e3ad500066668fb253dcaac56f56c68c7bbc6", default-features = false, features = ["local-prover"] } +masp_primitives = { git = "https://github.com/anoma/masp", rev = "12ed8b060b295c06502a2ff8468e4a941cb7cca4" } +masp_proofs = { git = "https://github.com/anoma/masp", rev = "12ed8b060b295c06502a2ff8468e4a941cb7cca4", default-features = false, features = ["local-prover"] } num256 = "0.3.5" num_cpus = "1.13.0" num-derive = "0.4" diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/fuzz_txs_mempool.rs index 6798e1af83..81b3e99a92 100644 --- a/fuzz/fuzz_targets/fuzz_txs_mempool.rs +++ b/fuzz/fuzz_targets/fuzz_txs_mempool.rs @@ -5,7 +5,7 @@ use libfuzzer_sys::fuzz_target; use namada_node::shell; use namada_node::shell::test_utils::TestShell; use namada_node::shell::MempoolTxType; -use namada_tx::Tx; +use namada_tx::{Section, Tx}; lazy_static! { static ref SHELL: TestShell = { @@ -15,9 +15,7 @@ lazy_static! { } fuzz_target!(|tx: Tx| { - // Sometimes the generated `Tx` cannot be serialized (due to e.g. broken - // invariants in the `Section::MaspTx`) and it may also panic - if let Ok(Ok(tx_bytes)) = std::panic::catch_unwind(|| tx.try_to_bytes()) { + if let Ok(tx_bytes) = tx.try_to_bytes() { SHELL.mempool_validate(&tx_bytes, MempoolTxType::NewTransaction); } }); From 671be7d2cbf81ae1be9805c46d6e2f3c1102c0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 16 Jul 2024 09:14:42 +0100 Subject: [PATCH 17/30] impl Arbitrary for MaspBuilder to derive tx sections --- crates/core/src/masp.rs | 3 + crates/core/src/storage.rs | 1 + crates/core/src/token.rs | 1 + crates/tx/src/types.rs | 214 +++++++++++-------------------------- 4 files changed, 69 insertions(+), 150 deletions(-) diff --git a/crates/core/src/masp.rs b/crates/core/src/masp.rs index b814532091..7ad4053d11 100644 --- a/crates/core/src/masp.rs +++ b/crates/core/src/masp.rs @@ -50,6 +50,7 @@ where } /// Wrapper for masp_primitive's TxId +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Serialize, Deserialize, @@ -84,6 +85,7 @@ pub type TxId = MaspTxId; /// Wrapper type around `Epoch` for type safe operations involving the masp /// epoch +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( BorshSerialize, BorshDeserialize, @@ -149,6 +151,7 @@ impl MaspEpoch { } /// The plain representation of a MASP aaset +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( BorshSerialize, BorshDeserialize, diff --git a/crates/core/src/storage.rs b/crates/core/src/storage.rs index 6ca5cd4e66..364931d03f 100644 --- a/crates/core/src/storage.rs +++ b/crates/core/src/storage.rs @@ -1163,6 +1163,7 @@ impl KeySeg for common::PublicKey { } /// Epoch identifier. Epochs are identified by consecutive numbers. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, diff --git a/crates/core/src/token.rs b/crates/core/src/token.rs index 8347c5871b..ba78b58d8b 100644 --- a/crates/core/src/token.rs +++ b/crates/core/src/token.rs @@ -878,6 +878,7 @@ impl From for Amount { /// The four possible u64 words in a [`Uint`]. /// Used for converting to MASP amounts. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Copy, Clone, diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 2b8788e2da..2f5d21c58a 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -761,9 +761,71 @@ impl MaspBuilder { } } +#[cfg(feature = "arbitrary")] +impl arbitrary::Arbitrary<'_> for MaspBuilder { + fn arbitrary( + u: &mut arbitrary::Unstructured<'_>, + ) -> arbitrary::Result { + use masp_primitives::transaction::builder::MapBuilder; + use masp_primitives::transaction::components::sapling::builder::MapBuilder as SapMapBuilder; + use masp_primitives::zip32::ExtendedSpendingKey; + struct WalletMap; + + impl + SapMapBuilder + for WalletMap + { + fn map_params(&self, _s: P1) {} + + fn map_key( + &self, + s: ExtendedSpendingKey, + ) -> ExtendedFullViewingKey { + (&s).into() + } + } + impl + MapBuilder< + P1, + ExtendedSpendingKey, + N1, + (), + ExtendedFullViewingKey, + (), + > for WalletMap + { + fn map_notifier(&self, _s: N1) {} + } + + let target_height: masp_primitives::consensus::BlockHeight = + arbitrary::Arbitrary::arbitrary(u)?; + Ok(MaspBuilder { + target: arbitrary::Arbitrary::arbitrary(u)?, + asset_types: arbitrary::Arbitrary::arbitrary(u)?, + metadata: arbitrary::Arbitrary::arbitrary(u)?, + builder: Builder::new( + masp_primitives::consensus::TestNetwork, + target_height, + ) + .map_builder(WalletMap), + }) + } + + fn size_hint(depth: usize) -> (usize, Option) { + arbitrary::size_hint::and_all( + &[ + ::size_hint(depth), + ::size_hint(depth), + as arbitrary::Arbitrary>::size_hint(depth), + ::size_hint(depth), + ], + ) + } +} + /// A section of a transaction. Carries an independent piece of information /// necessary for the processing of a transaction. -// #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Debug, @@ -797,154 +859,6 @@ pub enum Section { Header(Header), } -#[cfg(feature = "arbitrary")] -std::thread_local! { - #[allow(non_upper_case_globals)] - static RECURSIVE_COUNT_Section: ::core::cell::Cell = ::core::cell::Cell::new(0); -} - -#[cfg(feature = "arbitrary")] -impl<'arbitrary> arbitrary::Arbitrary<'arbitrary> for Section { - fn arbitrary( - u: &mut arbitrary::Unstructured<'arbitrary>, - ) -> arbitrary::Result { - let guard_against_recursion = u.is_empty(); - if guard_against_recursion { - RECURSIVE_COUNT_Section.with(|count| { - if count.get() > 0 { - return Err(arbitrary::Error::NotEnoughData); - } - count.set(count.get() + 1); - Ok(()) - })?; - } - let result = (|| { - Ok( - match (u64::from(::arbitrary(u)?) - * 6u64) - >> 32 - { - 0u64 => Section::Data(arbitrary::Arbitrary::arbitrary(u)?), - 1u64 => { - Section::ExtraData(arbitrary::Arbitrary::arbitrary(u)?) - } - 2u64 => Section::Code(arbitrary::Arbitrary::arbitrary(u)?), - 3u64 => Section::Authorization( - arbitrary::Arbitrary::arbitrary(u)?, - ), - 4u64 => { - Section::MaspTx(arbitrary::Arbitrary::arbitrary(u)?) - } - // 5u64 => { - // Section::MaspBuilder(arbitrary::Arbitrary::arbitrary(u)?) - // } - 5u64 => { - Section::Header(arbitrary::Arbitrary::arbitrary(u)?) - } - _ => panic!("internal error: entered unreachable code",), - }, - ) - })(); - if guard_against_recursion { - RECURSIVE_COUNT_Section.with(|count| { - count.set(count.get() - 1); - }); - } - result - } - - fn arbitrary_take_rest( - mut u: arbitrary::Unstructured<'arbitrary>, - ) -> arbitrary::Result { - let guard_against_recursion = u.is_empty(); - if guard_against_recursion { - RECURSIVE_COUNT_Section.with(|count| { - if count.get() > 0 { - return Err(arbitrary::Error::NotEnoughData); - } - count.set(count.get() + 1); - Ok(()) - })?; - } - let result = (|| { - Ok( - match (u64::from(::arbitrary( - &mut u, - )?) * 6u64) - >> 32 - { - 0u64 => Section::Data( - arbitrary::Arbitrary::arbitrary_take_rest(u)?, - ), - 1u64 => Section::ExtraData( - arbitrary::Arbitrary::arbitrary_take_rest(u)?, - ), - 2u64 => Section::Code( - arbitrary::Arbitrary::arbitrary_take_rest(u)?, - ), - 3u64 => Section::Authorization( - arbitrary::Arbitrary::arbitrary_take_rest(u)?, - ), - 4u64 => Section::MaspTx( - arbitrary::Arbitrary::arbitrary_take_rest(u)?, - ), - // 5u64 => { - // Section::MaspBuilder( - // arbitrary::Arbitrary::arbitrary_take_rest(u)?, - // ) - // } - 5u64 => Section::Header( - arbitrary::Arbitrary::arbitrary_take_rest(u)?, - ), - _ => panic!("internal error: entered unreachable code",), - }, - ) - })(); - if guard_against_recursion { - RECURSIVE_COUNT_Section.with(|count| { - count.set(count.get() - 1); - }); - } - result - } - - #[inline] - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and( - ::size_hint(depth), - arbitrary::size_hint::recursion_guard(depth, |depth| { - arbitrary::size_hint::or_all(&[ - arbitrary::size_hint::and_all(&[ - ::size_hint(depth), - ]), - arbitrary::size_hint::and_all(&[ - ::size_hint(depth), - ]), - arbitrary::size_hint::and_all(&[ - ::size_hint(depth), - ]), - arbitrary::size_hint::and_all(&[ - ::size_hint( - depth, - ), - ]), - // arbitrary::size_hint::and_all( - // &[::size_hint(depth)], - // ), - // arbitrary::size_hint::and_all( - // &[::size_hint(depth)], - // ), - arbitrary::size_hint::and_all(&[ -
::size_hint(depth), - ]), - ]) - }), - ) - } -} - impl Section { /// Hash this section. Section hashes are useful for signatures and also for /// allowing transaction sections to cross reference. @@ -2059,8 +1973,8 @@ mod test { use std::collections::BTreeMap; use std::fs; - use borsh::schema::BorshSchema; use data_encoding::HEXLOWER; + use namada_core::borsh::schema::BorshSchema; use super::*; From b8fc3ae6a2bfe1eeeb68edcc247d4080fc5aa947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 16 Jul 2024 09:15:07 +0100 Subject: [PATCH 18/30] fuzz_txs_mempool: rm unused import --- fuzz/fuzz_targets/fuzz_txs_mempool.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/fuzz_txs_mempool.rs index 81b3e99a92..ef82aa47a3 100644 --- a/fuzz/fuzz_targets/fuzz_txs_mempool.rs +++ b/fuzz/fuzz_targets/fuzz_txs_mempool.rs @@ -5,7 +5,7 @@ use libfuzzer_sys::fuzz_target; use namada_node::shell; use namada_node::shell::test_utils::TestShell; use namada_node::shell::MempoolTxType; -use namada_tx::{Section, Tx}; +use namada_tx::Tx; lazy_static! { static ref SHELL: TestShell = { From 9de44c48aad0c467e8e67a9c5609bd32faa819b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 16 Jul 2024 09:52:17 +0100 Subject: [PATCH 19/30] tx: prevent overflow in arbitrary masp builder --- crates/tx/src/types.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 2f5d21c58a..0a12f51eab 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -797,8 +797,9 @@ impl arbitrary::Arbitrary<'_> for MaspBuilder { fn map_notifier(&self, _s: N1) {} } - let target_height: masp_primitives::consensus::BlockHeight = - arbitrary::Arbitrary::arbitrary(u)?; + let target_height = masp_primitives::consensus::BlockHeight::from( + u.int_in_range(0_u32..=100_000_000)?, + ); Ok(MaspBuilder { target: arbitrary::Arbitrary::arbitrary(u)?, asset_types: arbitrary::Arbitrary::arbitrary(u)?, From 72ec0d5934520cbf78c6b586ff4b132b6086ca09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 16 Jul 2024 10:05:01 +0100 Subject: [PATCH 20/30] fix clippy --- Cargo.lock | 2 +- Makefile | 4 ++-- crates/node/src/shell/mod.rs | 20 +++++++++----------- wasm/Cargo.lock | 14 +++++++------- wasm_for_tests/Cargo.lock | 14 +++++++------- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f90e8976a..060a91ce78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5194,7 +5194,7 @@ dependencies = [ "futures", "init-once", "itertools 0.12.1", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "kdam", "lazy_static", "linkme", diff --git a/Makefile b/Makefile index 3fbc68ac4a..24cf101dab 100644 --- a/Makefile +++ b/Makefile @@ -117,8 +117,8 @@ clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --a # Need a separate command for benchmarks to prevent the "testing" feature flag from being activated clippy: - $(cargo) +$(nightly) clippy $(jobs) --all-targets --workspace --exclude namada_benchmarks -- -D warnings && \ - $(cargo) +$(nightly) clippy $(jobs) --all-targets --package namada_benchmarks -- -D warnings && \ + $(cargo) +$(nightly) clippy $(jobs) --all-targets --workspace --exclude namada_benchmarks -- -D warnings --check-cfg 'cfg(fuzzing)' && \ + $(cargo) +$(nightly) clippy $(jobs) --all-targets --package namada_benchmarks -- -D warnings --check-cfg 'cfg(fuzzing)' && \ make -C $(wasms) clippy && \ make -C $(wasms_for_tests) clippy diff --git a/crates/node/src/shell/mod.rs b/crates/node/src/shell/mod.rs index e91efd95bf..648d05bb8a 100644 --- a/crates/node/src/shell/mod.rs +++ b/crates/node/src/shell/mod.rs @@ -1503,12 +1503,12 @@ pub mod test_utils { /// Generate a random public/private keypair #[inline] - pub(super) fn gen_keypair() -> common::SecretKey { + pub fn gen_keypair() -> common::SecretKey { gen_ed25519_keypair() } /// Generate a random ed25519 public/private keypair - pub(super) fn gen_ed25519_keypair() -> common::SecretKey { + pub fn gen_ed25519_keypair() -> common::SecretKey { use rand::prelude::ThreadRng; use rand::thread_rng; @@ -1517,7 +1517,7 @@ pub mod test_utils { } /// Generate a random secp256k1 public/private keypair - pub(super) fn gen_secp256k1_keypair() -> common::SecretKey { + pub fn gen_secp256k1_keypair() -> common::SecretKey { use rand::prelude::ThreadRng; use rand::thread_rng; @@ -1528,9 +1528,7 @@ pub mod test_utils { } /// Invalidate a valid signature `sig`. - pub(super) fn invalidate_signature( - sig: common::Signature, - ) -> common::Signature { + pub fn invalidate_signature(sig: common::Signature) -> common::Signature { match sig { common::Signature::Ed25519(ed25519::Signature(ref sig)) => { let mut sig_bytes = sig.to_bytes(); @@ -1816,7 +1814,7 @@ pub mod test_utils { /// Start a new test shell and initialize it. Returns the shell paired with /// a broadcast receiver, which will receives any protocol txs sent by the /// shell. - pub(super) fn setup_with_cfg>( + pub fn setup_with_cfg>( SetupCfg { last_height, num_validators, @@ -1877,7 +1875,7 @@ pub mod test_utils { /// Same as [`setup_at_height`], but returns a shell at the given block /// height, with a single validator. #[inline] - pub(super) fn setup_at_height>( + pub fn setup_at_height>( last_height: H, ) -> ( TestShell, @@ -1936,7 +1934,7 @@ pub mod test_utils { } /// Set the Ethereum bridge to be inactive - pub(super) fn deactivate_bridge(shell: &mut TestShell) { + pub fn deactivate_bridge(shell: &mut TestShell) { use eth_bridge::storage::active_key; use eth_bridge::storage::eth_bridge_queries::EthBridgeStatus; shell @@ -1945,7 +1943,7 @@ pub mod test_utils { .expect("Test failed"); } - pub(super) fn get_pkh_from_address( + pub fn get_pkh_from_address( storage: &S, params: &PosParams, address: Address, @@ -1963,7 +1961,7 @@ pub mod test_utils { TryFrom::try_from(decoded).unwrap() } - pub(super) fn next_block_for_inflation( + pub fn next_block_for_inflation( shell: &mut TestShell, proposer_address: Vec, votes: Vec, diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 172d4b85c3..1e94c7b2fc 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "jubjub" version = "0.10.0" -source = "git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19#e887d6964985f267a1085d480756f20d9eaceb19" +source = "git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c#a373686962f4e9d0edb3b4716f86ff6bbd9aa86c" dependencies = [ "bitvec", "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "borsh", "chacha20", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "aes", "bip0039", @@ -3384,7 +3384,7 @@ dependencies = [ "group", "hex", "incrementalmerkletree", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "lazy_static", "masp_note_encryption", "memuse", @@ -3401,7 +3401,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "bellman", "blake2b_simd", @@ -3410,7 +3410,7 @@ dependencies = [ "getrandom 0.2.15", "group", "itertools 0.11.0", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "lazy_static", "masp_primitives", "minreq", @@ -3804,7 +3804,7 @@ dependencies = [ "futures", "init-once", "itertools 0.12.1", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "kdam", "lazy_static", "masp_primitives", diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index 3281a9f6c4..171f1f9f5a 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "jubjub" version = "0.10.0" -source = "git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19#e887d6964985f267a1085d480756f20d9eaceb19" +source = "git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c#a373686962f4e9d0edb3b4716f86ff6bbd9aa86c" dependencies = [ "bitvec", "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "borsh", "chacha20", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "aes", "bip0039", @@ -3384,7 +3384,7 @@ dependencies = [ "group", "hex", "incrementalmerkletree", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "lazy_static", "masp_note_encryption", "memuse", @@ -3401,7 +3401,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=9c5e3ad500066668fb253dcaac56f56c68c7bbc6#9c5e3ad500066668fb253dcaac56f56c68c7bbc6" +source = "git+https://github.com/anoma/masp?rev=12ed8b060b295c06502a2ff8468e4a941cb7cca4#12ed8b060b295c06502a2ff8468e4a941cb7cca4" dependencies = [ "bellman", "blake2b_simd", @@ -3410,7 +3410,7 @@ dependencies = [ "getrandom 0.2.15", "group", "itertools 0.11.0", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "lazy_static", "masp_primitives", "minreq", @@ -3804,7 +3804,7 @@ dependencies = [ "futures", "init-once", "itertools 0.12.1", - "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=a373686962f4e9d0edb3b4716f86ff6bbd9aa86c)", "kdam", "lazy_static", "masp_primitives", From dd25917fb9e362ec905a90bea99a7d63f29acb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 16 Jul 2024 10:08:44 +0100 Subject: [PATCH 21/30] fuzz: use a shorter target name --- Makefile | 2 +- fuzz/Cargo.toml | 2 -- fuzz/fuzz_targets/{fuzz_txs_mempool.rs => txs_mempool.rs} | 0 3 files changed, 1 insertion(+), 3 deletions(-) rename fuzz/fuzz_targets/{fuzz_txs_mempool.rs => txs_mempool.rs} (100%) diff --git a/Makefile b/Makefile index 24cf101dab..6e98678071 100644 --- a/Makefile +++ b/Makefile @@ -276,7 +276,7 @@ bench: # NOTE: running in `--dev` as release build takes over 64GB memory, but # dev is still configured for opt-level=3 fuzz-txs-mempool: - $(cargo) +$(nightly) fuzz run fuzz_txs_mempool --dev + $(cargo) +$(nightly) fuzz run txs_mempool --dev build-doc: $(cargo) doc --no-deps diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 1539112ded..a213a5b547 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -16,8 +16,6 @@ lazy_static.workspace = true libfuzzer-sys = "0.4" [[bin]] -name = "fuzz_txs_mempool" -path = "fuzz_targets/fuzz_txs_mempool.rs" test = false doc = false bench = false diff --git a/fuzz/fuzz_targets/fuzz_txs_mempool.rs b/fuzz/fuzz_targets/txs_mempool.rs similarity index 100% rename from fuzz/fuzz_targets/fuzz_txs_mempool.rs rename to fuzz/fuzz_targets/txs_mempool.rs From 8748322623425d5c24548e036c147809adce79e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 16 Jul 2024 11:53:11 +0100 Subject: [PATCH 22/30] fuzz: add txs_prepare_proposal --- Makefile | 3 +++ fuzz/Cargo.toml | 9 +++++++ fuzz/fuzz_targets/txs_prepare_proposal.rs | 33 +++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 fuzz/fuzz_targets/txs_prepare_proposal.rs diff --git a/Makefile b/Makefile index 6e98678071..70974c4fd7 100644 --- a/Makefile +++ b/Makefile @@ -278,6 +278,9 @@ bench: fuzz-txs-mempool: $(cargo) +$(nightly) fuzz run txs_mempool --dev +fuzz-txs-prepare-proposal: + $(cargo) +$(nightly) fuzz run txs_prepare_proposal --dev + build-doc: $(cargo) doc --no-deps diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index a213a5b547..d398f01384 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -16,6 +16,15 @@ lazy_static.workspace = true libfuzzer-sys = "0.4" [[bin]] +name = "txs_mempool" +path = "fuzz_targets/txs_mempool.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "txs_prepare_proposal" +path = "fuzz_targets/txs_prepare_proposal.rs" test = false doc = false bench = false diff --git a/fuzz/fuzz_targets/txs_prepare_proposal.rs b/fuzz/fuzz_targets/txs_prepare_proposal.rs new file mode 100644 index 0000000000..444eb2e6b7 --- /dev/null +++ b/fuzz/fuzz_targets/txs_prepare_proposal.rs @@ -0,0 +1,33 @@ +#![no_main] + +use lazy_static::lazy_static; +use libfuzzer_sys::fuzz_target; +use namada_node::facade::tendermint_proto::v0_37::abci::RequestPrepareProposal; +use namada_node::shell; +use namada_node::shell::test_utils::TestShell; +use namada_node::shims::abcipp_shim_types::shim::TxBytes; +use namada_tx::Tx; + +lazy_static! { + static ref SHELL: TestShell = { + let (shell, _recv, _, _) = shell::test_utils::setup(); + shell + }; +} + +fuzz_target!(|txs: Vec| { + let mut txs_bytes: Vec = Vec::with_capacity(txs.len()); + for tx in txs { + if let Ok(tx_bytes) = tx.try_to_bytes() { + txs_bytes.push(tx_bytes.into()); + } else { + return; + } + } + + let req = RequestPrepareProposal { + txs: txs_bytes, + ..Default::default() + }; + SHELL.prepare_proposal(req); +}); From 4b5971cd714df3eeb8cec1c91f6284dd0af21523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 17 Jul 2024 13:59:17 +0100 Subject: [PATCH 23/30] prepare_proposal: make tx fee checks pass for fuzzing --- crates/node/src/protocol.rs | 9 +++++++++ crates/node/src/shell/prepare_proposal.rs | 3 +++ 2 files changed, 12 insertions(+) diff --git a/crates/node/src/protocol.rs b/crates/node/src/protocol.rs index 46a3e69307..88acdc7ea4 100644 --- a/crates/node/src/protocol.rs +++ b/crates/node/src/protocol.rs @@ -558,6 +558,7 @@ where ) .map_err(Error::StorageError)?; + #[cfg(not(fuzzing))] let balance = token::read_balance( shell_params.state, &wrapper.fee.token, @@ -565,6 +566,11 @@ where ) .map_err(Error::StorageError)?; + // Use half of the max value to make the balance check pass + // sometimes with arbitrary fees + #[cfg(fuzzing)] + let balance = Amount::max().checked_div_u64(2).unwrap(); + let (post_bal, valid_batched_tx_result) = if let Some(post_bal) = balance.checked_sub(fees) { @@ -583,12 +589,15 @@ where if let Ok(Some(valid_batched_tx_result)) = try_masp_fee_payment(shell_params, tx, tx_index) { + #[cfg(not(fuzzing))] let balance = token::read_balance( shell_params.state, &wrapper.fee.token, &wrapper.fee_payer(), ) .expect("Could not read balance key from storage"); + #[cfg(fuzzing)] + let balance = Amount::max().checked_div_u64(2).unwrap(); let post_bal = match balance.checked_sub(fees) { Some(post_bal) => { diff --git a/crates/node/src/shell/prepare_proposal.rs b/crates/node/src/shell/prepare_proposal.rs index ac0812a74d..4474e6222d 100644 --- a/crates/node/src/shell/prepare_proposal.rs +++ b/crates/node/src/shell/prepare_proposal.rs @@ -366,6 +366,7 @@ where D: DB + for<'iter> DBIter<'iter> + Sync + 'static, H: StorageHasher + Sync + 'static, { + #[cfg(not(fuzzing))] let consensus_min_gas_price = namada_sdk::parameters::read_gas_cost(temp_state, fee_token) .expect("Must be able to read gas cost parameter") @@ -375,6 +376,8 @@ where payment", ))) })?; + #[cfg(fuzzing)] + let consensus_min_gas_price = Amount::from_u64(10); let Some(config) = proposer_local_config else { return Ok(consensus_min_gas_price); From 62d63cc81d9095d403b036df31432d6c975bc4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 18 Jul 2024 11:08:44 +0100 Subject: [PATCH 24/30] token: avoid trying to read denom when fuzzing --- crates/trans_token/src/storage.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/trans_token/src/storage.rs b/crates/trans_token/src/storage.rs index 574799d38c..b4f6d67893 100644 --- a/crates/trans_token/src/storage.rs +++ b/crates/trans_token/src/storage.rs @@ -405,12 +405,21 @@ pub fn denom_to_amount( token: &Address, storage: &impl StorageRead, ) -> storage::Result { - let denom = read_denom(storage, token)?.ok_or_else(|| { - storage::Error::SimpleMessage( - "No denomination found in storage for the given token", - ) - })?; - denom_amount.scale(denom).map_err(storage::Error::new) + #[cfg(not(fuzzing))] + { + let denom = read_denom(storage, token)?.ok_or_else(|| { + storage::Error::SimpleMessage( + "No denomination found in storage for the given token", + ) + })?; + denom_amount.scale(denom).map_err(storage::Error::new) + } + + #[cfg(fuzzing)] + { + let _ = (token, storage); + Ok(denom_amount.amount()) + } } #[cfg(test)] From 5e9a8be2298e2e05fdc61b67105b1ffcee00c0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 18 Jul 2024 11:09:12 +0100 Subject: [PATCH 25/30] fuzz: add README.md --- fuzz/README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 fuzz/README.md diff --git a/fuzz/README.md b/fuzz/README.md new file mode 100644 index 0000000000..ac1c09e18e --- /dev/null +++ b/fuzz/README.md @@ -0,0 +1,46 @@ +# Fuzz testing + +- Uses [cargo-fuzz](https://rust-fuzz.github.io/book/cargo-fuzz.html) which depends on LLVM libFuzzer +- When ran, a target generates arbitrary input setup for the test. This can be structured data with derived or manually implemented [`trait Arbitrary`](https://crates.io/crates/arbitrary) +- To ensure that the fuzzer explored all interesting branches fuzz testing is used together with code coverage reports + +## How to run + +- Install + - `cargo install cargo-fuzz` - the runner + - `cargo install rustfilt` - symbol demangler which makes coverage reports easier to read +- Run e.g. `make fuzz-txs-mempool` (uses nightly) +- If there is any crash, the fuzzer has found an issue. Read the stack trace for details. It will also print instructions on how to re-run the same case. +- When there are no panics you'll see it printing statistics. E.g. `cov: 26771 ft: 111572 corp: 2688/1423Kb lim: 2369 exec/s: 39 rss: 647Mb L: 2232/2335 MS: 5` +- The important stat you'll want to look watch is the very first one - `cov` - "Total number of code blocks or edges covered by executing the current corpus." (more details at ) +- After the number in `cov` seems to have settled and is no longer increasing, the fuzzer has most likely explored all possible branches. We're going to check that next with coverage. +- To generate raw coverage data, run e.g. `cargo +$(cat rust-nightly-version) fuzz coverage txs_mempool --dev`. This will create `fuzz/coverage/txs_mempool/coverage.profdata` (the path gets printed at the end). +- To turn the raw coverage data into a report: + - Find the system root for the nightly toolchain with `rustc +$(cat rust-nightly-version) --print sysroot` + - Use `llvm-cov` installed with this toolchain in `lib/rustlib/x86_64-unknown-linux-gnu/bin/` sub-dir of the sysroot + - The path to `llvm-cov` has to be the one provided by nightly toolchain. Using an unmatched version (e.g. a system-wide installation) will likely make it fail with: "Failed to load coverage: unsupported instrumentation profile format version" + - Provide the path to the built target, e.g. `target/x86_64-unknown-linux-gnu/coverage/x86_64-unknown-linux-gnu/debug/txs_mempool` + - `--ignore-filename-regex` is used to avoid getting coverage for dependencies + - The full command is e.g.: + + ```bash + /home/ubuntu/.rustup/toolchains/nightly-2024-05-15-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov \ + show \ + target/x86_64-unknown-linux-gnu/coverage/x86_64-unknown-linux-gnu/debug/txs_mempool \ + --format=html \ + --ignore-filename-regex="(/rustc|\.cargo)" \ + -Xdemangler=rustfilt \ + -instr-profile=fuzz/coverage/txs_mempool/coverage.profdata \ + > index.html + ``` + + - Open the `index.html` in the browser. It's usually quite large and can take a while to fully load be searchable (you can also extend `--ignore-filename-regex` with paths that you're not interested in to trim it down). Red code means that the fuzzer didn't reach the colored lines. Otherwise, the second column from the left indicates a number of times a given line has been covered. + - If some code that should be fuzzed isn't covered, you may need to add conditional compilation. Refer to [Side notes](#side-notes) below. + +## Side notes + +- `#[cfg(fuzzing)]` may be used to turn off certain code paths - for example: + - to make a tx signature verification always pass as an arbitrary tx is never going to have a valid signature + - to make a tx fee check pass even when the source doesn't have sufficient balance + - to make a tx fee check pass with an invalid token address +- In release build, fuzzer compilation of the `namada_node` crate requires crazy amount of memory (ran out on 64GB machine). To get around it, we're only using debug build (corresponds `--dev` flag for `cargo fuzz`), but this build is still configured with `opt-level=3` so there should be no perceivable slowdown. From 54571e0744ffc0a32f61aa11fde1c6fb8678470d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 18 Jul 2024 11:25:25 +0100 Subject: [PATCH 26/30] fuzz: add txs_process_proposal --- Makefile | 3 +++ crates/node/src/shell/prepare_proposal.rs | 5 +++- fuzz/Cargo.toml | 7 ++++++ fuzz/fuzz_targets/txs_process_proposal.rs | 30 +++++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 fuzz/fuzz_targets/txs_process_proposal.rs diff --git a/Makefile b/Makefile index 70974c4fd7..4f00cb37d3 100644 --- a/Makefile +++ b/Makefile @@ -281,6 +281,9 @@ fuzz-txs-mempool: fuzz-txs-prepare-proposal: $(cargo) +$(nightly) fuzz run txs_prepare_proposal --dev +fuzz-txs-process-proposal: + $(cargo) +$(nightly) fuzz run txs_process_proposal --dev + build-doc: $(cargo) doc --no-deps diff --git a/crates/node/src/shell/prepare_proposal.rs b/crates/node/src/shell/prepare_proposal.rs index 4474e6222d..27529cfe07 100644 --- a/crates/node/src/shell/prepare_proposal.rs +++ b/crates/node/src/shell/prepare_proposal.rs @@ -377,7 +377,10 @@ where ))) })?; #[cfg(fuzzing)] - let consensus_min_gas_price = Amount::from_u64(10); + let consensus_min_gas_price = { + let _ = temp_state; + Amount::from_u64(10) + }; let Some(config) = proposer_local_config else { return Ok(consensus_min_gas_price); diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index d398f01384..d2991b4253 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -28,3 +28,10 @@ path = "fuzz_targets/txs_prepare_proposal.rs" test = false doc = false bench = false + +[[bin]] +name = "txs_process_proposal" +path = "fuzz_targets/txs_process_proposal.rs" +test = false +doc = false +bench = false diff --git a/fuzz/fuzz_targets/txs_process_proposal.rs b/fuzz/fuzz_targets/txs_process_proposal.rs new file mode 100644 index 0000000000..f355d15efa --- /dev/null +++ b/fuzz/fuzz_targets/txs_process_proposal.rs @@ -0,0 +1,30 @@ +#![no_main] + +use lazy_static::lazy_static; +use libfuzzer_sys::fuzz_target; +use namada_node::shell; +use namada_node::shell::test_utils::{ProcessProposal, TestShell}; +use namada_tx::Tx; + +lazy_static! { + static ref SHELL: TestShell = { + let (shell, _recv, _, _) = shell::test_utils::setup(); + shell + }; +} + +fuzz_target!(|txs: Vec| { + let mut txs_bytes: Vec> = Vec::with_capacity(txs.len()); + for tx in txs { + if let Ok(tx_bytes) = tx.try_to_bytes() { + txs_bytes.push(tx_bytes); + } else { + return; + } + } + + let req = ProcessProposal { txs: txs_bytes }; + // An err means that the proposal was rejected, which is fine. We're only + // looking for crashes here + let _res = SHELL.process_proposal(req); +}); From 422e2affae747d4b05f5fa483a16255a0e162433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 23 Jul 2024 20:41:21 +0100 Subject: [PATCH 27/30] add conditional fuzzing sig acceptance at lower level --- crates/core/src/key/ed25519.rs | 13 ++++++++++-- crates/core/src/key/secp256k1.rs | 27 ++++++++++++++++--------- crates/node/src/shell/mod.rs | 3 --- crates/tx/src/types.rs | 34 ++++++++++++++++++++++++++------ 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/crates/core/src/key/ed25519.rs b/crates/core/src/key/ed25519.rs index 31efebe94f..df53775cd8 100644 --- a/crates/core/src/key/ed25519.rs +++ b/crates/core/src/key/ed25519.rs @@ -390,8 +390,17 @@ impl super::SigScheme for SigScheme { where H: 'static + StorageHasher, { - pk.0.verify(&sig.0, &data.signable_hash::()) - .map_err(|err| VerifySigError::SigVerifyError(err.to_string())) + #[cfg(not(fuzzing))] + { + pk.0.verify(&sig.0, &data.signable_hash::()) + .map_err(|err| VerifySigError::SigVerifyError(err.to_string())) + } + + #[cfg(fuzzing)] + { + let _ = (pk, data, sig); + Ok(()) + } } } diff --git a/crates/core/src/key/secp256k1.rs b/crates/core/src/key/secp256k1.rs index 619d7ec08f..5e3747da22 100644 --- a/crates/core/src/key/secp256k1.rs +++ b/crates/core/src/key/secp256k1.rs @@ -586,16 +586,25 @@ impl super::SigScheme for SigScheme { where H: 'static + StorageHasher, { - use k256::ecdsa::signature::hazmat::PrehashVerifier; + #[cfg(not(fuzzing))] + { + use k256::ecdsa::signature::hazmat::PrehashVerifier; + + let vrf_key = k256::ecdsa::VerifyingKey::from(&pk.0); + let msg = data.signable_hash::(); + vrf_key.verify_prehash(&msg, &sig.0).map_err(|e| { + VerifySigError::SigVerifyError(format!( + "Error verifying secp256k1 signature: {}", + e + )) + }) + } - let vrf_key = k256::ecdsa::VerifyingKey::from(&pk.0); - let msg = data.signable_hash::(); - vrf_key.verify_prehash(&msg, &sig.0).map_err(|e| { - VerifySigError::SigVerifyError(format!( - "Error verifying secp256k1 signature: {}", - e - )) - }) + #[cfg(fuzzing)] + { + let _ = (pk, data, sig); + Ok(()) + } } } diff --git a/crates/node/src/shell/mod.rs b/crates/node/src/shell/mod.rs index 648d05bb8a..2be5e16004 100644 --- a/crates/node/src/shell/mod.rs +++ b/crates/node/src/shell/mod.rs @@ -1032,7 +1032,6 @@ where } // Tx signature check - #[cfg(not(fuzzing))] let tx_type = match tx.validate_tx() { Ok(_) => tx.header(), Err(msg) => { @@ -1041,8 +1040,6 @@ where return response; } }; - #[cfg(fuzzing)] - let tx_type = tx.header(); // try to parse a vote extension protocol tx from // the provided tx data diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 0a12f51eab..0de78b0811 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -568,9 +568,15 @@ impl Authorization { Signer::PubKeys(pks) => { let hash = self.get_raw_hash(); for (idx, pk) in pks.iter().enumerate() { - if let Some(map_idx) = - public_keys_index_map.get_index_from_public_key(pk) - { + let map_idx = + public_keys_index_map.get_index_from_public_key(pk); + + // Use the first signature when fuzzing as the map is + // unlikely to contain matching PKs + #[cfg(fuzzing)] + let map_idx = map_idx.or(Some(0_u8)); + + if let Some(map_idx) = map_idx { let sig_idx = u8::try_from(idx) .map_err(|_| VerifySigError::PksOverflow)?; consume_verify_sig_gas()?; @@ -589,6 +595,14 @@ impl Authorization { } } } + + // There's usually not enough signatures when fuzzing, this makes it + // more likely to pass authorization. + #[cfg(fuzzing)] + { + verifications = 1; + } + Ok(verifications) } } @@ -1438,13 +1452,21 @@ impl Tx { // Check that the hashes being checked are a subset of those in // this section. Also ensure that all the sections the signature // signs over are present. - if hashes.iter().all(|x| { + let matching_hashes = hashes.iter().all(|x| { signatures.targets.contains(x) || section.get_hash() == *x }) && signatures .targets .iter() - .all(|x| self.get_section(x).is_some()) - { + .all(|x| self.get_section(x).is_some()); + + // Don't require matching hashes when fuzzing as it's unlikely + // to be true + #[cfg(fuzzing)] + let _ = matching_hashes; + #[cfg(fuzzing)] + let matching_hashes = true; + + if matching_hashes { // Finally verify that the signature itself is valid let amt_verifieds = signatures .verify_signature( From b18507afda0bf0d2b2f2d271a8e7b5e35cec133b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 24 Jul 2024 13:39:45 +0100 Subject: [PATCH 28/30] fuzz: add txs_finalize_block target --- Cargo.lock | 3 ++ Makefile | 3 ++ fuzz/Cargo.toml | 11 ++++ fuzz/fuzz_targets/txs_finalize_block.rs | 70 +++++++++++++++++++++++++ wasm/Makefile | 2 +- wasm_for_tests/Makefile | 2 +- 6 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 fuzz/fuzz_targets/txs_finalize_block.rs diff --git a/Cargo.lock b/Cargo.lock index 060a91ce78..7ab4f65fe1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4897,9 +4897,12 @@ dependencies = [ name = "namada_fuzz" version = "0.0.0" dependencies = [ + "data-encoding", "lazy_static", "libfuzzer-sys", "masp_primitives", + "namada_apps_lib", + "namada_core", "namada_node", "namada_tx", ] diff --git a/Makefile b/Makefile index 4f00cb37d3..64c0a9caaf 100644 --- a/Makefile +++ b/Makefile @@ -284,6 +284,9 @@ fuzz-txs-prepare-proposal: fuzz-txs-process-proposal: $(cargo) +$(nightly) fuzz run txs_process_proposal --dev +fuzz-txs-finalize-block: + $(cargo) +$(nightly) fuzz run txs_finalize_block --dev + build-doc: $(cargo) doc --no-deps diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index d2991b4253..5718758a65 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -8,8 +8,12 @@ edition = "2021" cargo-fuzz = true [dependencies] +namada_apps_lib = { path = "../crates/apps_lib", features = ["testing"] } +namada_core = { path = "../crates/core", features = ["testing"] } namada_node = { path = "../crates/node", features = ["testing"] } namada_tx = { path = "../crates/tx", features = ["arbitrary"] } + +data-encoding = { workspace = true } masp_primitives = { workspace = true, features = ["arbitrary"] } lazy_static.workspace = true @@ -35,3 +39,10 @@ path = "fuzz_targets/txs_process_proposal.rs" test = false doc = false bench = false + +[[bin]] +name = "txs_finalize_block" +path = "fuzz_targets/txs_finalize_block.rs" +test = false +doc = false +bench = false diff --git a/fuzz/fuzz_targets/txs_finalize_block.rs b/fuzz/fuzz_targets/txs_finalize_block.rs new file mode 100644 index 0000000000..d60277fa7c --- /dev/null +++ b/fuzz/fuzz_targets/txs_finalize_block.rs @@ -0,0 +1,70 @@ +#![no_main] +#![allow(clippy::disallowed_methods)] + +use data_encoding::HEXUPPER; +use libfuzzer_sys::fuzz_target; +use namada_apps_lib::wallet; +use namada_core::address::Address; +use namada_core::key::PublicKeyTmRawHash; +use namada_core::time::DateTimeUtc; +use namada_node::shell; +use namada_node::shell::test_utils::TestShell; +use namada_node::shims::abcipp_shim_types::shim::request::{ + FinalizeBlock, ProcessedTx, +}; +use namada_node::shims::abcipp_shim_types::shim::TxBytes; +use namada_tx::data::TxType; +use namada_tx::Tx; + +static mut SHELL: Option = None; + +fuzz_target!(|txs: Vec| { + let mut txs_bytes: Vec = Vec::with_capacity(txs.len()); + for tx in txs { + // Skip raw transactions, they should never be included by an honest + // prepare_proposal + if let TxType::Raw = tx.header().tx_type { + continue; + } + // Only use transactions that can be encoded + if let Ok(tx_bytes) = tx.try_to_bytes() { + txs_bytes.push(tx_bytes.into()); + } + } + + let shell = unsafe { + match SHELL.as_mut() { + Some(shell) => shell, + None => { + let (shell, _recv, _, _) = shell::test_utils::setup(); + SHELL = Some(shell); + SHELL.as_mut().unwrap() + } + } + }; + + let proposer_pk = wallet::defaults::validator_keypair().to_public(); + let proposer_address = Address::from(&proposer_pk); + let block_time = DateTimeUtc::now(); + let processing_results = + shell.process_txs(&txs_bytes, block_time, &proposer_address); + let mut txs = Vec::with_capacity(txs_bytes.len()); + for (result, tx) in + processing_results.into_iter().zip(txs_bytes.into_iter()) + { + txs.push(ProcessedTx { tx, result }); + } + + let proposer_address_bytes = HEXUPPER + .decode(proposer_pk.tm_raw_hash().as_bytes()) + .unwrap(); + let req = FinalizeBlock { + txs, + proposer_address: proposer_address_bytes, + ..Default::default() + }; + let _events = shell.finalize_block(req).unwrap(); + + // Commit the block + shell.commit(); +}); diff --git a/wasm/Makefile b/wasm/Makefile index 6c38626701..d4c5b0a52f 100644 --- a/wasm/Makefile +++ b/wasm/Makefile @@ -16,7 +16,7 @@ check: $(cargo) +$(nightly) check --workspace --target wasm32-unknown-unknown clippy: - $(cargo) +$(nightly) clippy --all-targets --workspace -- -D warnings + $(cargo) +$(nightly) clippy --all-targets --workspace -- -D warnings --check-cfg 'cfg(fuzzing)' clippy-fix: $(cargo) +$(nightly) clippy --fix -Z unstable-options --workspace --allow-dirty --allow-staged diff --git a/wasm_for_tests/Makefile b/wasm_for_tests/Makefile index 67a95dbbc1..71b418cc19 100644 --- a/wasm_for_tests/Makefile +++ b/wasm_for_tests/Makefile @@ -39,7 +39,7 @@ check: $(cargo) +$(nightly) check --workspace --target wasm32-unknown-unknown clippy: - $(cargo) +$(nightly) clippy --all-targets --workspace -- -D warnings + $(cargo) +$(nightly) clippy --all-targets --workspace -- -D warnings --check-cfg 'cfg(fuzzing)' clippy-fix: $(cargo) +$(nightly) clippy --fix -Z unstable-options --workspace --allow-dirty --allow-staged From 19793eacb23e970d8fc940650dace7443660162d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 30 Jul 2024 12:29:26 +0100 Subject: [PATCH 29/30] fuzz: add txs_wasm_run --- Cargo.lock | 77 +++--- Cargo.toml | 6 +- Makefile | 11 +- crates/account/Cargo.toml | 2 + crates/account/src/types.rs | 2 + crates/core/Cargo.toml | 8 +- crates/core/src/dec.rs | 1 + crates/core/src/eth_bridge_pool.rs | 4 + crates/core/src/ibc.rs | 1 + crates/core/src/uint.rs | 1 + crates/governance/Cargo.toml | 2 + crates/governance/src/storage/proposal.rs | 7 + crates/governance/src/storage/vote.rs | 3 +- crates/ibc/Cargo.toml | 2 + crates/ibc/src/msg.rs | 2 + crates/sdk/Cargo.toml | 9 + crates/token/Cargo.toml | 2 + crates/token/src/lib.rs | 2 + crates/tx/src/data/pgf.rs | 1 + crates/tx/src/data/pos.rs | 8 + fuzz/Cargo.toml | 13 +- fuzz/fuzz_targets/txs_wasm_run.rs | 307 ++++++++++++++++++++++ wasm/Cargo.lock | 60 ++--- wasm_for_tests/Cargo.lock | 60 ++--- 24 files changed, 490 insertions(+), 101 deletions(-) create mode 100644 fuzz/fuzz_targets/txs_wasm_run.rs diff --git a/Cargo.lock b/Cargo.lock index 7ab4f65fe1..087aeb1a0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3235,7 +3235,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-apps", "ibc-clients", @@ -3248,7 +3248,7 @@ dependencies = [ [[package]] name = "ibc-app-nft-transfer" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-nft-transfer-types", "ibc-core", @@ -3258,8 +3258,9 @@ dependencies = [ [[package]] name = "ibc-app-nft-transfer-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "base64 0.22.1", "borsh", "derive_more", @@ -3279,7 +3280,7 @@ dependencies = [ [[package]] name = "ibc-app-transfer" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-transfer-types", "ibc-core", @@ -3289,8 +3290,9 @@ dependencies = [ [[package]] name = "ibc-app-transfer-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3307,7 +3309,7 @@ dependencies = [ [[package]] name = "ibc-apps" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-nft-transfer", "ibc-app-transfer", @@ -3316,7 +3318,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "ibc-client-tendermint-types", @@ -3333,7 +3335,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "displaydoc", "ibc-core-client-types", @@ -3350,7 +3352,7 @@ dependencies = [ [[package]] name = "ibc-client-wasm-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "base64 0.22.1", "displaydoc", @@ -3364,7 +3366,7 @@ dependencies = [ [[package]] name = "ibc-clients" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-client-tendermint", "ibc-client-wasm-types", @@ -3373,7 +3375,7 @@ dependencies = [ [[package]] name = "ibc-core" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -3389,7 +3391,7 @@ dependencies = [ [[package]] name = "ibc-core-channel" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel-types", "ibc-core-client", @@ -3404,8 +3406,9 @@ dependencies = [ [[package]] name = "ibc-core-channel-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3427,7 +3430,7 @@ dependencies = [ [[package]] name = "ibc-core-client" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-client-context", "ibc-core-client-types", @@ -3440,7 +3443,7 @@ dependencies = [ [[package]] name = "ibc-core-client-context" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -3456,8 +3459,9 @@ dependencies = [ [[package]] name = "ibc-core-client-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3476,8 +3480,9 @@ dependencies = [ [[package]] name = "ibc-core-commitment-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3495,7 +3500,7 @@ dependencies = [ [[package]] name = "ibc-core-connection" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-client-wasm-types", "ibc-core-client", @@ -3509,8 +3514,9 @@ dependencies = [ [[package]] name = "ibc-core-connection-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3530,7 +3536,7 @@ dependencies = [ [[package]] name = "ibc-core-handler" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -3545,8 +3551,9 @@ dependencies = [ [[package]] name = "ibc-core-handler-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3569,7 +3576,7 @@ dependencies = [ [[package]] name = "ibc-core-host" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -3587,7 +3594,7 @@ dependencies = [ [[package]] name = "ibc-core-host-cosmos" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -3610,8 +3617,9 @@ dependencies = [ [[package]] name = "ibc-core-host-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3625,7 +3633,7 @@ dependencies = [ [[package]] name = "ibc-core-router" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -3639,7 +3647,7 @@ dependencies = [ [[package]] name = "ibc-core-router-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -3658,7 +3666,7 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.7.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "proc-macro2", "quote", @@ -3668,8 +3676,9 @@ dependencies = [ [[package]] name = "ibc-primitives" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ + "arbitrary", "borsh", "derive_more", "displaydoc", @@ -3708,7 +3717,7 @@ dependencies = [ [[package]] name = "ibc-query" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "displaydoc", "ibc", @@ -3719,7 +3728,7 @@ dependencies = [ [[package]] name = "ibc-testkit" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "basecoin-store", "derive_more", @@ -4615,6 +4624,7 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" name = "namada_account" version = "0.42.0" dependencies = [ + "arbitrary", "borsh", "linkme", "namada_core", @@ -4897,6 +4907,7 @@ dependencies = [ name = "namada_fuzz" version = "0.0.0" dependencies = [ + "arbitrary", "data-encoding", "lazy_static", "libfuzzer-sys", @@ -4904,7 +4915,9 @@ dependencies = [ "namada_apps_lib", "namada_core", "namada_node", + "namada_sdk", "namada_tx", + "prost 0.12.3", ] [[package]] @@ -4927,6 +4940,7 @@ dependencies = [ name = "namada_governance" version = "0.42.0" dependencies = [ + "arbitrary", "assert_matches", "borsh", "itertools 0.12.1", @@ -4958,6 +4972,7 @@ dependencies = [ name = "namada_ibc" version = "0.42.0" dependencies = [ + "arbitrary", "assert_matches", "borsh", "data-encoding", @@ -5177,6 +5192,7 @@ dependencies = [ name = "namada_sdk" version = "0.42.0" dependencies = [ + "arbitrary", "assert_matches", "async-trait", "base58", @@ -5409,6 +5425,7 @@ dependencies = [ name = "namada_token" version = "0.42.0" dependencies = [ + "arbitrary", "borsh", "namada_core", "namada_events", diff --git a/Cargo.toml b/Cargo.toml index 646138be2e..a89709686e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,9 +115,9 @@ flume = "0.11.0" fs_extra = "1.2.0" futures = "0.3" git2 = { version = "0.18.1", default-features = false } -ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b", features = ["serde"] } -ibc-derive = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" } -ibc-testkit = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b", default-features = false } +ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "0c3b3c0ab598e1e627089d06941efe0e39b61cd7", features = ["serde"] } +ibc-derive = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "0c3b3c0ab598e1e627089d06941efe0e39b61cd7" } +ibc-testkit = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "0c3b3c0ab598e1e627089d06941efe0e39b61cd7", default-features = false } ics23 = "0.11.0" index-set = { git = "https://github.com/heliaxdev/index-set", tag = "v0.8.1", features = ["serialize-borsh", "serialize-serde"] } indexmap = { git = "https://github.com/heliaxdev/indexmap", tag = "2.2.4-heliax-1", features = ["borsh-schema", "serde"] } diff --git a/Makefile b/Makefile index 64c0a9caaf..5411368330 100644 --- a/Makefile +++ b/Makefile @@ -276,16 +276,19 @@ bench: # NOTE: running in `--dev` as release build takes over 64GB memory, but # dev is still configured for opt-level=3 fuzz-txs-mempool: - $(cargo) +$(nightly) fuzz run txs_mempool --dev + $(cargo) +$(nightly) fuzz run txs_mempool --dev -- -rss_limit_mb=4096 fuzz-txs-prepare-proposal: - $(cargo) +$(nightly) fuzz run txs_prepare_proposal --dev + $(cargo) +$(nightly) fuzz run txs_prepare_proposal --dev -- -rss_limit_mb=4096 fuzz-txs-process-proposal: - $(cargo) +$(nightly) fuzz run txs_process_proposal --dev + $(cargo) +$(nightly) fuzz run txs_process_proposal --dev -- -rss_limit_mb=4096 fuzz-txs-finalize-block: - $(cargo) +$(nightly) fuzz run txs_finalize_block --dev + $(cargo) +$(nightly) fuzz run txs_finalize_block --dev -- -rss_limit_mb=4096 + +fuzz-txs-wasm-run: + $(cargo) +$(nightly) fuzz run txs_wasm_run --dev -- -rss_limit_mb=4096 --sanitizer=none build-doc: $(cargo) doc --no-deps diff --git a/crates/account/Cargo.toml b/crates/account/Cargo.toml index 3ed213ba62..281f700f15 100644 --- a/crates/account/Cargo.toml +++ b/crates/account/Cargo.toml @@ -15,6 +15,7 @@ version.workspace = true [features] default = [] testing = ["namada_core/testing", "proptest"] +arbitrary = ["dep:arbitrary", "namada_core/arbitrary"] migrations = ["namada_migrations", "linkme"] [dependencies] @@ -23,6 +24,7 @@ namada_macros = { path = "../macros" } namada_migrations = { path = "../migrations", optional = true } namada_storage = { path = "../storage" } +arbitrary = { workspace = true, optional = true } borsh.workspace = true linkme = {workspace = true, optional = true } proptest = { workspace = true, optional = true } diff --git a/crates/account/src/types.rs b/crates/account/src/types.rs index f8b5791d7e..4f27e26551 100644 --- a/crates/account/src/types.rs +++ b/crates/account/src/types.rs @@ -8,6 +8,7 @@ use namada_migrations::*; use serde::{Deserialize, Serialize}; /// A tx data type to initialize a new established account +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -31,6 +32,7 @@ pub struct InitAccount { } /// A tx data type to update an account's validity predicate +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index fa1fb3c665..acecec74ba 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -30,7 +30,13 @@ migrations = [ ] benches = ["proptest"] control_flow = ["futures", "lazy_static", "tokio", "wasmtimer"] -arbitrary = ["dep:arbitrary", "chrono/arbitrary", "indexmap/arbitrary"] +arbitrary = [ + "dep:arbitrary", + "chrono/arbitrary", + "ibc/arbitrary", + "indexmap/arbitrary", + "masp_primitives/arbitrary", +] [dependencies] namada_macros = {path = "../macros"} diff --git a/crates/core/src/dec.rs b/crates/core/src/dec.rs index e05e7ca8c2..35d7b80116 100644 --- a/crates/core/src/dec.rs +++ b/crates/core/src/dec.rs @@ -33,6 +33,7 @@ pub type Result = std::result::Result; /// /// To be precise, an instance X of this type should be /// interpreted as the Dec X * 10 ^ (-[`POS_DECIMAL_PRECISION`]) +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, diff --git a/crates/core/src/eth_bridge_pool.rs b/crates/core/src/eth_bridge_pool.rs index 854aac4df1..d577221e3c 100644 --- a/crates/core/src/eth_bridge_pool.rs +++ b/crates/core/src/eth_bridge_pool.rs @@ -72,6 +72,7 @@ const VERSION: u8 = 1; const NAMESPACE: &str = "transfer"; /// Transfer to Ethereum kinds. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Copy, Clone, @@ -170,6 +171,7 @@ impl<'transfer> PendingTransferAppendix<'transfer> { /// A transfer message to be submitted to Ethereum /// to move assets from Namada across the bridge. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -200,6 +202,7 @@ pub struct TransferToEthereum { /// A transfer message to Ethereum sitting in the /// bridge pool, waiting to be relayed +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -338,6 +341,7 @@ impl From<&PendingTransfer> for Key { /// The amount of fees to be paid, in Namada, to the relayer /// of a transfer across the Ethereum Bridge, compensating /// for Ethereum gas costs. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/core/src/ibc.rs b/crates/core/src/ibc.rs index 8473095275..757d5a512b 100644 --- a/crates/core/src/ibc.rs +++ b/crates/core/src/ibc.rs @@ -76,6 +76,7 @@ impl FromStr for IbcTxDataRefs { } /// The target of a PGF payment +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/core/src/uint.rs b/crates/core/src/uint.rs index 14a361f871..40c07eeafb 100644 --- a/crates/core/src/uint.rs +++ b/crates/core/src/uint.rs @@ -481,6 +481,7 @@ pub const MAX_SIGNED_VALUE: Uint = const MINUS_ZERO: Uint = Uint([0u64, 0u64, 0u64, 9223372036854775808]); /// A signed 256 big integer. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Copy, Clone, diff --git a/crates/governance/Cargo.toml b/crates/governance/Cargo.toml index b3f7d33a18..caba406454 100644 --- a/crates/governance/Cargo.toml +++ b/crates/governance/Cargo.toml @@ -14,6 +14,7 @@ version.workspace = true [features] testing = ["proptest"] +arbitrary = ["dep:arbitrary", "namada_core/arbitrary"] migrations = [ "namada_migrations", "linkme", @@ -30,6 +31,7 @@ namada_systems = { path = "../systems" } namada_tx = { path = "../tx" } namada_vp = { path = "../vp" } +arbitrary = { workspace = true, optional = true } borsh.workspace = true itertools.workspace = true linkme = {workspace = true, optional = true} diff --git a/crates/governance/src/storage/proposal.rs b/crates/governance/src/storage/proposal.rs index c535199750..884a2c52f0 100644 --- a/crates/governance/src/storage/proposal.rs +++ b/crates/governance/src/storage/proposal.rs @@ -29,6 +29,7 @@ pub enum ProposalError { } /// A tx data type to hold proposal data +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -66,6 +67,7 @@ impl InitProposalData { } /// A tx data type to hold vote proposal data +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -189,6 +191,7 @@ impl StoragePgfFunding { } /// The type of a Proposal +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -216,6 +219,7 @@ pub enum ProposalType { } /// An add or remove action for PGF +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -250,6 +254,7 @@ where } /// The target of a PGF payment +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -304,6 +309,7 @@ impl Display for PGFTarget { } /// The target of a PGF payment +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -327,6 +333,7 @@ pub struct PGFInternalTarget { } /// The actions that a PGF Steward can propose to execute +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/governance/src/storage/vote.rs b/crates/governance/src/storage/vote.rs index ef0129011f..449e43af4c 100644 --- a/crates/governance/src/storage/vote.rs +++ b/crates/governance/src/storage/vote.rs @@ -6,6 +6,8 @@ use namada_macros::BorshDeserializer; use namada_migrations::*; use serde::{Deserialize, Serialize}; +/// The vote for a proposal +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -18,7 +20,6 @@ use serde::{Deserialize, Serialize}; Serialize, Deserialize, )] -/// The vote for a proposal pub enum ProposalVote { /// Yes Yay, diff --git a/crates/ibc/Cargo.toml b/crates/ibc/Cargo.toml index 53cd38d568..d424a1bb2e 100644 --- a/crates/ibc/Cargo.toml +++ b/crates/ibc/Cargo.toml @@ -19,6 +19,7 @@ migrations = [ "linkme", ] testing = ["namada_core/testing", "ibc-testkit", "proptest"] +arbitrary = ["dep:arbitrary", "namada_core/arbitrary", "namada_token/arbitrary"] [dependencies] namada_core = { path = "../core" } @@ -32,6 +33,7 @@ namada_systems = { path = "../systems" } namada_tx = { path = "../tx" } namada_vp = { path = "../vp" } +arbitrary = { workspace = true, optional = true } borsh.workspace = true data-encoding.workspace = true konst.workspace = true diff --git a/crates/ibc/src/msg.rs b/crates/ibc/src/msg.rs index 44b23fae74..c784cb8b93 100644 --- a/crates/ibc/src/msg.rs +++ b/crates/ibc/src/msg.rs @@ -29,6 +29,7 @@ pub enum IbcMessage { } /// IBC transfer message with `Transfer` +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone)] pub struct MsgTransfer { /// IBC transfer message @@ -78,6 +79,7 @@ impl BorshSchema for MsgTransfer { } /// IBC NFT transfer message with `Transfer` +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone)] pub struct MsgNftTransfer { /// IBC NFT transfer message diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 1aa16eb32f..f45a646956 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -40,6 +40,14 @@ testing = [ "proptest", "jubjub", ] +arbitrary = [ + "dep:arbitrary", + "namada_account/arbitrary", + "namada_core/arbitrary", + "namada_governance/arbitrary", + "namada_ibc/arbitrary", + "namada_token/arbitrary", +] download-params = ["namada_token/download-params"] migrations = [ @@ -78,6 +86,7 @@ namada_vm = { path = "../vm", default-features = false } namada_vote_ext = { path = "../vote_ext" } namada_vp = { path = "../vp" } +arbitrary = { workspace = true, optional = true } async-trait.workspace = true bimap.workspace = true borsh.workspace = true diff --git a/crates/token/Cargo.toml b/crates/token/Cargo.toml index 10cb33eb77..62bf495b69 100644 --- a/crates/token/Cargo.toml +++ b/crates/token/Cargo.toml @@ -17,6 +17,7 @@ default = [] multicore = ["namada_shielded_token/multicore"] download-params = ["namada_shielded_token/download-params"] testing = ["namada_core/testing", "namada_shielded_token/testing", "proptest"] +arbitrary = ["dep:arbitrary", "namada_core/arbitrary"] [dependencies] namada_core = { path = "../core" } @@ -27,6 +28,7 @@ namada_storage = { path = "../storage" } namada_systems = { path = "../systems" } namada_trans_token = { path = "../trans_token" } +arbitrary = { workspace = true, optional = true } borsh.workspace = true proptest = { workspace = true, optional = true } serde.workspace = true diff --git a/crates/token/src/lib.rs b/crates/token/src/lib.rs index bf408aac1f..6ba04fbe7e 100644 --- a/crates/token/src/lib.rs +++ b/crates/token/src/lib.rs @@ -125,6 +125,7 @@ where } /// Accounts can send or receive funds in a transparent token transfer +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -148,6 +149,7 @@ pub struct Account { } /// Arguments for a multi-party token transfer +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/tx/src/data/pgf.rs b/crates/tx/src/data/pgf.rs index 2da23db625..93828c03eb 100644 --- a/crates/tx/src/data/pgf.rs +++ b/crates/tx/src/data/pgf.rs @@ -16,6 +16,7 @@ pub enum PgfError { } /// A tx data type to hold proposal data +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/crates/tx/src/data/pos.rs b/crates/tx/src/data/pos.rs index 01ce2bbf7d..a2047316c3 100644 --- a/crates/tx/src/data/pos.rs +++ b/crates/tx/src/data/pos.rs @@ -11,6 +11,7 @@ use namada_migrations::*; use serde::{Deserialize, Serialize}; /// A tx data type to become a validator account. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -56,6 +57,7 @@ pub struct BecomeValidator { /// A bond is a validator's self-bond or a delegation from non-validator to a /// validator. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -83,6 +85,7 @@ pub struct Bond { pub type Unbond = Bond; /// A withdrawal of an unbond. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -105,6 +108,7 @@ pub struct Withdraw { } /// A claim of pending rewards. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -127,6 +131,7 @@ pub struct ClaimRewards { } /// A redelegation of bonded tokens from one validator to another. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -152,6 +157,7 @@ pub struct Redelegation { } /// A change to the validator commission rate. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -173,6 +179,7 @@ pub struct CommissionChange { } /// A change to the validator metadata. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -206,6 +213,7 @@ pub struct MetaDataChange { } /// A change to the validator's consensus key. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 5718758a65..09fdcb8845 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -11,13 +11,15 @@ cargo-fuzz = true namada_apps_lib = { path = "../crates/apps_lib", features = ["testing"] } namada_core = { path = "../crates/core", features = ["testing"] } namada_node = { path = "../crates/node", features = ["testing"] } +namada_sdk = { path = "../crates/sdk", features = ["testing", "arbitrary"] } namada_tx = { path = "../crates/tx", features = ["arbitrary"] } +arbitrary = { workspace = true } data-encoding = { workspace = true } -masp_primitives = { workspace = true, features = ["arbitrary"] } - lazy_static.workspace = true libfuzzer-sys = "0.4" +masp_primitives = { workspace = true, features = ["arbitrary"] } +prost = { workspace = true } [[bin]] name = "txs_mempool" @@ -46,3 +48,10 @@ path = "fuzz_targets/txs_finalize_block.rs" test = false doc = false bench = false + +[[bin]] +name = "txs_wasm_run" +path = "fuzz_targets/txs_wasm_run.rs" +test = false +doc = false +bench = false diff --git a/fuzz/fuzz_targets/txs_wasm_run.rs b/fuzz/fuzz_targets/txs_wasm_run.rs new file mode 100644 index 0000000000..4c8f183a51 --- /dev/null +++ b/fuzz/fuzz_targets/txs_wasm_run.rs @@ -0,0 +1,307 @@ +//! Test running well-formed inner WASM txs via finalize block handler. + +#![no_main] + +use std::sync::Mutex; + +use arbitrary::Arbitrary; +use data_encoding::HEXUPPER; +use lazy_static::lazy_static; +use libfuzzer_sys::fuzz_target; +use namada_apps_lib::wallet; +use namada_core::key::PublicKeyTmRawHash; +use namada_node::shell; +use namada_node::shell::test_utils::TestShell; +use namada_node::shims::abcipp_shim_types::shim::request::{ + FinalizeBlock, ProcessedTx, +}; +use namada_node::shims::abcipp_shim_types::shim::response::TxResult; +use namada_node::shims::abcipp_shim_types::shim::TxBytes; +use namada_sdk::address::Address; +use namada_sdk::eth_bridge_pool::PendingTransfer; +use namada_sdk::ibc::apps::nft_transfer::types::msgs::transfer::MsgTransfer as IbcMsgNftTransfer; +use namada_sdk::ibc::apps::transfer::types::msgs::transfer::MsgTransfer as IbcMsgTransfer; +use namada_sdk::ibc::core::handler::types::msgs::MsgEnvelope; +use namada_sdk::key::common; +use namada_sdk::token::{self, DenominatedAmount}; +use namada_sdk::tx::Tx; +use namada_sdk::{account, address, governance, storage, tx}; +use namada_tx::data::{pgf, pos}; + +lazy_static! { + static ref SHELL: Mutex = { + let (shell, _recv, _, _) = shell::test_utils::setup(); + Mutex::new(shell) + }; +} + +#[allow(clippy::large_enum_variant)] +#[derive(Arbitrary, Debug)] +enum TxKind { + InitAccount(account::InitAccount), + BecomeValidator(pos::BecomeValidator), + UnjailValidator(Address), + DeactivateValidator(Address), + ReactivateValidator(Address), + InitProposal(governance::InitProposalData), + VoteProposal(governance::VoteProposalData), + RevealPk(common::PublicKey), + UpdateAccount(account::UpdateAccount), + Transfer(token::Transfer), + Ibc(IbcData), + Bond(pos::Bond), + Unbond(pos::Unbond), + Withdraw(pos::Withdraw), + Redelegate(pos::Redelegation), + ClaimRewards(pos::ClaimRewards), + ChangeCommission(pos::CommissionChange), + ChangeConsensusKey(pos::ConsensusKeyChange), + ChangeMetadata(pos::MetaDataChange), + BridgePool(PendingTransfer), + ResignSteward(Address), + UpdateStewardCommission(pgf::UpdateStewardCommission), +} + +#[derive(Arbitrary, Debug)] +enum IbcData { + MsgEnvelope(MsgEnvelope), + MsgTransfer(IbcMsgTransfer), + MsgNftTransfer(IbcMsgNftTransfer), + BorshMsgTransfer(namada_sdk::ibc::MsgTransfer), + BorshMsgNftTransfer(namada_sdk::ibc::MsgNftTransfer), +} + +fuzz_target!(|kinds: NonEmptyVec| run(kinds)); + +fn run(kinds: NonEmptyVec) { + let kinds = kinds.into_vec(); + let mut shell = SHELL.lock().unwrap(); + + // Construct the txs + let mut txs_bytes: Vec = Vec::with_capacity(kinds.len()); + let signer = wallet::defaults::albert_keypair(); + for kind in kinds { + let mut tx = Tx::from_type(tx::data::TxType::Raw); + + use TxKind::*; + let code_tag = match kind { + InitAccount(data) => { + tx.add_data(data); + tx::TX_INIT_ACCOUNT_WASM + } + BecomeValidator(data) => { + tx.add_data(data); + tx::TX_BECOME_VALIDATOR_WASM + } + UnjailValidator(data) => { + tx.add_data(data); + tx::TX_UNJAIL_VALIDATOR_WASM + } + DeactivateValidator(data) => { + tx.add_data(data); + tx::TX_DEACTIVATE_VALIDATOR_WASM + } + ReactivateValidator(data) => { + tx.add_data(data); + tx::TX_REACTIVATE_VALIDATOR_WASM + } + InitProposal(data) => { + tx.add_data(data); + tx::TX_INIT_PROPOSAL + } + VoteProposal(data) => { + tx.add_data(data); + tx::TX_VOTE_PROPOSAL + } + RevealPk(data) => { + tx.add_data(data); + tx::TX_REVEAL_PK + } + UpdateAccount(data) => { + tx.add_data(data); + tx::TX_UPDATE_ACCOUNT_WASM + } + Transfer(data) => { + tx.add_data(data); + tx::TX_TRANSFER_WASM + } + Ibc(data) => { + add_ibc_tx_data(&mut tx, data); + tx::TX_IBC_WASM + } + Bond(data) => { + tx.add_data(data); + tx::TX_BOND_WASM + } + Unbond(data) => { + tx.add_data(data); + tx::TX_UNBOND_WASM + } + Withdraw(data) => { + tx.add_data(data); + tx::TX_WITHDRAW_WASM + } + Redelegate(data) => { + tx.add_data(data); + tx::TX_REDELEGATE_WASM + } + ClaimRewards(data) => { + tx.add_data(data); + tx::TX_CLAIM_REWARDS_WASM + } + ChangeCommission(data) => { + tx.add_data(data); + tx::TX_CHANGE_COMMISSION_WASM + } + ChangeConsensusKey(data) => { + tx.add_data(data); + tx::TX_CHANGE_CONSENSUS_KEY_WASM + } + ChangeMetadata(data) => { + tx.add_data(data); + tx::TX_CHANGE_METADATA_WASM + } + BridgePool(data) => { + tx.add_data(data); + tx::TX_BRIDGE_POOL_WASM + } + ResignSteward(data) => { + tx.add_data(data); + tx::TX_RESIGN_STEWARD + } + UpdateStewardCommission(data) => { + tx.add_data(data); + tx::TX_UPDATE_STEWARD_COMMISSION + } + }; + let code_hash = shell + .read_storage_key(&storage::Key::wasm_hash(code_tag)) + .unwrap(); + tx.add_code_from_hash(code_hash, Some(code_tag.to_string())); + + tx.update_header(tx::data::TxType::Wrapper(Box::new( + tx::data::WrapperTx::new( + tx::data::Fee { + token: address::testing::nam(), + amount_per_gas_unit: DenominatedAmount::native(1.into()), + }, + signer.to_public(), + 1_000_000.into(), + ), + ))); + tx.add_section(tx::Section::Authorization(tx::Authorization::new( + vec![tx.raw_header_hash()], + [(0, signer.clone())].into_iter().collect(), + None, + ))); + + txs_bytes.push(tx.to_bytes().into()); + } + + // Add a successful result for every tx + let mut txs = Vec::with_capacity(txs_bytes.len()); + for tx in txs_bytes.into_iter() { + let result = TxResult::default(); // default is success + txs.push(ProcessedTx { tx, result }); + } + + // Run the txs via a `FinalizeBlock` request + let proposer_pk = wallet::defaults::validator_keypair().to_public(); + let proposer_address_bytes = HEXUPPER + .decode(proposer_pk.tm_raw_hash().as_bytes()) + .unwrap(); + let req = FinalizeBlock { + txs, + proposer_address: proposer_address_bytes, + ..Default::default() + }; + let _event = shell.finalize_block(req).unwrap(); + + // Commit the block + shell.commit(); +} + +fn add_ibc_tx_data(tx: &mut Tx, data: IbcData) { + use namada_sdk::ibc::primitives::ToProto; + use prost::Message; + match data { + IbcData::MsgEnvelope(data) => { + let proto_data = match data { + MsgEnvelope::Client(data) => { + use namada_sdk::ibc::core::client::types::msgs::ClientMsg; + match data { + ClientMsg::CreateClient(data) => data.to_any(), + ClientMsg::UpdateClient(data) => data.to_any(), + ClientMsg::Misbehaviour(data) => data.to_any(), + ClientMsg::UpgradeClient(data) => data.to_any(), + ClientMsg::RecoverClient(data) => data.to_any(), + } + } + MsgEnvelope::Connection(data) => { + use namada_sdk::ibc::core::connection::types::msgs::ConnectionMsg; + match data { + ConnectionMsg::OpenInit(data) => data.to_any(), + ConnectionMsg::OpenTry(data) => data.to_any(), + ConnectionMsg::OpenAck(data) => data.to_any(), + ConnectionMsg::OpenConfirm(data) => data.to_any(), + } + } + MsgEnvelope::Channel(data) => { + use namada_sdk::ibc::core::channel::types::msgs::ChannelMsg; + match data { + ChannelMsg::OpenInit(data) => data.to_any(), + ChannelMsg::OpenTry(data) => data.to_any(), + ChannelMsg::OpenAck(data) => data.to_any(), + ChannelMsg::OpenConfirm(data) => data.to_any(), + ChannelMsg::CloseInit(data) => data.to_any(), + ChannelMsg::CloseConfirm(data) => data.to_any(), + } + } + MsgEnvelope::Packet(data) => { + use namada_sdk::ibc::core::channel::types::msgs::PacketMsg; + match data { + PacketMsg::Recv(data) => data.to_any(), + PacketMsg::Ack(data) => data.to_any(), + PacketMsg::Timeout(data) => data.to_any(), + PacketMsg::TimeoutOnClose(data) => data.to_any(), + } + } + }; + let mut bytes = vec![]; + proto_data.encode(&mut bytes).unwrap(); + tx.set_data(tx::Data::new(bytes)); + } + IbcData::MsgTransfer(data) => { + let mut bytes = vec![]; + data.to_any().encode(&mut bytes).unwrap(); + tx.set_data(tx::Data::new(bytes)); + } + IbcData::MsgNftTransfer(data) => { + let mut bytes = vec![]; + data.to_any().encode(&mut bytes).unwrap(); + tx.set_data(tx::Data::new(bytes)); + } + IbcData::BorshMsgTransfer(data) => { + tx.add_data(data); + } + IbcData::BorshMsgNftTransfer(data) => { + tx.add_data(data); + } + } +} + +#[derive(Arbitrary, Debug)] +struct NonEmptyVec { + // `vec` may be empty + vec: Vec, + // there's always at least one element + last: T, +} + +impl NonEmptyVec { + fn into_vec(self) -> Vec { + let NonEmptyVec { mut vec, last } = self; + vec.push(last); + vec + } +} diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 1e94c7b2fc..e80ea49ad7 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -2453,7 +2453,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-apps", "ibc-clients", @@ -2466,7 +2466,7 @@ dependencies = [ [[package]] name = "ibc-app-nft-transfer" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-nft-transfer-types", "ibc-core", @@ -2476,7 +2476,7 @@ dependencies = [ [[package]] name = "ibc-app-nft-transfer-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "base64 0.22.1", "borsh", @@ -2497,7 +2497,7 @@ dependencies = [ [[package]] name = "ibc-app-transfer" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-transfer-types", "ibc-core", @@ -2507,7 +2507,7 @@ dependencies = [ [[package]] name = "ibc-app-transfer-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2525,7 +2525,7 @@ dependencies = [ [[package]] name = "ibc-apps" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-nft-transfer", "ibc-app-transfer", @@ -2534,7 +2534,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "ibc-client-tendermint-types", @@ -2551,7 +2551,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "displaydoc", "ibc-core-client-types", @@ -2568,7 +2568,7 @@ dependencies = [ [[package]] name = "ibc-client-wasm-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "base64 0.22.1", "displaydoc", @@ -2582,7 +2582,7 @@ dependencies = [ [[package]] name = "ibc-clients" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-client-tendermint", "ibc-client-wasm-types", @@ -2591,7 +2591,7 @@ dependencies = [ [[package]] name = "ibc-core" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -2607,7 +2607,7 @@ dependencies = [ [[package]] name = "ibc-core-channel" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel-types", "ibc-core-client", @@ -2622,7 +2622,7 @@ dependencies = [ [[package]] name = "ibc-core-channel-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2645,7 +2645,7 @@ dependencies = [ [[package]] name = "ibc-core-client" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-client-context", "ibc-core-client-types", @@ -2658,7 +2658,7 @@ dependencies = [ [[package]] name = "ibc-core-client-context" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2674,7 +2674,7 @@ dependencies = [ [[package]] name = "ibc-core-client-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2694,7 +2694,7 @@ dependencies = [ [[package]] name = "ibc-core-commitment-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2713,7 +2713,7 @@ dependencies = [ [[package]] name = "ibc-core-connection" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-client-wasm-types", "ibc-core-client", @@ -2727,7 +2727,7 @@ dependencies = [ [[package]] name = "ibc-core-connection-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2748,7 +2748,7 @@ dependencies = [ [[package]] name = "ibc-core-handler" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -2763,7 +2763,7 @@ dependencies = [ [[package]] name = "ibc-core-handler-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2787,7 +2787,7 @@ dependencies = [ [[package]] name = "ibc-core-host" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2805,7 +2805,7 @@ dependencies = [ [[package]] name = "ibc-core-host-cosmos" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2828,7 +2828,7 @@ dependencies = [ [[package]] name = "ibc-core-host-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2843,7 +2843,7 @@ dependencies = [ [[package]] name = "ibc-core-router" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2857,7 +2857,7 @@ dependencies = [ [[package]] name = "ibc-core-router-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2876,7 +2876,7 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.7.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "proc-macro2", "quote", @@ -2886,7 +2886,7 @@ dependencies = [ [[package]] name = "ibc-primitives" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2926,7 +2926,7 @@ dependencies = [ [[package]] name = "ibc-query" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "displaydoc", "ibc", @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "ibc-testkit" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "basecoin-store", "derive_more", diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index 171f1f9f5a..d29fc983fe 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -2453,7 +2453,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-apps", "ibc-clients", @@ -2466,7 +2466,7 @@ dependencies = [ [[package]] name = "ibc-app-nft-transfer" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-nft-transfer-types", "ibc-core", @@ -2476,7 +2476,7 @@ dependencies = [ [[package]] name = "ibc-app-nft-transfer-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "base64 0.22.1", "borsh", @@ -2497,7 +2497,7 @@ dependencies = [ [[package]] name = "ibc-app-transfer" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-transfer-types", "ibc-core", @@ -2507,7 +2507,7 @@ dependencies = [ [[package]] name = "ibc-app-transfer-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2525,7 +2525,7 @@ dependencies = [ [[package]] name = "ibc-apps" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-app-nft-transfer", "ibc-app-transfer", @@ -2534,7 +2534,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "ibc-client-tendermint-types", @@ -2551,7 +2551,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "displaydoc", "ibc-core-client-types", @@ -2568,7 +2568,7 @@ dependencies = [ [[package]] name = "ibc-client-wasm-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "base64 0.22.1", "displaydoc", @@ -2582,7 +2582,7 @@ dependencies = [ [[package]] name = "ibc-clients" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-client-tendermint", "ibc-client-wasm-types", @@ -2591,7 +2591,7 @@ dependencies = [ [[package]] name = "ibc-core" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -2607,7 +2607,7 @@ dependencies = [ [[package]] name = "ibc-core-channel" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel-types", "ibc-core-client", @@ -2622,7 +2622,7 @@ dependencies = [ [[package]] name = "ibc-core-channel-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2645,7 +2645,7 @@ dependencies = [ [[package]] name = "ibc-core-client" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-client-context", "ibc-core-client-types", @@ -2658,7 +2658,7 @@ dependencies = [ [[package]] name = "ibc-core-client-context" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2674,7 +2674,7 @@ dependencies = [ [[package]] name = "ibc-core-client-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2694,7 +2694,7 @@ dependencies = [ [[package]] name = "ibc-core-commitment-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2713,7 +2713,7 @@ dependencies = [ [[package]] name = "ibc-core-connection" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-client-wasm-types", "ibc-core-client", @@ -2727,7 +2727,7 @@ dependencies = [ [[package]] name = "ibc-core-connection-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2748,7 +2748,7 @@ dependencies = [ [[package]] name = "ibc-core-handler" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -2763,7 +2763,7 @@ dependencies = [ [[package]] name = "ibc-core-handler-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2787,7 +2787,7 @@ dependencies = [ [[package]] name = "ibc-core-host" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2805,7 +2805,7 @@ dependencies = [ [[package]] name = "ibc-core-host-cosmos" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2828,7 +2828,7 @@ dependencies = [ [[package]] name = "ibc-core-host-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2843,7 +2843,7 @@ dependencies = [ [[package]] name = "ibc-core-router" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "derive_more", "displaydoc", @@ -2857,7 +2857,7 @@ dependencies = [ [[package]] name = "ibc-core-router-types" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2876,7 +2876,7 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.7.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "proc-macro2", "quote", @@ -2886,7 +2886,7 @@ dependencies = [ [[package]] name = "ibc-primitives" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "borsh", "derive_more", @@ -2926,7 +2926,7 @@ dependencies = [ [[package]] name = "ibc-query" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "displaydoc", "ibc", @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "ibc-testkit" version = "0.53.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b#1dd9be8c1cdc773e6b5b0b3609f3390a9a69eb9b" +source = "git+https://github.com/heliaxdev/cosmos-ibc-rs?rev=0c3b3c0ab598e1e627089d06941efe0e39b61cd7#0c3b3c0ab598e1e627089d06941efe0e39b61cd7" dependencies = [ "basecoin-store", "derive_more", From a47bfa7fed19fcb60771e32b18a5b340908c838e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 16 Aug 2024 11:36:02 +0100 Subject: [PATCH 30/30] changelog: add #3445 --- .changelog/unreleased/testing/3445-fuzz-tx.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/testing/3445-fuzz-tx.md diff --git a/.changelog/unreleased/testing/3445-fuzz-tx.md b/.changelog/unreleased/testing/3445-fuzz-tx.md new file mode 100644 index 0000000000..aae35fb42b --- /dev/null +++ b/.changelog/unreleased/testing/3445-fuzz-tx.md @@ -0,0 +1,2 @@ +- Added fuzz testing targets for txs in mempool, block proposals and finalize + block. ([\#3445](https://github.com/anoma/namada/pull/3445)) \ No newline at end of file