Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: implement integration test for zksync contracts #227

Merged
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
26d70e5
fix: transfer refactored to new PaymentRegistry.tranfer() version
uri-99 Apr 9, 2024
0eaddaa
fix: added eth/.env.test missing variables
uri-99 Apr 9, 2024
7bde201
fix: refactored claimPaymentZKSync to latest version
uri-99 Apr 9, 2024
b627883
fix: L1->L2 message on zksync integration test, was reading wrong env…
uri-99 Apr 9, 2024
c4dc30d
refactor: remove old comments
uri-99 Apr 9, 2024
cda84ef
feat: add files to CI, wip CI development
uri-99 Apr 9, 2024
a60060f
feat: zksync-integration-test.yml
uri-99 Apr 9, 2024
3c0215c
feat(wip): send Dockerized L1-L2 to bg, + fixed zksync setup
uri-99 Apr 9, 2024
21a2fec
test(wip): trying to execute make target to avoid migrating whole pro…
uri-99 Apr 9, 2024
e46c377
test(wip): trying to execute make target
uri-99 Apr 9, 2024
5c0fc31
fix: make target name
uri-99 Apr 9, 2024
545b839
fix: add zksync/test/.env.test to repo (was gitignored)
uri-99 Apr 9, 2024
2aa02ba
fix: comment make install-eth-foundry
uri-99 Apr 9, 2024
56fa8f9
fix: run make target on same CI step as start dockerized L1L2
uri-99 Apr 9, 2024
112b3d2
fix: add sleep to let docker set up
uri-99 Apr 9, 2024
7c3dfb4
fix: more wait time + skip_verify on test
uri-99 Apr 9, 2024
2cc0141
fix: add fake etherscan_api_key
uri-99 Apr 10, 2024
22f9a69
fix(wip): test deploy without --verify
uri-99 Apr 10, 2024
52bee73
fix: undo previous remove
uri-99 Apr 10, 2024
a73d637
add ETHERSCAN_API_KEY in CI
uri-99 Apr 10, 2024
46ac077
fix: (temp) lower sleep in run Dockerized L1-L2
uri-99 Apr 10, 2024
e3eb4f7
fix: add more explicit env var sourcing in CI
uri-99 Apr 10, 2024
e7957ad
fix: CI run Docker command
uri-99 Apr 10, 2024
3ab88fa
feat: new CI.env to make source .env in CI
uri-99 Apr 10, 2024
a260ab5
fix: .env file path
uri-99 Apr 10, 2024
8bd8fbb
refactor: echos during CI to visualize progress + removed extra . fil…
uri-99 Apr 10, 2024
8020001
fix: make target refactored for CI
uri-99 Apr 10, 2024
2f2ada2
remove: commented setup in CI
uri-99 Apr 10, 2024
a02ecfc
fix: viewing if ETH_RPC var is read correctly
uri-99 Apr 10, 2024
8341057
fix: trying to correctly source .env in CI
uri-99 Apr 10, 2024
6182acb
fix: change source to .
uri-99 Apr 10, 2024
4b871ed
fix: source .env worked, trying whole CI test again
uri-99 Apr 10, 2024
d93e9f5
fix: added ETHERSCAN_API_KEY in CI again
uri-99 Apr 10, 2024
3cf05d6
feat: redirect docker output to /dev.null
uri-99 Apr 10, 2024
832191f
fix: add . to deploy.s.sol to see if it gets its env vars as it should
uri-99 Apr 10, 2024
038064c
fix: correctly redirect output to dev/null
uri-99 Apr 10, 2024
fe80514
fix: exporting vars in deploy.sh to make seploy.s.sol get env vars
uri-99 Apr 10, 2024
6f79648
fix: build in make-integration-ci
uri-99 Apr 10, 2024
35ad441
fix: zksync-integration-ci make target
uri-99 Apr 10, 2024
57b96e6
fix: prefunded deployer ZKSync wallet private key in CI
uri-99 Apr 10, 2024
bad1398
fix: increment CI sleep to let docker setup correctly
uri-99 Apr 10, 2024
5b715fc
fix: more sleep in ZKSync CI
uri-99 Apr 10, 2024
6d4c68e
refactor: run docker at the beggining of CI
uri-99 Apr 10, 2024
0f30ba5
refactor: remove build from make target, added directly to ci
uri-99 Apr 10, 2024
0c4d798
test(wip): CI cheching if docker runs parallely
uri-99 Apr 10, 2024
f89794d
fix: fixing dockerized setup, geth is not starting
uri-99 Apr 10, 2024
5158918
feat: read ZKSYNC_DIAMOND_PROXY_ADDRESS from docker ./start.sh output
uri-99 Apr 10, 2024
b239519
fix: remove ZKSYNC_DIAMOND_PROXY_ADDRESS from .env
uri-99 Apr 10, 2024
eb80e0b
fix: re-trigger CI, github actions had an outage
uri-99 Apr 10, 2024
095adc5
fix: CI export diamond proxy from ./start.sh
uri-99 Apr 10, 2024
bf57a67
fix: better prints in CI to view if new technique works
uri-99 Apr 10, 2024
65b9524
fix: more sleep to give time to ./start to create diamond proxy
uri-99 Apr 10, 2024
bfb38e3
test: in CI if another step can read a previously generated step's file
uri-99 Apr 10, 2024
c61174e
test: reading files in CI environment
uri-99 Apr 10, 2024
cf11ee0
fix: move to local-setup dir in the other target
uri-99 Apr 10, 2024
1e7ce08
feat: integration test runner reads ZKSYNC_DIAMOND_PROXY_ADDRESS from…
uri-99 Apr 10, 2024
e88d127
fix: tuning env var reading
uri-99 Apr 10, 2024
76fa868
refactor: changed prefunded account for deployments
uri-99 Apr 10, 2024
a2c0b53
refactor: uncomment line for debugging failed tx
uri-99 Apr 10, 2024
12c9e91
fix: more time so ./start funds initial wallets
uri-99 Apr 10, 2024
8e13587
refactor: debugging ZKSync deploy
uri-99 Apr 10, 2024
8f5ea3e
fix: zksync netowkr deploying
uri-99 Apr 10, 2024
fec116b
fix: if test==true in deploy.sh zksync
uri-99 Apr 10, 2024
83663df
fix: use alternative operator that should work in CI
uri-99 Apr 10, 2024
db1286f
fix: change --chain to --rpc in zksync-cli usage
uri-99 Apr 10, 2024
f6a8de3
feat: add node in ci for zksync-cli
uri-99 Apr 10, 2024
a463a5e
fix: debugging set_order.sh in ZKSync CI, npx having issued
uri-99 Apr 10, 2024
f8d612f
fix: set --gas-price in L1 transfer
uri-99 Apr 10, 2024
d545c65
fix: add --gas-price to claim_payment (worked on transfer)
uri-99 Apr 10, 2024
66a2940
feat: wrapping up claim_payment
uri-99 Apr 10, 2024
30b2e8e
feat: add assert.sh at the end of CI
uri-99 Apr 10, 2024
b8ce122
fix: assert.sh in CI
uri-99 Apr 10, 2024
eccee09
fix: remove decimals from eth get balance
uri-99 Apr 10, 2024
c5a70a3
fix(wip): asseert.sh values at the end of CI
uri-99 Apr 11, 2024
d922b96
feat: save all balances during zksync integration test process
uri-99 Apr 11, 2024
424ed54
refactor: format of saved variables
uri-99 Apr 11, 2024
175c4b4
feat: set assert values
uri-99 Apr 11, 2024
e9e95cd
refactor: tidy .yml
uri-99 Apr 11, 2024
d5e5ef8
refactor: tidy up comments and prints for PR
uri-99 Apr 11, 2024
703e52d
refactor: clean up code
uri-99 Apr 11, 2024
0803452
refactor: assert tidy + .env pub key of MM L1
uri-99 Apr 11, 2024
3c0fd47
fix: new correct expected assert values
uri-99 Apr 11, 2024
bc948bd
refactor: tuning assert.sh values
uri-99 Apr 11, 2024
bba9949
fix: tuning assert.sh
uri-99 Apr 11, 2024
ce7f32f
fix: zksync values in wei
uri-99 Apr 11, 2024
50810c9
fix: separated deployer from user/mm addresses
uri-99 Apr 11, 2024
747697e
fix: BALANCE_MM_L2_AFTER_CLAIMPAYMENT takes logical value
uri-99 Apr 11, 2024
cb450bd
refactor: change npx wallet balance to cast balance
uri-99 Apr 11, 2024
b3efee5
fix: overflow on BALANCE_MM_L2_AFTER_CLAIMPAYMENT in assert
uri-99 Apr 11, 2024
699ee93
refactor: use vars in assert
uri-99 Apr 11, 2024
8bd9e12
refactor: mm zksync has no initial funds
uri-99 Apr 11, 2024
dc01d04
refactor: remove () in BALANCE_MM_L2_AFTER_CLAIMPAYMENT in assert
uri-99 Apr 11, 2024
976ffe9
fix: exit 0 at the end of assert
uri-99 Apr 12, 2024
7a1f136
refactor: small clean un code and comments
uri-99 Apr 15, 2024
77670db
refactor: move integratio test executor files to .githubb/workflows f…
uri-99 Apr 15, 2024
b5a5d24
refactor: removed comment
uri-99 Apr 15, 2024
cdd595d
refactor: change log formats
uri-99 Apr 15, 2024
fb14483
refactor: eth for logs, wei for asserts
uri-99 Apr 15, 2024
05b9837
refactor: remove claimPayment tx logs
uri-99 Apr 15, 2024
c44cbdf
refactor: wei or eth comments + set_order logging
uri-99 Apr 15, 2024
ddbcb61
refactor: CI logs with less \n
uri-99 Apr 15, 2024
f195501
refactor: remove 'asserting values' echo in integration ci
uri-99 Apr 15, 2024
c853854
refactor: move some export vars from deploy.sh to zksync-integration.yml
uri-99 Apr 15, 2024
27208e7
fix: checking if current CI declaration of MM_ETHEREUM_WALLET_ADDRESS…
uri-99 Apr 15, 2024
59888eb
refactor: Update .github/workflows/zksync-scripts/claim_payment.sh
uri-99 Apr 18, 2024
ac7864e
refactor: removed commented lines
uri-99 Apr 18, 2024
8117902
fix(wip): print docker output to check why CI has broken
uri-99 Apr 18, 2024
1b6cf18
fix: git clone a specific stable commit of local-setup.git
uri-99 Apr 18, 2024
6be7a61
fix: use stable version of dockerized local-node
uri-99 Apr 18, 2024
250fee0
fix: changed folder name to cd after git clone
uri-99 Apr 18, 2024
3f92b7c
refactor: finished, removing debug prints
uri-99 Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/zksync-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: ZKSync Integration Test
on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
Test:
runs-on: ubuntu-latest
environment: Test

steps:
- uses: actions/checkout@v4

# Run Dockerized L1-L2, goes first because it takes a lot of time
- name: Setup Dockerized L1-L2
run: |
export ETHERSCAN_API_KEY=${{vars.ETHERSCAN_API_KEY}}
git clone https://github.com/matter-labs/local-setup.git

echo git cloned, starting:
cd local-setup

echo starting:
touch ../docker_output.log
./start.sh &> ../docker_output.log &

# Ethereum Setup
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install Forge
run: |
cd contracts/ethereum
forge install

# ZKSync Setup
- name: Install ZKSync libraries
run: |
cd ./contracts/zksync/ && yarn install

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '20.11.1'
cache: 'npm'
cache-dependency-path: '**/.github/workflows/*.yml'

- name: Download zksync-cli
run: |
npx zksync-cli --version

# Build Ethereum Contract
- name: Build Ethereum Contract
run: |
make ethereum-build

# Build ZKSync Contract
- name: Build ZKSync Contract
run: |
make zksync-build

# Run Dockerized L1-L2
- name: Running integration test
run: |
export ETHERSCAN_API_KEY=${{vars.ETHERSCAN_API_KEY}}

export STARKNET_MESSAGING_ADDRESS=${{vars.STARKNET_MESSAGING_ADDRESS}}
export STARKNET_CLAIM_PAYMENT_SELECTOR=${{vars.STARKNET_CLAIM_PAYMENT_SELECTOR}}
export STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR=${{vars.STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR}}
export ZKSYNC_CLAIM_PAYMENT_SELECTOR=${{vars.ZKSYNC_CLAIM_PAYMENT_SELECTOR}}
export ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR=${{vars.ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR}}
export STARKNET_CHAIN_ID=${{vars.STARKNET_CHAIN_ID}}
export ZKSYNC_CHAIN_ID=${{vars.ZKSYNC_CHAIN_ID}}

export MM_ETHEREUM_WALLET_ADDRESS=${{vars.MM_ETHEREUM_WALLET_ADDRESS}}
export TEST=true

echo sleeping 250 to wait for ./start to setup
sleep 250

export ZKSYNC_DIAMOND_PROXY_ADDRESS=$(cat docker_output.log | sed -n 's/.*CONTRACTS_DIAMOND_PROXY_ADDR=\(0x[a-fA-F0-9]*\).*/\1/p')
echo stored ZKSYNC_DIAMOND_PROXY_ADDRESS variable:
echo $ZKSYNC_DIAMOND_PROXY_ADDRESS

echo running make-test-integration-ci
make zksync-test-integration-ci

exit 0
29 changes: 29 additions & 0 deletions .github/workflows/zksync-scripts/assert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

. contracts/utils/colors.sh #for ANSI colors

echo "\n"
FAILED=false

assert() {
#Usage: assert <variable_name> <obtained> <expected>
if [ $2 = $3 ] ; then
printf "${GREEN}✓ $1 passed.${RESET}\n"
else
printf "${RED}x $1 assertion failed: Obtained value: $2, Expected value: $3.${RESET}\n"
FAILED=true
fi
}

assert "Escrow balance after SetOrder" $BALANCE_ESCROW_L2_AFTER_SETORDER_WEI $VALUE_WEI #2000000000000000000
assert "Escrow balance after Claim Payment" $BALANCE_ESCROW_L2_AFTER_CLAIMPAYMENT_WEI 0

assert "User balance" $BALANCE_USER_L1_AFTER_TRANSFER_WEI $BRIDGE_AMOUNT_WEI #1990000000000000000

assert "MM balance" $(($BALANCE_MM_L2_AFTER_CLAIMPAYMENT_WEI)) $(($BALANCE_MM_L2_BEFORE_CLAIMPAYMENT_WEI + $VALUE_WEI))

if $FAILED; then
echo "One of the previous tests failed, all should pass for Integration Test to be successful"
exit 1
fi
exit 0
36 changes: 36 additions & 0 deletions .github/workflows/zksync-scripts/ci.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## ETH.env
SKIP_VERIFY=true #cant verify on local devnet

ETHEREUM_RPC=http://localhost:8545 #local devnet L1 rpc url

ETHEREUM_PRIVATE_KEY=0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 #prefunded 0

MM_ETHEREUM_PRIVATE_KEY=0xd293c684d884d56f8d6abd64fc76757d3664904e309a0645baf8522ab6366d9e #prefunded 2
MM_ETHEREUM_WALLET_ADDRESS=0x0D43eB5B8a47bA8900d84AA36656c92024e9772e #prefunded 2

USER_ETHEREUM_PUBLIC_ADDRESS=0xCEEe57f2B700c2f37D1476A7974965E149Fce2D4 #random address with no funds

ZKSYNC_CLAIM_PAYMENT_SELECTOR=0xa5168739
ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR=0x156be1ae
ZKSYNC_CHAIN_ID=300


# These SN variables don't affect this test, but are necessary for deploy
STARKNET_CLAIM_PAYMENT_SELECTOR=0x03636c566f6409560d55d5f6d1eb4ee163b096b4698c503e69e210be79de2afa
STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR=0x0354a01e49fe07e43306a97ed84dbd5de8238c7d8ff616caa3444630cfc559e6
STARKNET_MESSAGING_ADDRESS=0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057
STARKNET_CHAIN_ID=0x534e5f5345504f4c4941


## ZKSYNC.env
TEST=true

WALLET_PRIVATE_KEY=0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 #prefunded 0
MM_ZKSYNC_WALLET=0xbE85c9531BE760B6964cdA4A8826b9Cb0391E32C #random address with no funds

NATIVE_TOKEN_ETH_IN_ZKSYNC=0x000000000000000000000000000000000000800A

USER_ZKSYNC_PRIVATE_ADDRESS=0xf12e28c0eb1ef4ff90478f6805b68d63737b7f33abfa091601140805da450d93 #prefunded 4
USER_ZKSYNC_PUBLIC_ADDRESS=0x8002cD98Cfb563492A6fB3E7C8243b7B9Ad4cc92 #prefunded 4


33 changes: 33 additions & 0 deletions .github/workflows/zksync-scripts/claim_payment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

. contracts/utils/colors.sh #for ANSI colors

printf "${GREEN}\n=> [ETH] Making Claim Payment${COLOR_RESET}\n"

BALANCE_ESCROW_L2_BEFORE_CLAIMPAYMENT=$(cast balance --rpc-url http://localhost:3050 $ZKSYNC_ESCROW_CONTRACT_ADDRESS)
echo "Initial Escrow balance: $BALANCE_ESCROW_L2_BEFORE_CLAIMPAYMENT"

# BALANCE_MM_L1_BEFORE_CLAIMPAYMENT=$(cast balance --rpc-url $ETHEREUM_RPC $MM_ETHEREUM_WALLET_ADDRESS)
# echo "\nInitial MM balance: $BALANCE_MM_L1_BEFORE_CLAIMPAYMENT"
uri-99 marked this conversation as resolved.
Show resolved Hide resolved

BALANCE_MM_L2_BEFORE_CLAIMPAYMENT_WEI=$(cast balance --rpc-url http://localhost:3050 $MM_ZKSYNC_WALLET) #for assert.sh
BALANCE_MM_L2_BEFORE_CLAIMPAYMENT=$(cast balance --rpc-url http://localhost:3050 --ether $MM_ZKSYNC_WALLET) #for logging
echo "Initial MM balance: $BALANCE_MM_L2_BEFORE_CLAIMPAYMENT"

echo "Withdrawing $BRIDGE_AMOUNT_ETH ETH" # == $BRIDGE_AMOUNT_WEI WEI"
cast send --rpc-url $ETHEREUM_RPC --private-key $ETHEREUM_PRIVATE_KEY --gas-price 2000000000 \
$PAYMENT_REGISTRY_PROXY_ADDRESS "claimPaymentZKSync(uint256, address, uint256, uint256, uint256)" \
"0" $USER_ETHEREUM_PUBLIC_ADDRESS $BRIDGE_AMOUNT_WEI 2000000 800 \
--value 5000000000000000000 > /dev/null

# echo "\nMM L1 funds after Claim Payment"
# BALANCE_MM_L1_AFTER_CLAIMPAYMENT=$(cast balance --rpc-url $ETHEREUM_RPC $MM_ETHEREUM_WALLET_ADDRESS)
# echo "$BALANCE_MM_L1_AFTER_CLAIMPAYMENT"
uri-99 marked this conversation as resolved.
Show resolved Hide resolved

BALANCE_ESCROW_L2_AFTER_CLAIMPAYMENT_WEI=$(cast balance --rpc-url http://localhost:3050 $ZKSYNC_ESCROW_CONTRACT_ADDRESS) #for assert.sh
BALANCE_ESCROW_L2_AFTER_CLAIMPAYMENT=$(cast balance --rpc-url http://localhost:3050 --ether $ZKSYNC_ESCROW_CONTRACT_ADDRESS) #for logging
echo "Final Escrow balance: $BALANCE_ESCROW_L2_AFTER_CLAIMPAYMENT"

BALANCE_MM_L2_AFTER_CLAIMPAYMENT_WEI=$(cast balance --rpc-url http://localhost:3050 $MM_ZKSYNC_WALLET) #for assert.sh
BALANCE_MM_L2_AFTER_CLAIMPAYMENT=$(cast balance --rpc-url http://localhost:3050 --ether $MM_ZKSYNC_WALLET) #for logging
echo "Final MM balance:$BALANCE_MM_L2_AFTER_CLAIMPAYMENT"
33 changes: 33 additions & 0 deletions .github/workflows/zksync-scripts/set_order.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

. contracts/utils/colors.sh #for ANSI colors

FEE=10000000000000000 #in WEI
VALUE=2 #in ETH
VALUE_WEI=$(echo "scale=0; $VALUE * 10^18" | bc)
BRIDGE_AMOUNT_WEI=$(echo "scale=0; $VALUE_WEI - $FEE" | bc)
BRIDGE_AMOUNT_ETH=$(echo "scale=18; $BRIDGE_AMOUNT_WEI / 10^18" | bc)

echo USER_ZKSYNC_PUBLIC_ADDRESS
echo $USER_ZKSYNC_PUBLIC_ADDRESS
echo ZKSYNC_ESCROW_CONTRACT_ADDRESS
echo $ZKSYNC_ESCROW_CONTRACT_ADDRESS

printf "${GREEN}\n=> [SN] Making Set Order on Escrow${COLOR_RESET}\n"
echo "$ZKSYNC_ESCROW_CONTRACT_ADDRESS\n"

BALANCE_USER_L2_BEFORE_SETORDER=$(cast balance --rpc-url http://localhost:3050 $USER_ZKSYNC_PUBLIC_ADDRESS)
echo "Initial User funds: $BALANCE_USER_L2_BEFORE_SETORDER"

BALANCE_ESCROW_L2_BEFORE_SETORDER=$(cast balance --rpc-url http://localhost:3050 $ZKSYNC_ESCROW_CONTRACT_ADDRESS)
echo "Initial Escrow funds: $BALANCE_ESCROW_L2_BEFORE_SETORDER"

npx zksync-cli contract write --private-key $USER_ZKSYNC_PRIVATE_ADDRESS --rpc http://localhost:3050 --contract "$ZKSYNC_ESCROW_CONTRACT_ADDRESS" --method "set_order(address recipient_address, uint256 fee)" --args "$USER_ETHEREUM_PUBLIC_ADDRESS" "$FEE" --value "$VALUE" >> /dev/null

BALANCE_USER_L2_AFTER_SETORDER=$(cast balance --rpc-url http://localhost:3050 $USER_ZKSYNC_PUBLIC_ADDRESS)
echo "Final User funds: $BALANCE_USER_L2_AFTER_SETORDER"


BALANCE_ESCROW_L2_AFTER_SETORDER_WEI=$(cast balance --rpc-url http://localhost:3050 $ZKSYNC_ESCROW_CONTRACT_ADDRESS) #for assert.sh
BALANCE_ESCROW_L2_AFTER_SETORDER=$(cast balance --rpc-url http://localhost:3050 $ZKSYNC_ESCROW_CONTRACT_ADDRESS) #for logging
echo "Final Escrow funds:$BALANCE_ESCROW_L2_AFTER_SETORDER"
24 changes: 24 additions & 0 deletions .github/workflows/zksync-scripts/transfer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

. contracts/utils/colors.sh #for ANSI colors

printf "${GREEN}\n=> [ETH] Making transfer to Destination account${COLOR_RESET}\n"

BALANCE_MM_L1_BEFORE_TRANSFER=$(cast balance --rpc-url $ETHEREUM_RPC $MM_ETHEREUM_WALLET_ADDRESS)
echo "Initial MM Balance: $BALANCE_MM_L1_BEFORE_TRANSFER"

BALANCE_USER_L1_BEFORE_TRANSFER=$(cast balance --rpc-url $ETHEREUM_RPC $USER_ETHEREUM_PUBLIC_ADDRESS)
echo "Initial User Balance: $BALANCE_USER_L1_BEFORE_TRANSFER"

echo "Transferring $BRIDGE_AMOUNT_ETH ETH to $USER_ETHEREUM_PUBLIC_ADDRESS"
cast send --rpc-url $ETHEREUM_RPC --private-key $MM_ETHEREUM_PRIVATE_KEY --gas-price 2000000000 \
$PAYMENT_REGISTRY_PROXY_ADDRESS "transfer(uint256, address, uint128)" \
"0" $USER_ETHEREUM_PUBLIC_ADDRESS $ZKSYNC_CHAIN_ID \
--value $BRIDGE_AMOUNT_WEI >> /dev/null

BALANCE_MM_L1_AFTER_TRANSFER=$(cast balance --rpc-url $ETHEREUM_RPC $MM_ETHEREUM_WALLET_ADDRESS)
echo "Final MM Balance: $BALANCE_MM_L1_AFTER_TRANSFER"

BALANCE_USER_L1_AFTER_TRANSFER_WEI=$(cast balance --rpc-url $ETHEREUM_RPC $USER_ETHEREUM_PUBLIC_ADDRESS) #for assert.sh
BALANCE_USER_L1_AFTER_TRANSFER=$(cast balance --rpc-url $ETHEREUM_RPC --ether $USER_ETHEREUM_PUBLIC_ADDRESS) #for logging
echo "Final User Balance: $BALANCE_USER_L1_AFTER_TRANSFER"
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,26 @@ zksync-test: zksync-build
zksync-test-in-memory: zksync-build
@cd ./contracts/zksync/ && yarn test-in-memory

#wip:
zksync-test-integration:
zksync-test-integration-ci:
@. ./.github/workflows/zksync-scripts/ci.env.test && \
. ./contracts/ethereum/deploy.sh && \
. ./contracts/zksync/deploy.sh && \
. ./contracts/ethereum/set_zksync_escrow.sh && \
. ./.github/workflows/zksync-scripts/set_order.sh && \
. ./.github/workflows/zksync-scripts/transfer.sh && \
. ./.github/workflows/zksync-scripts/claim_payment.sh && \
. ./.github/workflows/zksync-scripts/assert.sh

zksync-test-integration-local:
@make ethereum-build && make zksync-build && \
. ./contracts/ethereum/test/.env.test && . ./contracts/zksync/test/.env.test && \
. ./contracts/ethereum/deploy.sh && \
. ./contracts/zksync/deploy.sh && \
. ./contracts/ethereum/set_zksync_escrow.sh && \
. ./contracts/zksync/test/set_order.sh && \
. ./contracts/zksync/test/transfer.sh && \
. ./contracts/zksync/test/claim_payment.sh
. ./.github/workflows/zksync-scripts/set_order.sh && \
. ./.github/workflows/zksync-scripts/transfer.sh && \
. ./.github/workflows/zksync-scripts/claim_payment.sh && \
. ./.github/workflows/zksync-scripts/assert.sh

# zksync-upgrade: WIP

Expand Down
2 changes: 1 addition & 1 deletion contracts/ethereum/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ cd contracts/ethereum

printf "${GREEN}\n=> [ETH] Deploying ERC1967Proxy & PaymentRegistry ${COLOR_RESET}\n"


export ETHEREUM_PRIVATE_KEY=$ETHEREUM_PRIVATE_KEY

RESULT_LOG=$(forge script ./script/Deploy.s.sol --rpc-url $ETHEREUM_RPC --broadcast ${SKIP_VERIFY:---verify})
# echo "$RESULT_LOG" #uncomment this line for debugging in detail


# Getting result addresses
PAYMENT_REGISTRY_PROXY_ADDRESS=$(echo "$RESULT_LOG" | grep -Eo '0: address ([^\n]+)' | awk '{print $NF}')
PAYMENT_REGISTRY_ADDRESS=$(echo "$RESULT_LOG" | grep -Eo '1: address ([^\n]+)' | awk '{print $NF}')
Expand Down
27 changes: 22 additions & 5 deletions contracts/ethereum/test/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@ SKIP_VERIFY=true #cant verify on local devnet

ETHEREUM_RPC=http://localhost:8545 #local devnet L1 rpc url

ZKSYNC_DIAMOND_PROXY_ADDRESS=0x97589bcE7727f5D0C8082440681DB6092b6Dda1a
ZKSYNC_DIAMOND_PROXY_ADDRESS=0xdA7aA6e28eD3164bF5383eCe38868ADc7686A2F0


ETHEREUM_PRIVATE_KEY=0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 #prefunded 0

MM_ETHEREUM_PRIVATE_KEY=0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 #prefunded 0
MM_ETHEREUM_PUBLIC_ADDRESS=0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 #prefunded 0
MM_ETHEREUM_PRIVATE_KEY=0xd293c684d884d56f8d6abd64fc76757d3664904e309a0645baf8522ab6366d9e #prefunded 2
MM_ETHEREUM_WALLET_ADDRESS=0x0D43eB5B8a47bA8900d84AA36656c92024e9772e #prefunded 2

USER_ETHEREUM_PUBLIC_ADDRESS=0xCEEe57f2B700c2f37D1476A7974965E149Fce2D4 #random address with no funds

ETHERSCAN_API_KEY=0x1

ZKSYNC_CLAIM_PAYMENT_SELECTOR=0xa5168739
ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR=0x156be1ae
ZKSYNC_CHAIN_ID=300


#irrelevant SN variables
STARKNET_CLAIM_PAYMENT_SELECTOR=0x03636c566f6409560d55d5f6d1eb4ee163b096b4698c503e69e210be79de2afa
STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR=0x0354a01e49fe07e43306a97ed84dbd5de8238c7d8ff616caa3444630cfc559e6
STARKNET_MESSAGING_ADDRESS=0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057
STARKNET_CHAIN_ID=0x534e5f5345504f4c4941





USER_ETHEREUM_PUBLIC_ADDRESS=0xceee57f2b700c2f37d1476a7974965e149fce2d4 #random address with no funds
USER_ETHEREUM_PUBLIC_ADDRESS_UINT=1181367337507422765615536123397692015769584198356
1 change: 0 additions & 1 deletion contracts/zksync/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ typings/

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
6 changes: 4 additions & 2 deletions contracts/zksync/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ if [ -z "$PAYMENT_REGISTRY_PROXY_ADDRESS" ]; then
fi

DEPLOY="deploy"
if [ "$TEST" == true ]; then
if [ "$TEST" = true ]; then
DEPLOY="deploy-devnet"
fi

export WALLET_PRIVATE_KEY=$WALLET_PRIVATE_KEY
export PAYMENT_REGISTRY_PROXY_ADDRESS=$PAYMENT_REGISTRY_PROXY_ADDRESS
export MM_ZKSYNC_WALLET=$MM_ZKSYNC_WALLET

ZKSYNC_ESCROW_CONTRACT_ADDRESS=$(yarn $DEPLOY | grep "Contract address:" | egrep -i -o '0x[a-zA-Z0-9]{40}')
RESULT_LOG=$(yarn $DEPLOY)
# echo $RESULT_LOG #uncomment this line for debugging
ZKSYNC_ESCROW_CONTRACT_ADDRESS=$(echo "$RESULT_LOG" | grep "Contract address:" | egrep -i -o '0x[a-zA-Z0-9]{40}')

if [ -z "$ZKSYNC_ESCROW_CONTRACT_ADDRESS" ]; then
printf "\n${RED}ERROR:${COLOR_RESET}\n"
Expand Down
10 changes: 10 additions & 0 deletions contracts/zksync/test/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TEST=true


uri-99 marked this conversation as resolved.
Show resolved Hide resolved
WALLET_PRIVATE_KEY=0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 #prefunded 0
MM_ZKSYNC_WALLET=0xbE85c9531BE760B6964cdA4A8826b9Cb0391E32C #random address with no funds

NATIVE_TOKEN_ETH_IN_ZKSYNC=0x000000000000000000000000000000000000800A

USER_ZKSYNC_PRIVATE_ADDRESS=0xf12e28c0eb1ef4ff90478f6805b68d63737b7f33abfa091601140805da450d93 #prefunded 4
USER_ZKSYNC_PUBLIC_ADDRESS=0x8002cD98Cfb563492A6fB3E7C8243b7B9Ad4cc92 #prefunded 4
Loading
Loading