From 94b4f538ffbb5116281340da6a0f647007c33fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 10 Nov 2023 16:25:57 +0100 Subject: [PATCH 1/2] protocol: remove `panic::catch_unwind` for PoS VP --- shared/src/ledger/pos/vp.rs | 25 ------------------------- shared/src/ledger/protocol/mod.rs | 28 +++++++--------------------- 2 files changed, 7 insertions(+), 46 deletions(-) diff --git a/shared/src/ledger/pos/vp.rs b/shared/src/ledger/pos/vp.rs index 76607c3199..506ef489ca 100644 --- a/shared/src/ledger/pos/vp.rs +++ b/shared/src/ledger/pos/vp.rs @@ -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; @@ -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 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 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>, diff --git a/shared/src/ledger/protocol/mod.rs b/shared/src/ledger/protocol/mod.rs index d142781127..7b331ebdc9 100644 --- a/shared/src/ledger/protocol/mod.rs +++ b/shared/src/ledger/protocol/mod.rs @@ -1,6 +1,5 @@ //! The ledger's protocol use std::collections::BTreeSet; -use std::panic; use borsh_ext::BorshSerializeExt; use eyre::{eyre, WrapErr}; @@ -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 From 517c81ab9468dcc4d2863f1b46c5a8be86bd2ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 10 Nov 2023 16:30:44 +0100 Subject: [PATCH 2/2] changelog: add #2145 --- .changelog/unreleased/miscellaneous/2145-pos-vp-no-catch.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/miscellaneous/2145-pos-vp-no-catch.md diff --git a/.changelog/unreleased/miscellaneous/2145-pos-vp-no-catch.md b/.changelog/unreleased/miscellaneous/2145-pos-vp-no-catch.md new file mode 100644 index 0000000000..812e6d7975 --- /dev/null +++ b/.changelog/unreleased/miscellaneous/2145-pos-vp-no-catch.md @@ -0,0 +1,2 @@ +- Removed catching of panics from PoS VP. + ([\#2145](https://github.com/anoma/namada/pull/2145)) \ No newline at end of file