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

test/e2e/double_singing: wait for first block #1253

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .changelog/unreleased/bug-fixes/1246-fix-pos-slashing.md
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 4 additions & 2 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -404,8 +408,6 @@ where
.wl_storage
.update_epoch(height, header_time)
.expect("Must be able to update epoch");

self.slash();
(height, new_epoch)
}

Expand Down
29 changes: 29 additions & 0 deletions scripts/repeat-e2e-test.sh
Original file line number Diff line number Diff line change
@@ -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


6 changes: 5 additions & 1 deletion tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3211,11 +3211,15 @@ fn double_signing_gets_slashed() -> Result<()> {
run_as!(test, Who::Validator(0), Bin::Node, args, Some(40))?;
validator_0.exp_string("Namada ledger node started")?;
validator_0.exp_string("This node is a validator")?;
let _bg_validator_0 = validator_0.background();
let mut validator_1 =
run_as!(test, Who::Validator(1), Bin::Node, args, Some(40))?;
validator_1.exp_string("Namada ledger node started")?;
validator_1.exp_string("This node is a validator")?;

// Wait for a first block
validator_0.exp_string("Committed block hash")?;

let _bg_validator_0 = validator_0.background();
let bg_validator_1 = validator_1.background();

// 2. Copy the first genesis validator base-dir
Expand Down