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

protocol: remove panic::catch_unwind for PoS VP #2145

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/miscellaneous/2145-pos-vp-no-catch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Removed catching of panics from PoS VP.
([\#2145](https://github.com/anoma/namada/pull/2145))
25 changes: 0 additions & 25 deletions shared/src/ledger/pos/vp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Proof-of-Stake native validity predicate.

use std::collections::BTreeSet;
use std::panic::{RefUnwindSafe, UnwindSafe};

use namada_core::ledger::storage_api::governance;
// use borsh::BorshDeserialize;
Expand Down Expand Up @@ -58,30 +57,6 @@ where
}
}

// TODO this is temporarily to run PoS native VP in a new thread to avoid
// crashing the ledger (in apps/src/lib/node/ledger/protocol/mod.rs). The
// RefCells contained within PosVP are not thread-safe, but each thread has its
// own instances.
impl<DB, H, CA> UnwindSafe for PosVP<'_, DB, H, CA>
where
DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>,
H: 'static + StorageHasher,
CA: 'static + WasmCacheAccess,
{
}

// TODO this is temporarily to run PoS native VP in a new thread to avoid
// crashing the ledger (in apps/src/lib/node/ledger/protocol/mod.rs). The
// RefCells contained within PosVP are not thread-safe, but each thread has its
// own instances.
impl<DB, H, CA> RefUnwindSafe for PosVP<'_, DB, H, CA>
where
DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>,
H: 'static + StorageHasher,
CA: 'static + WasmCacheAccess,
{
}

impl<'a, DB, H, CA> NativeVp for PosVP<'a, DB, H, CA>
where
DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>,
Expand Down
28 changes: 7 additions & 21 deletions shared/src/ledger/protocol/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! The ledger's protocol
use std::collections::BTreeSet;
use std::panic;

use borsh_ext::BorshSerializeExt;
use eyre::{eyre, WrapErr};
Expand Down Expand Up @@ -854,26 +853,13 @@ where
// and `RefUnwindSafe` in
// shared/src/ledger/pos/vp.rs)
let keys_changed_ref = &keys_changed;
let result =
match panic::catch_unwind(move || {
pos_ref
.validate_tx(
tx,
keys_changed_ref,
verifiers_addr_ref,
)
.map_err(Error::PosNativeVpError)
}) {
Ok(result) => result,
Err(err) => {
tracing::error!(
"PoS native VP failed with \
{:#?}",
err
);
Err(Error::PosNativeVpRuntime)
}
};
let result = pos_ref
.validate_tx(
tx,
keys_changed_ref,
verifiers_addr_ref,
)
.map_err(Error::PosNativeVpError);
// Take the gas meter and sentinel
// back
// out of the context
Expand Down
Loading