From 3eeaf4fa01d2b1224dde53853a0f68e52ffee930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 23 Mar 2023 08:45:45 +0000 Subject: [PATCH 1/3] scripts: add a helper to repeat e2e test --- scripts/repeat-e2e-test.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/repeat-e2e-test.sh diff --git a/scripts/repeat-e2e-test.sh b/scripts/repeat-e2e-test.sh new file mode 100755 index 0000000000..3257e631da --- /dev/null +++ b/scripts/repeat-e2e-test.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Run an e2e test at most n times, exit at first failure. +# This can be handy for testing of non-deterministic issues that are tricky to +# reproduce. +# +# The first arg is the max number of repetitions and second is the exact name +# of the test. +# +# Usage example: +# $ scripts/repeat-e2e-test.sh 10 e2e::ledger_tests::run_ledger +# +# Adapted from https://gitlab.com/tezos/tezos/-/blob/master/tests_python/scripts/repeat_test.sh + +NUM=$1 +TEST=$2 +# Thanks internet https://stackoverflow.com/a/4774063/3210255 +SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +NIGHTLY=$(cat "$SCRIPTPATH"/../rust-nightly-version) + +for i in $(seq 1 "$NUM") +do + echo "Execution $i/$NUM" + if ! RUST_BACKTRACE=1 NAMADA_E2E_KEEP_TEMP=true NAMADA_E2E_DEBUG=true cargo "+$NIGHTLY" test "$TEST" -Z unstable-options -- --exact --test-threads=1 --nocapture; then + exit 1 + fi +done +exit 0 + + From 08fb1d2d2c2250761831a3b3cf98cbdac13c6bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 23 Mar 2023 08:33:22 +0000 Subject: [PATCH 2/3] app/ledger/finalize_block: slash after copying of validator sets --- apps/src/lib/node/ledger/shell/finalize_block.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 336c4d9415..3acaff27ba 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -73,6 +73,10 @@ where )?; } + // Invariant: This has to be applied after + // `copy_validator_sets_and_positions` if we're starting a new epoch + self.slash(); + let wrapper_fees = self.get_wrapper_tx_fees(); let mut stats = InternalStats::default(); @@ -404,8 +408,6 @@ where .wl_storage .update_epoch(height, header_time) .expect("Must be able to update epoch"); - - self.slash(); (height, new_epoch) } From cdcf1c0a5ca986c2157e82468eee361f7d7c13aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Fri, 24 Mar 2023 09:46:21 +0000 Subject: [PATCH 3/3] changelog: add #1246 --- .changelog/unreleased/bug-fixes/1246-fix-pos-slashing.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/unreleased/bug-fixes/1246-fix-pos-slashing.md diff --git a/.changelog/unreleased/bug-fixes/1246-fix-pos-slashing.md b/.changelog/unreleased/bug-fixes/1246-fix-pos-slashing.md new file mode 100644 index 0000000000..797a75230a --- /dev/null +++ b/.changelog/unreleased/bug-fixes/1246-fix-pos-slashing.md @@ -0,0 +1,3 @@ +- PoS: Fixed an issue with slashable evidence processed + and applied at a new epoch causing a ledger to crash. + ([#1246](https://github.com/anoma/namada/pull/1246)) \ No newline at end of file