Skip to content

Commit

Permalink
feat(kurtosis-devnet): add non-trivial smoke test
Browse files Browse the repository at this point in the history
This checks L2 to L2 messages against an interop devnet.
  • Loading branch information
sigma committed Jan 15, 2025
1 parent dcc3d7f commit e02406e
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 16 deletions.
10 changes: 0 additions & 10 deletions kurtosis-devnet/tests/boilerplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
set -euo pipefail

# Default values
DEVNET=""
ENVIRONMENT=""

# Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--devnet)
DEVNET="$2"
shift 2
;;
--environment)
ENVIRONMENT="$2"
shift 2
Expand All @@ -25,11 +20,6 @@ while [[ $# -gt 0 ]]; do
done

# Validate required arguments
if [ -z "$DEVNET" ]; then
echo "Error: --devnet argument is required" >&2
exit 1
fi

if [ -z "$ENVIRONMENT" ]; then
echo "Error: --environment argument is required" >&2
exit 1
Expand Down
97 changes: 91 additions & 6 deletions kurtosis-devnet/tests/interop-smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,96 @@
# shellcheck disable=SC1091
source "$(dirname "$0")/boilerplate.sh"

echo "DEVNET: $DEVNET"
echo "ENVIRONMENT:"
cat "$ENVIRONMENT"
blue=$(tput setaf 4)
normal=$(tput sgr0)

l1_name=$(cat "$ENVIRONMENT" | jq -r '.l1.name')
echo "L1 NAME: $l1_name"
function getData() {
jq -r "$1" "$ENVIRONMENT"
}

function step() {
echo "${blue}$1${normal}"
}

export L2_1_PORT=$(getData '.l2[0].nodes[0].services.el.endpoints.rpc.port')
export L2_2_PORT=$(getData '.l2[1].nodes[0].services.el.endpoints.rpc.port')
export L2_1_RPC="http://127.0.0.1:$L2_1_PORT"
export L2_2_RPC="http://127.0.0.1:$L2_2_PORT"

export L2_1_CHAINID=$(getData '.l2[0].id')
export L2_2_CHAINID=$(getData '.l2[1].id')

export MNEMONIC='test test test test test test test test test test test junk'
export USER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT

step "Wrap ETH into SuperchainWETH"
cast send 0x4200000000000000000000000000000000000024 \
--value "10ether" \
--rpc-url "$L2_1_RPC" \
--mnemonic "$MNEMONIC"

step "Check SuperchainWETH balance"
BALANCE=$(cast call 0x4200000000000000000000000000000000000024 \
"balanceOf(address)(uint256)" "$USER_ADDRESS" \
--rpc-url "$L2_1_RPC")
echo
echo "SuperchainWETH balance: $BALANCE"

step "Send SuperchainWETH through the SuperchainTokenBridge"
cast send 0x4200000000000000000000000000000000000028 \
"sendERC20(address,address,uint256,uint256)" \
0x4200000000000000000000000000000000000024 \
"$USER_ADDRESS" \
1000000000000000000 \
"$L2_2_CHAINID" \
--rpc-url "$L2_1_RPC" \
--mnemonic "$MNEMONIC" | tee "$TMPDIR/send_superchainweth.txt"

step "Build Identifier and payload"
grep '^logs\b' "$TMPDIR/send_superchainweth.txt" | sed -e 's/^logs/\{"logs":/' -e 's/$/\}/' > "$TMPDIR/send_superchainweth_logs.json"

function get_info() {
jq -r --arg addr "0x4200000000000000000000000000000000000023" \
'.logs[] | select(.address == $addr)' \
"$TMPDIR/send_superchainweth_logs.json"
}

export BLOCK_NUMBER=$(get_info | jq -r '.blockNumber')
export LOG_INDEX=$(get_info | jq -r '.logIndex')

export DEC_BLOCK_NUMBER=`cast to-dec $BLOCK_NUMBER`
export TIMESTAMP=`cast block $DEC_BLOCK_NUMBER --rpc-url $L2_1_RPC --field timestamp`

export TOPICS=$(get_info | jq -r '(.topics | join("") | gsub("0x"; ""))')
export DATA=$(get_info | jq -r '(.data | gsub("0x"; ""))')

export EVENT_PAYLOAD="0x$TOPICS$DATA"

echo "Event payload: $EVENT_PAYLOAD"

step "Relay SuperchainWETH through the L2toL2CrossDomainMessenger"
cast send 0x4200000000000000000000000000000000000023 \
"relayMessage((address,uint256,uint256,uint256,uint256),bytes)" \
"(0x4200000000000000000000000000000000000023,$BLOCK_NUMBER,$LOG_INDEX,$TIMESTAMP,$L2_1_CHAINID)" \
"$EVENT_PAYLOAD" \
--rpc-url "$L2_2_RPC" \
--mnemonic "$MNEMONIC"


#TODO: handle reverted duplicate
#step "Relay SuperchainWETH through the L2toL2CrossDomainMessenger"
#TX=$(cast send 0x4200000000000000000000000000000000000023 \
# "relayMessage((address,uint256,uint256,uint256,uint256),bytes)" \
# "(0x4200000000000000000000000000000000000023,$BLOCK_NUMBER,$LOG_INDEX,$TIMESTAMP,$L2_1_CHAINID)" \
# "$EVENT_PAYLOAD" \
# --rpc-url "$L2_2_RPC" \
# --mnemonic "$MNEMONIC" \
# --async)
#
#echo "TX: $TX"
#
#cast tx "$TX" --rpc-url "$L2_2_RPC"

cast --version

0 comments on commit e02406e

Please sign in to comment.