Skip to content

Commit

Permalink
Generate a parser for MASP transactions.
Browse files Browse the repository at this point in the history
  • Loading branch information
murisi committed Feb 27, 2024
1 parent 5901dcb commit 9e7e21c
Show file tree
Hide file tree
Showing 12 changed files with 597 additions and 32 deletions.
11 changes: 6 additions & 5 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ ledger-transport-hid = "0.10.0"
libc = "0.2.97"
libloading = "0.7.2"
# branch = "murisi/namada-integration"
masp_primitives = { git = "https://github.com/anoma/masp", tag = "v1.1.0" }
masp_proofs = { git = "https://github.com/anoma/masp", tag = "v1.1.0", default-features = false, features = ["local-prover"] }
masp_primitives = { git = "https://github.com/anoma/masp", branch = "murisi/borsh-schemas" }
masp_proofs = { git = "https://github.com/anoma/masp", branch = "murisi/borsh-schemas", default-features = false, features = ["local-prover"] }
num256 = "0.3.5"
num_cpus = "1.13.0"
num-derive = "0.3.3"
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/types/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::fmt::Display;
use std::str::FromStr;

use borsh::{BorshDeserialize, BorshSerialize};
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh_ext::BorshSerializeExt;
use masp_primitives::asset_type::AssetType;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -31,6 +31,7 @@ use crate::types::token::{Denomination, MaspDigitPos};
Hash,
Serialize,
Deserialize,
BorshSchema,
)]
pub struct AssetData {
/// The token associated with this asset type
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/types/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ impl From<Amount> for Uint {
BorshDeserialize,
Serialize,
Deserialize,
BorshSchema,
)]
#[repr(u8)]
#[allow(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ pub mod testing {
}

// Maximum number of notes to include in a transaction
const MAX_ASSETS: usize = 10;
const MAX_ASSETS: usize = 2;

// Type of MASP transaction
#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/src/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3184,7 +3184,7 @@ pub mod testing {
// Maximum value for a note partition
const MAX_MONEY: u64 = 100;
// Maximum number of partitions for a note
const MAX_SPLITS: usize = 10;
const MAX_SPLITS: usize = 3;

prop_compose! {
// Arbitrarily partition the given vector of integers into sets and sum
Expand Down
22 changes: 7 additions & 15 deletions crates/tx/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,13 @@ impl From<SaplingMetadataSerde> for Vec<u8> {
/// A section providing the auxiliary inputs used to construct a MASP
/// transaction
#[derive(
Clone, Debug, BorshSerialize, BorshDeserialize, Serialize, Deserialize,
Clone,
Debug,
BorshSerialize,
BorshDeserialize,
Serialize,
Deserialize,
BorshSchema,
)]
pub struct MaspBuilder {
/// The MASP transaction that this section witnesses
Expand Down Expand Up @@ -684,20 +690,6 @@ impl MaspBuilder {
}
}

impl borsh::BorshSchema for MaspBuilder {
fn add_definitions_recursively(
_definitions: &mut BTreeMap<
borsh::schema::Declaration,
borsh::schema::Definition,
>,
) {
}

fn declaration() -> borsh::schema::Declaration {
"Builder".into()
}
}

/// A section of a transaction. Carries an independent piece of information
/// necessary for the processing of a transaction.
#[derive(
Expand Down
5 changes: 5 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ version.workspace = true
name = "generate-txs"
path = "generate_txs.rs"

[[example]]
name = "generate-parser"
path = "generate_parser.rs"

[dev-dependencies]
masp_primitives.workspace = true
masp_proofs = { workspace = true, default-features = false, features = ["local-prover", "download-params"] }
namada_sdk = { path = "../crates/sdk", default-features = false, features = ["namada-sdk", "std", "testing"] }
proptest.workspace = true
Expand Down
Loading

0 comments on commit 9e7e21c

Please sign in to comment.