Skip to content

Commit

Permalink
Generate Tx Borsh schema using the latest MASP schema, whilst avoidin…
Browse files Browse the repository at this point in the history
…g name collissions.
  • Loading branch information
murisi committed Mar 21, 2024
1 parent 5e0b162 commit 582537d
Show file tree
Hide file tree
Showing 35 changed files with 252 additions and 179 deletions.
6 changes: 3 additions & 3 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 @@ -116,8 +116,8 @@ libc = "0.2.97"
libloading = "0.7.2"
linkme = "0.3.24"
# branch = "murisi/namada-integration"
masp_primitives = { git = "https://github.com/anoma/masp", rev = "30492323d98b0531fd18b6285cd94afcaa4066d2" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "30492323d98b0531fd18b6285cd94afcaa4066d2", default-features = false, features = ["local-prover"] }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "6cbc8bd90a71cc280492c44bc3415162093daa76" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "6cbc8bd90a71cc280492c44bc3415162093daa76", default-features = false, features = ["local-prover"] }
num256 = "0.3.5"
num_cpus = "1.13.0"
num-derive = "0.3.3"
Expand Down
6 changes: 3 additions & 3 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use namada::ledger::queries::{
use namada::state::StorageRead;
use namada::tx::data::pos::Bond;
use namada::tx::data::{TxResult, VpsResult};
use namada::tx::{Code, Data, Section, Signature, Tx};
use namada::tx::{Authorization, Code, Data, Section, Tx};
use namada::vm::wasm::run;
use namada::{proof_of_stake, tendermint};
use namada_sdk::masp::{
Expand Down Expand Up @@ -319,7 +319,7 @@ impl BenchShell {
}

for signer in signers {
tx.add_section(Section::Signature(Signature::new(
tx.add_section(Section::Authorization(Authorization::new(

Check warning on line 322 in crates/apps/src/lib/bench_utils.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/bench_utils.rs#L322

Added line #L322 was not covered by tests
vec![tx.raw_header_hash()],
[(0, signer.clone())].into_iter().collect(),
None,
Expand Down Expand Up @@ -586,7 +586,7 @@ pub fn generate_foreign_key_tx(signer: &SecretKey) -> Tx {
}
.serialize_to_vec(),
));
tx.add_section(Section::Signature(Signature::new(
tx.add_section(Section::Authorization(Authorization::new(

Check warning on line 589 in crates/apps/src/lib/bench_utils.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/bench_utils.rs#L589

Added line #L589 was not covered by tests
vec![tx.raw_header_hash()],
[(0, signer.clone())].into_iter().collect(),
None,
Expand Down
4 changes: 2 additions & 2 deletions crates/apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub async fn with_hardware_wallet<'a, U: WalletIo + Clone>(
};
// Expand out the signature before adding it to the
// transaction
tx.add_section(Section::Signature(compressed.expand(&tx)));
tx.add_section(Section::Authorization(compressed.expand(&tx)));

Check warning on line 136 in crates/apps/src/lib/client/tx.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/tx.rs#L136

Added line #L136 was not covered by tests
}
// Sign the fee header if that is requested
if parts.contains(&signing::Signable::FeeHeader) {
Expand All @@ -151,7 +151,7 @@ pub async fn with_hardware_wallet<'a, U: WalletIo + Clone>(
};
// Expand out the signature before adding it to the
// transaction
tx.add_section(Section::Signature(compressed.expand(&tx)));
tx.add_section(Section::Authorization(compressed.expand(&tx)));

Check warning on line 154 in crates/apps/src/lib/client/tx.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/tx.rs#L154

Added line #L154 was not covered by tests
}
Ok(tx)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/apps/src/lib/config/genesis/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ impl<T> Signed<T> {
.sections
.into_iter()
.find_map(|sec| {
if let Section::Signature(signatures) = sec {
if let Section::Authorization(signatures) = sec {

Check warning on line 805 in crates/apps/src/lib/config/genesis/transactions.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/config/genesis/transactions.rs#L805

Added line #L805 was not covered by tests
if [raw_header_hash] == signatures.targets.as_slice() {
Some(signatures)
} else {
Expand Down
14 changes: 7 additions & 7 deletions crates/apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ mod test_finalize_block {
use namada::tendermint::abci::types::{Misbehavior, MisbehaviorKind};
use namada::token::{Amount, DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES};
use namada::tx::data::Fee;
use namada::tx::{Code, Data, Signature};
use namada::tx::{Authorization, Code, Data};
use namada::vote_ext::ethereum_events;
use namada_sdk::eth_bridge::MinimumConfirmations;
use namada_sdk::governance::ProposalVote;
Expand Down Expand Up @@ -825,7 +825,7 @@ mod test_finalize_block {
wrapper_tx.set_data(Data::new(
"Encrypted transaction data".as_bytes().to_owned(),
));
wrapper_tx.add_section(Section::Signature(Signature::new(
wrapper_tx.add_section(Section::Authorization(Authorization::new(
wrapper_tx.sechashes(),
[(0, keypair.clone())].into_iter().collect(),
None,
Expand Down Expand Up @@ -2779,12 +2779,12 @@ mod test_finalize_block {
GAS_LIMIT_MULTIPLIER.into(),
None,
))));
new_wrapper.add_section(Section::Signature(Signature::new(
new_wrapper.add_section(Section::Authorization(Authorization::new(
new_wrapper.sechashes(),
[(0, keypair_2)].into_iter().collect(),
None,
)));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
Expand Down Expand Up @@ -3068,7 +3068,7 @@ mod test_finalize_block {
wrapper.set_data(Data::new(
"Encrypted transaction data".as_bytes().to_owned(),
));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
Expand Down Expand Up @@ -3147,7 +3147,7 @@ mod test_finalize_block {
wrapper.set_data(Data::new(
"Encrypted transaction data".as_bytes().to_owned(),
));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, keypair.clone())].into_iter().collect(),
None,
Expand Down Expand Up @@ -3230,7 +3230,7 @@ mod test_finalize_block {
wrapper.set_data(Data::new(
"Enxrypted transaction data".as_bytes().to_owned(),
));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, crate::wallet::defaults::albert_keypair())]
.into_iter()
Expand Down
32 changes: 17 additions & 15 deletions crates/apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ mod shell_tests {
use namada::token::read_denom;
use namada::tx::data::protocol::{ProtocolTx, ProtocolTxType};
use namada::tx::data::Fee;
use namada::tx::{Code, Data, Signature, Signed};
use namada::tx::{Authorization, Code, Data, Signed};
use namada::vote_ext::{
bridge_pool_roots, ethereum_events, ethereum_tx_data_variants,
};
Expand Down Expand Up @@ -2375,7 +2375,7 @@ mod shell_tests {
// invalid tx type, it doesn't match the
// tx type declared in the header
tx.set_data(Data::new(ext.serialize_to_vec()));
tx.add_section(Section::Signature(Signature::new(
tx.add_section(Section::Authorization(Authorization::new(
tx.sechashes(),
[(0, protocol_key)].into_iter().collect(),
None,
Expand Down Expand Up @@ -2452,11 +2452,13 @@ mod shell_tests {
.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
invalid_wrapper
.set_data(Data::new("transaction data".as_bytes().to_owned()));
invalid_wrapper.add_section(Section::Signature(Signature::new(
invalid_wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
)));
invalid_wrapper.add_section(Section::Authorization(
Authorization::new(
invalid_wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
),
));

// we mount a malleability attack to try and remove the fee
let mut new_wrapper =
Expand Down Expand Up @@ -2522,7 +2524,7 @@ mod shell_tests {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
Expand Down Expand Up @@ -2675,7 +2677,7 @@ mod shell_tests {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
Expand Down Expand Up @@ -2708,7 +2710,7 @@ mod shell_tests {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
Expand Down Expand Up @@ -2747,7 +2749,7 @@ mod shell_tests {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, crate::wallet::defaults::albert_keypair())]
.into_iter()
Expand Down Expand Up @@ -2782,7 +2784,7 @@ mod shell_tests {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, crate::wallet::defaults::albert_keypair())]
.into_iter()
Expand Down Expand Up @@ -2818,7 +2820,7 @@ mod shell_tests {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, crate::wallet::defaults::albert_keypair())]
.into_iter()
Expand Down Expand Up @@ -2854,7 +2856,7 @@ mod shell_tests {
wrapper.header.chain_id = shell.chain_id.clone();
wrapper.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new("transaction data".as_bytes().to_owned()));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, crate::wallet::defaults::albert_keypair())]
.into_iter()
Expand Down Expand Up @@ -2902,7 +2904,7 @@ mod shell_tests {
wrapper
.set_code(Code::new("wasm_code".as_bytes().to_owned(), None));
wrapper.set_data(Data::new(vec![0; size as usize]));
wrapper.add_section(Section::Signature(Signature::new(
wrapper.add_section(Section::Authorization(Authorization::new(
wrapper.sechashes(),
[(0, keypair)].into_iter().collect(),
None,
Expand Down
Loading

0 comments on commit 582537d

Please sign in to comment.