Commit 1b0f606a authored by Matt Solomon's avatar Matt Solomon

chore: fix shellcheck errors, warnings, and info level messages

parent dc01c039
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}") CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}")
MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}") MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}")
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}") CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}")
MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}") MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}")
...@@ -34,10 +34,10 @@ echo " Block Oracle Proxy at $BLOCK_ORACLE_PROXY" ...@@ -34,10 +34,10 @@ echo " Block Oracle Proxy at $BLOCK_ORACLE_PROXY"
echo "----------------------------------------------------------------" echo "----------------------------------------------------------------"
CHARLIE_ADDRESS="0xF45B7537828CB2fffBC69996B054c2Aaf36DC778" CHARLIE_ADDRESS="0xF45B7537828CB2fffBC69996B054c2Aaf36DC778"
CHARLIE_KEY="74feb147d72bfae943e6b4e483410933d9e447d5dc47d52432dcc2c1454dabb7" # CHARLIE_KEY="74feb147d72bfae943e6b4e483410933d9e447d5dc47d52432dcc2c1454dabb7"
MALLORY_ADDRESS="0x4641c704a6c743f73ee1f36C7568Fbf4b80681e4" MALLORY_ADDRESS="0x4641c704a6c743f73ee1f36C7568Fbf4b80681e4"
MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715" # MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
echo "----------------------------------------------------------------" echo "----------------------------------------------------------------"
echo " - Fetching balance of the sponsor" echo " - Fetching balance of the sponsor"
...@@ -61,7 +61,7 @@ done ...@@ -61,7 +61,7 @@ done
# Root claim commits to the entire trace. # Root claim commits to the entire trace.
# Alphabet game claim construction: keccak256(abi.encode(trace_index, trace[trace_index])) # Alphabet game claim construction: keccak256(abi.encode(trace_index, trace[trace_index]))
ROOT_CLAIM=$(cast keccak $(cast abi-encode "f(uint256,uint256)" 15 122)) ROOT_CLAIM=$(cast keccak "$(cast abi-encode "f(uint256,uint256)" 15 122)")
# Replace the first byte of the claim with the invalid vm status indicator # Replace the first byte of the claim with the invalid vm status indicator
ROOT_CLAIM="0x01${ROOT_CLAIM:4}" ROOT_CLAIM="0x01${ROOT_CLAIM:4}"
......
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}") CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}")
MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}") MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}")
......
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*}") CHALLENGER_DIR="${SOURCE_DIR%/*}"
MONOREPO_DIR=$(echo "${CHALLENGER_DIR%/*}")
# ./create_game.sh <rpc-addr> <dispute-game-factory-addr> <cast signing args> # ./create_game.sh <rpc-addr> <dispute-game-factory-addr> <cast signing args>
RPC=${1:?Must specify RPC address} RPC=${1:?Must specify RPC address}
FACTORY_ADDR=${2:?Must specify factory address} FACTORY_ADDR=${2:?Must specify factory address}
ROOT_CLAIM=${3:?Must specify root claim} ROOT_CLAIM=${3:?Must specify root claim}
SIGNER_ARGS="${@:4}" SIGNER_ARGS=("${@:4}")
# Default to Cannon Fault game type # Default to Cannon Fault game type
GAME_TYPE=${GAME_TYPE:-0} GAME_TYPE=${GAME_TYPE:-0}
...@@ -33,8 +32,7 @@ echo "L2 Block Number: ${L2_BLOCK_NUM}" ...@@ -33,8 +32,7 @@ echo "L2 Block Number: ${L2_BLOCK_NUM}"
# Create a checkpoint in the block oracle to commit to the current L1 head. # Create a checkpoint in the block oracle to commit to the current L1 head.
# This defines the L1 head that will be used in the dispute game. # This defines the L1 head that will be used in the dispute game.
echo "Checkpointing the block oracle..." echo "Checkpointing the block oracle..."
# shellcheck disable=SC2086 L1_CHECKPOINT=$(cast send --rpc-url "${RPC}" "${SIGNER_ARGS[@]}" "${BLOCK_ORACLE_ADDR}" "checkpoint()" --json | jq -r '.logs[0].topics[1]' | cast to-dec)
L1_CHECKPOINT=$(cast send --rpc-url "${RPC}" ${SIGNER_ARGS} "${BLOCK_ORACLE_ADDR}" "checkpoint()" --json | jq -r '.logs[0].topics[1]' | cast to-dec)
echo "L1 Checkpoint: $L1_CHECKPOINT" echo "L1 Checkpoint: $L1_CHECKPOINT"
# Fault dispute game extra data is calculated as follows. # Fault dispute game extra data is calculated as follows.
...@@ -42,8 +40,7 @@ echo "L1 Checkpoint: $L1_CHECKPOINT" ...@@ -42,8 +40,7 @@ echo "L1 Checkpoint: $L1_CHECKPOINT"
EXTRA_DATA=$(cast abi-encode "f(uint256,uint256)" "${L2_BLOCK_NUM}" "${L1_CHECKPOINT}") EXTRA_DATA=$(cast abi-encode "f(uint256,uint256)" "${L2_BLOCK_NUM}" "${L1_CHECKPOINT}")
echo "Initializing the game" echo "Initializing the game"
# shellcheck disable=SC2086 FAULT_GAME_DATA=$(cast send --rpc-url "${RPC}" "${SIGNER_ARGS[@]}" "${FACTORY_ADDR}" "create(uint8,bytes32,bytes) returns(address)" "${GAME_TYPE}" "${ROOT_CLAIM}" "${EXTRA_DATA}" --json)
FAULT_GAME_DATA=$(cast send --rpc-url "${RPC}" ${SIGNER_ARGS} "${FACTORY_ADDR}" "create(uint8,bytes32,bytes) returns(address)" "${GAME_TYPE}" "${ROOT_CLAIM}" "${EXTRA_DATA}" --json)
# Extract the address of the newly created game from the receipt logs. # Extract the address of the newly created game from the receipt logs.
FAULT_GAME_ADDRESS=$(echo "${FAULT_GAME_DATA}" | jq -r '.logs[0].topics[1]' | cast parse-bytes32-address) FAULT_GAME_ADDRESS=$(echo "${FAULT_GAME_DATA}" | jq -r '.logs[0].topics[1]' | cast parse-bytes32-address)
......
...@@ -11,10 +11,9 @@ echo "Claim count: ${COUNT}" ...@@ -11,10 +11,9 @@ echo "Claim count: ${COUNT}"
for i in $(seq 0 "${COUNT}") for i in $(seq 0 "${COUNT}")
do do
CLAIM=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" 'claimData(uint256) returns(uint32 parentIndex, bool countered, bytes32 claim, uint128 position, uint128 clock)' "${i}") CLAIM=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" 'claimData(uint256) returns(uint32 parentIndex, bool countered, bytes32 claim, uint128 position, uint128 clock)' "${i}")
SAVEIFS=$IFS # Save current IFS (Internal Field Separator) # Use read -ra to safely split the string into an array named CLAIM, assuming
IFS=$'\n' # Change IFS to newline char # data is newline-separated.
CLAIM=($CLAIM) # split the string into an array by the same name IFS=$'\n' read -ra CLAIM <<< "$CLAIM"
IFS=$SAVEIFS # Restore original IFS
echo "${i} Parent: ${CLAIM[0]} Countered: ${CLAIM[1]} Claim: ${CLAIM[2]} Position: ${CLAIM[3]} Clock ${CLAIM[4]}" echo "${i} Parent: ${CLAIM[0]} Countered: ${CLAIM[1]} Claim: ${CLAIM[2]} Position: ${CLAIM[3]} Clock ${CLAIM[4]}"
done done
...@@ -15,11 +15,9 @@ fi ...@@ -15,11 +15,9 @@ fi
for i in $(seq 0 "${COUNT}") for i in $(seq 0 "${COUNT}")
do do
GAME=$(cast call --rpc-url "${RPC}" "${FACTORY_ADDR}" 'gameAtIndex(uint256) returns(uint8, uint64, address)' "${i}") GAME=$(cast call --rpc-url "${RPC}" "${FACTORY_ADDR}" 'gameAtIndex(uint256) returns(uint8, uint64, address)' "${i}")
# Use read -ra to safely split the string into an array named GAME, assuming
SAVEIFS=$IFS # Save current IFS (Internal Field Separator) # data is newline-separated.
IFS=$'\n' # Change IFS to newline char IFS=$'\n' read -ra GAME <<< "$GAME"
GAME=($GAME) # split the string into an array by the same name
IFS=$SAVEIFS # Restore original IFS
GAME_ADDR="${GAME[2]}" GAME_ADDR="${GAME[2]}"
CLAIMS=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" "claimDataLen() returns(uint256)") CLAIMS=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" "claimDataLen() returns(uint256)")
......
...@@ -6,7 +6,8 @@ GAME_ADDR=${2:?Must specify game address} ...@@ -6,7 +6,8 @@ GAME_ADDR=${2:?Must specify game address}
ACTION=${3:?Must specify attack or defend} ACTION=${3:?Must specify attack or defend}
PARENT_INDEX=${4:?Must specify parent index. Use latest to counter the latest claim added to the game.} PARENT_INDEX=${4:?Must specify parent index. Use latest to counter the latest claim added to the game.}
CLAIM=${5:?Must specify claim hash} CLAIM=${5:?Must specify claim hash}
SIGNER_ARGS="${@:6}" SIGNER_ARGS=("${@:6}")
if [[ "${ACTION}" != "attack" && "${ACTION}" != "defend" ]] if [[ "${ACTION}" != "attack" && "${ACTION}" != "defend" ]]
then then
...@@ -22,5 +23,4 @@ then ...@@ -22,5 +23,4 @@ then
fi fi
# Perform the move. # Perform the move.
# shellcheck disable=SC2086 cast send --rpc-url "${RPC}" "${SIGNER_ARGS[@]}" "${GAME_ADDR}" "$ACTION(uint256,bytes32)" "${PARENT_INDEX}" "${CLAIM}"
cast send --rpc-url "${RPC}" ${SIGNER_ARGS} "${GAME_ADDR}" "$ACTION(uint256,bytes32)" "${PARENT_INDEX}" "${CLAIM}"
...@@ -3,11 +3,11 @@ set -euo pipefail ...@@ -3,11 +3,11 @@ set -euo pipefail
RPC=${1:?Must specify RPC URL} RPC=${1:?Must specify RPC URL}
GAME_ADDR=${2:?Must specify game address} GAME_ADDR=${2:?Must specify game address}
SIGNER_ARGS="${@:3}" SIGNER_ARGS=("${@:3}")
# Perform the move. # Perform the move.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
RESULT_DATA=$(cast send --rpc-url "${RPC}" ${SIGNER_ARGS} "${GAME_ADDR}" "resolve()" --json) RESULT_DATA=$(cast send --rpc-url "${RPC}" "${SIGNER_ARGS[@]}" "${GAME_ADDR}" "resolve()" --json)
RESULT=$(echo "${RESULT_DATA}" | jq -r '.logs[0].topics[1]' | cast to-dec) RESULT=$(echo "${RESULT_DATA}" | jq -r '.logs[0].topics[1]' | cast to-dec)
if [[ "${RESULT}" == "0" ]] if [[ "${RESULT}" == "0" ]]
......
#!/usr/bin/env bash
echo "$1" echo "$1"
jq '.frames[] | {timestamp, inclusion_block}' "$1" jq '.frames[] | {timestamp, inclusion_block}' "$1"
jq '.batches[]|.Timestamp' "$1" jq '.batches[]|.Timestamp' "$1"
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
cd "$SOURCE_DIR" cd "$SOURCE_DIR"
export ETH_RPC_URL=https://ethereum-goerli-rpc.allthatnode.com export ETH_RPC_URL=https://ethereum-goerli-rpc.allthatnode.com
......
...@@ -14,8 +14,8 @@ WS_PORT="${WS_PORT:-8546}" ...@@ -14,8 +14,8 @@ WS_PORT="${WS_PORT:-8546}"
if [ ! -d "$GETH_KEYSTORE_DIR" ]; then if [ ! -d "$GETH_KEYSTORE_DIR" ]; then
echo "$GETH_KEYSTORE_DIR missing, running account import" echo "$GETH_KEYSTORE_DIR missing, running account import"
echo -n "pwd" > "$GETH_DATA_DIR"/password printf "%s" "pwd" > "$GETH_DATA_DIR"/password
echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key printf "%s" "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key
geth account import \ geth account import \
--datadir="$GETH_DATA_DIR" \ --datadir="$GETH_DATA_DIR" \
--password="$GETH_DATA_DIR"/password \ --password="$GETH_DATA_DIR"/password \
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
code=$? code=$?
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CONTRACTS_BASE=$(dirname $SCRIPT_DIR) CONTRACTS_BASE=$(dirname "$SCRIPT_DIR")
MONOREPO_BASE=$(dirname $(dirname $CONTRACTS_BASE)) MONOREPO_BASE=$(dirname "$(dirname "$CONTRACTS_BASE")")
for config in $CONTRACTS_BASE/deploy-config/*.json; do for config in "$CONTRACTS_BASE"/deploy-config/*.json; do
go run $MONOREPO_BASE/op-chain-ops/cmd/check-deploy-config/main.go --path $config # shellcheck disable=SC2086
[ $? -eq 0 ] || code=$? if ! go run "$MONOREPO_BASE/op-chain-ops/cmd/check-deploy-config/main.go" --path $config; then
code=1
fi
done done
exit $code exit $code
...@@ -38,7 +38,7 @@ wait_l2_outfile() { ...@@ -38,7 +38,7 @@ wait_l2_outfile() {
continue continue
fi fi
if [ $(du -m "$OUTFILE_L2" | cut -f1) -lt 8 ]; then if [ "$(du -m "$OUTFILE_L2" | cut -f1)" -lt 8 ]; then
sleep "$1" sleep "$1"
continue continue
fi fi
......
...@@ -63,7 +63,6 @@ if [[ ! -z "$TRIAGE_MODE" ]]; then ...@@ -63,7 +63,6 @@ if [[ ! -z "$TRIAGE_MODE" ]]; then
# If the slither report was generated successfully, and the slither triage exists, clean up the triaged output. # If the slither report was generated successfully, and the slither triage exists, clean up the triaged output.
if [ -f "$SLITHER_REPORT" ] && [ -f "$SLITHER_TRIAGE_REPORT" ]; then if [ -f "$SLITHER_REPORT" ] && [ -f "$SLITHER_TRIAGE_REPORT" ]; then
json=$(cat $SLITHER_TRIAGE_REPORT)
# The following jq command selects a subset of fields in each of the slither triage report description and element objects. # The following jq command selects a subset of fields in each of the slither triage report description and element objects.
# This significantly slims down the output json, on the order of 100 magnitudes smaller. # This significantly slims down the output json, on the order of 100 magnitudes smaller.
updated_json=$(cat $SLITHER_TRIAGE_REPORT | jq -r '[.[] | .id as $id | .description as $description | .check as $check | .impact as $impact | .confidence as $confidence | (.elements[] | .type as $type | .name as $name | (.source_mapping | { "id": $id, "impact": $impact, "confidence": $confidence, "check": $check, "description": $description, "type": $type, "name": $name, start, length, filename_relative } ))]') updated_json=$(cat $SLITHER_TRIAGE_REPORT | jq -r '[.[] | .id as $id | .description as $description | .check as $check | .impact as $impact | .confidence as $confidence | (.elements[] | .type as $type | .name as $name | (.source_mapping | { "id": $id, "impact": $impact, "confidence": $confidence, "check": $check, "description": $description, "type": $type, "name": $name, start, length, filename_relative } ))]')
...@@ -74,7 +73,7 @@ fi ...@@ -74,7 +73,7 @@ fi
# If slither failed to generate a report, exit with an error. # If slither failed to generate a report, exit with an error.
if [ ! -f "$SLITHER_REPORT" ]; then if [ ! -f "$SLITHER_REPORT" ]; then
echo "Slither output:\n$SLITHER_OUTPUT" printf "Slither output:\n%s\n" "$SLITHER_OUTPUT"
echo "Slither failed to generate a report." echo "Slither failed to generate a report."
if [ -e "$SLITHER_REPORT_BACKUP" ]; then if [ -e "$SLITHER_REPORT_BACKUP" ]; then
mv $SLITHER_REPORT_BACKUP $SLITHER_REPORT mv $SLITHER_REPORT_BACKUP $SLITHER_REPORT
...@@ -88,7 +87,6 @@ fi ...@@ -88,7 +87,6 @@ fi
# The following jq command selects a subset of fields in each of the slither triage report description and element objects. # The following jq command selects a subset of fields in each of the slither triage report description and element objects.
# This significantly slims down the output json, on the order of 100 magnitudes smaller. # This significantly slims down the output json, on the order of 100 magnitudes smaller.
echo "Slither ran successfully, generating minimzed report..." echo "Slither ran successfully, generating minimzed report..."
json=$(cat $SLITHER_REPORT)
updated_json=$(cat $SLITHER_REPORT | jq -r '[.results.detectors[] | .id as $id | .description as $description | .check as $check | .impact as $impact | .confidence as $confidence | (.elements[] | .type as $type | .name as $name | (.source_mapping | { "id": $id, "impact": $impact, "confidence": $confidence, "check": $check, "description": $description, "type": $type, "name": $name, start, length, filename_relative } ))]') updated_json=$(cat $SLITHER_REPORT | jq -r '[.results.detectors[] | .id as $id | .description as $description | .check as $check | .impact as $impact | .confidence as $confidence | (.elements[] | .type as $type | .name as $name | (.source_mapping | { "id": $id, "impact": $impact, "confidence": $confidence, "check": $check, "description": $description, "type": $type, "name": $name, start, length, filename_relative } ))]')
echo "$updated_json" > $SLITHER_REPORT echo "$updated_json" > $SLITHER_REPORT
echo "Slither report stored at $DIR/$SLITHER_REPORT" echo "Slither report stored at $DIR/$SLITHER_REPORT"
......
...@@ -31,6 +31,7 @@ export KONTROL_RELEASE=${KONTROLRC} ...@@ -31,6 +31,7 @@ export KONTROL_RELEASE=${KONTROLRC}
############# #############
kontrol_build() { kontrol_build() {
notif "Kontrol Build" notif "Kontrol Build"
# shellcheck disable=SC2086
docker_exec kontrol build \ docker_exec kontrol build \
--verbose \ --verbose \
--require ${lemmas} \ --require ${lemmas} \
...@@ -40,6 +41,7 @@ kontrol_build() { ...@@ -40,6 +41,7 @@ kontrol_build() {
kontrol_prove() { kontrol_prove() {
notif "Kontrol Prove" notif "Kontrol Prove"
# shellcheck disable=SC2086
docker_exec kontrol prove \ docker_exec kontrol prove \
--max-depth ${max_depth} \ --max-depth ${max_depth} \
--max-iterations ${max_iterations} \ --max-iterations ${max_iterations} \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment