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
set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}")
MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}")
......
......@@ -2,7 +2,7 @@
set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}")
MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}")
......@@ -34,10 +34,10 @@ echo " Block Oracle Proxy at $BLOCK_ORACLE_PROXY"
echo "----------------------------------------------------------------"
CHARLIE_ADDRESS="0xF45B7537828CB2fffBC69996B054c2Aaf36DC778"
CHARLIE_KEY="74feb147d72bfae943e6b4e483410933d9e447d5dc47d52432dcc2c1454dabb7"
# CHARLIE_KEY="74feb147d72bfae943e6b4e483410933d9e447d5dc47d52432dcc2c1454dabb7"
MALLORY_ADDRESS="0x4641c704a6c743f73ee1f36C7568Fbf4b80681e4"
MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
# MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
echo "----------------------------------------------------------------"
echo " - Fetching balance of the sponsor"
......@@ -61,7 +61,7 @@ done
# Root claim commits to the entire trace.
# 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
ROOT_CLAIM="0x01${ROOT_CLAIM:4}"
......
#!/usr/bin/env bash
set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*/*}")
MONOREPO_DIR=$(echo "${SOURCE_DIR%/*/*/*}")
......
#!/usr/bin/env bash
set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
CHALLENGER_DIR=$(echo "${SOURCE_DIR%/*}")
MONOREPO_DIR=$(echo "${CHALLENGER_DIR%/*}")
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR="${SOURCE_DIR%/*}"
# ./create_game.sh <rpc-addr> <dispute-game-factory-addr> <cast signing args>
RPC=${1:?Must specify RPC address}
FACTORY_ADDR=${2:?Must specify factory address}
ROOT_CLAIM=${3:?Must specify root claim}
SIGNER_ARGS="${@:4}"
SIGNER_ARGS=("${@:4}")
# Default to Cannon Fault game type
GAME_TYPE=${GAME_TYPE:-0}
......@@ -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.
# This defines the L1 head that will be used in the dispute game.
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"
# Fault dispute game extra data is calculated as follows.
......@@ -42,8 +40,7 @@ echo "L1 Checkpoint: $L1_CHECKPOINT"
EXTRA_DATA=$(cast abi-encode "f(uint256,uint256)" "${L2_BLOCK_NUM}" "${L1_CHECKPOINT}")
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.
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}"
for i in $(seq 0 "${COUNT}")
do
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)
IFS=$'\n' # Change IFS to newline char
CLAIM=($CLAIM) # split the string into an array by the same name
IFS=$SAVEIFS # Restore original IFS
# Use read -ra to safely split the string into an array named CLAIM, assuming
# data is newline-separated.
IFS=$'\n' read -ra CLAIM <<< "$CLAIM"
echo "${i} Parent: ${CLAIM[0]} Countered: ${CLAIM[1]} Claim: ${CLAIM[2]} Position: ${CLAIM[3]} Clock ${CLAIM[4]}"
done
......@@ -15,11 +15,9 @@ fi
for i in $(seq 0 "${COUNT}")
do
GAME=$(cast call --rpc-url "${RPC}" "${FACTORY_ADDR}" 'gameAtIndex(uint256) returns(uint8, uint64, address)' "${i}")
SAVEIFS=$IFS # Save current IFS (Internal Field Separator)
IFS=$'\n' # Change IFS to newline char
GAME=($GAME) # split the string into an array by the same name
IFS=$SAVEIFS # Restore original IFS
# Use read -ra to safely split the string into an array named GAME, assuming
# data is newline-separated.
IFS=$'\n' read -ra GAME <<< "$GAME"
GAME_ADDR="${GAME[2]}"
CLAIMS=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" "claimDataLen() returns(uint256)")
......
......@@ -6,7 +6,8 @@ GAME_ADDR=${2:?Must specify game address}
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.}
CLAIM=${5:?Must specify claim hash}
SIGNER_ARGS="${@:6}"
SIGNER_ARGS=("${@:6}")
if [[ "${ACTION}" != "attack" && "${ACTION}" != "defend" ]]
then
......@@ -22,5 +23,4 @@ then
fi
# 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
RPC=${1:?Must specify RPC URL}
GAME_ADDR=${2:?Must specify game address}
SIGNER_ARGS="${@:3}"
SIGNER_ARGS=("${@:3}")
# Perform the move.
# 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)
if [[ "${RESULT}" == "0" ]]
......
#!/usr/bin/env bash
echo "$1"
jq '.frames[] | {timestamp, inclusion_block}' "$1"
jq '.batches[]|.Timestamp' "$1"
#!/bin/bash
set -euo pipefail
SOURCE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
cd "$SOURCE_DIR"
export ETH_RPC_URL=https://ethereum-goerli-rpc.allthatnode.com
......
......@@ -14,8 +14,8 @@ WS_PORT="${WS_PORT:-8546}"
if [ ! -d "$GETH_KEYSTORE_DIR" ]; then
echo "$GETH_KEYSTORE_DIR missing, running account import"
echo -n "pwd" > "$GETH_DATA_DIR"/password
echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key
printf "%s" "pwd" > "$GETH_DATA_DIR"/password
printf "%s" "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key
geth account import \
--datadir="$GETH_DATA_DIR" \
--password="$GETH_DATA_DIR"/password \
......
......@@ -7,12 +7,14 @@
code=$?
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CONTRACTS_BASE=$(dirname $SCRIPT_DIR)
MONOREPO_BASE=$(dirname $(dirname $CONTRACTS_BASE))
CONTRACTS_BASE=$(dirname "$SCRIPT_DIR")
MONOREPO_BASE=$(dirname "$(dirname "$CONTRACTS_BASE")")
for config in $CONTRACTS_BASE/deploy-config/*.json; do
go run $MONOREPO_BASE/op-chain-ops/cmd/check-deploy-config/main.go --path $config
[ $? -eq 0 ] || code=$?
for config in "$CONTRACTS_BASE"/deploy-config/*.json; do
# shellcheck disable=SC2086
if ! go run "$MONOREPO_BASE/op-chain-ops/cmd/check-deploy-config/main.go" --path $config; then
code=1
fi
done
exit $code
......@@ -38,7 +38,7 @@ wait_l2_outfile() {
continue
fi
if [ $(du -m "$OUTFILE_L2" | cut -f1) -lt 8 ]; then
if [ "$(du -m "$OUTFILE_L2" | cut -f1)" -lt 8 ]; then
sleep "$1"
continue
fi
......
......@@ -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 [ -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.
# 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 } ))]')
......@@ -74,7 +73,7 @@ fi
# If slither failed to generate a report, exit with an error.
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."
if [ -e "$SLITHER_REPORT_BACKUP" ]; then
mv $SLITHER_REPORT_BACKUP $SLITHER_REPORT
......@@ -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.
# This significantly slims down the output json, on the order of 100 magnitudes smaller.
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 } ))]')
echo "$updated_json" > $SLITHER_REPORT
echo "Slither report stored at $DIR/$SLITHER_REPORT"
......
......@@ -31,6 +31,7 @@ export KONTROL_RELEASE=${KONTROLRC}
#############
kontrol_build() {
notif "Kontrol Build"
# shellcheck disable=SC2086
docker_exec kontrol build \
--verbose \
--require ${lemmas} \
......@@ -40,6 +41,7 @@ kontrol_build() {
kontrol_prove() {
notif "Kontrol Prove"
# shellcheck disable=SC2086
docker_exec kontrol prove \
--max-depth ${max_depth} \
--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