-
Notifications
You must be signed in to change notification settings - Fork 956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tx batching #3103
Tx batching #3103
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3103 +/- ##
==========================================
+ Coverage 60.24% 60.40% +0.16%
==========================================
Files 303 303
Lines 93191 94176 +985
==========================================
+ Hits 56145 56890 +745
- Misses 37046 37286 +240 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to the Tx
format look good to me. Given that the only change in the format is that the data, code, and memo hashes are vectorized, hardware wallet support for singleton batch transactions (where batch.len() == 1
) should be quickly achievable. But it will probably take some time to implement support non-singleton batch transactions because the hardware wallet codebase wasn't structured for holding, printing, and signing multiple transactions in one go.
ref cmt, | ||
} = tx_data; | ||
let _data = | ||
signed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably BatchedTx
would benefit from a fn data(&self) -> Option<Vec<u8>> { ... }
method. This signed.data(cmt)
pattern (where cmt
and signed
come from the same BatchedTx
) seems to be repeated somewhat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will be addressed (in some way) by #3200
|
||
/// Add a new inner tx to the transaction. Returns `false` if the | ||
/// commitments already existed in the collection. This function expects a | ||
/// transaction carrying a single inner tx as input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this function is limited to a single inner tx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment the support to build batched transactions is very limited. We'll probably want to rework the way we construct txs so for now I've implemented something minimal. The caller can invoke this function multiple times if needed
/// Add a new inner tx to the transaction. Returns `false` if the | ||
/// commitments already existed in the collection. This function expects a | ||
/// transaction carrying a single inner tx as input | ||
pub fn add_inner_tx(&mut self, other: Tx, cmt: TxCommitments) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this function is limited to a single inner tx, then I guess the pair (other, cmt)
is conceptually a BatchedTx
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you are right! Still, I think it would just be better to rework this function completely in the near future
* grarco/tx-batch: Restores `batch_size` arg for `fetch` Refactors `dispatch_tx` to return a result Refactors masp events to avoid dynamic attributes Short-circuit atomic batches at the first failure Implements a `get_tx_data` method on `Ctx` Refactors validity booleans into a `ValidityFlags` struct Refactors buckets in write log with iterator chains Misc refactors, fixes typo Improves unit tests for batches Refactors match on inner tx result Preserve txs order when constructing batch in the sdk Drops duplicated events for errored batch More unit tests for tx batching Appends inner tx result even in case of out of gas Better handling of batch errors Restores shielded sync struct in the sdk Reverts wrong shielded sync cli changes Removes broken batch section optimization Extracts ok tx result evaluation to a separate function Changes error code for batches. Fixes missing events Refactors `evaluate_tx_result`. Updates stats Renames `TxInfo` and fixes write log commit in `finalize_block` Refactors stats accounting Reverts `TryFrom` impls for ethereum data to `Tx` Changelog #1356 Adds unit tests for tx batches Updates tx types comparisons and avoid duplicated signatures for batches Updates error message in ibc test Fixes bug in wrapper keys Fixes fee payemnt logic and unit tests Recomputes signatures for localnet genesis Clippy fix Removes unused `Ciphertext` section Updates `add_inner_tx` to avoid duplicated sections Adds new `mk_tx_batch` for unit testing Fixes tx interface to attach a new inner tx Updates comments Adds an SDK function to construct tx batches Renames `Commitments` and update docs Refactors the batch write log Refactors tx result handling in `finalize_block` Removes custom borsh impls for `BatchedTx` and `BatchedTxRef` More refactoring Misc refactoring Fixes benchmarks Fixes integration tests Fixes wasm tests Refactors test envs Fixes serialization of tx result and unit tests Rebuilds wasm for tests Recomputes genesis signatures. Fixes missing commitments in tests Updates `VpEval` Fixes wasm for test. Clippy + fmt Updates wasm interface and codes Renames batched txs structs Misc updates to write log. Updates tx result handling in `finalize_block` Updates `WriteLog` to support tx batches Improves handling of txs' results in `dispatch_tx` and `finalize_block` Introduces `OwnedBatchedTx` for benchmarks. Fixes benches and tests Generic `TxResult` Updates contexts for batched transactions. Misc updates to protocol Updates logs and tx result to support batching Adds `BatchedTx` struct and updated the native vps and transactions execution Updates core tx methods and masp client functions Adds multiple tx commitments in `Header`
* origin/grarco/tx-batch: Restores `batch_size` arg for `fetch` Refactors `dispatch_tx` to return a result Refactors masp events to avoid dynamic attributes Short-circuit atomic batches at the first failure Implements a `get_tx_data` method on `Ctx` Refactors validity booleans into a `ValidityFlags` struct Refactors buckets in write log with iterator chains Misc refactors, fixes typo Improves unit tests for batches Refactors match on inner tx result Preserve txs order when constructing batch in the sdk Drops duplicated events for errored batch More unit tests for tx batching Appends inner tx result even in case of out of gas Better handling of batch errors Restores shielded sync struct in the sdk Reverts wrong shielded sync cli changes Removes broken batch section optimization Extracts ok tx result evaluation to a separate function Changes error code for batches. Fixes missing events Refactors `evaluate_tx_result`. Updates stats Renames `TxInfo` and fixes write log commit in `finalize_block` Refactors stats accounting Reverts `TryFrom` impls for ethereum data to `Tx` Changelog #1356 Adds unit tests for tx batches Updates tx types comparisons and avoid duplicated signatures for batches Updates error message in ibc test Fixes bug in wrapper keys Fixes fee payemnt logic and unit tests Recomputes signatures for localnet genesis Clippy fix Removes unused `Ciphertext` section Updates `add_inner_tx` to avoid duplicated sections Adds new `mk_tx_batch` for unit testing Fixes tx interface to attach a new inner tx Updates comments Adds an SDK function to construct tx batches Renames `Commitments` and update docs Refactors the batch write log Refactors tx result handling in `finalize_block` Removes custom borsh impls for `BatchedTx` and `BatchedTxRef` More refactoring Misc refactoring Fixes benchmarks Fixes integration tests Fixes wasm tests Refactors test envs Fixes serialization of tx result and unit tests Rebuilds wasm for tests Recomputes genesis signatures. Fixes missing commitments in tests Updates `VpEval` Fixes wasm for test. Clippy + fmt Updates wasm interface and codes Renames batched txs structs Misc updates to write log. Updates tx result handling in `finalize_block` Updates `WriteLog` to support tx batches Improves handling of txs' results in `dispatch_tx` and `finalize_block` Introduces `OwnedBatchedTx` for benchmarks. Fixes benches and tests Generic `TxResult` Updates contexts for batched transactions. Misc updates to protocol Updates logs and tx result to support batching Adds `BatchedTx` struct and updated the native vps and transactions execution Updates core tx methods and masp client functions Adds multiple tx commitments in `Header`
* origin/grarco/tx-batch: Restores `batch_size` arg for `fetch` Refactors `dispatch_tx` to return a result Refactors masp events to avoid dynamic attributes Short-circuit atomic batches at the first failure Implements a `get_tx_data` method on `Ctx` Refactors validity booleans into a `ValidityFlags` struct Refactors buckets in write log with iterator chains Misc refactors, fixes typo Improves unit tests for batches Refactors match on inner tx result Preserve txs order when constructing batch in the sdk Drops duplicated events for errored batch More unit tests for tx batching Appends inner tx result even in case of out of gas Better handling of batch errors Restores shielded sync struct in the sdk Reverts wrong shielded sync cli changes Removes broken batch section optimization Extracts ok tx result evaluation to a separate function Changes error code for batches. Fixes missing events Refactors `evaluate_tx_result`. Updates stats Renames `TxInfo` and fixes write log commit in `finalize_block` Refactors stats accounting Reverts `TryFrom` impls for ethereum data to `Tx` Changelog #1356 Adds unit tests for tx batches Updates tx types comparisons and avoid duplicated signatures for batches Updates error message in ibc test Fixes bug in wrapper keys Fixes fee payemnt logic and unit tests Recomputes signatures for localnet genesis Clippy fix Removes unused `Ciphertext` section Updates `add_inner_tx` to avoid duplicated sections Adds new `mk_tx_batch` for unit testing Fixes tx interface to attach a new inner tx Updates comments Adds an SDK function to construct tx batches Renames `Commitments` and update docs Refactors the batch write log Refactors tx result handling in `finalize_block` Removes custom borsh impls for `BatchedTx` and `BatchedTxRef` More refactoring Misc refactoring Fixes benchmarks Fixes integration tests Fixes wasm tests Refactors test envs Fixes serialization of tx result and unit tests Rebuilds wasm for tests Recomputes genesis signatures. Fixes missing commitments in tests Updates `VpEval` Fixes wasm for test. Clippy + fmt Updates wasm interface and codes Renames batched txs structs Misc updates to write log. Updates tx result handling in `finalize_block` Updates `WriteLog` to support tx batches Improves handling of txs' results in `dispatch_tx` and `finalize_block` Introduces `OwnedBatchedTx` for benchmarks. Fixes benches and tests Generic `TxResult` Updates contexts for batched transactions. Misc updates to protocol Updates logs and tx result to support batching Adds `BatchedTx` struct and updated the native vps and transactions execution Updates core tx methods and masp client functions Adds multiple tx commitments in `Header`
* tomas/split-up-apps: changelog: add #3259 test/apps_lib: fix the top-level dir check fix paths for split up namada_apps_lib git: ignore the new generated version.rs path symlink proto from `apps_lib` `mv crates/apps/build.rs crates/apps_lib/` `mv crates/apps_lib/src/lib/mod.rs crates/apps_lib/src/lib.rs` `mv crates/apps/src/lib crates/apps_lib/src` apps_lib: add a new crate for apps lib crate fixup! Merge branch 'grarco/masp-fees' (#3217) fixup! Merge branch 'grarco/tx-batch' (#3103) fixup! Merge branch 'grarco/tx-batch' (#3103) fixup! Merge branch 'bat/fix/issue-1796' (#3226) fixup! Merge branch 'tiago/max-proposal-bytes-validation' (#3220) fixup! Merge branch 'tomas/more-checked-arith' (#3214) empty commit changelog: add #3216 deliberatly empty Changelog #2817 added clone to transaction structs
Describe your changes
Closes #1356.
Implements transaction batching by extending the
Tx
type to carry a set of commitments todata
,code
andmemo
. Every tx now is a batch (the default case is a batch of a single inner tx) and can be set to be an atomic batch if needed. In summary the changes are:Header
level, as in we sign the entire batch header (which contains the commitments of all the txs). This way the logic is simplified and the transaction can carry less signaturesWriteLog
andTxResult
have been updated to support this new logicEvent
emitted by the transaction has been updated to carry the results of all the inner txs of the batchThis is a first attempt to achieve tx batching but the feature should not be considered stabilized yet. More specifically I believe more work will be needed to:
evalute_tx_result
function infinalize_block
)Indicate on which release or other PRs this topic is based on
v0.35.1
Checklist before merging to
draft