diff --git a/Cargo.lock b/Cargo.lock index 49188b7254..d04ce78bd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4141,7 +4141,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "borsh 1.2.1", "chacha20", @@ -4154,7 +4154,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "aes", "bip0039", @@ -4186,7 +4186,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "bellman", "blake2b_simd", @@ -4699,6 +4699,7 @@ version = "0.36.1" dependencies = [ "borsh 1.2.1", "data-encoding", + "masp_primitives", "masp_proofs", "namada_apps_lib", "namada_macros", diff --git a/Cargo.toml b/Cargo.toml index eef45461eb..1f9c58f492 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,8 +125,8 @@ libc = "0.2.97" libloading = "0.7.2" linkme = "0.3.24" # branch = "main" -masp_primitives = { git = "https://github.com/anoma/masp", rev = "3aacc707c5948e7423589ac617305448bead9842" } -masp_proofs = { git = "https://github.com/anoma/masp", rev = "3aacc707c5948e7423589ac617305448bead9842", default-features = false, features = ["local-prover"] } +masp_primitives = { git = "https://github.com/anoma/masp", rev = "4ede1c42d76d6348af8224bc8bfac4404321fe82" } +masp_proofs = { git = "https://github.com/anoma/masp", rev = "4ede1c42d76d6348af8224bc8bfac4404321fe82", default-features = false, features = ["local-prover"] } num256 = "0.3.5" num_cpus = "1.13.0" num-derive = "0.4" diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index f1d6d672ee..2d6c060c4d 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -801,6 +801,7 @@ pub mod testing { use borsh_ext::BorshSerializeExt; use governance::ProposalType; use ibc::primitives::proto::Any; + use masp_primitives::transaction::components::sapling::builder::StoredBuildParams; use masp_primitives::transaction::TransparentAddress; use namada_account::{InitAccount, UpdateAccount}; use namada_core::address::testing::{ @@ -870,6 +871,7 @@ pub mod testing { VoteProposal(VoteProposalData), Withdraw(Withdraw), Transfer(Transfer), + MaspTransfer(Transfer, (StoredBuildParams, String)), Bond(Bond), Redelegation(Redelegation), UpdateStewardCommission(UpdateStewardCommission), @@ -1067,7 +1069,7 @@ pub mod testing { mut header in arb_header(), wrapper in arb_wrapper_tx(), code_hash in arb_hash(), - (masp_tx_type, (shielded_transfer, asset_types)) in prop_oneof![ + (masp_tx_type, (shielded_transfer, asset_types, build_params)) in prop_oneof![ (Just(MaspTxType::Shielded), arb_shielded_transfer(0..MAX_ASSETS)), (Just(MaspTxType::Shielding), arb_shielding_transfer(encode_address(&transfer.source), 1)), (Just(MaspTxType::Deshielding), arb_deshielding_transfer(encode_address(&transfer.target), 1)), @@ -1116,7 +1118,9 @@ pub mod testing { // Link the Builder to the Transaction by hash code target: masp_tx_hash, }); - (tx, TxData::Transfer(transfer)) + let build_param_bytes = + data_encoding::HEXLOWER.encode(&build_params.serialize_to_vec()); + (tx, TxData::MaspTransfer(transfer, (build_params, build_param_bytes))) } } diff --git a/crates/sdk/src/masp.rs b/crates/sdk/src/masp.rs index 7247d3e2c5..9b10163a24 100644 --- a/crates/sdk/src/masp.rs +++ b/crates/sdk/src/masp.rs @@ -2219,6 +2219,7 @@ pub mod testing { use masp_primitives::sapling::prover::TxProver; use masp_primitives::sapling::redjubjub::Signature; use masp_primitives::sapling::{ProofGenerationKey, Rseed}; + use masp_primitives::transaction::components::sapling::builder::StoredBuildParams; use masp_primitives::transaction::components::GROTH_PROOF_SIZE; use masp_proofs::bellman::groth16::Proof; use proptest::prelude::*; @@ -2990,19 +2991,20 @@ pub mod testing { prover_rng in arb_rng().prop_map(TestCsprng), mut rng in arb_rng().prop_map(TestCsprng), bparams_rng in arb_rng().prop_map(TestCsprng), - ) -> (ShieldedTransfer, HashMap) { + ) -> (ShieldedTransfer, HashMap, StoredBuildParams) { + let mut rng_build_params = RngBuildParams::new(bparams_rng); let (masp_tx, metadata) = builder.clone().build( &MockTxProver(Mutex::new(prover_rng)), &FeeRule::non_standard(U64Sum::zero()), &mut rng, - &mut RngBuildParams::new(bparams_rng), + &mut rng_build_params, ).unwrap(); (ShieldedTransfer { builder: builder.map_builder(WalletMap), metadata, masp_tx, epoch, - }, asset_types) + }, asset_types, rng_build_params.to_stored().unwrap()) } } @@ -3020,19 +3022,20 @@ pub mod testing { prover_rng in arb_rng().prop_map(TestCsprng), mut rng in arb_rng().prop_map(TestCsprng), bparams_rng in arb_rng().prop_map(TestCsprng), - ) -> (ShieldedTransfer, HashMap) { + ) -> (ShieldedTransfer, HashMap, StoredBuildParams) { + let mut rng_build_params = RngBuildParams::new(bparams_rng); let (masp_tx, metadata) = builder.clone().build( &MockTxProver(Mutex::new(prover_rng)), &FeeRule::non_standard(U64Sum::zero()), &mut rng, - &mut RngBuildParams::new(bparams_rng), + &mut rng_build_params, ).unwrap(); (ShieldedTransfer { builder: builder.map_builder(WalletMap), metadata, masp_tx, epoch, - }, asset_types) + }, asset_types, rng_build_params.to_stored().unwrap()) } } @@ -3050,19 +3053,20 @@ pub mod testing { prover_rng in arb_rng().prop_map(TestCsprng), mut rng in arb_rng().prop_map(TestCsprng), bparams_rng in arb_rng().prop_map(TestCsprng), - ) -> (ShieldedTransfer, HashMap) { + ) -> (ShieldedTransfer, HashMap, StoredBuildParams) { + let mut rng_build_params = RngBuildParams::new(bparams_rng); let (masp_tx, metadata) = builder.clone().build( &MockTxProver(Mutex::new(prover_rng)), &FeeRule::non_standard(U64Sum::zero()), &mut rng, - &mut RngBuildParams::new(bparams_rng), + &mut rng_build_params, ).unwrap(); (ShieldedTransfer { builder: builder.map_builder(WalletMap), metadata, masp_tx, epoch, - }, asset_types) + }, asset_types, rng_build_params.to_stored().unwrap()) } } } diff --git a/examples/Cargo.toml b/examples/Cargo.toml index a95700f17a..d5303d31fd 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -28,6 +28,7 @@ path = "make-db-migration.rs" namada-eth-bridge = ["namada_sdk/namada-eth-bridge"] [dev-dependencies] +masp_primitives = { workspace = true, features = ["transparent-inputs"] } masp_proofs = { workspace = true, default-features = false, features = ["local-prover", "download-params"] } namada_apps_lib = {path = "../crates/apps_lib", features = ["migrations"]} namada_macros = {path = "../crates/macros"} diff --git a/examples/tx_schema.rs b/examples/tx_schema.rs index e3d678eefe..1fcf24e162 100644 --- a/examples/tx_schema.rs +++ b/examples/tx_schema.rs @@ -1,6 +1,7 @@ use std::collections::BTreeMap; use std::error::Error; +use masp_primitives::transaction::components::sapling::builder::StoredBuildParams; use namada_sdk::borsh::BorshSchema; use namada_sdk::tx::Tx; @@ -12,6 +13,7 @@ fn main() -> Result<(), Box> { } let mut definitions = BTreeMap::new(); Tx::add_definitions_recursively(&mut definitions); + StoredBuildParams::add_definitions_recursively(&mut definitions); std::fs::write(&args[1], format!("{:#?}", definitions)) .expect("unable to save schema"); Ok(()) diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 71e195bbf1..0c8c434430 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -3384,7 +3384,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "borsh 1.4.0", "chacha20", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "aes", "bip0039", @@ -3429,7 +3429,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "bellman", "blake2b_simd", diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index aacadf28d1..2403064f78 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -3364,7 +3364,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "borsh 1.2.1", "chacha20", @@ -3377,7 +3377,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "aes", "bip0039", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=3aacc707c5948e7423589ac617305448bead9842#3aacc707c5948e7423589ac617305448bead9842" +source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" dependencies = [ "bellman", "blake2b_simd",