Skip to content
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

Fix allowlist checks #2819

Merged
merged 23 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
edfa418
First compiling version
batconjurer Feb 13, 2024
61484a4
[fix]: unit test now passing
batconjurer Feb 15, 2024
5738288
fixed integration tests
batconjurer Feb 15, 2024
3f06283
Fixing e2e tests
batconjurer Feb 16, 2024
32157be
added changelog
batconjurer Feb 16, 2024
816db39
Small fixes
batconjurer Feb 16, 2024
93888b9
[fix]: Fix benchmarks
batconjurer Feb 19, 2024
bf8d573
Update crates/tx/src/data/wrapper.rs
batconjurer Feb 20, 2024
a106856
Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
batconjurer Feb 20, 2024
b373402
Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
batconjurer Feb 20, 2024
e3481c8
Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
batconjurer Feb 20, 2024
a8abe56
Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
batconjurer Feb 20, 2024
569277b
Update crates/apps/src/lib/node/ledger/shell/block_alloc.rs
batconjurer Feb 20, 2024
2a3bf58
Addressing review comments
batconjurer Feb 20, 2024
57a599c
addressing review comments
batconjurer Feb 20, 2024
4770db6
Rebased. Might require more fixes but unit tests are passing
batconjurer Mar 2, 2024
e138cfb
[fix]: Integration tests
batconjurer Mar 3, 2024
3a6b2d0
Updates governance test to cover vp allowlist
grarco Mar 5, 2024
04a322a
Ensures fee payment even in case of unallowed wasm code
grarco Mar 5, 2024
f8de05f
Moves tx allowlist check to allow replay protection optimizations
grarco Mar 5, 2024
35e7c6d
Improves tx allowlist error. Tx allowlist check in mempool and `proce…
grarco Mar 5, 2024
4993b10
Fixes and improves allowlist test
grarco Mar 5, 2024
c76bead
Changelog #2819
grarco Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/2819-allowlist-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Adjusts the tx allowlist check to not prevent fee payment.
([\#2819](https://github.com/anoma/namada/pull/2819))
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 @@ -84,6 +84,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::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 @@
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);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L292 was not covered by tests

// 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 @@

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);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L332 was not covered by tests
let code_hash = self
.read_storage_key(&Key::wasm_hash(wasm_code_path))
.unwrap();
Expand Down Expand Up @@ -564,7 +560,18 @@

// 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,
);

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

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/bench_utils.rs#L563-L574

Added lines #L563 - L574 were not covered by tests
self.last_block_masp_txs
.push((masp_tx, self.state.write_log().get_keys()));
self.state.commit_tx();
Expand All @@ -575,9 +582,7 @@
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);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L585 was not covered by tests
tx.set_code(Code::new(wasm_code, None));
tx.set_data(Data::new(
TxWriteData {
Expand Down Expand Up @@ -857,6 +862,7 @@
.map(|(idx, (_tx, changed_keys))| {
let tx_result = TxResult {
gas_used: 0.into(),
wrapper_changed_keys: Default::default(),

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L865 was not covered by tests
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 @@
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 @@
.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 warning on line 209 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L206-L209

Added lines #L206 - L209 were not covered by tests
{
// Check if this transfer pertains to the supplied owner
let mut relevant = match &query_owner {
Expand Down Expand Up @@ -2769,23 +2773,10 @@
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)

Check warning on line 2779 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L2776-L2779

Added lines #L2776 - L2779 were not covered by tests
}
}
}
Expand Down