Commit cfffa383 authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

op-challenger: Update manual testing scripts (#8948)

Removes the `make alphabet` target and associated scripts as its no longer possible to specify an alternate canonical alphabet so both challengers are being honest.
parent a1e846d1
...@@ -19,19 +19,8 @@ test: ...@@ -19,19 +19,8 @@ test:
visualize: visualize:
./scripts/visualize.sh ./scripts/visualize.sh
alphabet:
./scripts/alphabet/init_game.sh
make alphabet-actors
alphabet-actors:
@./scripts/parallel.sh \
./scripts/alphabet/mallory.sh 'mallory' \
./scripts/alphabet/charlie.sh 'charlie'
.PHONY: \ .PHONY: \
op-challenger \ op-challenger \
clean \ clean \
test \ test \
visualize \ visualize
alphabet \
alphabet-actors
...@@ -94,18 +94,15 @@ These scripts assume that the following tools are installed and available on the ...@@ -94,18 +94,15 @@ These scripts assume that the following tools are installed and available on the
### [create_game.sh](scripts/create_game.sh) ### [create_game.sh](scripts/create_game.sh)
```shell ```shell
./scripts/create_game.sh <RPC_URL> <GAME_FACTORY_ADDRESS> <ROOT_CLAIM> <SIGNER_ARGS>... ./scripts/create_game.sh <RPC_URL> <GAME_FACTORY_ADDRESS> <OUTPUT_ROOT> <L2_BLOCK_NUM> <SIGNER_ARGS>...
``` ```
Starts a new fault dispute game that disputes the latest output proposal in the L2 output oracle. Starts a new fault dispute game that disputes the latest output proposal in the L2 output oracle.
* `RPC_URL` - the RPC endpoint of the L1 endpoint to use (e.g. `http://localhost:8545`). * `RPC_URL` - the RPC endpoint of the L1 endpoint to use (e.g. `http://localhost:8545`).
* `GAME_FACTORY_ADDRESS` - the address of the dispute game factory contract on L1. * `GAME_FACTORY_ADDRESS` - the address of the dispute game factory contract on L1.
* `ROOT_CLAIM` a hex encoded 32 byte hash to use as the root claim for the created game. * `OUTPUT_ROOT` a hex encoded 32 byte hash that is used as the proposed output root.
* The root claim must have the high-order byte set to the * `L2_BLOCK_NUM` the L2 block number the proposed output root is from.
invalid [VM status](../specs/cannon-fault-proof-vm.md#state-hash) (`0x01`) to indicate that the trace concludes
that the disputed output root is invalid.
e.g. `0x0146381068b59d2098495baa72ed2f773c1e09458610a7a208984859dff73add`
* `SIGNER_ARGS` the remaining args are past as arguments to `cast` when sending transactions. * `SIGNER_ARGS` the remaining args are past as arguments to `cast` when sending transactions.
These arguments must specify a way for `cast` to sign the transactions. These arguments must specify a way for `cast` to sign the transactions.
See `cast send --help` for supported options. See `cast send --help` for supported options.
......
#!/usr/bin/env bash
set -euo pipefail
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR="${SOURCE_DIR%/*/*}"
MONOREPO_DIR="${SOURCE_DIR%/*/*/*}"
# Check that the fault game address file exists
FAULT_GAME_ADDR_FILE="$CHALLENGER_DIR/.fault-game-address"
if [[ ! -f "$FAULT_GAME_ADDR_FILE" ]]; then
echo "Game not initialized, exiting..."
exit 1
fi
# Charlie's Address: 0xF45B7537828CB2fffBC69996B054c2Aaf36DC778
CHARLIE_KEY="74feb147d72bfae943e6b4e483410933d9e447d5dc47d52432dcc2c1454dabb7"
DISPUTE_GAME_PROXY=$(jq -r .DisputeGameFactoryProxy "$MONOREPO_DIR"/.devnet/addresses.json)
FAULT_GAME_ADDRESS=$(cat "$FAULT_GAME_ADDR_FILE")
echo "Fault dispute game address: $FAULT_GAME_ADDRESS"
DATADIR=$(mktemp -d)
trap cleanup SIGINT
cleanup(){
rm -rf "${DATADIR}"
}
"$CHALLENGER_DIR"/bin/op-challenger \
--l1-eth-rpc http://localhost:8545 \
--trace-type="alphabet" \
--alphabet "abcdefgh" \
--datadir "${DATADIR}" \
--game-factory-address "$DISPUTE_GAME_PROXY" \
--game-allowlist "$FAULT_GAME_ADDRESS" \
--private-key "$CHARLIE_KEY" \
--num-confirmations 1 \
--metrics.enabled --metrics.port=7304 \
--pprof.enabled --pprof.port=6064
#!/usr/bin/env bash
set -euo pipefail
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR="${SOURCE_DIR%/*/*}"
MONOREPO_DIR="${SOURCE_DIR%/*/*/*}"
cd "$CHALLENGER_DIR"
make
cd "$MONOREPO_DIR"
make devnet-clean
make devnet-up
DEVNET_SPONSOR="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
DISPUTE_GAME_FACTORY=$(jq -r .DisputeGameFactoryProxy "$MONOREPO_DIR"/.devnet/addresses.json)
echo "----------------------------------------------------------------"
echo " Dispute Game Factory at $DISPUTE_GAME_FACTORY"
echo "----------------------------------------------------------------"
L2_OUTPUT_ORACLE_PROXY=$(jq -r .L2OutputOracleProxy "$MONOREPO_DIR"/.devnet/addresses.json)
echo "----------------------------------------------------------------"
echo " L2 Output Oracle Proxy at $L2_OUTPUT_ORACLE_PROXY"
echo "----------------------------------------------------------------"
BLOCK_ORACLE_PROXY=$(jq -r .BlockOracle "$MONOREPO_DIR"/.devnet/addresses.json)
echo "----------------------------------------------------------------"
echo " Block Oracle Proxy at $BLOCK_ORACLE_PROXY"
echo "----------------------------------------------------------------"
CHARLIE_ADDRESS="0xF45B7537828CB2fffBC69996B054c2Aaf36DC778"
MALLORY_ADDRESS="0x4641c704a6c743f73ee1f36C7568Fbf4b80681e4"
echo "----------------------------------------------------------------"
echo " - Fetching balance of the sponsor"
echo " - Balance: $(cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)"
echo "----------------------------------------------------------------"
echo "Funding Charlie"
cast send "$CHARLIE_ADDRESS" --value 5ether --private-key "$DEVNET_SPONSOR"
echo "Funding Mallory"
cast send "$MALLORY_ADDRESS" --value 5ether --private-key "$DEVNET_SPONSOR"
# Loop and wait until there are at least 2 outputs in the l2 output oracle
echo "Waiting until 2 output proposals are in the l2 output oracle..."
echo "NOTE: This may show errors if no output proposals are in the oracle yet."
while [[ $(cast call "$L2_OUTPUT_ORACLE_PROXY" "latestOutputIndex()" | cast to-dec) -lt 2 ]]
do
echo "[BLOCK: $(cast block-number)] Waiting for output proposals..."
sleep 2
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)")
# Replace the first byte of the claim with the invalid vm status indicator
ROOT_CLAIM="0x01${ROOT_CLAIM:4}"
GAME_TYPE=255 "${SOURCE_DIR}"/../create_game.sh http://localhost:8545 "${DISPUTE_GAME_FACTORY}" "${ROOT_CLAIM}" --private-key "${DEVNET_SPONSOR}"
#!/usr/bin/env bash
set -euo pipefail
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR="${SOURCE_DIR%/*/*}"
MONOREPO_DIR="${SOURCE_DIR%/*/*/*}"
# Check that the fault game address file exists
FAULT_GAME_ADDR_FILE="$CHALLENGER_DIR/.fault-game-address"
if [[ ! -f "$FAULT_GAME_ADDR_FILE" ]]; then
echo "Game not initialized, exiting..."
exit 1
fi
# Mallory's Address: 0x4641c704a6c743f73ee1f36C7568Fbf4b80681e4
MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
DISPUTE_GAME_PROXY=$(jq -r .DisputeGameFactoryProxy "$MONOREPO_DIR"/.devnet/addresses.json)
FAULT_GAME_ADDRESS=$(cat "$FAULT_GAME_ADDR_FILE")
echo "Fault dispute game address: $FAULT_GAME_ADDRESS"
DATADIR=$(mktemp -d)
trap cleanup SIGINT
cleanup(){
rm -rf "${DATADIR}"
}
"$CHALLENGER_DIR"/bin/op-challenger \
--l1-eth-rpc http://localhost:8545 \
--trace-type="alphabet" \
--alphabet "abcdexyz" \
--datadir "${DATADIR}" \
--game-factory-address "$DISPUTE_GAME_PROXY" \
--game-allowlist "$FAULT_GAME_ADDRESS" \
--private-key "$MALLORY_KEY" \
--num-confirmations 1 \
--metrics.enabled --metrics.port=7305 \
--pprof.enabled --pprof.port=6065
...@@ -4,40 +4,19 @@ set -euo pipefail ...@@ -4,40 +4,19 @@ set -euo pipefail
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CHALLENGER_DIR="${SOURCE_DIR%/*}" CHALLENGER_DIR="${SOURCE_DIR%/*}"
# ./create_game.sh <rpc-addr> <dispute-game-factory-addr> <root-claim> <cast signing args> # ./create_game.sh <rpc-addr> <dispute-game-factory-addr> <output-root> <l2-block-num> <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 claimed output root}
SIGNER_ARGS=("${@:4}") L2_BLOCK_NUM=${4:?Must specify L2 block number of claimed output root}
SIGNER_ARGS=("${@:5}")
# Default to Cannon Fault game type # Default to Cannon Fault game type
GAME_TYPE=${GAME_TYPE:-0} GAME_TYPE=${GAME_TYPE:-0}
# Get the fault dispute game implementation addr
GAME_IMPL_ADDR=$(cast call --rpc-url "${RPC}" "${FACTORY_ADDR}" 'gameImpls(uint8) returns(address)' "${GAME_TYPE}")
echo "Fault dispute game impl: ${GAME_IMPL_ADDR}"
# Get the L2 output oracle address
L2OO_ADDR=$(cast call --rpc-url "${RPC}" "${GAME_IMPL_ADDR}" 'L2_OUTPUT_ORACLE() returns(address)')
echo "L2OO: ${L2OO_ADDR}"
# Get the block oracle address
BLOCK_ORACLE_ADDR=$(cast call --rpc-url "${RPC}" "${GAME_IMPL_ADDR}" 'BLOCK_ORACLE() returns(address)')
echo "Block Oracle: ${BLOCK_ORACLE_ADDR}"
# Get the L2 block number of the latest output proposal. This is the proposal that will be disputed by the created game.
L2_BLOCK_NUM=$(cast call --rpc-url "${RPC}" "${L2OO_ADDR}" 'latestBlockNumber() returns(uint256)')
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..."
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. # Fault dispute game extra data is calculated as follows.
# abi.encode(uint256(l2_block_number), uint256(l1 checkpoint)) # abi.encode(uint256(l2_block_number), uint256(l1 checkpoint))
EXTRA_DATA=$(cast abi-encode "f(uint256,uint256)" "${L2_BLOCK_NUM}" "${L1_CHECKPOINT}") EXTRA_DATA=$(cast abi-encode "f(uint256)" "${L2_BLOCK_NUM}" )
echo "Initializing the game" echo "Initializing the game"
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)
......
...@@ -10,12 +10,12 @@ echo "Claim count: ${COUNT}" ...@@ -10,12 +10,12 @@ echo "Claim count: ${COUNT}"
((COUNT=COUNT-1)) ((COUNT=COUNT-1))
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, address counteredBy, address claimant, uint128 bond, bytes32 claim, uint128 position, uint128 clock)' "${i}")
SAVEIFS=$IFS # Save current IFS (Internal Field Separator) SAVEIFS=$IFS # Save current IFS (Internal Field Separator)
IFS=$'\n' # Change IFS to newline char IFS=$'\n' # Change IFS to newline char
# shellcheck disable=SC2206 # shellcheck disable=SC2206
CLAIM=($CLAIM) # split the string into an array by the same name CLAIM=($CLAIM) # split the string into an array by the same name
IFS=$SAVEIFS # Restore original IFS 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 By: ${CLAIM[1]} Claimant: ${CLAIM[2]} Bond: ${CLAIM[3]} Claim: ${CLAIM[4]} Position: ${CLAIM[5]} Clock ${CLAIM[6]}"
done done
...@@ -23,7 +23,7 @@ do ...@@ -23,7 +23,7 @@ do
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)")
STATUS=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" "status() return(uint8)" | cast to-dec) STATUS=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" "status() returns(uint8)" | cast to-dec)
if [[ "${STATUS}" == "0" ]] if [[ "${STATUS}" == "0" ]]
then then
STATUS="In Progress" STATUS="In Progress"
......
#!/usr/bin/env bash
# set -x
trap killgroup SIGINT
killgroup(){
echo killing...
kill 0
}
$1 | sed "s/^/[$2] /" &
$3 | sed "s/^/[$4] /" &
wait
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