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

Commit

Permalink
feat: update test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Dec 5, 2023
1 parent 55c191a commit 53b9db3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 31 deletions.
2 changes: 1 addition & 1 deletion driver/anchor_tx_constructor/anchor_tx_constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *AnchorTxConstructor) transactOpts(
) (*bind.TransactOpts, error) {
var (
signer = types.LatestSignerForChainID(c.rpc.L2ChainID)
parentHeight = new(big.Int).Sub(l2Height, big.NewInt(1))
parentHeight = new(big.Int).Sub(l2Height, common.Big1)
)

// Get the nonce of golden touch account at the specified parentHeight.
Expand Down
37 changes: 28 additions & 9 deletions integration_test/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ fi

TESTNET_CONFIG=$DIR/nodes/docker-compose.yml

TAIKO_L2_CONTRACT_ADDRESS=0x1670010000000000000000000000000000010001
L2_SIGNAL_SERVICE_CONTRACT_ADDRESS=0x1670010000000000000000000000000000010005
L1_SECURITY_COUNCIL_ADDRESS=0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f
TAIKO_TOKEN_PREMINT_RECIPIENT_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
TREASURY=0xdf09A0afD09a63fb04ab3573922437e1e637dE8b
L1_CONTRACT_OWNER_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
L1_SECURITY_COUNCIL_PRIVATE_KEY=dbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
L1_PROPOSER_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
L1_PROVER_PRIVATE_KEY=59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d

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
Expand All @@ -27,7 +42,7 @@ DEPLOYMENT_JSON=$(cat $TAIKO_MONO_DIR/packages/protocol/deployments/deploy_l1.js
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')
ADDRESS_MANAGER_CONTRACT_ADDRESS=$(echo $DEPLOYMENT_JSON | jq '.rollup_address_manager' | 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')
Expand All @@ -38,11 +53,16 @@ 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 \
Expand All @@ -51,19 +71,18 @@ if [ "$RUN_TESTS" == "true" ]; then
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=0x1670010000000000000000000000000000010001 \
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 \
ADDRESS_MANAGER_CONTRACT_ADDRESS=$ADDRESS_MANAGER_CONTRACT_ADDRESS \
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=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
L1_SECURITY_COUNCIL_PRIVATE_KEY=dbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 \
L1_PROPOSER_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
L2_SUGGESTED_FEE_RECIPIENT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
L1_PROVER_PRIVATE_KEY=59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d \
TREASURY=0xdf09A0afD09a63fb04ab3573922437e1e637dE8b \
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
else
Expand Down
32 changes: 20 additions & 12 deletions integration_test/nodes/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,34 @@ L2_GENESIS_HASH=$(
localhost:28545 | jq .result.hash | sed 's/\"//g'
)

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=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
GUARDIAN_PROVERS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8,0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266,0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC,0x90F79bf6EB2c4f870365E785982E1f101E93b906,0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 \
OWNER=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC \
TAIKO_L2_ADDRESS=0x1670010000000000000000000000000000010001 \
L2_SIGNAL_SERVICE=0x1670010000000000000000000000000000010005 \
SECURITY_COUNCIL=0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f \
SHARED_ADDRESS_MANAGER=0x0000000000000000000000000000000000000000 \
PROPOSER=0x0000000000000000000000000000000000000000 \
PROPOSER_ONE=0x0000000000000000000000000000000000000000 \
TAIKO_TOKEN_PREMINT_RECIPIENT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
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=5 \
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 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--private-key 0x$L1_CONTRACT_OWNER_PRIVATE_KEY \
--block-gas-limit 100000000
6 changes: 3 additions & 3 deletions pkg/tx_list_validator/tx_list_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ func rlpEncodedTransactionBytes(l int, signed bool) []byte {
txData := &types.LegacyTx{
Nonce: 1,
To: &testAddr,
GasPrice: big.NewInt(100),
Value: big.NewInt(1),
GasPrice: common.Big256,
Value: common.Big1,
Gas: 10,
}

tx = types.MustSignNewTx(testKey, types.LatestSigner(genesis.Config), txData)
} else {
tx = types.NewTransaction(1, testAddr, big.NewInt(1), 10, big.NewInt(100), nil)
tx = types.NewTransaction(1, testAddr, common.Big1, 10, common.Big256, nil)
}
txs = append(
txs,
Expand Down
7 changes: 5 additions & 2 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ func (s *ProverTestSuite) SetupTest() {
port, err := strconv.Atoi(proverServerUrl.Port())
s.Nil(err)

allowance := new(big.Int).Exp(big.NewInt(1_000_000_100), big.NewInt(18), nil)
decimal, err := s.RpcClient.TaikoToken.Decimals(nil)
s.Nil(err)

allowance := new(big.Int).Exp(big.NewInt(1_000_000_100), new(big.Int).SetUint64(uint64(decimal)), nil)

ctx, cancel := context.WithCancel(context.Background())
p := new(Prover)
Expand Down Expand Up @@ -421,7 +424,7 @@ func (s *ProverTestSuite) TestSetApprovalAlreadySetHigher() {
originalAllowance, err := s.p.rpc.TaikoToken.Allowance(&bind.CallOpts{}, s.p.proverAddress, s.p.cfg.TaikoL1Address)
s.Nil(err)

amt := big.NewInt(1)
amt := common.Big1
s.p.cfg.Allowance = amt

s.Nil(s.p.setApprovalAmount(context.Background()))
Expand Down
2 changes: 1 addition & 1 deletion prover/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (srv *ProverServer) GetSignedBlocks(c echo.Context) error {
var signedBlocks []SignedBlock

// start iterator at 0
start := big.NewInt(0)
start := common.Big0

// if latestBlock is greater than the number of blocks to return, we only want to return
// the most recent N blocks signed by this guardian prover.
Expand Down
9 changes: 6 additions & 3 deletions testutils/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ func (s *ClientTestSuite) SetupTest() {
_, err = rpc.WaitReceipt(context.Background(), rpcCli.L1, tx)
s.Nil(err)

decimal, err := rpcCli.TaikoToken.Decimals(nil)
s.Nil(err)

// Increase allowance for AssignmentHook and TaikoL1
opts, err = bind.NewKeyedTransactorWithChainID(l1ProverPrivKey, rpcCli.L1ChainID)
s.Nil(err)

bigInt := new(big.Int).Exp(big.NewInt(1_000_000_000), big.NewInt(18), nil)
bigInt := new(big.Int).Exp(big.NewInt(1_000_000_000), new(big.Int).SetUint64(uint64(decimal)), nil)
_, err = rpcCli.TaikoToken.Approve(
opts,
common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")),
Expand Down Expand Up @@ -155,7 +158,7 @@ func (s *ClientTestSuite) setAddress(ownerPrivKey *ecdsa.PrivateKey, name [32]by

tx, err := controller.Schedule(
opts,
common.HexToAddress(os.Getenv("ADDRESS_MANAGER_CONTRACT_ADDRESS")),
common.HexToAddress(os.Getenv("ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS")),
common.Big0,
data,
[32]byte{},
Expand All @@ -169,7 +172,7 @@ func (s *ClientTestSuite) setAddress(ownerPrivKey *ecdsa.PrivateKey, name [32]by

tx, err = controller.Execute(
opts,
common.HexToAddress(os.Getenv("ADDRESS_MANAGER_CONTRACT_ADDRESS")),
common.HexToAddress(os.Getenv("ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS")),
common.Big0,
data,
[32]byte{},
Expand Down

0 comments on commit 53b9db3

Please sign in to comment.