Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(prover): fix / upgrade integration test (#496)
Browse files Browse the repository at this point in the history
Co-authored-by: David <[email protected]>
  • Loading branch information
mask-pp and davidtaikocha committed Jan 12, 2024
1 parent 3794caf commit c63e681
Show file tree
Hide file tree
Showing 27 changed files with 183 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Install protocol dependencies
working-directory: ${{ env.TAIKO_MONO_DIR }}
run: cd ./packages/protocol && pnpm install && ./script/download_solc.sh && forge install
run: cd ./packages/protocol && pnpm install && forge install

- name: Test
working-directory: ${{ env.CLIENT_DIR }}
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ lint:

test:
@TAIKO_MONO_DIR=${TAIKO_MONO_DIR} \
COMPILE_PROTOCOL=${COMPILE_PROTOCOL} \
PACKAGE=${PACKAGE} \
RUN_TESTS=true \
./integration_test/entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion bindings/encoding/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestUnpackTxListBytes(t *testing.T) {
)
require.Nil(t, err)

l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
require.Nil(t, err)

opts, err := bind.NewKeyedTransactorWithChainID(l1ProposerPrivKey, chainID)
Expand Down
14 changes: 14 additions & 0 deletions docker/docker_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

export L1_NODE_HTTP_ENDPOINT=http://localhost:18545
export L1_NODE_WS_ENDPOINT=ws://localhost:18546
export L1_EXECUTION_ENGINE_AUTH_ENDPOINT=http://localhost:18551

export L2_EXECUTION_ENGINE_HTTP_ENDPOINT=http://localhost:28545
export L2_EXECUTION_ENGINE_WS_ENDPOINT=ws://localhost:28546
export L2_EXECUTION_ENGINE_AUTH_ENDPOINT=http://localhost:28551
export JWT_SECRET=$DIR/nodes/jwt.hex

export DOCKER_SERVICE_LIST=("l1_node" "l2_execution_engine")
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: "3.9"

services:
l1_node:
container_name: l1_node
image: ghcr.dockerproxy.com/foundry-rs/foundry:latest
restart: unless-stopped
pull_policy: always
Expand All @@ -14,6 +15,7 @@ services:
- "0.0.0.0"

l2_execution_engine:
container_name: l2_node
image: gcr.dockerproxy.com/evmchain/taiko-geth:taiko
restart: unless-stopped
pull_policy: always
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

source scripts/common.sh
source docker/docker_env.sh

# start docker compose service list
echo "start docker compose service: ${DOCKER_SERVICE_LIST[*]}"

compose_up "${DOCKER_SERVICE_LIST[@]}"

# check until L1 chain is ready
until cast chain-id --rpc-url "$L2_EXECUTION_ENGINE_HTTP_ENDPOINT"; do
sleep 1
done

# show all the running containers
echo
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}\t{{.Status}}"
9 changes: 9 additions & 0 deletions docker/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash


source scripts/common.sh
source docker/docker_env.sh

echo "stop docker compose service: ${DOCKER_SERVICE_LIST[*]}"

compose_down "${DOCKER_SERVICE_LIST[@]}"
2 changes: 1 addition & 1 deletion driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *CalldataSyncerTestSuite) SetupTest() {
s.s = syncer

prop := new(proposer.Proposer)
l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests

Expand Down
4 changes: 2 additions & 2 deletions driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *ChainSyncerTestSuite) SetupTest() {
s.s = syncer

prop := new(proposer.Proposer)
l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)
proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests

Expand Down Expand Up @@ -90,7 +90,7 @@ func (s *ChainSyncerTestSuite) TestAheadOfProtocolVerifiedHead2() {

// NOTE: need to prove the proposed blocks to be verified, writing helper function
// generate transactopts to interact with TaikoL1 contract with.
privKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY")))
privKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY")))
s.Nil(err)
opts, err := bind.NewKeyedTransactorWithChainID(privKey, s.RpcClient.L1ChainID)
s.Nil(err)
Expand Down
2 changes: 1 addition & 1 deletion driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *DriverTestSuite) SetupTest() {
// Init proposer
p := new(proposer.Proposer)

l1ProposerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)

proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests
Expand Down
19 changes: 19 additions & 0 deletions integration_test/deploy_l1_contract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

source scripts/common.sh

# load l1 chain deploy contracts environment variables
source integration_test/l1_env.sh

# check taiko-mono dir path environment.
check_env "TAIKO_MONO_DIR"

cd "$TAIKO_MONO_DIR"/packages/protocol &&
forge script script/DeployOnL1.s.sol:DeployOnL1 \
--fork-url "$L1_NODE_HTTP_ENDPOINT" \
--broadcast \
--ffi \
-vvvvv \
--private-key "$PRIVATE_KEY" \
--block-gas-limit 100000000

101 changes: 30 additions & 71 deletions integration_test/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,51 @@

set -eou pipefail

DIR=$(
cd $(dirname ${BASH_SOURCE[0]})
pwd
)

# load tool commands.
source "./scripts/common.sh"
source scripts/common.sh

# make sure all the commands are available.
check_command "solc"
check_command "cast"
check_command "forge"
check_command "docker"

# make sure environment variables are set
check_env "TAIKO_MONO_DIR"

TESTNET_CONFIG=$DIR/nodes/docker-compose.yml
# start and stop docker compose
docker/start.sh
trap "docker/stop.sh" EXIT INT KILL ERR

TAIKO_L2_CONTRACT_ADDRESS=0x1670010000000000000000000000000000010001
L2_SIGNAL_SERVICE_CONTRACT_ADDRESS=0x1670010000000000000000000000000000010005
L1_SECURITY_COUNCIL_ADDRESS=0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f
TAIKO_TOKEN_PREMINT_RECIPIENT_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
TREASURY=0x1670010000000000000000000000000000010001
L1_CONTRACT_OWNER_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
L1_SECURITY_COUNCIL_PRIVATE_KEY=dbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
L1_PROPOSER_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
L1_PROVER_PRIVATE_KEY=59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
# deploy l1 contracts
integration_test/deploy_l1_contract.sh

L1_CONTRACT_OWNER_PRIVATE_KEY=$L1_CONTRACT_OWNER_PRIVATE_KEY \
L2_SIGNAL_SERVICE_CONTRACT_ADDRESS=$L2_SIGNAL_SERVICE_CONTRACT_ADDRESS \
TAIKO_L2_CONTRACT_ADDRESS=$TAIKO_L2_CONTRACT_ADDRESS \
L1_SECURITY_COUNCIL_ADDRESS=$L1_SECURITY_COUNCIL_ADDRESS \
TAIKO_TOKEN_PREMINT_RECIPIENT_ADDRESS=$TAIKO_TOKEN_PREMINT_RECIPIENT_ADDRESS \
TESTNET_CONFIG=$TESTNET_CONFIG \
TAIKO_MONO_DIR=$TAIKO_MONO_DIR \
$DIR/nodes/init.sh
# load environment variables for integration test
source integration_test/test_env.sh

DEPLOYMENT_JSON=$(cat $TAIKO_MONO_DIR/packages/protocol/deployments/deploy_l1.json)
TAIKO_L1_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.taiko' | sed 's/\"//g')
L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.signal_service' | sed 's/\"//g')
TAIKO_TOKEN_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.taiko_token' | sed 's/\"//g')
ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.rollup_address_manager' | sed 's/\"//g')
GUARDIAN_PROVER_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.guardian_prover' | sed 's/\"//g')
ASSIGNMENT_HOOK_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.assignment_hook' | sed 's/\"//g')
TIMELOCK_CONTROLLER=$(echo $DEPLOYMENT_JSON | jq '.timelock_controller' | sed 's/\"//g')

trap "docker compose -f $TESTNET_CONFIG down -v" EXIT INT KILL ERR
# make sure environment variables are set
check_env "TAIKO_MONO_DIR"
check_env "L1_NODE_HTTP_ENDPOINT"
check_env "L1_NODE_WS_ENDPOINT"
check_env "L2_EXECUTION_ENGINE_HTTP_ENDPOINT"
check_env "L2_EXECUTION_ENGINE_WS_ENDPOINT"
check_env "L2_EXECUTION_ENGINE_AUTH_ENDPOINT"
check_env "TAIKO_L1_ADDRESS"
check_env "TAIKO_L2_ADDRESS"
check_env "TAIKO_TOKEN_ADDRESS"
check_env "ASSIGNMENT_HOOK_ADDRESS"
check_env "TIMELOCK_CONTROLLER"
check_env "ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS"
check_env "GUARDIAN_PROVER_CONTRACT_ADDRESS"
check_env "L1_SIGNAL_SERVICE_CONTRACT_ADDRESS"
check_env "L1_CONTRACT_OWNER_PRIVATE_KEY"
check_env "L1_SECURITY_COUNCIL_PRIVATE_KEY"
check_env "L1_PROPOSER_PRIVATE_KEY"
check_env "L1_PROVER_PRIVATE_KEY"
check_env "TREASURY"
check_env "JWT_SECRET"

RUN_TESTS=${RUN_TESTS:-false}
PACKAGE=${PACKAGE:-...}

echo "TAIKO_L1_CONTRACT_ADDRESS: $TAIKO_L1_CONTRACT_ADDRESS"
echo "TAIKO_L2_CONTRACT_ADDRESS: $TAIKO_L2_CONTRACT_ADDRESS"
echo "L2_SIGNAL_SERVICE_CONTRACT_ADDRESS: $L2_SIGNAL_SERVICE_CONTRACT_ADDRESS"
echo "TAIKO_TOKEN_CONTRACT_ADDRESS: $TAIKO_TOKEN_CONTRACT_ADDRESS"
echo "L1_SIGNAL_SERVICE_CONTRACT_ADDRESS: $L1_SIGNAL_SERVICE_CONTRACT_ADDRESS"
echo "GUARDIAN_PROVER_CONTRACT_ADDRESS: $GUARDIAN_PROVER_CONTRACT_ADDRESS"
echo "ASSIGNMENT_HOOK_CONTRACT_ADDRESS: $ASSIGNMENT_HOOK_CONTRACT_ADDRESS"
echo "TIMELOCK_CONTROLLER: $TIMELOCK_CONTROLLER"
echo "L1_SECURITY_COUNCIL_PRIVATE_KEY: $L1_SECURITY_COUNCIL_PRIVATE_KEY"
echo "TAIKO_TOKEN_PREMINT_RECIPIENT_ADDRESS: $TAIKO_TOKEN_PREMINT_RECIPIENT_ADDRESS"
echo "TREASURY: $TREASURY"

if [ "$RUN_TESTS" == "true" ]; then
L1_NODE_HTTP_ENDPOINT=http://localhost:18545 \
L1_NODE_WS_ENDPOINT=ws://localhost:18546 \
L2_EXECUTION_ENGINE_HTTP_ENDPOINT=http://localhost:28545 \
L2_EXECUTION_ENGINE_WS_ENDPOINT=ws://localhost:28546 \
L2_EXECUTION_ENGINE_AUTH_ENDPOINT=http://localhost:28551 \
TAIKO_L1_ADDRESS=$TAIKO_L1_CONTRACT_ADDRESS \
TAIKO_L2_ADDRESS=$TAIKO_L2_CONTRACT_ADDRESS \
TAIKO_TOKEN_ADDRESS=$TAIKO_TOKEN_CONTRACT_ADDRESS \
ASSIGNMENT_HOOK_ADDRESS=$ASSIGNMENT_HOOK_CONTRACT_ADDRESS \
TIMELOCK_CONTROLLER=$TIMELOCK_CONTROLLER \
ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS=$ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS \
GUARDIAN_PROVER_CONTRACT_ADDRESS=$GUARDIAN_PROVER_CONTRACT_ADDRESS \
L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$L1_SIGNAL_SERVICE_CONTRACT_ADDRESS \
L1_CONTRACT_OWNER_PRIVATE_KEY=$L1_CONTRACT_OWNER_PRIVATE_KEY \
L1_SECURITY_COUNCIL_PRIVATE_KEY=$L1_SECURITY_COUNCIL_PRIVATE_KEY \
L1_PROPOSER_PRIVATE_KEY=$L1_PROPOSER_PRIVATE_KEY \
L1_PROVER_PRIVATE_KEY=$L1_PROVER_PRIVATE_KEY \
TREASURY=$TREASURY \
JWT_SECRET=$DIR/nodes/jwt.hex \
go test -v -p=1 ./$PACKAGE -coverprofile=coverage.out -covermode=atomic -timeout=700s
go test -v -p=1 ./"$PACKAGE" -coverprofile=coverage.out -covermode=atomic -timeout=700s
else
echo "💻 Local dev net started"
docker compose -f $TESTNET_CONFIG logs -f l2_execution_engine
fi
30 changes: 30 additions & 0 deletions integration_test/l1_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

source docker/docker_env.sh

export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
export TAIKO_L2_ADDRESS=0x1670010000000000000000000000000000010001
export L2_SIGNAL_SERVICE=0x1670010000000000000000000000000000010005
export SECURITY_COUNCIL=0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f
export TAIKO_TOKEN_PREMINT_RECIPIENT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
export TAIKO_TOKEN_NAME="Taiko Token Test"
export TAIKO_TOKEN_SYMBOL="TTKOt"

export SHARED_ADDRESS_MANAGER=0x0000000000000000000000000000000000000000
export PROPOSER=0x0000000000000000000000000000000000000000
export PROPOSER_ONE=0x0000000000000000000000000000000000000000

GUARDIAN_PROVERS_ADDRESSES_LIST=(
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
"0x90F79bf6EB2c4f870365E785982E1f101E93b906"
"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65"
)
GUARDIAN_PROVERS_ADDRESSES=$(printf ",%s" "${GUARDIAN_PROVERS_ADDRESSES_LIST[@]}")
export GUARDIAN_PROVERS=${GUARDIAN_PROVERS_ADDRESSES:1}
export MIN_GUARDIANS=${#GUARDIAN_PROVERS_ADDRESSES_LIST[@]}

# Get the hash of L2 genesis.
export L2_GENESIS_HASH=$(cast block --rpc-url "$L2_EXECUTION_ENGINE_HTTP_ENDPOINT" 0x0 -f hash)
echo "L2 chain genesis hash: $L2_GENESIS_HASH"
53 changes: 0 additions & 53 deletions integration_test/nodes/init.sh

This file was deleted.

23 changes: 23 additions & 0 deletions integration_test/test_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

source docker/docker_env.sh
source scripts/common.sh

# make sure environment variables are set.
check_env "TAIKO_MONO_DIR"

# get deployed contract address.
DEPLOYMENT_JSON=$(cat "$TAIKO_MONO_DIR"/packages/protocol/deployments/deploy_l1.json)
export TAIKO_L1_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.taiko' | sed 's/\"//g')
export TAIKO_L2_ADDRESS=0x1670010000000000000000000000000000010001
export TAIKO_TOKEN_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.taiko_token' | sed 's/\"//g')
export ASSIGNMENT_HOOK_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.assignment_hook' | sed 's/\"//g')
export TIMELOCK_CONTROLLER=$(echo "$DEPLOYMENT_JSON" | jq '.timelock_controller' | sed 's/\"//g')
export ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.rollup_address_manager' | sed 's/\"//g')
export GUARDIAN_PROVER_CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.guardian_prover' | sed 's/\"//g')
export L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.signal_service' | sed 's/\"//g')
export L1_CONTRACT_OWNER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
export L1_SECURITY_COUNCIL_PRIVATE_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
export L1_PROPOSER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
export L1_PROVER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
export TREASURY=0x1670010000000000000000000000000000010001
21 changes: 0 additions & 21 deletions integration_test/util/wait_for_node.sh

This file was deleted.

Loading

0 comments on commit c63e681

Please sign in to comment.