diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 579539709..f93e27ddb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} diff --git a/Makefile b/Makefile index 93809c88f..1ec9e2422 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/bindings/encoding/input_test.go b/bindings/encoding/input_test.go index 23ed6cff5..0415d77c4 100644 --- a/bindings/encoding/input_test.go +++ b/bindings/encoding/input_test.go @@ -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) diff --git a/docker/docker_env.sh b/docker/docker_env.sh new file mode 100755 index 000000000..880c5ecc5 --- /dev/null +++ b/docker/docker_env.sh @@ -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") diff --git a/integration_test/nodes/docker-compose.yml b/docker/nodes/docker-compose.yml similarity index 95% rename from integration_test/nodes/docker-compose.yml rename to docker/nodes/docker-compose.yml index 7c52581fe..c22036495 100644 --- a/integration_test/nodes/docker-compose.yml +++ b/docker/nodes/docker-compose.yml @@ -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 @@ -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 diff --git a/integration_test/nodes/jwt.hex b/docker/nodes/jwt.hex similarity index 100% rename from integration_test/nodes/jwt.hex rename to docker/nodes/jwt.hex diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 000000000..65fa77d00 --- /dev/null +++ b/docker/start.sh @@ -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}}" diff --git a/docker/stop.sh b/docker/stop.sh new file mode 100755 index 000000000..919bb3521 --- /dev/null +++ b/docker/stop.sh @@ -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[@]}" diff --git a/driver/chain_syncer/calldata/syncer_test.go b/driver/chain_syncer/calldata/syncer_test.go index 54043f427..518d61992 100644 --- a/driver/chain_syncer/calldata/syncer_test.go +++ b/driver/chain_syncer/calldata/syncer_test.go @@ -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 diff --git a/driver/chain_syncer/chain_syncer_test.go b/driver/chain_syncer/chain_syncer_test.go index e323b650d..a64c133b9 100644 --- a/driver/chain_syncer/chain_syncer_test.go +++ b/driver/chain_syncer/chain_syncer_test.go @@ -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 @@ -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) diff --git a/driver/driver_test.go b/driver/driver_test.go index d5f233233..4f939dd48 100644 --- a/driver/driver_test.go +++ b/driver/driver_test.go @@ -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 diff --git a/integration_test/deploy_l1_contract.sh b/integration_test/deploy_l1_contract.sh new file mode 100755 index 000000000..e3480017a --- /dev/null +++ b/integration_test/deploy_l1_contract.sh @@ -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 + \ No newline at end of file diff --git a/integration_test/entrypoint.sh b/integration_test/entrypoint.sh index 566f13269..6e7447478 100755 --- a/integration_test/entrypoint.sh +++ b/integration_test/entrypoint.sh @@ -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 diff --git a/integration_test/l1_env.sh b/integration_test/l1_env.sh new file mode 100755 index 000000000..870294b7f --- /dev/null +++ b/integration_test/l1_env.sh @@ -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" diff --git a/integration_test/nodes/init.sh b/integration_test/nodes/init.sh deleted file mode 100755 index be96471c9..000000000 --- a/integration_test/nodes/init.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -eou pipefail - -DIR=$( - cd $(dirname ${BASH_SOURCE[0]}) - pwd -) - -echo "Starting testnet..." - -docker compose -f $TESTNET_CONFIG down -v --remove-orphans &>/dev/null -docker compose -f $TESTNET_CONFIG up -d - -echo "Waiting till testnet nodes fully started..." - -NODE_URL=localhost:18545 $DIR/../util/wait_for_node.sh -NODE_URL=localhost:28545 $DIR/../util/wait_for_node.sh - -# Get the hash of L2 genesis. -L2_GENESIS_HASH=$(cast block --rpc-url localhost:28545 0x0 -f hash) - -GUARDIAN_PROVERS_ADDRESSES_LIST=( - "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" - "0x90F79bf6EB2c4f870365E785982E1f101E93b906" - "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65" -) -GUARDIAN_PROVERS_ADDRESSES=$(printf ",%s" "${GUARDIAN_PROVERS_ADDRESSES_LIST[@]}") - -# Deploy Taiko protocol. -cd $TAIKO_MONO_DIR/packages/protocol && - PRIVATE_KEY=0x$L1_CONTRACT_OWNER_PRIVATE_KEY \ - GUARDIAN_PROVERS=${GUARDIAN_PROVERS_ADDRESSES:1} \ - TAIKO_L2_ADDRESS=$TAIKO_L2_CONTRACT_ADDRESS \ - L2_SIGNAL_SERVICE=$L2_SIGNAL_SERVICE_CONTRACT_ADDRESS \ - SECURITY_COUNCIL=$L1_SECURITY_COUNCIL_ADDRESS \ - TAIKO_TOKEN_PREMINT_RECIPIENT=$TAIKO_TOKEN_PREMINT_RECIPIENT_ADDRESS \ - TAIKO_TOKEN_NAME="Taiko Token Test" \ - TAIKO_TOKEN_SYMBOL=TTKOt \ - L2_GENESIS_HASH=$L2_GENESIS_HASH \ - MIN_GUARDIANS=${#GUARDIAN_PROVERS_ADDRESSES_LIST[@]} \ - SHARED_ADDRESS_MANAGER=0x0000000000000000000000000000000000000000 \ - PROPOSER=0x0000000000000000000000000000000000000000 \ - PROPOSER_ONE=0x0000000000000000000000000000000000000000 \ - forge script script/DeployOnL1.s.sol:DeployOnL1 \ - --fork-url http://localhost:18545 \ - --broadcast \ - --ffi \ - -vvvvv \ - --private-key 0x$L1_CONTRACT_OWNER_PRIVATE_KEY \ - --block-gas-limit 100000000 diff --git a/integration_test/test_env.sh b/integration_test/test_env.sh new file mode 100755 index 000000000..8ff64aa61 --- /dev/null +++ b/integration_test/test_env.sh @@ -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 diff --git a/integration_test/util/wait_for_node.sh b/integration_test/util/wait_for_node.sh deleted file mode 100755 index 4ad0b182c..000000000 --- a/integration_test/util/wait_for_node.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -eou pipefail - -if [[ -z $NODE_URL ]]; then - echo "Must pass NODE_URL" - exit 1 -fi - -JSON_REQUEST_BODY='{"jsonrpc":"2.0","id":0,"method":"eth_chainId","params":[]}' - -while ! curl \ - --fail \ - --silent \ - -X POST \ - -H "Content-Type: application/json" \ - -d "$JSON_REQUEST_BODY" \ - $NODE_URL > /dev/null -do - sleep 1 -done diff --git a/pkg/rpc/utils_test.go b/pkg/rpc/utils_test.go index 7a4edac67..c548208cf 100644 --- a/pkg/rpc/utils_test.go +++ b/pkg/rpc/utils_test.go @@ -43,7 +43,7 @@ func TestL1ContentFrom(t *testing.T) { baseFee, err := client.TaikoL2.GetBasefee(nil, 0, uint32(l2Head.GasUsed)) require.Nil(t, err) - testAddrPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY"))) + testAddrPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY"))) require.Nil(t, err) testAddr := crypto.PubkeyToAddress(testAddrPrivKey.PublicKey) diff --git a/proposer/proposer_test.go b/proposer/proposer_test.go index 0809c0142..4832af01f 100644 --- a/proposer/proposer_test.go +++ b/proposer/proposer_test.go @@ -25,7 +25,7 @@ type ProposerTestSuite struct { func (s *ProposerTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - 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) p := new(Proposer) diff --git a/proposer/prover_selector/eth_fee_eoa_selector_test.go b/proposer/prover_selector/eth_fee_eoa_selector_test.go index e77b1f427..70428806b 100644 --- a/proposer/prover_selector/eth_fee_eoa_selector_test.go +++ b/proposer/prover_selector/eth_fee_eoa_selector_test.go @@ -23,7 +23,7 @@ type ProverSelectorTestSuite struct { func (s *ProverSelectorTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) s.proverAddress = crypto.PubkeyToAddress(l1ProverPrivKey.PublicKey) diff --git a/prover/config.go b/prover/config.go index e71cd097e..fcdc1cca9 100644 --- a/prover/config.go +++ b/prover/config.go @@ -59,7 +59,7 @@ type Config struct { // NewConfigFromCliContext creates a new config instance from command line flags. func NewConfigFromCliContext(c *cli.Context) (*Config, error) { - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(c.String(flags.L1ProverPrivKey.Name))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(c.String(flags.L1ProverPrivKey.Name))) if err != nil { return nil, fmt.Errorf("invalid L1 prover private key: %w", err) } diff --git a/prover/proof_submitter/proof_submitter_test.go b/prover/proof_submitter/proof_submitter_test.go index 7da91c2db..d484e2b52 100644 --- a/prover/proof_submitter/proof_submitter_test.go +++ b/prover/proof_submitter/proof_submitter_test.go @@ -33,7 +33,7 @@ type ProofSubmitterTestSuite struct { func (s *ProofSubmitterTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) s.proofCh = make(chan *proofProducer.ProofWithHeader, 1024) @@ -83,7 +83,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { // Init proposer 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 diff --git a/prover/proof_submitter/transaction/sender_test.go b/prover/proof_submitter/transaction/sender_test.go index f45c4548a..51663dfb4 100644 --- a/prover/proof_submitter/transaction/sender_test.go +++ b/prover/proof_submitter/transaction/sender_test.go @@ -31,7 +31,7 @@ type TransactionTestSuite struct { func (s *TransactionTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) s.sender = NewSender(s.RpcClient, 5*time.Second, nil, 1*time.Minute) diff --git a/prover/prover_test.go b/prover/prover_test.go index 71bef0cd9..2260eac93 100644 --- a/prover/prover_test.go +++ b/prover/prover_test.go @@ -38,7 +38,7 @@ func (s *ProverTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() // Init prover - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) proverServerUrl := testutils.LocalRandomProverEndpoint() @@ -109,7 +109,7 @@ func (s *ProverTestSuite) SetupTest() { s.d = d // Init 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) prop := new(proposer.Proposer) @@ -145,7 +145,7 @@ func (s *ProverTestSuite) TestName() { func (s *ProverTestSuite) TestInitError() { ctx, cancel := context.WithCancel(context.Background()) cancel() - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) p := new(Prover) @@ -168,7 +168,7 @@ func (s *ProverTestSuite) TestInitError() { func (s *ProverTestSuite) TestOnBlockProposed() { // Init prover - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) s.p.cfg.L1ProverPrivKey = l1ProverPrivKey // Valid block diff --git a/prover/server/server_test.go b/prover/server/server_test.go index 1890f0e85..fa506ff2d 100644 --- a/prover/server/server_test.go +++ b/prover/server/server_test.go @@ -28,7 +28,7 @@ type ProverServerTestSuite struct { } func (s *ProverServerTestSuite) SetupTest() { - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) timeout := 5 * time.Second diff --git a/scripts/common.sh b/scripts/common.sh index 2d3744e0a..1c42be75f 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -3,6 +3,8 @@ RED='\033[1;31m' NC='\033[0m' # No Color +COMPOSE="docker compose -f docker/nodes/docker-compose.yml" + print_error() { local msg="$1" echo -e "${RED}$msg${NC}" @@ -25,3 +27,18 @@ check_command() { fi } +compose_down() { + local services=("$@") + echo + echo "stopping services..." + $COMPOSE down "${services[@]}" #--remove-orphans + echo "done" +} + +compose_up() { + local services=("$@") + echo + echo "launching services..." + $COMPOSE up --quiet-pull "${services[@]}" -d --wait + echo "done" +} diff --git a/testutils/suite.go b/testutils/suite.go index baf805c6b..482fbb182 100644 --- a/testutils/suite.go +++ b/testutils/suite.go @@ -61,7 +61,7 @@ func (s *ClientTestSuite) SetupTest() { s.Nil(err) s.RpcClient = rpcCli - l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROVER_PRIVATE_KEY"))) + l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) s.ProverEndpoints = []*url.URL{LocalRandomProverEndpoint()} @@ -72,12 +72,12 @@ func (s *ClientTestSuite) SetupTest() { if balance.Cmp(common.Big0) == 0 { // Do not verify zk && sgx proofs in tests. - securityConcilPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_SECURITY_COUNCIL_PRIVATE_KEY"))) + securityConcilPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_SECURITY_COUNCIL_PRIVATE_KEY"))) s.Nil(err) s.setAddress(securityConcilPrivKey, rpc.StringToBytes32("tier_sgx_and_pse_zkevm"), common.Address{}) s.setAddress(securityConcilPrivKey, rpc.StringToBytes32("tier_sgx"), common.Address{}) - ownerPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_CONTRACT_OWNER_PRIVATE_KEY"))) + ownerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_CONTRACT_OWNER_PRIVATE_KEY"))) s.Nil(err) // Transfer some tokens to provers.