Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ac39259
Adds multiple tx commitments in `Header`
grarco Apr 5, 2024
086a8a8
Updates core tx methods and masp client functions
grarco Apr 15, 2024
9bfed1c
Adds `BatchedTx` struct and updated the native vps and transactions e…
grarco Apr 17, 2024
50518ea
Updates logs and tx result to support batching
grarco Apr 19, 2024
167204f
Updates contexts for batched transactions. Misc updates to protocol
grarco Apr 21, 2024
1da5b0a
Generic `TxResult`
grarco Apr 21, 2024
5853fb1
Introduces `OwnedBatchedTx` for benchmarks. Fixes benches and tests
grarco Apr 21, 2024
6374f1a
Improves handling of txs' results in `dispatch_tx` and `finalize_block`
grarco Apr 22, 2024
3a846bd
Updates `WriteLog` to support tx batches
grarco Apr 23, 2024
8fdea42
Misc updates to write log. Updates tx result handling in `finalize_bl…
grarco Apr 24, 2024
7267a43
Renames batched txs structs
grarco Apr 26, 2024
da34ab9
Updates wasm interface and codes
grarco Apr 26, 2024
af4513d
Fixes wasm for test. Clippy + fmt
grarco Apr 26, 2024
eace62f
Updates `VpEval`
grarco Apr 26, 2024
c4d19fa
Recomputes genesis signatures. Fixes missing commitments in tests
grarco Apr 28, 2024
b4176e9
Rebuilds wasm for tests
grarco Apr 28, 2024
55dae06
Fixes serialization of tx result and unit tests
grarco Apr 28, 2024
2fd7f4c
Refactors test envs
grarco Apr 28, 2024
b342781
Fixes wasm tests
grarco Apr 28, 2024
aaf26c4
Fixes integration tests
grarco Apr 29, 2024
07ec96e
Fixes benchmarks
grarco Apr 29, 2024
baac8ec
Misc refactoring
grarco Apr 29, 2024
593be95
More refactoring
grarco Apr 30, 2024
a50b4d8
Removes custom borsh impls for `BatchedTx` and `BatchedTxRef`
grarco Apr 30, 2024
25bb28c
Refactors tx result handling in `finalize_block`
grarco Apr 30, 2024
dc364c6
Refactors the batch write log
grarco Apr 30, 2024
db3e688
Renames `Commitments` and update docs
grarco Apr 30, 2024
4d0d34e
Adds an SDK function to construct tx batches
grarco Apr 30, 2024
3ec07af
Updates comments
grarco Apr 30, 2024
39ae3e9
Fixes tx interface to attach a new inner tx
grarco Apr 30, 2024
fedccfa
Adds new `mk_tx_batch` for unit testing
grarco Apr 30, 2024
74d11f8
Updates `add_inner_tx` to avoid duplicated sections
grarco May 1, 2024
245c702
Removes unused `Ciphertext` section
grarco May 1, 2024
0798717
Merge branch 'v0.34.0' into grarco/tx-batch
grarco May 1, 2024
2a55ca4
Clippy fix
grarco May 1, 2024
709de20
Recomputes signatures for localnet genesis
grarco May 1, 2024
6665cb1
Fixes fee payemnt logic and unit tests
grarco May 1, 2024
502efc5
Fixes bug in wrapper keys
grarco May 2, 2024
32d2888
Merge branch 'base' into grarco/tx-batch
grarco May 2, 2024
f6448d3
Updates error message in ibc test
grarco May 2, 2024
704ce45
Updates tx types comparisons and avoid duplicated signatures for batches
grarco May 2, 2024
e8090ed
Adds unit tests for tx batches
grarco May 2, 2024
08c93e4
Changelog #1356
grarco May 2, 2024
c918b37
Reverts `TryFrom` impls for ethereum data to `Tx`
grarco May 3, 2024
77326c7
Refactors stats accounting
grarco May 3, 2024
4be5dbc
Renames `TxInfo` and fixes write log commit in `finalize_block`
grarco May 4, 2024
6b1a5e1
Refactors `evaluate_tx_result`. Updates stats
grarco May 4, 2024
047a00d
Changes error code for batches. Fixes missing events
grarco May 5, 2024
2bd903d
Extracts ok tx result evaluation to a separate function
grarco May 5, 2024
d5c50c9
Removes broken batch section optimization
grarco May 6, 2024
93376c7
Reverts wrong shielded sync cli changes
grarco May 6, 2024
d5b4bb5
Restores shielded sync struct in the sdk
grarco May 6, 2024
cfb6cc3
Better handling of batch errors
grarco May 6, 2024
86515cf
Appends inner tx result even in case of out of gas
grarco May 6, 2024
c4410f2
More unit tests for tx batching
grarco May 6, 2024
678f029
Drops duplicated events for errored batch
grarco May 6, 2024
47ccfd3
Preserve txs order when constructing batch in the sdk
grarco May 7, 2024
7874576
Refactors match on inner tx result
grarco May 7, 2024
c1e7f7e
Improves unit tests for batches
grarco May 7, 2024
7b26560
Misc refactors, fixes typo
grarco May 7, 2024
9422864
Refactors buckets in write log with iterator chains
grarco May 7, 2024
525d044
Refactors validity booleans into a `ValidityFlags` struct
grarco May 7, 2024
0a40071
Implements a `get_tx_data` method on `Ctx`
grarco May 7, 2024
8ab0f38
Short-circuit atomic batches at the first failure
grarco May 7, 2024
01510ea
Refactors masp events to avoid dynamic attributes
grarco May 8, 2024
db8fa36
Refactors `dispatch_tx` to return a result
grarco May 8, 2024
7f4b6c1
Merge branch 'v0.35.1' into grarco/tx-batch
grarco May 10, 2024
97a2d8d
Restores `batch_size` arg for `fetch`
grarco May 16, 2024
d460c09
Removes `unshield_section_hash` from `WrapperTx`. Updates the relativ…
grarco May 8, 2024
747e2f6
Removes fee unshielding cli and tx args
grarco May 8, 2024
01de2ab
Removes redundandt wrapper types
grarco May 9, 2024
8572a1e
Removes `descriptions_limit` protocol param
grarco May 9, 2024
cd834a3
Removes error/functions related to fee unshielding
grarco May 9, 2024
9b7351b
Renames `wrapper_fee_check`
grarco May 9, 2024
bd14c9d
Reworks sdk fee validation
grarco May 9, 2024
57d2cbe
Updates TODO comments
grarco May 9, 2024
8ab87d4
Recomputes wasm for tests modules
grarco May 9, 2024
732d3f2
Recomputes tx test fixture
grarco May 9, 2024
da6b779
Removes fee unshielding integration tests
grarco May 9, 2024
3fa05cd
Removes fee unshielding e2e test
grarco May 9, 2024
268adf0
Removes `wrapper_changed_keys` from `TxResult`
grarco May 13, 2024
6fe09f3
Assigns issues to TODOs
grarco May 15, 2024
c2e98ab
Changelog #3217
grarco May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/1356-tx-batch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Introduced transaction batches.
([\#1356](https://github.com/anoma/namada/pull/1356))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/3217-masp-fees.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Removed fee unshielding from wrapper transactions.
([\#3217](https://github.com/anoma/namada/pull/3217))
3 changes: 3 additions & 0 deletions Cargo.lock

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

88 changes: 60 additions & 28 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use namada::core::masp::{
use namada::core::storage::{BlockHeight, Epoch, Key, KeySeg, TxIndex};
use namada::core::time::DateTimeUtc;
use namada::core::token::{Amount, DenominatedAmount, Transfer};
use namada::events::extend::{ComposeEvent, ValidMaspTx};
use namada::events::extend::{ComposeEvent, MaspTxBatchRefs, MaspTxBlockIndex};
use namada::events::Event;
use namada::governance::storage::proposal::ProposalType;
use namada::governance::InitProposalData;
Expand Down Expand Up @@ -74,9 +74,13 @@ use namada::ledger::queries::{
};
use namada::state::StorageRead;
use namada::tx::data::pos::Bond;
use namada::tx::data::{Fee, TxResult, VpsResult};
use namada::tx::event::{new_tx_event, InnerTx};
use namada::tx::{Authorization, Code, Data, Section, Tx};
use namada::tx::data::{
BatchResults, BatchedTxResult, Fee, TxResult, VpsResult,
};
use namada::tx::event::{new_tx_event, Batch};
use namada::tx::{
Authorization, BatchedTx, BatchedTxRef, Code, Data, Section, Tx,
};
use namada::vm::wasm::run;
use namada::{proof_of_stake, tendermint};
use namada_sdk::masp::{
Expand Down Expand Up @@ -240,7 +244,7 @@ impl Default for BenchShell {
vec![&defaults::albert_keypair()],
);

bench_shell.execute_tx(&signed_tx);
bench_shell.execute_tx(&signed_tx.to_ref());
bench_shell.state.commit_tx();

// Initialize governance proposal
Expand All @@ -265,7 +269,7 @@ impl Default for BenchShell {
vec![&defaults::albert_keypair()],
);

bench_shell.execute_tx(&signed_tx);
bench_shell.execute_tx(&signed_tx.to_ref());
bench_shell.state.commit_tx();
bench_shell.commit_block();

Expand All @@ -291,7 +295,7 @@ impl BenchShell {
shielded: Option<Transaction>,
extra_sections: Option<Vec<Section>>,
signers: Vec<&SecretKey>,
) -> Tx {
) -> BatchedTx {
let mut tx = Tx::from_type(namada::tx::data::TxType::Raw);

// NOTE: here we use the code hash to avoid including the cost for the
Expand Down Expand Up @@ -327,10 +331,15 @@ impl BenchShell {
)));
}

tx
let cmt = tx.first_commitments().unwrap().clone();
tx.batch_tx(cmt)
}

pub fn generate_ibc_tx(&self, wasm_code_path: &str, data: Vec<u8>) -> Tx {
pub fn generate_ibc_tx(
&self,
wasm_code_path: &str,
data: Vec<u8>,
) -> BatchedTx {
// This function avoid serializaing the tx data with Borsh
let mut tx = Tx::from_type(namada::tx::data::TxType::Raw);
let code_hash = self
Expand All @@ -343,10 +352,11 @@ impl BenchShell {

tx.set_data(Data::new(data));
// NOTE: the Ibc VP doesn't actually check the signature
tx
let cmt = tx.first_commitments().unwrap().clone();
tx.batch_tx(cmt)
}

pub fn generate_ibc_transfer_tx(&self) -> Tx {
pub fn generate_ibc_transfer_tx(&self) -> BatchedTx {
let token = PrefixedCoin {
denom: address::testing::nam().to_string().parse().unwrap(),
amount: Amount::native_whole(1000)
Expand Down Expand Up @@ -390,14 +400,18 @@ impl BenchShell {
}

/// Execute the tx and return a set of verifiers inserted by the tx.
pub fn execute_tx(&mut self, tx: &Tx) -> BTreeSet<Address> {
pub fn execute_tx(
&mut self,
batched_tx: &BatchedTxRef,
) -> BTreeSet<Address> {
let gas_meter =
RefCell::new(TxGasMeter::new_from_sub_limit(u64::MAX.into()));
run::tx(
&mut self.inner.state,
&gas_meter,
&TxIndex(0),
tx,
batched_tx.tx,
batched_tx.cmt,
&mut self.inner.vp_wasm_cache,
&mut self.inner.tx_wasm_cache,
)
Expand Down Expand Up @@ -595,15 +609,14 @@ impl BenchShell {
},
defaults::albert_keypair().ref_to(),
0.into(),
None,
);
self.last_block_masp_txs
.push((masp_tx, self.state.write_log().get_keys()));
self.state.commit_tx();
}
}

pub fn generate_foreign_key_tx(signer: &SecretKey) -> Tx {
pub fn generate_foreign_key_tx(signer: &SecretKey) -> BatchedTx {
let wasm_code =
std::fs::read("../../wasm_for_tests/tx_write.wasm").unwrap();

Expand All @@ -622,7 +635,8 @@ pub fn generate_foreign_key_tx(signer: &SecretKey) -> Tx {
None,
)));

tx
let cmt = tx.first_commitments().unwrap().clone();
tx.batch_tx(cmt)
}

pub struct BenchShieldedCtx {
Expand Down Expand Up @@ -885,17 +899,33 @@ impl Client for BenchShell {
.iter()
.enumerate()
.map(|(idx, (tx, changed_keys))| {
let tx_result = TxResult {
let tx_result = TxResult::<String> {
gas_used: 0.into(),
wrapper_changed_keys: Default::default(),
changed_keys: changed_keys.to_owned(),
vps_result: VpsResult::default(),
initialized_accounts: vec![],
events: BTreeSet::default(),
batch_results: BatchResults(
[(
tx.first_commitments().unwrap().get_hash(),
Ok(BatchedTxResult {
changed_keys: changed_keys.to_owned(),
vps_result: VpsResult::default(),
initialized_accounts: vec![],
events: BTreeSet::default(),
}),
)]
.into_iter()
.collect(),
),
};
let event: Event = new_tx_event(tx, height.value())
.with(InnerTx(&tx_result))
.with(ValidMaspTx(TxIndex::must_from_usize(idx)))
.with(Batch(&tx_result))
.with(MaspTxBlockIndex(TxIndex::must_from_usize(
idx,
)))
.with(MaspTxBatchRefs(
vec![
tx.first_commitments().unwrap().get_hash(),
]
.into(),
))
.into();
namada::tendermint::abci::Event::from(event)
})
Expand Down Expand Up @@ -1005,7 +1035,7 @@ impl BenchShieldedCtx {
amount: Amount,
source: TransferSource,
target: TransferTarget,
) -> (Self, Tx) {
) -> (Self, BatchedTx) {
let denominated_amount = DenominatedAmount::native(amount);
let async_runtime = tokio::runtime::Runtime::new().unwrap();
let spending_key = self
Expand Down Expand Up @@ -1101,7 +1131,7 @@ impl BenchShieldedCtx {
amount: Amount,
source: TransferSource,
target: TransferTarget,
) -> (Self, Tx) {
) -> (Self, BatchedTx) {
let (ctx, tx) = self.generate_masp_tx(
amount,
source.clone(),
Expand Down Expand Up @@ -1141,8 +1171,10 @@ impl BenchShieldedCtx {
};

let transfer =
Transfer::deserialize(&mut tx.data().unwrap().as_slice()).unwrap();
Transfer::deserialize(&mut tx.tx.data(&tx.cmt).unwrap().as_slice())
.unwrap();
let masp_tx = tx
.tx
.get_section(&transfer.shielded.unwrap())
.unwrap()
.masp_tx()
Expand All @@ -1155,7 +1187,7 @@ impl BenchShieldedCtx {
let mut ibc_tx = ctx
.shell
.generate_ibc_tx(TX_IBC_WASM, msg.serialize_to_vec());
ibc_tx.add_masp_tx_section(masp_tx);
ibc_tx.tx.add_masp_tx_section(masp_tx);

(ctx, ibc_tx)
}
Expand Down
26 changes: 5 additions & 21 deletions crates/apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3089,8 +3089,6 @@ pub mod args {
pub const EXPIRATION_OPT: ArgOpt<DateTimeUtc> = arg_opt("expiration");
pub const EMAIL: Arg<String> = arg("email");
pub const EMAIL_OPT: ArgOpt<String> = EMAIL.opt();
pub const FEE_UNSHIELD_SPENDING_KEY: ArgOpt<WalletTransferSource> =
arg_opt("gas-spending-key");
pub const FEE_AMOUNT_OPT: ArgOpt<token::DenominatedAmount> =
arg_opt("gas-price");
pub const FEE_PAYER_OPT: ArgOpt<WalletPublicKey> = arg_opt("gas-payer");
Expand Down Expand Up @@ -6409,9 +6407,6 @@ pub mod args {
wallet_alias_force: self.wallet_alias_force,
fee_amount: self.fee_amount,
fee_token: ctx.get(&self.fee_token).into(),
fee_unshield: self
.fee_unshield
.map(|ref fee_unshield| ctx.get_cached(fee_unshield)),
gas_limit: self.gas_limit,
signing_keys: self
.signing_keys
Expand Down Expand Up @@ -6487,10 +6482,6 @@ pub mod args {
this transaction",
))
.arg(FEE_TOKEN.def().help("The token for paying the gas"))
.arg(FEE_UNSHIELD_SPENDING_KEY.def().help(
"The spending key to be used for fee unshielding. If none is \
provided, fee will be paid from the unshielded balance only.",
))
.arg(GAS_LIMIT.def().help(
"The multiplier of the gas limit resolution defining the \
maximum amount of gas needed to run transaction.",
Expand Down Expand Up @@ -6520,16 +6511,11 @@ pub mod args {
)
.conflicts_with_all([EXPIRATION_OPT.name]),
)
.arg(
DISPOSABLE_SIGNING_KEY
.def()
.help(
"Generates an ephemeral, disposable keypair to sign \
the wrapper transaction. This keypair will be \
immediately discarded after use.",
)
.requires(FEE_UNSHIELD_SPENDING_KEY.name),
)
.arg(DISPOSABLE_SIGNING_KEY.def().help(
"Generates an ephemeral, disposable keypair to sign the \
wrapper transaction. This keypair will be immediately \
discarded after use.",
))
.arg(
SIGNING_KEYS
.def()
Expand Down Expand Up @@ -6587,7 +6573,6 @@ pub mod args {
let fee_amount =
FEE_AMOUNT_OPT.parse(matches).map(InputAmount::Unvalidated);
let fee_token = FEE_TOKEN.parse(matches);
let fee_unshield = FEE_UNSHIELD_SPENDING_KEY.parse(matches);
let _wallet_alias_force = WALLET_ALIAS_FORCE.parse(matches);
let gas_limit = GAS_LIMIT.parse(matches);
let wallet_alias_force = WALLET_ALIAS_FORCE.parse(matches);
Expand Down Expand Up @@ -6622,7 +6607,6 @@ pub mod args {
wallet_alias_force,
fee_amount,
fee_token,
fee_unshield,
gas_limit,
expiration,
disposable_signing_key,
Expand Down
16 changes: 2 additions & 14 deletions crates/apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use namada_sdk::rpc::{
self, enriched_bonds_and_unbonds, query_epoch, TxResponse,
};
use namada_sdk::tendermint_rpc::endpoint::status;
use namada_sdk::tx::display_inner_resp;
use namada_sdk::tx::display_batch_resp;
use namada_sdk::wallet::AddressVpType;
use namada_sdk::{display, display_line, edisplay_line, error, Namada};

Expand Down Expand Up @@ -664,18 +664,6 @@ pub async fn query_protocol_parameters(
fee_unshielding_gas_limit
);

let key = param_storage::get_fee_unshielding_descriptions_limit_key();
let fee_unshielding_descriptions_limit: u64 =
query_storage_value(context.client(), &key)
.await
.expect("Parameter should be defined.");
display_line!(
context.io(),
"{:4}Fee unshielding descriptions limit: {:?}",
"",
fee_unshielding_descriptions_limit
);

let key = param_storage::get_gas_cost_key();
let gas_cost_table: BTreeMap<Address, token::Amount> =
query_storage_value(context.client(), &key)
Expand Down Expand Up @@ -1898,7 +1886,7 @@ pub async fn query_result(context: &impl Namada, args: args::QueryResult) {
cli::safe_exit(1)
}
};
display_inner_resp(context, &resp);
display_batch_resp(context, &resp);
}
Err(err) => {
// Print the errors that caused the lookups to fail
Expand Down
Loading