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

fix: send evidences with non-empty infraction block header #3578

Merged
merged 24 commits into from
Sep 13, 2023
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
6d323eb
try to fill infraction header in double voting msg
sainoe Aug 30, 2023
c4fb791
reformat
sainoe Aug 31, 2023
d02d6e9
fix nit
sainoe Aug 31, 2023
207f09a
fmt
sainoe Aug 31, 2023
b23ec91
Merge branch 'anca/evidene_worker_poc' into sainoe/evidence_worker_fix
romac Aug 31, 2023
98f244f
Formatting
romac Aug 31, 2023
4fb2ddc
Make infraction block header required
romac Aug 31, 2023
d9c28a3
Merge branch 'anca/evidene_worker_poc' into sainoe/evidence_worker_fix
romac Aug 31, 2023
be16f41
Stop after submitting double voting evidence to the provider
romac Aug 31, 2023
8b6c7d8
Force refresh of account before sending a tx
romac Aug 31, 2023
787ad43
Revert refresh on every call
romac Sep 4, 2023
22c0ea9
Remove hermes binary at root
romac Sep 6, 2023
b3acccc
Send ICS misbehaviour for CCV consumer chain in misbehaviour worker
romac Sep 6, 2023
b1f520d
Make the evidence command resilient to error, eg. because a client wa…
romac Sep 6, 2023
53391af
Improve logging
romac Sep 6, 2023
0b54904
Go back to refreshing the account everytime
romac Sep 6, 2023
9c4a83a
Improve CI test script
romac Sep 6, 2023
3894e8e
Improve logs
romac Sep 6, 2023
16fddc9
Add `key-name` and `check-past-blocks` arguments to `evidence` comman…
romac Sep 13, 2023
e70f2df
Patch check-guide tool with CCV protos
romac Sep 13, 2023
cf143ec
Do not refresh account everytime
romac Sep 13, 2023
586a598
Fix for zero height
romac Sep 13, 2023
8241fd9
Update ICS misbehaviour test to use a different wallet for the `evide…
romac Sep 13, 2023
e7e8085
Remove double sign script
romac Sep 13, 2023
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
122 changes: 73 additions & 49 deletions ci/misbehaviour-ics/misbehaviour_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu
set -eux

diag() {
echo ">>
Expand Down Expand Up @@ -28,14 +28,20 @@ PROV_NODE_DIR=${HOME_DIR}/provider-${MONIKER}
CONS_NODE_DIR=${HOME_DIR}/consumer-${MONIKER}
CONS_FORK_NODE_DIR=${HOME_DIR}/consumer-fork-${MONIKER}

# Coordinator key
PROV_KEY=${MONIKER}-key

# Coordinator keys
PROV_KEY1=${MONIKER}-key1
PROV_KEY2=${MONIKER}-key2

# Clean start
pkill -f interchain-security-pd &> /dev/null || true
rm -rf ${PROV_NODE_DIR}

pkill -f interchain-security-cd &> /dev/null || true
rm -rf ${CONS_NODE_DIR}
rm -rf ${CONS_FORK_NODE_DIR}

pkill -f hermes 2> /dev/null || true

# Build genesis file and node directory structure
interchain-security-pd init $MONIKER --chain-id provider --home ${PROV_NODE_DIR}
jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"86400s\"" \
Expand All @@ -44,18 +50,22 @@ jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.par

sleep 1

# Create account keypair
interchain-security-pd keys add $PROV_KEY --home ${PROV_NODE_DIR} --keyring-backend test --output json > ${PROV_NODE_DIR}/${PROV_KEY}.json 2>&1
# Create account keypairs
interchain-security-pd keys add $PROV_KEY1 --home ${PROV_NODE_DIR} --keyring-backend test --output json > ${PROV_NODE_DIR}/${PROV_KEY1}.json 2>&1
interchain-security-pd keys add $PROV_KEY2 --home ${PROV_NODE_DIR} --keyring-backend test --output json > ${PROV_NODE_DIR}/${PROV_KEY2}.json 2>&1
sleep 1

# Add stake to user
PROV_ACCOUNT_ADDR=$(jq -r '.address' ${PROV_NODE_DIR}/${PROV_KEY}.json)
interchain-security-pd add-genesis-account $PROV_ACCOUNT_ADDR $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test
# Add stake to users
PROV_ACCOUNT_ADDR1=$(jq -r '.address' ${PROV_NODE_DIR}/${PROV_KEY1}.json)
interchain-security-pd add-genesis-account $PROV_ACCOUNT_ADDR1 $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test
PROV_ACCOUNT_ADDR2=$(jq -r '.address' ${PROV_NODE_DIR}/${PROV_KEY2}.json)
interchain-security-pd add-genesis-account $PROV_ACCOUNT_ADDR2 $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test
sleep 1


# Stake 1/1000 user's coins
interchain-security-pd gentx $PROV_KEY $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER
interchain-security-pd gentx $PROV_KEY1 $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER
# interchain-security-pd gentx $PROV_KEY2 $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER
sleep 1

interchain-security-pd collect-gentxs --home ${PROV_NODE_DIR} --gentx-dir ${PROV_NODE_DIR}/config/gentx/
Expand Down Expand Up @@ -99,35 +109,35 @@ tee ${PROV_NODE_DIR}/consumer-proposal.json<<EOF
}
EOF

interchain-security-pd keys show $PROV_KEY --keyring-backend test --home ${PROV_NODE_DIR}
interchain-security-pd keys show $PROV_KEY1 --keyring-backend test --home ${PROV_NODE_DIR}
interchain-security-pd keys show $PROV_KEY2 --keyring-backend test --home ${PROV_NODE_DIR}

# Submit consumer chain proposal
interchain-security-pd tx gov submit-proposal consumer-addition ${PROV_NODE_DIR}/consumer-proposal.json --chain-id provider --from $PROV_KEY --home ${PROV_NODE_DIR} --node tcp://${NODE_IP}:26658 --keyring-backend test -b block -y
interchain-security-pd tx gov submit-proposal consumer-addition ${PROV_NODE_DIR}/consumer-proposal.json --chain-id provider --from $PROV_KEY1 --home ${PROV_NODE_DIR} --node tcp://${NODE_IP}:26658 --keyring-backend test -b block -y

sleep 1

# Vote yes to proposal
interchain-security-pd tx gov vote 1 yes --from $PROV_KEY --chain-id provider --home ${PROV_NODE_DIR} -b block -y --keyring-backend test
interchain-security-pd tx gov vote 1 yes --from $PROV_KEY1 --chain-id provider --home ${PROV_NODE_DIR} -b block -y --keyring-backend test
# interchain-security-pd tx gov vote 1 yes --from $PROV_KEY2 --chain-id provider --home ${PROV_NODE_DIR} -b block -y --keyring-backend test

sleep 3

## CONSUMER CHAIN ##

# Clean start
pkill -f interchain-security-cd &> /dev/null || true
rm -rf ${CONS_NODE_DIR}
rm -rf ${CONS_FORK_NODE_DIR}

# Build genesis file and node directory structure
interchain-security-cd init $MONIKER --chain-id consumer --home ${CONS_NODE_DIR}
interchain-security-cd init $MONIKER --chain-id consumer --home ${CONS_NODE_DIR}
sleep 1

# Create user account keypair
interchain-security-cd keys add $PROV_KEY --home ${CONS_NODE_DIR} --keyring-backend test --output json > ${CONS_NODE_DIR}/${PROV_KEY}.json 2>&1
# Create user account keypairs
interchain-security-cd keys add $PROV_KEY1 --home ${CONS_NODE_DIR} --keyring-backend test --output json > ${CONS_NODE_DIR}/${PROV_KEY1}.json 2>&1
interchain-security-cd keys add $PROV_KEY2 --home ${CONS_NODE_DIR} --keyring-backend test --output json > ${CONS_NODE_DIR}/${PROV_KEY2}.json 2>&1

# Add stake to user account
CONS_ACCOUNT_ADDR=$(jq -r '.address' ${CONS_NODE_DIR}/${PROV_KEY}.json)
interchain-security-cd add-genesis-account $CONS_ACCOUNT_ADDR 1000000000stake --home ${CONS_NODE_DIR}
# Add stake to user accounts
CONS_ACCOUNT_ADDR1=$(jq -r '.address' ${CONS_NODE_DIR}/${PROV_KEY1}.json)
interchain-security-cd add-genesis-account $CONS_ACCOUNT_ADDR1 1000000000stake --home ${CONS_NODE_DIR}
CONS_ACCOUNT_ADDR2=$(jq -r '.address' ${CONS_NODE_DIR}/${PROV_KEY2}.json)
interchain-security-cd add-genesis-account $CONS_ACCOUNT_ADDR2 1000000000stake --home ${CONS_NODE_DIR}

# Add consumer genesis states to genesis file
interchain-security-pd query provider consumer-genesis consumer --home ${PROV_NODE_DIR} -o json > consumer_gen.json
Expand All @@ -146,7 +156,7 @@ cp ${PROV_NODE_DIR}/config/node_key.json ${CONS_NODE_DIR}/config/node_key.json
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26648\"/" ${CONS_NODE_DIR}/config/client.toml

# Start gaia
interchain-security-cd start --home ${CONS_NODE_DIR} \
interchain-security-cd start --home ${CONS_NODE_DIR} \
--rpc.laddr tcp://${NODE_IP}:26648 \
--grpc.address ${NODE_IP}:9081 \
--address tcp://${NODE_IP}:26645 \
Expand All @@ -156,9 +166,6 @@ interchain-security-cd start --home ${CONS_NODE_DIR} \

sleep 3

# Setup Hermes in packet relayer mode
pkill -f hermes 2> /dev/null || true

tee $HOME_DIR/config.toml <<EOF
[global]
log_level = "debug"
Expand Down Expand Up @@ -189,7 +196,7 @@ grpc_addr = "tcp://${NODE_IP}:9081"
key_name = "relayer"
max_gas = 2000000
rpc_addr = "http://${NODE_IP}:26648"
rpc_timeout = "10s"
rpc_timeout = "30s"
store_prefix = "ibc"
trusting_period = "2days"
event_source = { mode = "push", url = "ws://${NODE_IP}:26648/websocket" }
Expand All @@ -211,7 +218,7 @@ grpc_addr = "tcp://${NODE_IP}:9091"
key_name = "relayer"
max_gas = 2000000
rpc_addr = "http://${NODE_IP}:26658"
rpc_timeout = "10s"
rpc_timeout = "30s"
store_prefix = "ibc"
trusting_period = "2days"
event_source = { mode = "push", url = "ws://${NODE_IP}:26658/websocket" }
Expand All @@ -230,9 +237,10 @@ $HERMES --config $HOME_DIR/config.toml keys delete --chain consumer --all
$HERMES --config $HOME_DIR/config.toml keys delete --chain provider --all

# Restore keys to hermes relayer
$HERMES --config $HOME_DIR/config.toml keys add --key-file ${CONS_NODE_DIR}/${PROV_KEY}.json --chain consumer
$HERMES --config $HOME_DIR/config.toml keys add --key-file ${PROV_NODE_DIR}/${PROV_KEY}.json --chain provider

$HERMES --config $HOME_DIR/config.toml keys add --key-name relayer --key-file ${CONS_NODE_DIR}/${PROV_KEY1}.json --chain consumer
$HERMES --config $HOME_DIR/config.toml keys add --key-name evidence --key-file ${CONS_NODE_DIR}/${PROV_KEY2}.json --chain consumer
$HERMES --config $HOME_DIR/config.toml keys add --key-name relayer --key-file ${PROV_NODE_DIR}/${PROV_KEY1}.json --chain provider
$HERMES --config $HOME_DIR/config.toml keys add --key-name evidence --key-file ${PROV_NODE_DIR}/${PROV_KEY2}.json --chain provider

sleep 5

Expand All @@ -253,22 +261,31 @@ $HERMES --config $HOME_DIR/config.toml \

sleep 5

$HERMES --config $HOME_DIR/config.toml --json start &> $HOME_DIR/hermes-logs &
$HERMES --config $HOME_DIR/config.toml start &> $HOME_DIR/hermes-logs &

interchain-security-pd q tendermint-validator-set --home ${PROV_NODE_DIR}
interchain-security-cd q tendermint-validator-set --home ${CONS_NODE_DIR}

DELEGATIONS=$(interchain-security-pd q staking delegations $PROV_ACCOUNT_ADDR --home ${PROV_NODE_DIR} -o json)
DELEGATIONS1=$(interchain-security-pd q staking delegations $PROV_ACCOUNT_ADDR1 --home ${PROV_NODE_DIR} -o json)
OPERATOR_ADDR1=$(echo $DELEGATIONS1 | jq -r '.delegation_responses[0].delegation.validator_address')

OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r '.delegation_responses[0].delegation.validator_address')
# DELEGATIONS2=$(interchain-security-pd q staking delegations $PROV_ACCOUNT_ADDR2 --home ${PROV_NODE_DIR} -o json)
# OPERATOR_ADDR2=$(echo $DELEGATIONS2 | jq -r '.delegation_responses[0].delegation.validator_address')

interchain-security-pd tx staking delegate $OPERATOR_ADDR 1000000stake \
--from $PROV_KEY \
interchain-security-pd tx staking delegate $OPERATOR_ADDR1 1000000stake \
--from $PROV_KEY1 \
--keyring-backend test \
--home ${PROV_NODE_DIR} \
--chain-id provider \
-y -b block

# interchain-security-pd tx staking delegate $OPERATOR_ADDR2 1000000stake \
# --from $PROV_KEY2 \
# --keyring-backend test \
# --home ${PROV_NODE_DIR} \
# --chain-id provider \
# -y -b block

sleep 13

interchain-security-pd q tendermint-validator-set --home ${PROV_NODE_DIR}
Expand Down Expand Up @@ -354,7 +371,7 @@ cp -r ${CONS_NODE_DIR} ${CONS_FORK_NODE_DIR}
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26638\"/" ${CONS_FORK_NODE_DIR}/config/client.toml

# Start gaia
interchain-security-cd start --home ${CONS_FORK_NODE_DIR} \
interchain-security-cd start --home ${CONS_FORK_NODE_DIR} \
--rpc.laddr tcp://${NODE_IP}:26638 \
--grpc.address ${NODE_IP}:9071 \
--address tcp://${NODE_IP}:26635 \
Expand All @@ -376,16 +393,23 @@ sleep 10
diag "Updating client on forked chain using trusted height $TRUSTED_HEIGHT"
$HERMES --config $HOME_DIR/config_fork.toml update client --client 07-tendermint-0 --host-chain provider --trusted-height $TRUSTED_HEIGHT

sleep 10

# Check the client state on provider and verify it is frozen
FROZEN_HEIGHT=$($HERMES --config $HOME_DIR/config.toml --json query client state --chain provider --client 07-tendermint-0 | tail -n 1 | jq '.result.frozen_height.revision_height')
for ((i = 0; i < 10; i++)); do
# Check the client state on provider and verify it is frozen
FROZEN_HEIGHT=$($HERMES --config $HOME_DIR/config.toml --json query client state --chain provider --client 07-tendermint-0 | tail -n 1 | jq '.result.frozen_height.revision_height')

diag "Frozen height: $FROZEN_HEIGHT"

diag "Frozen height: $FROZEN_HEIGHT"
if [ "$FROZEN_HEIGHT" != "null" ]; then
diag "Client is frozen, success!"
exit 0
else
diag "Client is not frozen, waiting 5 seconds..."
sleep 5
fi
done

if [ "$FROZEN_HEIGHT" != "null" ]; then
diag "Client is frozen, success!"
else
diag "Client is not frozen, aborting."
exit 1
fi
diag "Client is not frozen, aborting."
diag "Hermes logs:"
cat $HOME_DIR/hermes-logs
exit 1
Loading
Loading