diff --git a/.changelog/unreleased/CI/4140-ledger-namada-unit-tests-ci.md b/.changelog/unreleased/CI/4140-ledger-namada-unit-tests-ci.md new file mode 100644 index 0000000000..3bde9b2c7e --- /dev/null +++ b/.changelog/unreleased/CI/4140-ledger-namada-unit-tests-ci.md @@ -0,0 +1,2 @@ +- Add Ledger app unit tests to the Namada CI. + ([\#4140](https://github.com/anoma/namada/pull/4140)) \ No newline at end of file diff --git a/.changelog/unreleased/improvements/4182-tx-result-display.md b/.changelog/unreleased/improvements/4182-tx-result-display.md new file mode 100644 index 0000000000..b96a94c936 --- /dev/null +++ b/.changelog/unreleased/improvements/4182-tx-result-display.md @@ -0,0 +1,4 @@ +- The display of a transaction's result now includes the result code + and avoids displaying the gas unless the transaction was successful. + Improved the display of a dry-run and aligned it with the former. + ([\#4182](https://github.com/anoma/namada/pull/4182)) \ No newline at end of file diff --git a/.changelog/unreleased/miscellaneous/4177-inline-borsh-ext.md b/.changelog/unreleased/miscellaneous/4177-inline-borsh-ext.md new file mode 100644 index 0000000000..0f6c235e39 --- /dev/null +++ b/.changelog/unreleased/miscellaneous/4177-inline-borsh-ext.md @@ -0,0 +1,2 @@ +- Inline borsh-ext crate function in namada_core crate. + ([\#4177](https://github.com/anoma/namada/pull/4177)) \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 264b8342ac..0becb455ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,7 @@ env: AWS_REGION: us-west-2 NIGHTLY: nightly-2024-09-08 NAMADA_MASP_PARAMS_DIR: /masp/.masp-params + LEDGER_APP_VERSION: "1.0.6-ci-patch" jobs: changelog: @@ -651,6 +652,47 @@ jobs: fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} + test-ledger-app: + timeout-minutes: 30 + runs-on: [ubuntu-latest] + + env: + RUSTC_WRAPPER: "" + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + if: ${{ github.event_name != 'pull_request_target' }} + - name: Checkout PR + uses: actions/checkout@v4 + if: ${{ github.event_name == 'pull_request_target' }} + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Checkout ledger-namada + run: | + echo "Using Namada Ledger App version: v${LEDGER_APP_VERSION}" + git clone 'https://github.com/heliaxdev/ledger-namada' ../ledger-namada + cd ../ledger-namada + git checkout "v$LEDGER_APP_VERSION" + git submodule update --init --recursive + sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 + make deps + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Generate test vectors + run: | + # The path where the Ledger app test suite will locate test vectors + TESTVEC_PATH="../ledger-namada/tests/testvectors.json" + TESTDBG_PATH="../ledger-namada/tests/testdebugs.txt" + sudo apt-get install -y protobuf-compiler + cargo run --example generate-txs -- $TESTVEC_PATH $TESTDBG_PATH + - name: Check test vectors + run: | + cd ../ledger-namada + make cpp_test + test-e2e-with-device-automation: runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86] container: diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 968a956f81..83e05aed00 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,7 +14,7 @@ diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to a positive environment for our +Examples of behavior that contribute to a positive environment for our community include: * Demonstrating empathy and kindness toward other people @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an +standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within diff --git a/Cargo.lock b/Cargo.lock index 335b9db8aa..33fba74f2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -732,14 +732,6 @@ dependencies = [ "syn_derive", ] -[[package]] -name = "borsh-ext" -version = "1.2.0" -source = "git+https://github.com/heliaxdev/borsh-ext?tag=v1.2.0#a62fee3e847e512cad9ac0f1fd5a900e5db9ba37" -dependencies = [ - "borsh", -] - [[package]] name = "bs58" version = "0.5.0" @@ -1063,8 +1055,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "clru" -version = "0.5.0" -source = "git+https://github.com/marmeladema/clru-rs.git?rev=71ca566#71ca566915f21f3c308091ca7756a91b0f8b5afc" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" [[package]] name = "cobs" @@ -2221,8 +2214,9 @@ dependencies = [ [[package]] name = "ethbridge-bridge-contract" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccec11776e279f18dcef377c95932ac7e558358477870c972e3b5eba0f1cc661" dependencies = [ "ethbridge-bridge-events", "ethbridge-structs", @@ -2232,8 +2226,9 @@ dependencies = [ [[package]] name = "ethbridge-bridge-events" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f862616190f541d733357e234d65ba73fec0ddacd62e91abb26a0258048a6bb1" dependencies = [ "ethabi", "ethbridge-structs", @@ -2243,8 +2238,9 @@ dependencies = [ [[package]] name = "ethbridge-events" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de4045821e3fadfc5fa239825bc1c1f05fe8c4b149c09dfb2e6aa9d09d6780e" dependencies = [ "ethbridge-bridge-events", "ethers", @@ -2252,8 +2248,9 @@ dependencies = [ [[package]] name = "ethbridge-structs" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7b3e89a2332887bf096cd589ac5781a6664b4fb0881506aa99b2be32e8e086" dependencies = [ "ethabi", "ethers", @@ -3943,15 +3940,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" -[[package]] -name = "index-set" -version = "0.8.0" -source = "git+https://github.com/heliaxdev/index-set?tag=v0.8.1#b0d928f83cf0d465ccda299d131e8df2859b5184" -dependencies = [ - "borsh", - "serde", -] - [[package]] name = "indexmap" version = "1.9.3" @@ -4755,7 +4743,6 @@ dependencies = [ "base64 0.13.1", "bit-set", "borsh", - "borsh-ext", "clap", "color-eyre", "config", @@ -4813,7 +4800,6 @@ name = "namada_benchmarks" version = "0.46.1" dependencies = [ "borsh", - "borsh-ext", "criterion", "lazy_static", "masp_primitives", @@ -4849,7 +4835,6 @@ dependencies = [ "assert_matches", "bech32 0.8.1", "borsh", - "borsh-ext", "chrono", "data-encoding", "ed25519-consensus", @@ -4859,7 +4844,6 @@ dependencies = [ "ibc", "ics23", "impl-num-traits", - "index-set", "indexmap 2.2.4", "k256", "lazy_static", @@ -4892,6 +4876,7 @@ dependencies = [ "toml 0.5.11", "tracing", "uint", + "usize-set", "wasmtimer", "zeroize", ] @@ -5109,7 +5094,6 @@ name = "namada_light_sdk" version = "0.46.1" dependencies = [ "borsh", - "borsh-ext", "namada_sdk", "prost 0.13.2", "serde_json", @@ -5167,7 +5151,6 @@ dependencies = [ "base64 0.13.1", "blake2b-rs", "borsh", - "borsh-ext", "byte-unit", "bytes", "clap", @@ -5292,7 +5275,6 @@ dependencies = [ "async-trait", "bimap", "borsh", - "borsh-ext", "circular-queue", "clap", "data-encoding", @@ -5490,7 +5472,6 @@ dependencies = [ "assert_matches", "base64 0.13.1", "borsh", - "borsh-ext", "color-eyre", "concat-idents", "data-encoding", @@ -5763,7 +5744,6 @@ dependencies = [ "base58", "bimap", "borsh", - "borsh-ext", "data-encoding", "derivation-path", "fd-lock", @@ -7926,16 +7906,18 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "smooth-operator" -version = "0.7.0" -source = "git+https://github.com/heliaxdev/smooth-operator?tag=v0.7.0#0e182707f5e5bb9c6e0efa2d235dc9efd715d0a1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dece39b9b4d19edc6399498b056d1511135b70b5adf7822affdedf5715598" dependencies = [ "smooth-operator-impl", ] [[package]] name = "smooth-operator-impl" -version = "0.7.0" -source = "git+https://github.com/heliaxdev/smooth-operator?tag=v0.7.0#0e182707f5e5bb9c6e0efa2d235dc9efd715d0a1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "867851a695e22b0d1fc85f2f84dba29fef7e5d571f12fb23253e0b213bf190f7" dependencies = [ "proc-macro2", "quote", @@ -8840,7 +8822,8 @@ dependencies = [ [[package]] name = "tower-abci" version = "0.16.0" -source = "git+https://github.com/heliaxdev/tower-abci?rev=30d2a8cdf8321b599ae13ba74f4c78217a64ce58#30d2a8cdf8321b599ae13ba74f4c78217a64ce58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c31da2537c5f13b67d3f6aa9e5552a1a81a681debbcb3ce9ac6a34876cbcb2" dependencies = [ "bytes", "futures", @@ -9158,6 +9141,16 @@ dependencies = [ "serde", ] +[[package]] +name = "usize-set" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12fbfdf92a2a7f550e532818381f9e8367cac2115671edb024120836f33985e9" +dependencies = [ + "borsh", + "serde", +] + [[package]] name = "utf-8" version = "0.7.6" diff --git a/Cargo.toml b/Cargo.toml index 093a98e919..a9b41e08ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,7 @@ circular-queue = "0.2.6" clap = "4.5" clap_complete = "4.5" clap_complete_nushell = "4.5" -clru = {git = "https://github.com/marmeladema/clru-rs.git", rev = "71ca566"} +clru = "0.6.2" color-eyre = "0.6.2" concat-idents = "1.1.2" config = "0.14.1" @@ -104,10 +104,10 @@ ed25519-consensus = "2.1.0" either = "1.12.0" escargot = "0.5.7" ethabi = "18.0.0" -ethbridge-bridge-contract = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.24.0"} -ethbridge-bridge-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.24.0"} -ethbridge-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.24.0"} -ethbridge-structs = { git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.24.0" } +ethbridge-bridge-contract = "0.24.1" +ethbridge-bridge-events = "0.24.1" +ethbridge-events = "0.24.1" +ethbridge-structs = "0.24.1" ethers = "2.0.0" expectrl = "0.7.0" eyre = "0.6.12" @@ -122,7 +122,7 @@ ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f3511 ibc-derive = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd" } ibc-testkit = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd", default-features = false } ics23 = "0.12.0" -index-set = { git = "https://github.com/heliaxdev/index-set", tag = "v0.8.1", features = ["serialize-borsh", "serialize-serde"] } +usize-set = { version = "0.10.3", features = ["serialize-borsh", "serialize-serde"] } 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" @@ -179,7 +179,7 @@ sha2 = "0.9.3" sha2-const = "0.1.2" signal-hook = "0.3.9" slip10_ed25519 = "0.1.3" -smooth-operator = {git = "https://github.com/heliaxdev/smooth-operator", tag = "v0.7.0"} +smooth-operator = "0.7.2" # sysinfo with disabled multithread feature sysinfo = {version = "0.27.8", default-features = false} tar = "0.4.37" @@ -200,8 +200,7 @@ toml = "0.5.8" tonic = "0.8.3" tonic-build = "0.11.0" tower = "0.4" -# branch yuji/tendermint-0.38 -tower-abci = { git = "https://github.com/heliaxdev/tower-abci", rev = "30d2a8cdf8321b599ae13ba74f4c78217a64ce58" } +tower-abci = "0.16.0" tracing = "0.1.30" tracing-appender = "0.2.2" tracing-log = "0.2.0" diff --git a/README.md b/README.md index dc6a700aac..1a7cdf215d 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,16 @@ ## Overview -[Namada](http://namada.net) is a Proof-of-Stake L1 for interchain asset-agnostic privacy. Namada uses CometBFT +[Namada](http://namada.net) is a Proof-of-Stake L1 for multichain asset-agnostic data protection. Namada uses CometBFT consensus and enables multi-asset shielded transfers for any native -or non-native asset. Namada features full IBC protocol support, -a natively integrated Ethereum bridge, a modern proof-of-stake -system with automatic reward compounding and cubic slashing, and a -stake-weighted governance signalling mechanism. Users of shielded -transfers are rewarded for their contributions to the privacy set in +or non-native asset. Namada features full IBC protocol support, a modern proof-of-stake +system with cubic slashing, and a +stake-weighted on-chain governance mechanism. Users of Namada's MASP (Multi-Asset Shielded Pool) are rewarded for their contributions to the shielded set in the form of native protocol tokens. A multi-asset shielded transfer -wallet is provided in order to facilitate safe and private user +wallet is provided in order to facilitate safe user interaction with the protocol. -* Blogpost: [Introducing Namada: Interchain Asset-agnostic Privacy](https://namada.net/blog/introducing-namada-multichain-asset-agnostic-data-protection) +* Blogpost: [Introducing Namada: Multichain Asset-agnostic Data Protection](https://namada.net/blog/introducing-namada-multichain-asset-agnostic-data-protection) ## 📓 Docs diff --git a/crates/apps_lib/Cargo.toml b/crates/apps_lib/Cargo.toml index c0fd42e600..ee127eb212 100644 --- a/crates/apps_lib/Cargo.toml +++ b/crates/apps_lib/Cargo.toml @@ -40,7 +40,6 @@ namada_wallet = { path = "../wallet", features = ["std"]} async-trait.workspace = true base64.workspace = true borsh.workspace = true -borsh-ext.workspace = true clap.workspace = true color-eyre.workspace = true config.workspace = true diff --git a/crates/apps_lib/src/cli/wallet.rs b/crates/apps_lib/src/cli/wallet.rs index d383adb4d4..28fedf0a35 100644 --- a/crates/apps_lib/src/cli/wallet.rs +++ b/crates/apps_lib/src/cli/wallet.rs @@ -4,14 +4,13 @@ use std::fs::File; use std::io::{self, Write}; use std::str::FromStr; -use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; use color_eyre::eyre::Result; use itertools::sorted; use ledger_namada_rs::{BIP44Path, NamadaApp}; use namada_core::chain::BlockHeight; use namada_core::masp::{ExtendedSpendingKey, MaspValue, PaymentAddress}; use namada_sdk::address::{Address, DecodeError}; +use namada_sdk::borsh::{BorshDeserialize, BorshSerializeExt}; use namada_sdk::io::{display_line, edisplay_line, Io}; use namada_sdk::key::*; use namada_sdk::masp::find_valid_diversifier; diff --git a/crates/apps_lib/src/client/rpc.rs b/crates/apps_lib/src/client/rpc.rs index 447dffdecc..65a1371630 100644 --- a/crates/apps_lib/src/client/rpc.rs +++ b/crates/apps_lib/src/client/rpc.rs @@ -3,7 +3,6 @@ use std::collections::{BTreeMap, BTreeSet}; use std::io; -use borsh::BorshDeserialize; use color_eyre::owo_colors::OwoColorize; use data_encoding::HEXLOWER; use either::Either; @@ -15,6 +14,7 @@ use masp_primitives::zip32::ExtendedFullViewingKey; use namada_core::masp::{BalanceOwner, MaspEpoch}; use namada_core::token::Amount; use namada_sdk::address::{Address, InternalAddress, MASP}; +use namada_sdk::borsh::BorshDeserialize; use namada_sdk::chain::{BlockHeight, Epoch}; use namada_sdk::collections::{HashMap, HashSet}; use namada_sdk::control_flow::time::{Duration, Instant}; diff --git a/crates/apps_lib/src/client/tx.rs b/crates/apps_lib/src/client/tx.rs index 188c8bd80a..03a1414b15 100644 --- a/crates/apps_lib/src/client/tx.rs +++ b/crates/apps_lib/src/client/tx.rs @@ -1,8 +1,6 @@ use std::fs::File; use std::io::Write; -use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; use color_eyre::owo_colors::OwoColorize; use ledger_namada_rs::{BIP44Path, NamadaApp}; use masp_primitives::sapling::redjubjub; @@ -15,6 +13,7 @@ use masp_primitives::zip32::{ExtendedFullViewingKey, PseudoExtendedKey}; use namada_core::masp::MaspTransaction; use namada_sdk::address::{Address, ImplicitAddress, MASP}; use namada_sdk::args::TxBecomeValidator; +use namada_sdk::borsh::{BorshDeserialize, BorshSerializeExt}; use namada_sdk::collections::HashMap; use namada_sdk::governance::cli::onchain::{ DefaultProposal, PgfFundingProposal, PgfStewardProposal, diff --git a/crates/apps_lib/src/client/utils.rs b/crates/apps_lib/src/client/utils.rs index 4c3fcb0ea0..56733a0e08 100644 --- a/crates/apps_lib/src/client/utils.rs +++ b/crates/apps_lib/src/client/utils.rs @@ -3,7 +3,6 @@ use std::fs::{self, File, OpenOptions}; use std::io::Write; use std::path::{Path, PathBuf}; -use borsh_ext::BorshSerializeExt; use color_eyre::owo_colors::OwoColorize; use flate2::read::GzDecoder; use flate2::write::GzEncoder; @@ -12,6 +11,7 @@ use itertools::Either; use namada_sdk::account::AccountPublicKeysMap; use namada_sdk::address::{Address, ImplicitAddress}; use namada_sdk::args::DeviceTransport; +use namada_sdk::borsh::BorshSerializeExt; use namada_sdk::chain::ChainId; use namada_sdk::dec::Dec; use namada_sdk::ibc::trace::ibc_token; diff --git a/crates/apps_lib/src/config/genesis.rs b/crates/apps_lib/src/config/genesis.rs index 08ddec0b37..2feb725cf2 100644 --- a/crates/apps_lib/src/config/genesis.rs +++ b/crates/apps_lib/src/config/genesis.rs @@ -10,12 +10,12 @@ use std::collections::BTreeMap; use std::fmt::{Display, Formatter}; use std::str::FromStr; -use borsh::{BorshDeserialize, BorshSerialize}; use derivative::Derivative; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] use namada_migrations::*; use namada_sdk::address::{Address, EstablishedAddress}; +use namada_sdk::borsh::{BorshDeserialize, BorshSerialize}; use namada_sdk::collections::HashMap; use namada_sdk::eth_bridge::EthereumBridgeParams; use namada_sdk::governance::parameters::GovernanceParameters; @@ -672,8 +672,8 @@ pub fn make_dev_genesis( #[cfg(test)] pub mod tests { - use borsh_ext::BorshSerializeExt; use namada_sdk::address::testing::gen_established_address; + use namada_sdk::borsh::BorshSerializeExt; use namada_sdk::key::*; use rand::prelude::ThreadRng; use rand::thread_rng; diff --git a/crates/apps_lib/src/config/genesis/chain.rs b/crates/apps_lib/src/config/genesis/chain.rs index e23448e780..c1f2002f8d 100644 --- a/crates/apps_lib/src/config/genesis/chain.rs +++ b/crates/apps_lib/src/config/genesis/chain.rs @@ -2,8 +2,6 @@ use std::collections::BTreeMap; use std::path::Path; use std::str::FromStr; -use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use eyre::eyre; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] @@ -11,6 +9,7 @@ use namada_migrations::*; use namada_sdk::address::{ Address, EstablishedAddress, EstablishedAddressGen, InternalAddress, }; +use namada_sdk::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; use namada_sdk::chain::{ChainId, ChainIdPrefix}; use namada_sdk::eth_bridge::EthereumBridgeParams; use namada_sdk::governance::pgf::parameters::PgfParameters; diff --git a/crates/apps_lib/src/config/genesis/templates.rs b/crates/apps_lib/src/config/genesis/templates.rs index 3164af7548..4df147be93 100644 --- a/crates/apps_lib/src/config/genesis/templates.rs +++ b/crates/apps_lib/src/config/genesis/templates.rs @@ -4,11 +4,11 @@ use std::collections::{BTreeMap, BTreeSet}; use std::marker::PhantomData; use std::path::Path; -use borsh::{BorshDeserialize, BorshSerialize}; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] use namada_migrations::*; use namada_sdk::address::Address; +use namada_sdk::borsh::{BorshDeserialize, BorshSerialize}; use namada_sdk::dec::Dec; use namada_sdk::eth_bridge::storage::parameters::{ Contracts, Erc20WhitelistEntry, MinimumConfirmations, diff --git a/crates/apps_lib/src/config/genesis/transactions.rs b/crates/apps_lib/src/config/genesis/transactions.rs index cb3e3fb7fa..834a26bc8f 100644 --- a/crates/apps_lib/src/config/genesis/transactions.rs +++ b/crates/apps_lib/src/config/genesis/transactions.rs @@ -5,8 +5,6 @@ use std::env; use std::fmt::Debug; use std::net::SocketAddr; -use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use itertools::{Either, Itertools}; use ledger_namada_rs::NamadaApp; use namada_macros::BorshDeserializer; @@ -15,6 +13,7 @@ use namada_migrations::*; use namada_sdk::account::AccountPublicKeysMap; use namada_sdk::address::{Address, EstablishedAddress}; use namada_sdk::args::{DeviceTransport, Tx as TxArgs}; +use namada_sdk::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; use namada_sdk::chain::ChainId; use namada_sdk::collections::HashSet; use namada_sdk::dec::Dec; diff --git a/crates/apps_lib/src/tendermint_node.rs b/crates/apps_lib/src/tendermint_node.rs index 3c2197915a..6019c990cd 100644 --- a/crates/apps_lib/src/tendermint_node.rs +++ b/crates/apps_lib/src/tendermint_node.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use borsh_ext::BorshSerializeExt; +use namada_sdk::borsh::BorshSerializeExt; use namada_sdk::key::*; use serde_json::json; use sha2::{Digest, Sha256}; diff --git a/crates/benches/Cargo.toml b/crates/benches/Cargo.toml index 0cf8131cf5..8e76a54a2d 100644 --- a/crates/benches/Cargo.toml +++ b/crates/benches/Cargo.toml @@ -49,7 +49,6 @@ namada_vp = { path = "../vp" } masp_primitives.workspace = true masp_proofs = { workspace = true, features = ["benchmarks", "multicore"] } borsh.workspace = true -borsh-ext.workspace = true criterion = { version = "0.5", features = ["html_reports"] } lazy_static.workspace= true prost.workspace = true diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 92d82c3436..0e5ccdbf8f 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -47,7 +47,6 @@ arbitrary = { workspace = true, optional = true } arse-merkle-tree.workspace = true bech32.workspace = true borsh.workspace = true -borsh-ext.workspace = true chrono.workspace = true data-encoding.workspace = true ed25519-consensus.workspace = true @@ -57,7 +56,7 @@ eyre.workspace = true ibc.workspace = true ics23.workspace = true impl-num-traits = "0.1.2" -index-set.workspace = true +usize-set.workspace = true indexmap.workspace = true k256.workspace = true lazy_static = { workspace = true, optional = true } diff --git a/crates/core/src/address.rs b/crates/core/src/address.rs index a0a64e8b8f..7023b70b4a 100644 --- a/crates/core/src/address.rs +++ b/crates/core/src/address.rs @@ -641,10 +641,10 @@ impl InternalAddress { #[cfg(test)] pub mod tests { - use borsh_ext::BorshSerializeExt; use proptest::prelude::*; use super::*; + use crate::borsh::BorshSerializeExt; /// Run `cargo test gen_established_address -- --nocapture` to generate a /// new established address. diff --git a/crates/core/src/borsh.rs b/crates/core/src/borsh.rs new file mode 100644 index 0000000000..c74f0af770 --- /dev/null +++ b/crates/core/src/borsh.rs @@ -0,0 +1,33 @@ +//! Borsh binary encoding (re-exported) from official crate with custom +//! ext. + +pub use borsh::*; + +/// Extensions to types implementing [`BorshSerialize`]. +pub trait BorshSerializeExt { + /// Serialize a value to a [`Vec`] of bytes. + fn serialize_to_vec(&self) -> Vec; +} + +impl BorshSerializeExt for T { + fn serialize_to_vec(&self) -> Vec { + let Ok(vec) = borsh::to_vec(self) else { + unreachable!("Serializing to a Vec should be infallible"); + }; + vec + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_serialize_equal() { + let to_seriailze = + "this is some cool shizzle I can guarantee that much - t. knower"; + let serialized_this_lib = to_seriailze.serialize_to_vec(); + let serialized_borsh_native = borsh::to_vec(&to_seriailze).unwrap(); + assert_eq!(serialized_this_lib, serialized_borsh_native); + } +} diff --git a/crates/core/src/eth_bridge_pool.rs b/crates/core/src/eth_bridge_pool.rs index d577221e3c..eaf95d9ebb 100644 --- a/crates/core/src/eth_bridge_pool.rs +++ b/crates/core/src/eth_bridge_pool.rs @@ -4,7 +4,6 @@ use std::borrow::Cow; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use ethabi::token::Token; use namada_macros::{BorshDeserializer, StorageKeys}; #[cfg(feature = "migrations")] @@ -16,6 +15,7 @@ use super::keccak::KeccakHash; use super::storage::{self, KeySeg}; use crate as namada_core; // This is needed for `StorageKeys` macro use crate::address::Address; +use crate::borsh::BorshSerializeExt; use crate::eth_abi::Encode; use crate::ethereum_events::{ EthAddress, TransferToEthereum as TransferToEthereumEvent, diff --git a/crates/core/src/ethereum_events.rs b/crates/core/src/ethereum_events.rs index 63afa38589..5df4a86728 100644 --- a/crates/core/src/ethereum_events.rs +++ b/crates/core/src/ethereum_events.rs @@ -5,7 +5,6 @@ use std::fmt::{Display, Formatter}; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use ethabi::ethereum_types::{H160, U256 as ethUint}; use ethabi::Token; use eyre::{eyre, Context}; @@ -15,6 +14,7 @@ use namada_migrations::*; use serde::{Deserialize, Serialize}; use crate::address::Address; +use crate::borsh::BorshSerializeExt; use crate::eth_abi::Encode; use crate::ethereum_structs::Erc20Transfer; use crate::hash::Hash; diff --git a/crates/core/src/key/common.rs b/crates/core/src/key/common.rs index 1944397165..4ef9af6924 100644 --- a/crates/core/src/key/common.rs +++ b/crates/core/src/key/common.rs @@ -3,7 +3,6 @@ use std::fmt::{self, Display}; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use data_encoding::{HEXLOWER, HEXUPPER}; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] @@ -19,6 +18,7 @@ use super::{ ParseSignatureError, RefTo, SchemeType, SigScheme as SigSchemeTrait, VerifySigError, }; +use crate::borsh::BorshSerializeExt; use crate::ethereum_events::EthAddress; use crate::key::{SignableBytes, StorageHasher}; use crate::{impl_display_and_from_str_via_format, string_encoding}; diff --git a/crates/core/src/key/ed25519.rs b/crates/core/src/key/ed25519.rs index df53775cd8..8e53e051a8 100644 --- a/crates/core/src/key/ed25519.rs +++ b/crates/core/src/key/ed25519.rs @@ -8,7 +8,6 @@ use std::io::{Read, Write}; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] @@ -22,6 +21,7 @@ use super::{ ParsePublicKeyError, ParseSecretKeyError, ParseSignatureError, RefTo, SchemeType, SigScheme as SigSchemeTrait, SignableBytes, VerifySigError, }; +use crate::borsh::BorshSerializeExt; use crate::key::StorageHasher; const PUBLIC_KEY_LENGTH: usize = 32; diff --git a/crates/core/src/key/mod.rs b/crates/core/src/key/mod.rs index 6075c9091b..bf5c6e6cd2 100644 --- a/crates/core/src/key/mod.rs +++ b/crates/core/src/key/mod.rs @@ -9,7 +9,6 @@ use std::hash::Hash; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use data_encoding::HEXUPPER; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] @@ -21,6 +20,7 @@ use sha2::{Digest, Sha256}; use thiserror::Error; use crate::address; +use crate::borsh::BorshSerializeExt; use crate::hash::{KeccakHasher, Sha256Hasher, StorageHasher}; use crate::keccak::{keccak_hash, KeccakHash}; diff --git a/crates/core/src/key/secp256k1.rs b/crates/core/src/key/secp256k1.rs index 787b448935..fe1d709181 100644 --- a/crates/core/src/key/secp256k1.rs +++ b/crates/core/src/key/secp256k1.rs @@ -9,7 +9,6 @@ use std::io::{ErrorKind, Read, Write}; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; use ethabi::Token; use k256::ecdsa::RecoveryId; @@ -27,6 +26,7 @@ use super::{ ParsePublicKeyError, ParseSecretKeyError, ParseSignatureError, RefTo, SchemeType, SigScheme as SigSchemeTrait, SignableBytes, VerifySigError, }; +use crate::borsh::BorshSerializeExt; use crate::eth_abi::Encode; use crate::ethereum_events::EthAddress; use crate::key::StorageHasher; diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 2c2a1e63fa..919f444fd6 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -18,6 +18,7 @@ )] pub mod arith; +pub mod borsh; pub mod bytes; #[cfg(any(test, feature = "control_flow"))] pub mod control_flow; @@ -41,11 +42,6 @@ pub mod tendermint_proto { pub use tendermint_proto::google; // 💩 pub use tendermint_proto::v0_37::*; } -/// Borsh binary encoding (re-exported) from official crate with custom ext. -pub mod borsh { - pub use borsh::*; - pub use borsh_ext::*; -} #[allow(missing_docs)] pub mod collections { @@ -88,10 +84,9 @@ pub mod uint; pub mod validity_predicate; pub mod voting_power; -use borsh_ext::BorshSerializeExt; use thiserror::Error; -use crate::borsh::{BorshDeserialize, BorshSerialize}; +use crate::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; #[allow(missing_docs)] #[derive(Error, Debug)] diff --git a/crates/core/src/masp.rs b/crates/core/src/masp.rs index 37c4e648ae..caac4ccde8 100644 --- a/crates/core/src/masp.rs +++ b/crates/core/src/masp.rs @@ -6,7 +6,6 @@ use std::num::ParseIntError; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use masp_primitives::asset_type::AssetType; use masp_primitives::sapling::ViewingKey; use masp_primitives::transaction::TransparentAddress; @@ -22,6 +21,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use sha2::{Digest, Sha256}; use crate::address::{Address, DecodeError, HASH_HEX_LEN, IBC, MASP}; +use crate::borsh::BorshSerializeExt; use crate::chain::Epoch; use crate::impl_display_and_from_str_via_format; use crate::string_encoding::{ diff --git a/crates/core/src/mod.rs b/crates/core/src/mod.rs index e63a10463c..122c42457e 100644 --- a/crates/core/src/mod.rs +++ b/crates/core/src/mod.rs @@ -24,10 +24,9 @@ pub mod uint; pub mod validity_predicate; pub mod voting_power; -use borsh_ext::BorshSerializeExt; use thiserror::Error; -use crate::borsh::{BorshDeserialize, BorshSerialize}; +use crate::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; #[allow(missing_docs)] #[derive(Error, Debug)] diff --git a/crates/core/src/storage.rs b/crates/core/src/storage.rs index 15ed3c8d9f..bd05e17fdf 100644 --- a/crates/core/src/storage.rs +++ b/crates/core/src/storage.rs @@ -8,12 +8,13 @@ use std::str::FromStr; use arse_merkle_tree::InternalKey; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use data_encoding::BASE32HEX_NOPAD; -use index_set::vec::VecIndexSet; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] use namada_migrations::*; use serde::{Deserialize, Serialize}; use thiserror::Error; +use usize_set::vec::VecIndexSet; +use usize_set::IndexSet; use super::key::common; use crate::address::{self, Address, PARAMETERS}; diff --git a/crates/ibc/src/lib.rs b/crates/ibc/src/lib.rs index 74830fda51..9fa49d58aa 100644 --- a/crates/ibc/src/lib.rs +++ b/crates/ibc/src/lib.rs @@ -1284,8 +1284,8 @@ pub mod testing { prop_compose! { /// Generate an arbitrary IBC token ID vector - pub fn arb_ibc_token_ids()(token_ids in collection::vec(arb_ibc_token_id(), 1..10)) -> TokenIds { - TokenIds(token_ids) + pub fn arb_ibc_token_ids()(token_ids in collection::hash_set(arb_ibc_token_id().prop_map(|x| x.to_string()), 1..10)) -> TokenIds { + TokenIds::try_from(token_ids.into_iter().collect::>()).expect("generated invalid IBC token ID vector") } } diff --git a/crates/light_sdk/Cargo.toml b/crates/light_sdk/Cargo.toml index bad4cde8af..f44424d410 100644 --- a/crates/light_sdk/Cargo.toml +++ b/crates/light_sdk/Cargo.toml @@ -22,7 +22,6 @@ namada-eth-bridge = ["namada_sdk/namada-eth-bridge"] namada_sdk = { path = "../sdk" } borsh.workspace = true -borsh-ext.workspace = true prost.workspace = true tendermint-config.workspace = true tendermint-rpc = { workspace = true, features = ["http-client"] } diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index 239e77e273..6382d9c234 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -56,7 +56,6 @@ async-trait.workspace = true base64.workspace = true blake2b-rs.workspace = true borsh.workspace = true -borsh-ext.workspace = true byte-unit.workspace = true bytes = "1.1.0" clap = { workspace = true, optional = true } diff --git a/crates/node/src/bench_utils.rs b/crates/node/src/bench_utils.rs index 948d94d9fb..c56dd1303d 100644 --- a/crates/node/src/bench_utils.rs +++ b/crates/node/src/bench_utils.rs @@ -12,8 +12,6 @@ use std::path::PathBuf; use std::str::FromStr; use std::sync::{Arc, Once, RwLock, RwLockReadGuard, RwLockWriteGuard}; -use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use masp_primitives::transaction::components::sapling::builder::RngBuildParams; use masp_primitives::transaction::Transaction; use masp_primitives::zip32::ExtendedFullViewingKey; @@ -24,6 +22,9 @@ use namada_apps_lib::cli::Context; use namada_apps_lib::wallet::{defaults, CliWalletUtils}; use namada_sdk::address::{self, Address, InternalAddress, MASP}; use namada_sdk::args::ShieldedSync; +use namada_sdk::borsh::{ + self, BorshDeserialize, BorshSerialize, BorshSerializeExt, +}; use namada_sdk::chain::testing::get_dummy_header; use namada_sdk::chain::{BlockHeight, ChainId, Epoch}; use namada_sdk::events::extend::{ diff --git a/crates/node/src/dry_run_tx.rs b/crates/node/src/dry_run_tx.rs index 1957045f0b..f6f3097830 100644 --- a/crates/node/src/dry_run_tx.rs +++ b/crates/node/src/dry_run_tx.rs @@ -109,8 +109,7 @@ where #[cfg(test)] mod test { - use borsh::BorshDeserialize; - use borsh_ext::BorshSerializeExt; + use namada_sdk::borsh::{BorshDeserialize, BorshSerializeExt}; use namada_sdk::chain::BlockHeight; use namada_sdk::events::log::EventLog; use namada_sdk::hash::Hash; diff --git a/crates/node/src/ethereum_oracle/test_tools/events_endpoint.rs b/crates/node/src/ethereum_oracle/test_tools/events_endpoint.rs index 1886c78a03..b0e0666661 100644 --- a/crates/node/src/ethereum_oracle/test_tools/events_endpoint.rs +++ b/crates/node/src/ethereum_oracle/test_tools/events_endpoint.rs @@ -1,6 +1,6 @@ use std::net::SocketAddr; -use borsh::BorshDeserialize; +use namada_sdk::borsh::BorshDeserialize; use namada_sdk::ethereum_events::EthereumEvent; use tokio::sync::mpsc::Sender as BoundedSender; use tokio::sync::oneshot::{Receiver, Sender}; diff --git a/crates/node/src/shell/mod.rs b/crates/node/src/shell/mod.rs index ffb176ff1a..456dcede74 100644 --- a/crates/node/src/shell/mod.rs +++ b/crates/node/src/shell/mod.rs @@ -31,10 +31,9 @@ use std::path::{Path, PathBuf}; #[allow(unused_imports)] use std::rc::Rc; -use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; use namada_apps_lib::wallet::{self, ValidatorData, ValidatorKeys}; use namada_sdk::address::Address; +use namada_sdk::borsh::{BorshDeserialize, BorshSerializeExt}; use namada_sdk::chain::{BlockHeight, ChainId}; use namada_sdk::eth_bridge::protocol::validation::bridge_pool_roots::validate_bp_roots_vext; use namada_sdk::eth_bridge::protocol::validation::ethereum_events::validate_eth_events_vext; diff --git a/crates/node/src/shell/snapshots.rs b/crates/node/src/shell/snapshots.rs index 227fdd5daa..a0a8c4000a 100644 --- a/crates/node/src/shell/snapshots.rs +++ b/crates/node/src/shell/snapshots.rs @@ -1,8 +1,7 @@ use std::io::Write; -use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; use namada_sdk::arith::checked; +use namada_sdk::borsh::{BorshDeserialize, BorshSerializeExt}; use namada_sdk::hash::{Hash, Sha256Hasher}; use namada_sdk::state::{BlockHeight, StorageRead}; diff --git a/crates/node/src/shell/testing/node.rs b/crates/node/src/shell/testing/node.rs index 7bffba9090..b2136ebeca 100644 --- a/crates/node/src/shell/testing/node.rs +++ b/crates/node/src/shell/testing/node.rs @@ -39,7 +39,7 @@ use namada_sdk::tendermint_proto::google::protobuf::Timestamp; use namada_sdk::time::DateTimeUtc; use namada_sdk::tx::data::ResultCode; use namada_sdk::tx::event::{Batch as BatchAttr, Code as CodeAttr}; -use namada_sdk::{ethereum_structs, governance}; +use namada_sdk::{borsh, ethereum_structs, governance}; use regex::Regex; use tokio::sync::mpsc; diff --git a/crates/node/src/storage/mod.rs b/crates/node/src/storage/mod.rs index 18459a13f5..ca7c401623 100644 --- a/crates/node/src/storage/mod.rs +++ b/crates/node/src/storage/mod.rs @@ -55,8 +55,8 @@ fn new_blake2b() -> Blake2b { #[allow(clippy::arithmetic_side_effects, clippy::cast_sign_loss)] #[cfg(test)] mod tests { - use borsh::BorshDeserialize; use itertools::Itertools; + use namada_sdk::borsh::BorshDeserialize; use namada_sdk::chain::{BlockHeight, ChainId}; use namada_sdk::collections::HashMap; use namada_sdk::eth_bridge::storage::bridge_pool; diff --git a/crates/node/src/storage/rocksdb.rs b/crates/node/src/storage/rocksdb.rs index ac4717ae44..d6ed9e6715 100644 --- a/crates/node/src/storage/rocksdb.rs +++ b/crates/node/src/storage/rocksdb.rs @@ -51,12 +51,11 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::Mutex; -use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; use itertools::Either; use namada_replay_protection as replay_protection; use namada_sdk::arith::checked; +use namada_sdk::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; use namada_sdk::collections::HashSet; use namada_sdk::eth_bridge::storage::bridge_pool; use namada_sdk::eth_bridge::storage::proof::BridgePoolRootProof; diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index ccb795e9e9..517a0baaa1 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -93,7 +93,6 @@ arbitrary = { workspace = true, optional = true } async-trait.workspace = true bimap.workspace = true borsh.workspace = true -borsh-ext.workspace = true circular-queue.workspace = true clap = { version = "4.3", default-features = false, features = ["std"] } data-encoding.workspace = true diff --git a/crates/sdk/src/eth_bridge/bridge_pool.rs b/crates/sdk/src/eth_bridge/bridge_pool.rs index 985e589351..28f15c1186 100644 --- a/crates/sdk/src/eth_bridge/bridge_pool.rs +++ b/crates/sdk/src/eth_bridge/bridge_pool.rs @@ -6,7 +6,6 @@ use std::borrow::Cow; use std::cmp::Ordering; use std::sync::Arc; -use borsh_ext::BorshSerializeExt; use ethbridge_bridge_contract::Bridge; use ethers::providers::Middleware; use futures::future::FutureExt; @@ -30,6 +29,7 @@ use owo_colors::OwoColorize; use serde::Serialize; use super::{block_on_eth_sync, eth_sync_or_exit, BlockOnEthSync}; +use crate::borsh::BorshSerializeExt; use crate::control_flow::time::{Duration, Instant}; use crate::error::{ EncodingError, Error, EthereumBridgeError, QueryError, TxSubmitError, diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 52f0eb3398..7b175d79c5 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -854,8 +854,6 @@ where /// Tests and strategies for transactions #[cfg(any(test, feature = "testing"))] pub mod testing { - use ::borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; - use borsh_ext::BorshSerializeExt; use governance::ProposalType; use masp_primitives::transaction::components::sapling::builder::StoredBuildParams; use namada_account::{InitAccount, UpdateAccount}; @@ -891,6 +889,9 @@ pub mod testing { use super::*; use crate::account::tests::{arb_init_account, arb_update_account}; + use crate::borsh::{ + BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt, + }; use crate::chain::ChainId; use crate::eth_bridge_pool::testing::arb_pending_transfer; use crate::key::testing::arb_common_pk; @@ -1085,11 +1086,11 @@ pub mod testing { prop_compose! { /// Generate an arbitrary header - pub fn arb_header()( + pub fn arb_header(cmt_count: impl Into,)( chain_id in arb_chain_id(), expiration in option::of(arb_date_time_utc()), timestamp in arb_date_time_utc(), - batch in arb_tx_commitments(1..10), + batch in arb_tx_commitments(cmt_count), atomic in proptest::bool::ANY, tx_type in arb_tx_type(), ) -> Header { @@ -1123,7 +1124,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary masp transfer transaction pub fn arb_transfer_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), code_hash in arb_hash(), (transfer, aux) in arb_transfer(), @@ -1156,7 +1157,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary bond transaction pub fn arb_bond_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), bond in arb_bond(), code_hash in arb_hash(), @@ -1172,7 +1173,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary bond transaction pub fn arb_unbond_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), unbond in arb_bond(), code_hash in arb_hash(), @@ -1188,7 +1189,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary account initialization transaction pub fn arb_init_account_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), mut init_account in arb_init_account(), extra_data in arb_code(), @@ -1207,7 +1208,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary account initialization transaction pub fn arb_become_validator_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), become_validator in arb_become_validator(), code_hash in arb_hash(), @@ -1223,7 +1224,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary proposal initialization transaction pub fn arb_init_proposal_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), mut init_proposal in arb_init_proposal(), content_extra_data in arb_code(), @@ -1272,7 +1273,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary vote proposal transaction pub fn arb_vote_proposal_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), vote_proposal in arb_vote_proposal(), code_hash in arb_hash(), @@ -1288,7 +1289,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary reveal public key transaction pub fn arb_reveal_pk_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), pk in arb_common_pk(), code_hash in arb_hash(), @@ -1304,7 +1305,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary account initialization transaction pub fn arb_update_account_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), mut update_account in arb_update_account(), extra_data in arb_code(), @@ -1325,7 +1326,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary reveal public key transaction pub fn arb_withdraw_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), withdraw in arb_withdraw(), code_hash in arb_hash(), @@ -1341,7 +1342,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary claim rewards transaction pub fn arb_claim_rewards_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), claim_rewards in arb_withdraw(), code_hash in arb_hash(), @@ -1357,7 +1358,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary commission change transaction pub fn arb_commission_change_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), commission_change in arb_commission_change(), code_hash in arb_hash(), @@ -1373,7 +1374,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary commission change transaction pub fn arb_metadata_change_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), metadata_change in arb_metadata_change(), code_hash in arb_hash(), @@ -1389,7 +1390,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary unjail validator transaction pub fn arb_unjail_validator_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), address in arb_non_internal_address(), code_hash in arb_hash(), @@ -1405,7 +1406,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary deactivate validator transaction pub fn arb_deactivate_validator_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), address in arb_non_internal_address(), code_hash in arb_hash(), @@ -1421,7 +1422,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary reactivate validator transaction pub fn arb_reactivate_validator_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), address in arb_non_internal_address(), code_hash in arb_hash(), @@ -1437,7 +1438,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary consensus key change transaction pub fn arb_consensus_key_change_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), consensus_key_change in arb_consensus_key_change(), code_hash in arb_hash(), @@ -1453,7 +1454,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary redelegation transaction pub fn arb_redelegation_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), redelegation in arb_redelegation(), code_hash in arb_hash(), @@ -1469,7 +1470,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary redelegation transaction pub fn arb_update_steward_commission_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), update_steward_commission in arb_update_steward_commission(), code_hash in arb_hash(), @@ -1485,7 +1486,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary redelegation transaction pub fn arb_resign_steward_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), steward in arb_non_internal_address(), code_hash in arb_hash(), @@ -1501,7 +1502,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary pending transfer transaction pub fn arb_pending_transfer_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), pending_transfer in arb_pending_transfer(), code_hash in arb_hash(), @@ -1534,7 +1535,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary IBC any transaction pub fn arb_ibc_msg_transfer_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), (msg_transfer, aux) in arb_msg_transfer(), code_hash in arb_hash(), @@ -1584,7 +1585,7 @@ pub mod testing { prop_compose! { /// Generate an arbitrary IBC any transaction pub fn arb_ibc_msg_nft_transfer_tx()( - mut header in arb_header(), + mut header in arb_header(0), wrapper in arb_wrapper_tx(), (msg_transfer, aux) in arb_msg_nft_transfer(), code_hash in arb_hash(), diff --git a/crates/sdk/src/migrations.rs b/crates/sdk/src/migrations.rs index 062670e0d7..f229f60b41 100644 --- a/crates/sdk/src/migrations.rs +++ b/crates/sdk/src/migrations.rs @@ -6,7 +6,6 @@ use std::marker::PhantomData; use std::path::{Path, PathBuf}; use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use data_encoding::HEXUPPER; use eyre::eyre; use namada_core::chain::BlockHeight; @@ -19,6 +18,8 @@ use regex::Regex; use serde::de::{DeserializeOwned, Error, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use crate::borsh::BorshSerializeExt; + /// The maximum number of character printed per value. const PRINTLN_CUTOFF: usize = 300; diff --git a/crates/sdk/src/queries/mod.rs b/crates/sdk/src/queries/mod.rs index 202a99280c..b9828ffcd3 100644 --- a/crates/sdk/src/queries/mod.rs +++ b/crates/sdk/src/queries/mod.rs @@ -94,13 +94,13 @@ pub fn require_no_data(request: &RequestQuery) -> namada_storage::Result<()> { /// Queries testing helpers #[cfg(any(test, feature = "testing"))] pub(crate) mod testing { - use borsh_ext::BorshSerializeExt; use namada_core::chain::BlockHeight; use namada_io::client::Client; use namada_state::testing::TestState; use tendermint_rpc::Response; use super::*; + use crate::borsh::BorshSerializeExt; use crate::events::log::EventLog; use crate::tendermint_rpc::error::Error as RpcError; diff --git a/crates/sdk/src/queries/router.rs b/crates/sdk/src/queries/router.rs index d59d4a6c3f..ce0c765a6f 100644 --- a/crates/sdk/src/queries/router.rs +++ b/crates/sdk/src/queries/router.rs @@ -856,11 +856,11 @@ macro_rules! router { /// ``` #[cfg(test)] mod test_rpc_handlers { - use borsh_ext::BorshSerializeExt; use namada_core::chain::Epoch; use namada_core::token; use namada_state::{DBIter, StorageHasher, DB}; + use crate::borsh::BorshSerializeExt; use crate::queries::{ EncodedResponseQuery, RequestCtx, RequestQuery, ResponseQuery, }; diff --git a/crates/sdk/src/queries/shell.rs b/crates/sdk/src/queries/shell.rs index 66b55c551a..f515296404 100644 --- a/crates/sdk/src/queries/shell.rs +++ b/crates/sdk/src/queries/shell.rs @@ -3,7 +3,6 @@ use std::collections::BTreeMap; pub(super) mod eth_bridge; use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; use masp_primitives::asset_type::AssetType; use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::Node; @@ -27,6 +26,7 @@ use namada_token::storage_key::masp_token_map_key; use namada_tx::data::DryRunResult; use self::eth_bridge::{EthBridge, ETH_BRIDGE}; +use crate::borsh::BorshSerializeExt; use crate::events::log::dumb_queries; use crate::events::Event; use crate::ibc::core::host::types::identifiers::{ diff --git a/crates/sdk/src/queries/shell/eth_bridge.rs b/crates/sdk/src/queries/shell/eth_bridge.rs index 9923a0eafe..4e91333cd1 100644 --- a/crates/sdk/src/queries/shell/eth_bridge.rs +++ b/crates/sdk/src/queries/shell/eth_bridge.rs @@ -4,7 +4,6 @@ use std::borrow::Cow; use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use namada_core::address::Address; use namada_core::arith::checked; use namada_core::chain::{BlockHeight, Epoch}; @@ -42,6 +41,7 @@ use namada_vote_ext::validator_set_update::{ }; use serde::{Deserialize, Serialize}; +use crate::borsh::BorshSerializeExt; use crate::eth_bridge::ethers::abi::AbiDecode; use crate::governance; use crate::queries::{EncodedResponseQuery, RequestCtx, RequestQuery}; diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index 32f3c706c8..9f747aa815 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -577,21 +577,22 @@ pub async fn dry_run_tx( .await, )? .data; - let result_str = format!("Transaction consumed {} gas", result.1); - let mut cmt_result_str = String::new(); + display_line!(context.io(), "Dry-run result:"); + let mut all_inners_successful = true; for (inner_hash, cmt_result) in result.0.iter() { match cmt_result { Ok(result) => { if result.is_accepted() { - cmt_result_str.push_str(&format!( - "Inner transaction {inner_hash} was successfully \ - applied", - )); + display_line!( + context.io(), + "Transaction {inner_hash} was successfully applied", + ); } else { - cmt_result_str.push_str(&format!( - "Inner transaction {} was rejected by VPs: \ - {}\nErrors: {}\nChanged keys: {}", + display_line!( + context.io(), + "Transaction {} was rejected by VPs: {}\nErrors: \ + {}\nChanged keys: {}", inner_hash, serde_json::to_string_pretty( &result.vps_result.rejected_vps @@ -601,18 +602,33 @@ pub async fn dry_run_tx( .unwrap(), serde_json::to_string_pretty(&result.changed_keys) .unwrap(), - )) + ); + all_inners_successful = false; } } - Err(msg) => cmt_result_str.push_str(&format!( - "Inner transaction {inner_hash} failed with error: {msg}" - )), + Err(msg) => { + display_line!( + context.io(), + "Transaction {inner_hash} failed.\nDetails: {msg}" + ); + all_inners_successful = false; + } } } - display_line!( - context.io(), - "Dry-run result: {result_str}. {cmt_result_str}" - ); + + // Display the gas used only if the entire batch was successful. In all the + // other cases the gas consumed is misleading since most likely the inner + // transactions did not have the chance to run until completion. This could + // trick the user into setting wrong gas limit values when trying to + // resubmit the tx + if all_inners_successful { + display_line!( + context.io(), + "The batch consumed {} gas units.", + result.1 + ); + } + Ok(result) } diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index 98d87332ec..c3cb2427dc 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -6,7 +6,6 @@ use std::collections::BTreeMap; use std::fmt::Display; use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; use itertools::Itertools; use masp_primitives::asset_type::AssetType; @@ -21,11 +20,15 @@ use namada_core::key::*; use namada_core::masp::{ AssetData, ExtendedViewingKey, MaspTxId, PaymentAddress, }; +use namada_core::time::DateTimeUtc; use namada_core::token::{Amount, DenominatedAmount}; use namada_governance::storage::proposal::{ InitProposalData, ProposalType, VoteProposalData, }; use namada_governance::storage::vote::ProposalVote; +use namada_ibc::core::channel::types::timeout::{ + TimeoutHeight, TimeoutTimestamp, +}; use namada_ibc::{MsgNftTransfer, MsgTransfer}; use namada_io::*; use namada_parameters::storage as parameter_storage; @@ -40,6 +43,7 @@ use serde::{Deserialize, Serialize}; use tokio::sync::RwLock; use crate::args::SdkTypes; +use crate::borsh::BorshSerializeExt; use crate::error::{EncodingError, Error, TxSubmitError}; use crate::eth_bridge_pool::PendingTransfer; use crate::governance::storage::proposal::{AddRemove, PGFAction, PGFTarget}; @@ -1002,6 +1006,44 @@ fn find_masp_builder<'a>( Ok(None) } +// Format the date-time for the Ledger device +fn format_timestamp(datetime: DateTimeUtc) -> String { + let mut datetime = datetime.0.to_string(); + let mut secfrac_width = None; + for (i, ch) in datetime.char_indices() { + if ch == '.' { + secfrac_width = Some(0); + } else if let Some(ref mut secfrac_width) = &mut secfrac_width { + if ch.is_ascii_digit() { + *secfrac_width += 1; + } else { + let trailing = "0".repeat(9 - *secfrac_width); + datetime.insert_str(i, &trailing); + break; + } + } + } + datetime +} + +// Format the timeout timestamp for the Ledger device +fn format_timeout_timestamp(timestamp: &TimeoutTimestamp) -> String { + match timestamp { + TimeoutTimestamp::Never => "no timestamp".to_string(), + TimeoutTimestamp::At(timestamp) => { + timestamp.into_tm_time().to_rfc3339() + } + } +} + +// Format the timeout height for the Ledger device +fn format_timeout_height(height: &TimeoutHeight) -> String { + match height { + TimeoutHeight::Never => "no timeout".to_string(), + TimeoutHeight::At(height) => height.to_string(), + } +} + /// Converts the given transaction to the form that is displayed on the Ledger /// device pub async fn to_ledger_vector( @@ -1391,11 +1433,15 @@ pub async fn to_ledger_vector( ), format!( "Timeout height : {}", - transfer.message.timeout_height_on_b + format_timeout_height( + &transfer.message.timeout_height_on_b + ) ), format!( "Timeout timestamp : {}", - transfer.message.timeout_timestamp_on_b, + format_timeout_timestamp( + &transfer.message.timeout_timestamp_on_b + ), ), ]); tv.output_expert.extend(vec![ @@ -1420,11 +1466,15 @@ pub async fn to_ledger_vector( tv.output_expert.extend(vec![ format!( "Timeout height : {}", - transfer.message.timeout_height_on_b + format_timeout_height( + &transfer.message.timeout_height_on_b + ) ), format!( "Timeout timestamp : {}", - transfer.message.timeout_timestamp_on_b, + format_timeout_timestamp( + &transfer.message.timeout_timestamp_on_b + ), ), ]); if let Some(transfer) = transfer.transfer { @@ -1513,11 +1563,15 @@ pub async fn to_ledger_vector( tv.output.extend(vec![ format!( "Timeout height : {}", - transfer.message.timeout_height_on_b + format_timeout_height( + &transfer.message.timeout_height_on_b + ) ), format!( "Timeout timestamp : {}", - transfer.message.timeout_timestamp_on_b, + format_timeout_timestamp( + &transfer.message.timeout_timestamp_on_b + ), ), ]); tv.output_expert.extend(vec![ @@ -1581,11 +1635,15 @@ pub async fn to_ledger_vector( tv.output_expert.extend(vec![ format!( "Timeout height : {}", - transfer.message.timeout_height_on_b + format_timeout_height( + &transfer.message.timeout_height_on_b + ) ), format!( "Timeout timestamp : {}", - transfer.message.timeout_timestamp_on_b, + format_timeout_timestamp( + &transfer.message.timeout_timestamp_on_b + ), ), ]); if let Some(transfer) = transfer.transfer { @@ -2022,7 +2080,10 @@ pub async fn to_ledger_vector( let fee_amount_per_gas_unit = to_ledger_decimal(&wrapper.fee.amount_per_gas_unit.to_string()); tv.output_expert.extend(vec![ - format!("Timestamp : {}", tx.header.timestamp.0), + format!( + "Timestamp : {}", + format_timestamp(tx.header.timestamp) + ), format!("Pubkey : {}", wrapper.pk), format!("Gas limit : {}", u64::from(wrapper.gas_limit)), ]); diff --git a/crates/sdk/src/tx.rs b/crates/sdk/src/tx.rs index 6f7eb8247a..19a6a5ba17 100644 --- a/crates/sdk/src/tx.rs +++ b/crates/sdk/src/tx.rs @@ -7,7 +7,6 @@ use std::path::{Path, PathBuf}; use std::time::Duration; use borsh::BorshSerialize; -use borsh_ext::BorshSerializeExt; use masp_primitives::asset_type::AssetType; use masp_primitives::transaction::builder::Builder; use masp_primitives::transaction::components::sapling::builder::{ @@ -79,6 +78,7 @@ use crate::args::{ SdkTypes, TxShieldedTransferData, TxShieldingTransferData, TxTransparentTransferData, TxUnshieldingTransferData, }; +use crate::borsh::BorshSerializeExt; use crate::control_flow::time; use crate::error::{EncodingError, Error, QueryError, Result, TxSubmitError}; use crate::rpc::{ @@ -161,7 +161,7 @@ pub enum ProcessTxResponse { } impl ProcessTxResponse { - /// Returns a `TxResult` if the transaction applied and was it accepted by + /// Returns a `TxResult` if the transaction was applied and accepted by /// all VPs. Note that this always returns false for dry-run transactions. pub fn is_applied_and_valid( &self, @@ -435,20 +435,59 @@ pub async fn submit_tx( /// Display a result of a tx batch. pub fn display_batch_resp(context: &impl Namada, resp: &TxResponse) { // Wrapper-level logs - display_line!( - context.io(), - "Transaction batch {} was applied at height {}, consuming {} gas \ - units.", - resp.hash, - resp.height, - resp.gas_used - ); + let wrapper_successful = if let ResultCode::Ok = resp.code { + display_line!( + context.io(), + "Transaction batch {} was applied at height {}.", + resp.hash, + resp.height, + ); + true + } else { + let err = match resp.code { + ResultCode::Ok => unreachable!(), + ResultCode::WasmRuntimeError => "wasm runtime", + ResultCode::InvalidTx => "invalid transaction", + ResultCode::InvalidSig => "invalid signature", + ResultCode::AllocationError => "allocation", + ResultCode::ReplayTx => "transaction replay", + ResultCode::InvalidChainId => "invalid chain ID", + ResultCode::ExpiredTx => "transaction expired", + ResultCode::TxGasLimit => "gas limit", + ResultCode::FeeError => "fee", + ResultCode::InvalidVoteExtension => "invalid vote extension", + ResultCode::TooLarge => "transaction too large", + ResultCode::TxNotAllowlisted => "transaction not allowlisted", + }; + let err_msg = if resp.info.is_empty() { + err.to_string() + } else { + format!("{err}, {}", resp.info) + }; + display_line!( + context.io(), + "Transaction batch {} failed at height {} with error: {}.", + resp.hash, + resp.height, + err_msg + ); + false + }; let batch_results = resp.batch_result(); if !batch_results.is_empty() { + if !wrapper_successful { + display_line!( + context.io(), + "Since the batch in its entirety failed, none of the \ + transactions listed below have been committed. Their results \ + are provided for completeness.", + ); + } display_line!(context.io(), "Batch results:"); } // Batch-level logs + let mut all_inners_successful = true; for (inner_hash, result) in batch_results { match result { InnerTxResult::Success(_) => { @@ -477,6 +516,7 @@ pub fn display_batch_resp(context: &impl Namada, resp: &TxResponse) { .unwrap(), serde_json::to_string_pretty(&changed_keys).unwrap(), ); + all_inners_successful = false; } InnerTxResult::OtherFailure(msg) => { edisplay_line!( @@ -485,10 +525,24 @@ pub fn display_batch_resp(context: &impl Namada, resp: &TxResponse) { inner_hash, msg ); + all_inners_successful = false; } } } + // Display the gas used only if the entire batch was successful. In all the + // other cases the gas consumed is misleading since most likely the inner + // transactions did not have the chance to run until completion. This could + // trick the user into setting wrong gas limit values when trying to + // resubmit the tx + if wrapper_successful && all_inners_successful { + edisplay_line!( + context.io(), + "The batch consumed {} gas units.", + resp.gas_used, + ); + } + tracing::debug!( "Full result: {}", serde_json::to_string_pretty(&resp).unwrap() diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index 14e422cce2..add26e1621 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -66,7 +66,6 @@ assert_cmd.workspace = true assert_matches.workspace = true base64.workspace = true borsh.workspace = true -borsh-ext.workspace = true color-eyre.workspace = true data-encoding.workspace = true # NOTE: enable "print" feature to see output from builds ran by e2e tests diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index 26500ac32c..c4c09694cc 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -1894,13 +1894,13 @@ fn transfer_from_cosmos( fn check_tx_height(test: &Test, client: &mut NamadaCmd) -> Result { let (_unread, matched) = client.exp_regex(r"height .*")?; - // Expecting e.g. "height 1337, consuming x gas units." + // Expecting e.g. "height 1337." let height_str = matched .trim() .split_once(' ') .unwrap() .1 - .split_once(',') + .split_once('.') .unwrap() .0; let height: u32 = height_str.parse().unwrap(); diff --git a/crates/tests/src/integration/ledger_tests.rs b/crates/tests/src/integration/ledger_tests.rs index a90c2847fe..552d09861b 100644 --- a/crates/tests/src/integration/ledger_tests.rs +++ b/crates/tests/src/integration/ledger_tests.rs @@ -6,7 +6,6 @@ use std::str::FromStr; use assert_matches::assert_matches; use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; use color_eyre::eyre::Result; use data_encoding::HEXLOWER; use namada_apps_lib::wallet::defaults::{self, is_use_device}; @@ -21,6 +20,7 @@ use namada_node::shell::testing::utils::{Bin, CapturedOutput}; use namada_node::shell::SnapshotSync; use namada_node::storage::DbSnapshot; use namada_sdk::account::AccountPublicKeysMap; +use namada_sdk::borsh::BorshSerializeExt; use namada_sdk::collections::HashMap; use namada_sdk::error::TxSubmitError; use namada_sdk::migrations; diff --git a/crates/tests/src/native_vp/eth_bridge_pool.rs b/crates/tests/src/native_vp/eth_bridge_pool.rs index d2f556b688..5154840b53 100644 --- a/crates/tests/src/native_vp/eth_bridge_pool.rs +++ b/crates/tests/src/native_vp/eth_bridge_pool.rs @@ -4,10 +4,10 @@ mod test_bridge_pool_vp { use std::path::PathBuf; use borsh::BorshDeserialize; - use borsh_ext::BorshSerializeExt; use namada_apps_lib::wallet::defaults::{albert_address, bertha_address}; use namada_apps_lib::wasm_loader; use namada_sdk::address::testing::{nam, wnam}; + use namada_sdk::borsh::BorshSerializeExt; use namada_sdk::chain::ChainId; use namada_sdk::eth_bridge::storage::bridge_pool::BRIDGE_POOL_ADDRESS; use namada_sdk::eth_bridge::{ diff --git a/crates/tests/src/vm_host_env/mod.rs b/crates/tests/src/vm_host_env/mod.rs index 0a7a3c858a..c8d77b5508 100644 --- a/crates/tests/src/vm_host_env/mod.rs +++ b/crates/tests/src/vm_host_env/mod.rs @@ -22,10 +22,10 @@ mod tests { use std::collections::BTreeSet; use std::panic; - use borsh_ext::BorshSerializeExt; use itertools::Itertools; use namada_core::chain::testing::get_dummy_header; use namada_sdk::account::pks_handle; + use namada_sdk::borsh::BorshSerializeExt; use namada_sdk::hash::Hash; use namada_sdk::ibc::context::nft_transfer_mod::testing::DummyNftTransferModule; use namada_sdk::ibc::context::transfer_mod::testing::DummyTransferModule; diff --git a/crates/wallet/Cargo.toml b/crates/wallet/Cargo.toml index e46fecd33f..4a9c41ba19 100644 --- a/crates/wallet/Cargo.toml +++ b/crates/wallet/Cargo.toml @@ -26,7 +26,6 @@ namada_migrations = {path = "../migrations", optional = true } bimap.workspace = true borsh.workspace = true -borsh-ext.workspace = true itertools.workspace = true derivation-path.workspace = true data-encoding.workspace = true diff --git a/crates/wallet/src/keys.rs b/crates/wallet/src/keys.rs index bc66d9608e..77cfe44215 100644 --- a/crates/wallet/src/keys.rs +++ b/crates/wallet/src/keys.rs @@ -4,9 +4,8 @@ use std::fmt::{Display, Error, Formatter}; use std::marker::PhantomData; use std::str::FromStr; -use borsh::{BorshDeserialize, BorshSerialize}; -use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; +use namada_core::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt}; use namada_core::chain::BlockHeight; use namada_core::masp::{ExtendedSpendingKey, ExtendedViewingKey}; use orion::{aead, kdf}; diff --git a/examples/README.md b/examples/README.md index eb30173551..38e110029b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -13,5 +13,5 @@ This example is run as follows: cargo run --example generate-txs -- ``` where `` is the path where the JSON test vectors will be stored -and `` is where rust `Debug` representations oof this data will be +and `` is where rust `Debug` representations of this data will be stored. diff --git a/fuzz/README.md b/fuzz/README.md index ef225deecc..69887c2e98 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -12,7 +12,7 @@ - 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 ) +- The important stat you'll want to 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: diff --git a/genesis/README.md b/genesis/README.md index 1aec869104..541b9aae89 100644 --- a/genesis/README.md +++ b/genesis/README.md @@ -24,8 +24,6 @@ The [tokens.toml file](tokens.toml) contains tokens with their aliases and valid The [balances.toml file](balances.toml) contains token balances associated with the public keys. -TODO: add shielded balances - ## Parameters The [parameters.toml file](parameters.toml) contains the general chain parameters, PoS and governance parameters. diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index a1d6099149..343b1db0ad 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -576,14 +576,6 @@ dependencies = [ "syn_derive", ] -[[package]] -name = "borsh-ext" -version = "1.2.0" -source = "git+https://github.com/heliaxdev/borsh-ext?tag=v1.2.0#a62fee3e847e512cad9ac0f1fd5a900e5db9ba37" -dependencies = [ - "borsh", -] - [[package]] name = "bs58" version = "0.5.0" @@ -799,8 +791,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "clru" -version = "0.5.0" -source = "git+https://github.com/marmeladema/clru-rs.git?rev=71ca566#71ca566915f21f3c308091ca7756a91b0f8b5afc" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" [[package]] name = "coins-bip32" @@ -1621,8 +1614,9 @@ dependencies = [ [[package]] name = "ethbridge-bridge-contract" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccec11776e279f18dcef377c95932ac7e558358477870c972e3b5eba0f1cc661" dependencies = [ "ethbridge-bridge-events", "ethbridge-structs", @@ -1632,8 +1626,9 @@ dependencies = [ [[package]] name = "ethbridge-bridge-events" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f862616190f541d733357e234d65ba73fec0ddacd62e91abb26a0258048a6bb1" dependencies = [ "ethabi", "ethbridge-structs", @@ -1643,8 +1638,9 @@ dependencies = [ [[package]] name = "ethbridge-structs" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7b3e89a2332887bf096cd589ac5781a6664b4fb0881506aa99b2be32e8e086" dependencies = [ "ethabi", "ethers", @@ -3152,15 +3148,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" -[[package]] -name = "index-set" -version = "0.8.0" -source = "git+https://github.com/heliaxdev/index-set?tag=v0.8.1#b0d928f83cf0d465ccda299d131e8df2859b5184" -dependencies = [ - "borsh", - "serde", -] - [[package]] name = "indexmap" version = "1.9.3" @@ -3651,7 +3638,6 @@ version = "0.46.1" dependencies = [ "bech32 0.8.1", "borsh", - "borsh-ext", "chrono", "data-encoding", "ed25519-consensus", @@ -3661,7 +3647,6 @@ dependencies = [ "ibc", "ics23", "impl-num-traits", - "index-set", "indexmap 2.2.4", "k256", "lazy_static", @@ -3691,6 +3676,7 @@ dependencies = [ "tokio", "tracing", "uint", + "usize-set", "wasmtimer", "zeroize", ] @@ -3892,7 +3878,6 @@ dependencies = [ "async-trait", "bimap", "borsh", - "borsh-ext", "circular-queue", "clap", "data-encoding", @@ -4287,7 +4272,6 @@ version = "0.46.1" dependencies = [ "bimap", "borsh", - "borsh-ext", "data-encoding", "derivation-path", "fd-lock", @@ -6063,16 +6047,18 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smooth-operator" -version = "0.7.0" -source = "git+https://github.com/heliaxdev/smooth-operator?tag=v0.7.0#0e182707f5e5bb9c6e0efa2d235dc9efd715d0a1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dece39b9b4d19edc6399498b056d1511135b70b5adf7822affdedf5715598" dependencies = [ "smooth-operator-impl", ] [[package]] name = "smooth-operator-impl" -version = "0.7.0" -source = "git+https://github.com/heliaxdev/smooth-operator?tag=v0.7.0#0e182707f5e5bb9c6e0efa2d235dc9efd715d0a1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "867851a695e22b0d1fc85f2f84dba29fef7e5d571f12fb23253e0b213bf190f7" dependencies = [ "proc-macro2", "quote", @@ -7251,6 +7237,16 @@ dependencies = [ "serde", ] +[[package]] +name = "usize-set" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12fbfdf92a2a7f550e532818381f9e8367cac2115671edb024120836f33985e9" +dependencies = [ + "borsh", + "serde", +] + [[package]] name = "uuid" version = "0.8.2" diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index f87bc8edfd..f578ba42bc 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -369,14 +369,6 @@ dependencies = [ "syn_derive", ] -[[package]] -name = "borsh-ext" -version = "1.2.0" -source = "git+https://github.com/heliaxdev/borsh-ext?tag=v1.2.0#a62fee3e847e512cad9ac0f1fd5a900e5db9ba37" -dependencies = [ - "borsh", -] - [[package]] name = "bumpalo" version = "3.14.0" @@ -483,8 +475,9 @@ dependencies = [ [[package]] name = "clru" -version = "0.5.0" -source = "git+https://github.com/marmeladema/clru-rs.git?rev=71ca566#71ca566915f21f3c308091ca7756a91b0f8b5afc" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" [[package]] name = "const-default" @@ -810,8 +803,9 @@ dependencies = [ [[package]] name = "ethbridge-structs" -version = "0.24.0" -source = "git+https://github.com/heliaxdev/ethbridge-rs?tag=v0.24.0#d66708bb8a734111988b9eaf08c7473bd7020c00" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7b3e89a2332887bf096cd589ac5781a6664b4fb0881506aa99b2be32e8e086" dependencies = [ "ethabi", ] @@ -1658,15 +1652,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" -[[package]] -name = "index-set" -version = "0.8.0" -source = "git+https://github.com/heliaxdev/index-set?tag=v0.8.1#b0d928f83cf0d465ccda299d131e8df2859b5184" -dependencies = [ - "borsh", - "serde", -] - [[package]] name = "indexmap" version = "2.2.4" @@ -1974,7 +1959,6 @@ version = "0.46.1" dependencies = [ "bech32", "borsh", - "borsh-ext", "chrono", "data-encoding", "ed25519-consensus", @@ -1984,7 +1968,6 @@ dependencies = [ "ibc", "ics23", "impl-num-traits", - "index-set", "indexmap 2.2.4", "k256", "masp_primitives", @@ -2009,6 +1992,7 @@ dependencies = [ "tiny-keccak", "tracing", "uint", + "usize-set", "zeroize", ] @@ -3325,16 +3309,18 @@ dependencies = [ [[package]] name = "smooth-operator" -version = "0.7.0" -source = "git+https://github.com/heliaxdev/smooth-operator?tag=v0.7.0#0e182707f5e5bb9c6e0efa2d235dc9efd715d0a1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dece39b9b4d19edc6399498b056d1511135b70b5adf7822affdedf5715598" dependencies = [ "smooth-operator-impl", ] [[package]] name = "smooth-operator-impl" -version = "0.7.0" -source = "git+https://github.com/heliaxdev/smooth-operator?tag=v0.7.0#0e182707f5e5bb9c6e0efa2d235dc9efd715d0a1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "867851a695e22b0d1fc85f2f84dba29fef7e5d571f12fb23253e0b213bf190f7" dependencies = [ "proc-macro2", "quote", @@ -3902,6 +3888,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "usize-set" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12fbfdf92a2a7f550e532818381f9e8367cac2115671edb024120836f33985e9" +dependencies = [ + "borsh", + "serde", +] + [[package]] name = "version_check" version = "0.9.4"