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

Update misbehaviour-ics tests #3681

Merged
merged 4 commits into from
Nov 2, 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
52 changes: 39 additions & 13 deletions ci/misbehaviour-ics/double_sign_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ do

# 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 = \"10s\" | .app_state.staking.params.unbonding_time = \"86400s\"" \
jq ".app_state.gov.params.voting_period = \"5s\" | .app_state.staking.params.unbonding_time = \"86400s\"" \
${PROV_NODE_DIR}/config/genesis.json > \
${PROV_NODE_DIR}/edited_genesis.json && mv ${PROV_NODE_DIR}/edited_genesis.json ${PROV_NODE_DIR}/config/genesis.json

Expand All @@ -99,10 +99,10 @@ do

# 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
interchain-security-pd genesis add-genesis-account $PROV_ACCOUNT_ADDR $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
interchain-security-pd genesis add-genesis-account $PROV_ACCOUNT_ADDR2 $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test
sleep 1

# copy genesis out, unless this validator is the lead validator
Expand Down Expand Up @@ -141,7 +141,7 @@ do
fi

# 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 genesis gentx $PROV_KEY $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER
sleep 1

# Copy gentxs to the lead validator for possible future collection.
Expand All @@ -152,7 +152,7 @@ do
done

# Collect genesis transactions with lead validator
interchain-security-pd collect-gentxs --home ${LEAD_VALIDATOR_PROV_DIR} --gentx-dir ${LEAD_VALIDATOR_PROV_DIR}/config/gentx/
interchain-security-pd genesis collect-gentxs --home ${LEAD_VALIDATOR_PROV_DIR} --gentx-dir ${LEAD_VALIDATOR_PROV_DIR}/config/gentx/

sleep 1

Expand Down Expand Up @@ -222,7 +222,7 @@ done
tee ${LEAD_VALIDATOR_PROV_DIR}/consumer-proposal.json<<EOF
{
"title": "Create a chain",
"description": "Gonna be a great chain",
"summary": "Gonna be a great chain",
"chain_id": "consumer",
"initial_height": {
"revision_height": 1
Expand All @@ -244,9 +244,9 @@ sleep 5
interchain-security-pd keys show $LEAD_PROV_KEY --keyring-backend test --home ${LEAD_VALIDATOR_PROV_DIR}

# Submit consumer chain proposal
interchain-security-pd tx gov submit-proposal consumer-addition ${LEAD_VALIDATOR_PROV_DIR}/consumer-proposal.json --chain-id provider --from $LEAD_PROV_KEY --home ${LEAD_VALIDATOR_PROV_DIR} --node $LEAD_PROV_LISTEN_ADDR --keyring-backend test -b block -y --gas auto
interchain-security-pd tx gov submit-legacy-proposal consumer-addition ${LEAD_VALIDATOR_PROV_DIR}/consumer-proposal.json --chain-id provider --from $LEAD_PROV_KEY --home ${LEAD_VALIDATOR_PROV_DIR} --node $LEAD_PROV_LISTEN_ADDR --keyring-backend test -y --gas auto

sleep 1
sleep 3

# Vote yes to proposal
for index in "${!MONIKERS[@]}"
Expand All @@ -257,18 +257,44 @@ do
RPC_LADDR=tcp://${NODE_IP}:${RPC_LADDR_PORT}

PROV_NODE_DIR=${PROV_NODES_ROOT_DIR}/provider-${MONIKER}
interchain-security-pd tx gov vote 1 yes --from $PROV_KEY --chain-id provider --home ${PROV_NODE_DIR} --node $RPC_LADDR -b block -y --keyring-backend test
interchain-security-pd tx gov vote 1 yes --from $PROV_KEY --chain-id provider --home ${PROV_NODE_DIR} --node $RPC_LADDR -y --keyring-backend test
done

HERMES_PROV_NODE_DIR=${PROV_NODES_ROOT_DIR}/provider-${HERMES_VALIDATOR_MONIKER}
HERMES_KEY=${HERMES_VALIDATOR_MONIKER}-key
HERMES_KEY2=${HERMES_VALIDATOR_MONIKER}-key2
HERMES_CONS_NODE_DIR=${CONS_NODES_ROOT_DIR}/consumer-${HERMES_VALIDATOR_MONIKER}

# sleep 3

# # ## CONSUMER CHAIN ##

### Assert that the proposal for the consumer chain passed
PROPOSAL_STATUS_PASSED="PROPOSAL_STATUS_PASSED"
MAX_TRIES=10
TRIES=0

cat ${PROV_NODE_DIR}/config/genesis.json | grep "period"

while [ $TRIES -lt $MAX_TRIES ]; do
output=$(interchain-security-pd query gov proposal 1 --home ${LEAD_VALIDATOR_PROV_DIR} --node $LEAD_PROV_LISTEN_ADDR --output json)

proposal_status=$(echo "$output" | grep -o '"status":"[^"]*' | awk -F ':"' '{print $2}')
if [ "$proposal_status" = "$PROPOSAL_STATUS_PASSED" ]; then
echo "Proposal status is now $proposal_status. Exiting loop."
break
else
echo "Proposal status is $proposal_status. Continuing to check..."
fi
TRIES=$((TRIES + 1))

sleep 2
done

if [ $TRIES -eq $MAX_TRIES ]; then
echo "[ERROR] Failed due to an issue with the consumer proposal"
echo "This is likely due to a misconfiguration in the test script."
exit 0
fi

# # Clean start
for index in "${!MONIKERS[@]}"
do
Expand Down Expand Up @@ -299,9 +325,9 @@ do

# Add stake to user
CONS_ACCOUNT_ADDR=$(jq -r '.address' ${CONS_NODE_DIR}/${PROV_KEY}.json)
interchain-security-cd add-genesis-account $CONS_ACCOUNT_ADDR $USER_COINS --home ${CONS_NODE_DIR}
interchain-security-cd genesis add-genesis-account $CONS_ACCOUNT_ADDR $USER_COINS --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 $USER_COINS --home ${CONS_NODE_DIR}
interchain-security-cd genesis add-genesis-account $CONS_ACCOUNT_ADDR2 $USER_COINS --home ${CONS_NODE_DIR}
sleep 10

### this probably doesnt have to be done for each node
Expand Down
65 changes: 46 additions & 19 deletions ci/misbehaviour-ics/light_client_attack_freeze_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ STAKE2="4000000stake"
NODE_IP="127.0.0.1"

# Home directory
HOME_DIR="/tmp/hermes-ics-misbehaviour"
HOME_DIR=$HOME

# Hermes debug
if [ "$DEBUG" = true ]; then
Expand Down Expand Up @@ -85,7 +85,7 @@ rm -rf "${CONS_FORK_NODE_DIR}"

# 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\"" \
jq ".app_state.gov.params.voting_period = \"5s\" | .app_state.staking.params.unbonding_time = \"86400s\"" \
${PROV_NODE_DIR}/config/genesis.json > \
${PROV_NODE_DIR}/edited_genesis.json && mv ${PROV_NODE_DIR}/edited_genesis.json ${PROV_NODE_DIR}/config/genesis.json

Expand All @@ -94,10 +94,10 @@ interchain-security-pd keys add $PROV_KEY --home ${PROV_NODE_DIR} --keyring-back

# 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
interchain-security-pd genesis add-genesis-account "$PROV_ACCOUNT_ADDR" $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test

# 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 genesis gentx $PROV_KEY $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER

## config second node

Expand All @@ -113,14 +113,14 @@ cp ${PROV_NODE_DIR}/config/genesis.json ${PROV_NODE_SUB_DIR}/config/genesis.jso

# Add stake to user
PROV_ACCOUNT_ADDR=$(jq -r '.address' ${PROV_NODE_SUB_DIR}/${PROV_KEY_SUB}.json)
interchain-security-pd add-genesis-account "$PROV_ACCOUNT_ADDR" $USER_COINS --home ${PROV_NODE_SUB_DIR} --keyring-backend test
interchain-security-pd genesis add-genesis-account "$PROV_ACCOUNT_ADDR" $USER_COINS --home ${PROV_NODE_SUB_DIR} --keyring-backend test

cp -r ${PROV_NODE_DIR}/config/gentx/ ${PROV_NODE_SUB_DIR}/config/gentx/

# # Stake 1/1000 user's coins
interchain-security-pd gentx $PROV_KEY_SUB $STAKE2 --chain-id provider --home ${PROV_NODE_SUB_DIR} --keyring-backend test --moniker $MONIKER_SUB
interchain-security-pd genesis gentx $PROV_KEY_SUB $STAKE2 --chain-id provider --home ${PROV_NODE_SUB_DIR} --keyring-backend test --moniker $MONIKER_SUB

interchain-security-pd collect-gentxs --home ${PROV_NODE_SUB_DIR} --gentx-dir ${PROV_NODE_SUB_DIR}/config/gentx/
interchain-security-pd genesis collect-gentxs --home ${PROV_NODE_SUB_DIR} --gentx-dir ${PROV_NODE_SUB_DIR}/config/gentx/

cp ${PROV_NODE_SUB_DIR}/config/genesis.json ${PROV_NODE_DIR}/config/genesis.json

Expand All @@ -130,7 +130,7 @@ cp ${PROV_NODE_SUB_DIR}/config/genesis.json ${PROV_NODE_DIR}/config/genesis.jso
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26658\"/" ${PROV_NODE_DIR}/config/client.toml
sed -i -r 's/timeout_commit = "5s"/timeout_commit = "3s"/g' ${PROV_NODE_DIR}/config/config.toml
sed -i -r 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ${PROV_NODE_DIR}/config/config.toml
sed -i -r 's/fast_sync = true/fast_sync = false/g' ${PROV_NODE_DIR}/config/config.toml
sed -i -r 's/block_sync = true/block_sync = false/g' ${PROV_NODE_DIR}/config/config.toml

# Start gaia
interchain-security-pd start \
Expand All @@ -146,7 +146,7 @@ waiting 10 "for provider node to start"
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26628\"/" ${PROV_NODE_SUB_DIR}/config/client.toml
sed -i -r 's/timeout_commit = "5s"/timeout_commit = "3s"/g' ${PROV_NODE_SUB_DIR}/config/config.toml
sed -i -r 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ${PROV_NODE_SUB_DIR}/config/config.toml
sed -i -r 's/fast_sync = true/fast_sync = false/g' ${PROV_NODE_SUB_DIR}/config/config.toml
sed -i -r 's/block_sync = true/block_sync = false/g' ${PROV_NODE_SUB_DIR}/config/config.toml

# Start gaia
interchain-security-pd start \
Expand All @@ -163,7 +163,7 @@ waiting 10 "for provider sub-node to start"
tee ${PROV_NODE_DIR}/consumer-proposal.json<<EOF
{
"title": "Create a chain",
"description": "Gonna be a great chain",
"summary": "Gonna be a great chain",
"chain_id": "consumer",
"initial_height": {
"revision_height": 1
Expand All @@ -184,17 +184,45 @@ EOF
interchain-security-pd keys show $PROV_KEY --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-legacy-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 -y --gas auto

waiting 1 "for proposal to be submitted"
waiting 3 "for proposal to be submitted"

# 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

waiting 3 "for proposal to be voted on"
interchain-security-pd tx gov vote 1 yes --from $PROV_KEY --chain-id provider --home ${PROV_NODE_DIR} -y --keyring-backend test

# CONSUMER CHAIN ##

### Assert that the proposal for the consumer chain passed
PROPOSAL_STATUS_PASSED="PROPOSAL_STATUS_PASSED"
MAX_TRIES=10
TRIES=0

cat ${PROV_NODE_DIR}/config/genesis.json | grep "period"

while [ $TRIES -lt $MAX_TRIES ]; do
output=$(interchain-security-pd query gov proposal 1 --home ${PROV_NODE_DIR} --node tcp://${NODE_IP}:26658 --output json)

proposal_status=$(echo "$output" | grep -o '"status":"[^"]*' | awk -F ':"' '{print $2}')
if [ "$proposal_status" = "$PROPOSAL_STATUS_PASSED" ]; then
echo "Proposal status is now $proposal_status. Exiting loop."
break
else
echo "Proposal status is $proposal_status. Continuing to check..."
fi
TRIES=$((TRIES + 1))

sleep 2
done

if [ $TRIES -eq $MAX_TRIES ]; then
echo "[ERROR] Failed due to an issue with the consumer proposal"
echo "This is likely due to a misconfiguration in the test script."
exit 0
fi

waiting 3 "for passed proposal to be executed"

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

Expand All @@ -203,7 +231,7 @@ interchain-security-cd keys add $PROV_KEY --home ${CONS_NODE_DIR} --keyring-bac

# 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}
interchain-security-cd genesis add-genesis-account "$CONS_ACCOUNT_ADDR" 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 @@ -220,7 +248,7 @@ cp ${PROV_NODE_DIR}/config/node_key.json ${CONS_NODE_DIR}/config/node_key.json

# Set default client port
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26648\"/" ${CONS_NODE_DIR}/config/client.toml
sed -i -r 's/fast_sync = true/fast_sync = false/g' ${CONS_NODE_DIR}/config/config.toml
sed -i -r 's/block_sync = true/block_sync = false/g' ${CONS_NODE_DIR}/config/config.toml


# Start gaia
Expand Down Expand Up @@ -435,7 +463,7 @@ diag "Fork => Height: ${height}, Hash: ${hash}"
cp -r ${CONS_NODE_DIR} ${CONS_FORK_NODE_DIR}
# Set default client port
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26638\"/" ${CONS_FORK_NODE_DIR}/config/client.toml
sed -i -r 's/fast_sync = true/fast_sync = false/g' ${CONS_FORK_NODE_DIR}/config/config.toml
sed -i -r 's/block_sync = true/block_sync = false/g' ${CONS_FORK_NODE_DIR}/config/config.toml


# Start gaia
Expand Down Expand Up @@ -509,4 +537,3 @@ else
exit 1
fi
fi

Loading
Loading