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

Improve error messages returned by TX execution #2958

Merged
merged 24 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Replace `eyre!()` errors with `namada_storage` errors.
([\#2852](https://github.com/anoma/namada/pull/2852))
4 changes: 4 additions & 0 deletions .changelog/unreleased/improvements/2940-wasm-errs-ux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Change the return type of a VP's predicate function to a Result of unit or
some error. In case Namada users perform invalid state changes, they should
be met with more descriptive error messages explaining the cause of their tx's
rejection. ([\#2940](https://github.com/anoma/namada/pull/2940))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2958-tx-errs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Return error messages from tx execution, instead of aborting execution with no
context. ([\#2958](https://github.com/anoma/namada/pull/2958))
22 changes: 13 additions & 9 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 @@ -69,6 +69,7 @@ base64 = "0.13.0"
bech32 = "0.8.0"
bimap = {version = "0.6.2", features = ["serde"]}
bit-set = "0.5.2"
bitflags = { version = "2.5.0", features = ["serde"] }
blake2b-rs = "0.2.0"
bls12_381 = "0.8"
byte-unit = "4.0.13"
Expand Down
19 changes: 11 additions & 8 deletions crates/apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use namada::state::write_log::StorageModification;
use namada::state::{ResultExt, StorageWrite, EPOCH_SWITCH_BLOCKS_DELAY};
use namada::tx::data::protocol::ProtocolTxType;
use namada::tx::data::VpStatusFlags;
use namada::vote_ext::ethereum_events::MultiSignedEthEvent;
use namada::vote_ext::ethereum_tx_data_variants;
use namada_sdk::tx::new_tx_event;
Expand Down Expand Up @@ -458,7 +459,11 @@
// If decrypted tx failed for any reason but invalid
// signature, commit its hash to storage, otherwise
// allow for a replay
if !result.vps_result.invalid_sig {
if !result
.vps_result
.status_flags
.contains(VpStatusFlags::INVALID_SIGNATURE)
{

Check warning on line 466 in crates/apps/src/lib/node/ledger/shell/finalize_block.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/node/ledger/shell/finalize_block.rs#L466

Added line #L466 was not covered by tests
self.commit_inner_tx_hash(wrapper);
}
}
Expand Down Expand Up @@ -788,7 +793,6 @@
liveness_missed_votes_handle, liveness_sum_missed_votes_handle,
read_consensus_validator_set_addresses,
};
use namada_sdk::validity_predicate::VpSentinel;
use namada_test_utils::tx_data::TxWriteData;
use namada_test_utils::TestWasms;
use test_log::test;
Expand Down Expand Up @@ -4912,23 +4916,22 @@
));
let keys_changed = BTreeSet::from([min_confirmations_key()]);
let verifiers = BTreeSet::default();
let sentinel = RefCell::new(VpSentinel::default());
let ctx = namada::ledger::native_vp::Ctx::new(
shell.mode.get_validator_address().expect("Test failed"),
shell.state.read_only(),
&tx,
&TxIndex(0),
&gas_meter,
&sentinel,
&keys_changed,
&verifiers,
shell.vp_wasm_cache.clone(),
);
let parameters = ParametersVp { ctx };
let result = parameters
.validate_tx(&tx, &keys_changed, &verifiers)
.expect("Test failed");
assert!(result);
assert!(
parameters
.validate_tx(&tx, &keys_changed, &verifiers)
.is_ok()
);

// we advance forward to the next epoch
let mut req = FinalizeBlock::default();
Expand Down
Loading
Loading