Skip to content

Commit

Permalink
Merge branch 'bat/feat/remove-tx-queue' (#2627)
Browse files Browse the repository at this point in the history
* origin/bat/feat/remove-tx-queue:
  [fix]: Integration tests
  Rebased. Might require more fixes but unit tests are passing
  addressing review comments
  Addressing review comments
  Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
  Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
  Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
  Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
  Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
  Update crates/tx/src/data/wrapper.rs
  [fix]: Fix benchmarks
  Small fixes
  added changelog
  Fixing e2e tests
  fixed integration tests
  [fix]: unit test now passing
  First compiling version

# Conflicts:
#	crates/apps/src/lib/node/ledger/storage/rocksdb.rs
#	crates/storage/src/mockdb.rs
#	crates/storage/src/tx_queue.rs
  • Loading branch information
tzemanovic committed Apr 11, 2024
2 parents 7d70e5a + e138cfb commit a7a3233
Show file tree
Hide file tree
Showing 59 changed files with 942 additions and 2,400 deletions.
3 changes: 3 additions & 0 deletions .changelog/unreleased/improvements/2627-remove-tx-queue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Instead of having every user tx be executed across two blocks, the first executing a wrapper and the
second executing the main payload, this change makes it so that the entire tx is executed in a single
block (or rejected). ([\#2627](https://github.com/anoma/namada/pull/2627))
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ data-encoding = "2.3.2"
derivation-path = "0.2.0"
derivative = "2.2.0"
directories = "4.0.1"
drain_filter_polyfill = "0.1.3"
ed25519-consensus = "1.2.0"
escargot = "0.5.7"
ethabi = "18.0.0"
Expand Down
1 change: 1 addition & 0 deletions crates/apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ config.workspace = true
data-encoding.workspace = true
derivative.workspace = true
directories.workspace = true
drain_filter_polyfill.workspace = true
ed25519-consensus = { workspace = true, features = ["std"] }
ethabi.workspace = true
ethbridge-bridge-events.workspace = true
Expand Down
28 changes: 17 additions & 11 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use namada::ledger::queries::{
};
use namada::state::StorageRead;
use namada::tx::data::pos::Bond;
use namada::tx::data::{TxResult, VpsResult};
use namada::tx::data::{Fee, TxResult, VpsResult};
use namada::tx::{Code, Data, Section, Signature, Tx};
use namada::vm::wasm::run;
use namada::{proof_of_stake, tendermint};
Expand Down Expand Up @@ -289,9 +289,7 @@ impl BenchShell {
extra_sections: Option<Vec<Section>>,
signers: Vec<&SecretKey>,
) -> Tx {
let mut tx = Tx::from_type(namada::tx::data::TxType::Decrypted(
namada::tx::data::DecryptedTx::Decrypted,
));
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
// wasm validation. The wasm codes (both txs and vps) are always
Expand Down Expand Up @@ -331,9 +329,7 @@ impl BenchShell {

pub fn generate_ibc_tx(&self, wasm_code_path: &str, msg: impl Msg) -> Tx {
// This function avoid serializaing the tx data with Borsh
let mut tx = Tx::from_type(namada::tx::data::TxType::Decrypted(
namada::tx::data::DecryptedTx::Decrypted,
));
let mut tx = Tx::from_type(namada::tx::data::TxType::Raw);
let code_hash = self
.read_storage_key(&Key::wasm_hash(wasm_code_path))
.unwrap();
Expand Down Expand Up @@ -564,7 +560,18 @@ impl BenchShell {

// Commit a masp transaction and cache the tx and the changed keys for
// client queries
pub fn commit_masp_tx(&mut self, masp_tx: Tx) {
pub fn commit_masp_tx(&mut self, mut masp_tx: Tx) {
use namada::core::key::RefTo;
masp_tx.add_wrapper(
Fee {
amount_per_gas_unit: DenominatedAmount::native(0.into()),
token: self.state.in_mem().native_token.clone(),
},
defaults::albert_keypair().ref_to(),
self.state.in_mem().last_epoch,
0.into(),
None,
);
self.last_block_masp_txs
.push((masp_tx, self.state.write_log().get_keys()));
self.state.commit_tx();
Expand All @@ -575,9 +582,7 @@ pub fn generate_foreign_key_tx(signer: &SecretKey) -> Tx {
let wasm_code =
std::fs::read("../../wasm_for_tests/tx_write.wasm").unwrap();

let mut tx = Tx::from_type(namada::tx::data::TxType::Decrypted(
namada::tx::data::DecryptedTx::Decrypted,
));
let mut tx = Tx::from_type(namada::tx::data::TxType::Raw);
tx.set_code(Code::new(wasm_code, None));
tx.set_data(Data::new(
TxWriteData {
Expand Down Expand Up @@ -857,6 +862,7 @@ impl Client for BenchShell {
.map(|(idx, (_tx, changed_keys))| {
let tx_result = TxResult {
gas_used: 0.into(),
wrapper_changed_keys: Default::default(),
changed_keys: changed_keys.to_owned(),
vps_result: VpsResult::default(),
initialized_accounts: vec![],
Expand Down
31 changes: 11 additions & 20 deletions crates/apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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, display_wrapper_resp_and_get_result};
use namada_sdk::tx::display_inner_resp;
use namada_sdk::wallet::AddressVpType;
use namada_sdk::{display, display_line, edisplay_line, error, prompt, Namada};
use tokio::time::Instant;
Expand Down Expand Up @@ -201,8 +201,12 @@ pub async fn query_transfers(
.map(|fvk| (ExtendedFullViewingKey::from(*fvk).fvk.vk, fvk))
.collect();
// Now display historical shielded and transparent transactions
for (IndexedTx { height, index: idx }, (epoch, tfer_delta, tx_delta)) in
transfers
for (
IndexedTx {
height, index: idx, ..
},
(epoch, tfer_delta, tx_delta),
) in transfers
{
// Check if this transfer pertains to the supplied owner
let mut relevant = match &query_owner {
Expand Down Expand Up @@ -2769,23 +2773,10 @@ pub async fn query_result(context: &impl Namada, args: args::QueryResult) {
Ok(resp) => {
display_inner_resp(context, &resp);
}
Err(err1) => {
// If this fails then instead look for an acceptance event.
let wrapper_resp = query_tx_response(
context.client(),
namada_sdk::rpc::TxEventQuery::Accepted(&args.tx_hash),
)
.await;
match wrapper_resp {
Ok(resp) => {
display_wrapper_resp_and_get_result(context, &resp);
}
Err(err2) => {
// Print the errors that caused the lookups to fail
edisplay_line!(context.io(), "{}\n{}", err1, err2);
cli::safe_exit(1)
}
}
Err(err) => {
// Print the errors that caused the lookups to fail
edisplay_line!(context.io(), "{}", err);
cli::safe_exit(1)
}
}
}
Expand Down

0 comments on commit a7a3233

Please sign in to comment.