Skip to content

Commit

Permalink
Update ZKSync Scripts (#835)
Browse files Browse the repository at this point in the history
* Implment and add tests for LibUtil::revertWith()

* remove unneeded import

* deploy to staging

* temp - DO NOT PUSH

* split facets, test files, deploy scripts etc. to V1/V3

* fix: replaces address parameter in facet

* tests fixed

* demoscript can do ERC20 and native bridging

* ReceiverAcrossV3 + deploy script added (and deployed)

* added dest calls on demoscript

* ReceiverAcrossV3 updated (out-of-gas handling) & redeployed

* ReceiverAcrossV3 updated (will revert for out-of-gas during swap exec) & redeployed

* Successfully sent native+destCall with demoScript

* simplified demo script to only use one fromChain

* fixed failing test

* fix spelling error in import

* update forge coverage command in Github action

* adds a check that ensures receiver addresses match in case of no dst call

* solves stack-too-deep issue in GenericSwapFacetV3 test file (popped up due to solc upgrade)

* adds destinationCallFlag validation

* implements gas savings in ReceiverAcrossV3 and redeploys to staging

* updates docs

* removes coverage files as these should not be synced to github

* gas optimization: use solady lib in ReceiverAcrossV3

* change min solc version to ^0.8.17

* removes native asset handling from receiver since this is not required for AcrossV3

* removes coverage files as these should not be synced to github

* removes unused import

* redeployed ReceiverAcrossV3 to arbitrum

* updates CalldataVerificationFacet to support AcrossV3

* removes payable keyword (audit issue #13)

* removes unused import (audit issue #4)

* removes payable keyword from handleV3AcrossMessage function (audit issue #5)

* removes unused import (audit issue #7)

* adds more detailed explanations to revert handling in Receiver contract (audit issue #11)

* narrows variable type (audit issue #9)

* re-deploys facets to optimism staging

* updates expected gas values in tests

* trying to fix failing types action

* undo last commit

* updates typechain command in package.json

* finally fixed $§%&$%§&$% CI issue

* updates evm-version used for testing in Github action

* updates evm-version used for testing in Github action #2

* removes forge coverage from github action (unused anyway)

* disable PR reminder for PRs with label waitForBackend

* redeployed AcrossFacetV3 and ReceiverAcrossV3 to OPT & POL staging

* audit log updated and report added

* Deploy AcrossV3 (except for zksync)

* Deploy AcrossV3 packed (except for zksync)

* Deploy to zksync

* Deploy packed facet

* add task to update approvals for AcrossFacetPackedV3

* Fix AcrossFacetPackedV3 script

* update deploy requirements

* Fix update scripts

* Fix update scripts

* Cleanup

* fix imports

* import paths updated for zkSync scripts

* fixes one more import

* adds ready_for_review triggers to git actions

* adds support for exclusiveRelayer parameters

* redeployed facets to arbitrum and optimism STAGING

* update audit report (incl exclusivity relayer)

* deployments to various networks

* zksync deploy scripts updated

* updates deploy script for AcrossFacetPackedV3

* proposed diamondCuts & periphery update to all relevant diamonds (except: zksync)

* Deploy Across V3 to zkSync

* update across demo scripts

* Use foundry-zksync

* Add missing floating pragmas and ignore tests and scripts when compiling for zksync

* Use separate scripts for zksync

* forge install: era-contracts

* Fixes

* Remove old scripts

* Update verification and begin implementing create2 deployments

* Try and predict address using system contract

* Add remaining AcrossV3 deploy scripts

* Add missing deploy scripts to zksync

* Update logs

* Update log for EmergencyPauseFacet

* Auto build foundry-zksync docker image if it does not exist

* Start adding special update scritps for zksync

* Confirm deployment if already deployed

* Redeploy EmergencyPauseFacet

* Remove duplicates

* Add comments and remove unfinished/incomplete scripts

* Fix copy paste errors

* Remove unused code

* Update comments

* Remove lcov dir

* Add comment

---------

Co-authored-by: Daniel Bläcker <[email protected]>
Co-authored-by: Max Klenk <[email protected]>
  • Loading branch information
3 people authored Oct 28, 2024
1 parent 26a04dd commit f66d14d
Show file tree
Hide file tree
Showing 119 changed files with 928 additions and 1,541 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cache-zk/
artifacts/
artifacts-zk/
out/
zkout/
broadcast/

# autogenerated files
Expand Down
2 changes: 1 addition & 1 deletion config/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@
"TokenWrapper",
"LiFiDEXAggregator"
]
}
}
16 changes: 15 additions & 1 deletion deployments/_deployments_log_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -23822,6 +23822,20 @@
}
]
}
},
"zksync": {
"production": {
"1.0.0": [
{
"ADDRESS": "0xcF8c70683D7c0E2a094348896A46407646b94859",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-10-24 10:06:48",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000d38743b48d26743c0ec6898d699394fbc94657ee",
"SALT": "",
"VERIFIED": "true"
}
]
}
}
},
"AcrossFacetV3": {
Expand Down Expand Up @@ -24345,4 +24359,4 @@
}
}
}
}
}
14 changes: 13 additions & 1 deletion deployments/arbitrum.diamond.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@
"0xE15C7585636e62b88bA47A40621287086E0c2E33": {
"Name": "",
"Version": ""
},
"0x2b64B62cbCfB38560222eBcfbbc4e65eC34c8Ce8": {
"Name": "",
"Version": ""
},
"0x6124C65B6264bE13f059b7C3A891a5b77DA8Bd95": {
"Name": "AcrossFacetV3",
"Version": "1.0.0"
},
"0x4352459F6BE1C7D1278F8c34Bb598b0feeB50f8b": {
"Name": "AcrossFacetPackedV3",
"Version": "1.0.0"
}
},
"Periphery": {
Expand All @@ -155,4 +167,4 @@
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70"
}
}
}
}
2 changes: 1 addition & 1 deletion deployments/optimism.diamond.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70"
}
}
}
}
1 change: 1 addition & 0 deletions deployments/polygon.diamond.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"Receiver": "0x36E9B2E8A627474683eF3b1E9Df26D2bF04396f3",
"ReceiverAcrossV3": "",
"ReceiverStargateV2": "",
"ReceiverAcrossV3": "",
"RelayerCelerIM": "0xa1Ed8783AC96385482092b82eb952153998e9b70",
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70"
}
Expand Down
12 changes: 12 additions & 0 deletions foundry-zksync/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu

WORKDIR /foundry

RUN apt update && apt install -y wget jq
RUN wget https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
RUN tar -xzvf ./foundry_nightly_linux_amd64.tar.gz

RUN mv ./forge /usr/local/bin/forge
RUN mv ./cast /usr/local/bin/cast

CMD ["forge"]
6 changes: 6 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ fs_permissions = [
{ access = "read", path = "./deployments/" },
{ access = "read", path = "./config/" },
{ access = "read-write", path = "./test/logs/" },
{ access = "read", path = "./zkout/" },
]
ffi = true
libs = ["node_modules", "lib"]
cache = true

[profile.zksync]
solc_version = '0.8.26'
test = "notest"
script = "script/deploy/zksync"

[rpc_endpoints]
mainnet = "${ETH_NODE_URI_MAINNET}"
arbitrum = "${ETH_NODE_URI_ARBITRUM}"
Expand Down
40 changes: 38 additions & 2 deletions script/deploy/deploySingleContract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ deploySingleContract() {
echo ""
fi

# Handle ZkSync
# We need to use zksync specific scripts that are able to be compiled for
# the zkvm
if [[ $NETWORK == "zksync" ]]; then
DEPLOY_SCRIPT_DIRECTORY="script/deploy/zksync/"
fi

if [[ -z "$CONTRACT" ]]; then
# get user-selected deploy script and contract from list
SCRIPT=$(ls -1 "$DEPLOY_SCRIPT_DIRECTORY" | sed -e 's/\.s.sol$//' | grep 'Deploy' | gum filter --placeholder "Deploy Script")
Expand Down Expand Up @@ -184,6 +191,29 @@ deploySingleContract() {
fi
fi

if [[ $NETWORK == "zksync" ]]; then
# Check if a zksync contract has already been deployed for a specific
# version otherwise it might fail since create2 will try to deploy to the
# same address
DEPLOYED=$(findContractInMasterLog $CONTRACT $NETWORK $ENVIRONMENT $VERSION $LOG_FILE_PATH)
if [[ $? == 0 ]]; then
gum style \
--foreground 220 --border-foreground 220 --border double \
--align center --width 50 --margin "1 2" --padding "2 4" \
'WARNING' "$CONTRACT v$VERSION is already deployed to $NETWORK" 'Deployment might fail'
gum confirm "Deploy anyway?" || exit 0
fi
# Clean all old artifacts
rm -fr ./out
rm -fr ./zkout
# Clean zksync cache
docker run --rm -it --volume .:/foundry -u $(id -u):$(id -g) -e FOUNDRY_PROFILE=zksync foundry-zksync forge cache clean

# Run zksync specific fork of forge from Docker so as not to pollute the
# local foundry forge setup
docker run --rm -it --volume .:/foundry -u $(id -u):$(id -g) -e FOUNDRY_PROFILE=zksync foundry-zksync forge build --zksync
fi

# execute script
attempts=1

Expand All @@ -193,8 +223,14 @@ deploySingleContract() {
# ensure that gas price is below maximum threshold (for mainnet only)
doNotContinueUnlessGasIsBelowThreshold "$NETWORK"

# try to execute call
RAW_RETURN_DATA=$(DEPLOYSALT=$DEPLOYSALT CREATE3_FACTORY_ADDRESS=$CREATE3_FACTORY_ADDRESS NETWORK=$NETWORK FILE_SUFFIX=$FILE_SUFFIX DEFAULT_DIAMOND_ADDRESS_DEPLOYSALT=$DEFAULT_DIAMOND_ADDRESS_DEPLOYSALT DEPLOY_TO_DEFAULT_DIAMOND_ADDRESS=$DEPLOY_TO_DEFAULT_DIAMOND_ADDRESS PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT") DIAMOND_TYPE=$DIAMOND_TYPE forge script "$FULL_SCRIPT_PATH" -f $NETWORK -vvvvvv --json --silent --broadcast --skip-simulation --legacy)
if [[ $NETWORK == "zksync" ]]; then
# Deploy zksync scripts using the zksync specific fork of forge from Docker
RAW_RETURN_DATA=$(docker run --rm -it --volume .:/foundry -u $(id -u):$(id -g) -e FOUNDRY_PROFILE=zksync -e DEPLOYSALT=$DEPLOYSALT -e NETWORK=$NETWORK -e FILE_SUFFIX=$FILE_SUFFIX -e PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT") foundry-zksync forge script "$FULL_SCRIPT_PATH" -f $NETWORK --json --silent --broadcast --skip-simulation --slow --zksync)
else
# try to execute call
RAW_RETURN_DATA=$(DEPLOYSALT=$DEPLOYSALT CREATE3_FACTORY_ADDRESS=$CREATE3_FACTORY_ADDRESS NETWORK=$NETWORK FILE_SUFFIX=$FILE_SUFFIX DEFAULT_DIAMOND_ADDRESS_DEPLOYSALT=$DEFAULT_DIAMOND_ADDRESS_DEPLOYSALT DEPLOY_TO_DEFAULT_DIAMOND_ADDRESS=$DEPLOY_TO_DEFAULT_DIAMOND_ADDRESS PRIVATE_KEY=$(getPrivateKey "$NETWORK" "$ENVIRONMENT") DIAMOND_TYPE=$DIAMOND_TYPE forge script "$FULL_SCRIPT_PATH" -f $NETWORK -vvvvvv --json --silent --broadcast --skip-simulation --legacy)
fi

RETURN_CODE=$?

# print return data only if debug mode is activated
Expand Down
14 changes: 7 additions & 7 deletions script/deploy/deployUpgradesToSAFE.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ deployUpgradesToSAFE() {
exit 1
fi

# GIT_BRANCH=$(git branch --show-current)
# if [[ $GIT_BRANCH == "main" ]]; then
# # We can assume code in the main branch has been pre-approved and audited
GIT_BRANCH=$(git branch --show-current)
if [[ $GIT_BRANCH == "main" ]]; then
# We can assume code in the main branch has been pre-approved and audited
VERIFIED="OK"
# else
# VERIFIED=$(yarn --silent tsx script/deploy/github/verify-approvals.ts --branch "$GIT_BRANCH" --token "$GH_TOKEN" --facets "$SCRIPTS")
# fi

else
VERIFIED=$(yarn --silent tsx script/deploy/github/verify-approvals.ts --branch "$GIT_BRANCH" --token "$GH_TOKEN" --facets "$SCRIPTS")
fi
if [[ $VERIFIED == "OK" ]]; then
echo "PR has been approved. Continuing..."
# Loop through each script and call "forge script" to get the cut calldata
Expand Down
72 changes: 0 additions & 72 deletions script/deploy/zksync/001_deploy_initial_facets.ts

This file was deleted.

39 changes: 0 additions & 39 deletions script/deploy/zksync/002_deploy_diamond.ts

This file was deleted.

34 changes: 0 additions & 34 deletions script/deploy/zksync/003_init_facets.ts

This file was deleted.

47 changes: 0 additions & 47 deletions script/deploy/zksync/004_deploy_periphery_registry_facet.ts

This file was deleted.

Loading

0 comments on commit f66d14d

Please sign in to comment.