diff --git a/.env.example b/.env.example index c12ce8f..1b34445 100644 --- a/.env.example +++ b/.env.example @@ -18,6 +18,8 @@ RPC_BASE=https://base.llamarpc.com RPC_ZKEVM=https://zkevm-rpc.com RPC_GNOSIS=https://rpc.ankr.com/gnosis RPC_BNB=https://binance.llamarpc.com +RPC_ZK_SYNC=https://mainnet.era.zksync.io +RPC_ZK_SYNC_TESTNET=https://sepolia.era.zksync.dev # Etherscan api keys for verification & download utils ETHERSCAN_API_KEY_MAINNET= @@ -30,5 +32,4 @@ ETHERSCAN_API_KEY_BASE= ETHERSCAN_API_KEY_ZKEVM= ETHERSCAN_API_KEY_GNOSIS= ETHERSCAN_API_KEY_BNB= - - +ETHERSCAN_API_KEY_ZK_SYNC= diff --git a/.gitignore b/.gitignore index 60c655e..b521bfe 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ broadcast/ input.json run-latest.json +zkout/ +input.json diff --git a/.gitmodules b/.gitmodules index cdc9ba8..d00667d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,7 @@ [submodule "lib/aave-delivery-infrastructure"] path = lib/aave-delivery-infrastructure url = https://github.com/bgd-labs/aave-delivery-infrastructure +[submodule "lib/aave-helpers"] + path = lib/aave-helpers + url = https://github.com/bgd-labs/aave-helpers + branch = fix/e2e-fix-forwarder-diff-zksync diff --git a/Makefile b/Makefile index d514cad..521084d 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ BASE_KEY = --private-key ${PRIVATE_KEY} #custom_metis-testnet := --legacy --verifier-url https://goerli.explorer.metisdevops.link/api/ #custom_metis := --verifier-url https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan #custom_scroll-testnet := --legacy --with-gas-price 1000000000 # 1 gwei +custom_zksync := --zksync # params: # 1 - path/file_name @@ -31,25 +32,25 @@ BASE_KEY = --private-key ${PRIVATE_KEY} # to define custom params per network add vars custom_network-name # to use ledger, set LEDGER=true to env # default to testnet deployment, to run production, set PROD=true to env -#define deploy_single_fn -#forge script \ -# scripts/$(1).s.sol:$(if $(3),$(if $(PROD),$(3),$(3)_testnet),$(shell UP=$(if $(PROD),$(2),$(2)_testnet); echo $${UP} | perl -nE 'say ucfirst')) \ -# --rpc-url $(if $(PROD),$(2),$(2)-testnet) --broadcast --verify -vvvv \ -# $(if $(LEDGER),$(BASE_LEDGER),$(BASE_KEY)) \ -# $(custom_$(if $(PROD),$(2),$(2)-testnet)) -# -#endef - -# catapulta define deploy_single_fn -npx catapulta@latest script \ - scripts/$(1).s.sol:$(if $(3),$(3),$(shell UP=$(if $(PROD),$(2),$(2)_testnet); echo $${UP} | perl -nE 'say ucfirst')) \ - --network $(2) --slow --skip-git \ +forge script \ + scripts/$(1).s.sol:$(if $(3),$(if $(PROD),$(3),$(3)_testnet),$(shell UP=$(if $(PROD),$(2),$(2)_testnet); echo $${UP} | perl -nE 'say ucfirst')) \ + --rpc-url $(if $(PROD),$(2),$(2)-testnet) --broadcast --verify -vvvv \ $(if $(LEDGER),$(BASE_LEDGER),$(BASE_KEY)) \ $(custom_$(if $(PROD),$(2),$(2)-testnet)) endef +# catapulta +#define deploy_single_fn +#npx catapulta@latest script \ +# scripts/$(1).s.sol:$(if $(3),$(3),$(shell UP=$(if $(PROD),$(2),$(2)_testnet); echo $${UP} | perl -nE 'say ucfirst')) \ +# --network $(2) --slow --skip-git \ +# $(if $(LEDGER),$(BASE_LEDGER),$(BASE_KEY)) \ +# $(custom_$(if $(PROD),$(2),$(2)-testnet)) +# +#endef + define deploy_fn $(foreach network,$(2),$(call deploy_single_fn,$(1),$(network),$(3))) endef @@ -112,13 +113,16 @@ deploy-zkevm-adapters: deploy-wormhole-adapters: $(call deploy_fn,adapters/DeployWormholeAdapter,ethereum celo) +deploy-zksync-adapters-test: + $(call deploy_fn,adapters/DeployZkSyncAdapter,ethereum) + ## Set sender bridge dapters. Only eth pol avax are needed as other networks will only receive set-ccf-sender-adapters: - $(call deploy_fn,CCC/Set_CCF_Sender_Adapters,ethereum) + $(call deploy_fn,ccc/Set_CCF_Sender_Adapters,ethereum) # Set the bridge adapters allowed to receive messages set-ccr-receiver-adapters: - $(call deploy_fn,CCC/Set_CCR_Receivers_Adapters,ethereum polygon avalanche binance arbitrum optimism base metis gnosis zkevm) + $(call deploy_fn,ccc/Set_CCR_Receivers_Adapters,ethereum polygon avalanche binance arbitrum optimism base metis gnosis zkevm) # Sets the required confirmations set-ccr-confirmations: @@ -154,11 +158,11 @@ deploy-full: # Deploy Proxy Factories on all networks deploy-proxy-factory-test: - $(call deploy_fn,InitialDeployments,base) + $(call deploy_fn,InitialDeployments,zksync) # Deploy Cross Chain Infra on all networks deploy-cross-chain-infra-test: - $(call deploy_fn,CCC/Deploy_CCC,ethereum) + $(call deploy_fn,ccc/DeployCCC,zksync) ## Deploy CCIP bridge adapters on all networks deploy-ccip-bridge-adapters-test: @@ -202,15 +206,15 @@ deploy-base-adapters-test: ## Set sender bridge dapters. Only eth pol avax are needed as other networks will only receive set-ccf-sender-adapters-test: - $(call deploy_fn,CCC/Set_CCF_Sender_Adapters,avalanche) + $(call deploy_fn,ccc/Set_CCF_Sender_Adapters,ethereum) # Set the bridge adapters allowed to receive messages set-ccr-receiver-adapters-test: - $(call deploy_fn,CCC/Set_CCR_Receivers_Adapters,celo) + $(call deploy_fn,ccc/Set_CCR_Receivers_Adapters,zksync) # Sets the required confirmations set-ccr-confirmations-test: - $(call deploy_fn,CCC/Set_CCR_Confirmations,ethereum) + $(call deploy_fn,ccc/Set_CCR_Confirmations,zksync) ## Deploy and configure all contracts @@ -238,7 +242,7 @@ send-direct-message: $(call deploy_fn,helpers/Send_Direct_CCMessage,avalanche) deploy_mock_destination: - $(call deploy_fn,helpers/Deploy_Mock_destination,ethereum) + $(call deploy_fn,helpers/Deploy_Mock_destination,zksync) set-approved-ccf-senders: $(call deploy_fn,helpers/Set_Approved_Senders,ethereum) @@ -253,7 +257,7 @@ send-message-via-adapter: $(call deploy_fn,helpers/Send_Message_Via_Adapter,ethereum) deploy_ccc_granular_guardian: - $(call deploy_fn,access_control/DeployGranularGuardian,ethereum avalanche polygon binance gnosis metis scroll optimism arbitrum base) + $(call deploy_fn,access_control/network_scripts/GranularGuardianNetworkDeploys,zksync) deploy-ccc-revision-and-update: $(call deploy_fn,CCC/UpdateCCC,ethereum) @@ -263,3 +267,6 @@ deploy-ccc-update-payload: deploy-ccc-shuffle-payload: $(call deploy_fn,payloads/ccc/shuffle/Network_Deployments,metis) + +deploy-zksync-path-payload: + $(call deploy_fn,payloads/adapters/zksync/Network_Deployments,ethereum) diff --git a/deployments/ethereum.json b/deployments/ethereum.json index 4dd1fda..a383031 100644 --- a/deployments/ethereum.json +++ b/deployments/ethereum.json @@ -24,5 +24,5 @@ "scrollAdapter": "0xA4dC3F123e1c601A19B3DC8382BB9311F678cafA", "wormholeAdapter": "0x42206271373675661500F8a4d6A6CE2FDc6b5De5", "zkevmAdapter": "0xe0a6Eee6d0c883734A7a7e7B378BD09fffb89EB6", - "zksyncAdapter": "0x0000000000000000000000000000000000000000" + "zksyncAdapter": "0x6aD9d4147467f08b165e1b6364584C5d28898b84" } \ No newline at end of file diff --git a/deployments/ethereum_sepolia.json b/deployments/ethereum_sepolia.json index 42d8cee..15eb074 100644 --- a/deployments/ethereum_sepolia.json +++ b/deployments/ethereum_sepolia.json @@ -24,5 +24,5 @@ "scrollAdapter": "0xba62183cc12d68ca9Cf9a8b2ed64107fAd1F1d2f", "wormholeAdapter": "0x42D8D601cB91df86367229d04D8cf3556464c5c7", "zkevmAdapter": "0x0000000000000000000000000000000000000000", - "zksyncAdapter": "0x0000000000000000000000000000000000000000" + "zksyncAdapter": "0xC0d55FEa916180a8e38d842651c6472f4bA8337E" } diff --git a/deployments/pre_prod_ethereum.json b/deployments/pre_prod_ethereum.json index 399a995..8149df3 100644 --- a/deployments/pre_prod_ethereum.json +++ b/deployments/pre_prod_ethereum.json @@ -9,8 +9,8 @@ "crossChainControllerImpl": "0x04458aBf3844995FA28Fd5503034AE69A3E6a400", "emergencyRegistry": "0x0000000000000000000000000000000000000000", "gnosisAdapter": "0x0BED83079C2c994C54112d07110F09C9Be6d485E", - "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", "granularCCCGuardian": "0x0000000000000000000000000000000000000000", + "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", "hlAdapter": "0x834607F5d65451918a8fDD5D22d6eF97f84917ef", "lzAdapter": "0xE35B90E1B1eF522dC40a5829c59e3d2d291a9360", "metisAdapter": "0x92bce04e8B33c7098AA0bEc7663cA8Eb0930f6a4", @@ -24,5 +24,5 @@ "scrollAdapter": "0x525EC320AbD05FF316683BA3e38023CEe72f9868", "wormholeAdapter": "0x7458fd003C60D6B581D20249386188eA976e0556", "zkevmAdapter": "0x0000000000000000000000000000000000000000", - "zksyncAdapter": "0x0000000000000000000000000000000000000000" -} + "zksyncAdapter": "0x22b56CC7c45ed007eA7E4Ea10D28967d36E314D6" +} \ No newline at end of file diff --git a/deployments/pre_prod_zksync.json b/deployments/pre_prod_zksync.json new file mode 100644 index 0000000..5c2234b --- /dev/null +++ b/deployments/pre_prod_zksync.json @@ -0,0 +1,28 @@ +{ + "arbAdapter": "0x0000000000000000000000000000000000000000", + "baseAdapter": "0x0000000000000000000000000000000000000000", + "ccipAdapter": "0x0000000000000000000000000000000000000000", + "chainId": 324, + "clEmergencyOracle": "0x0000000000000000000000000000000000000000", + "create3Factory": "0x0000000000000000000000000000000000000000", + "crossChainController": "0xEFB85c47F666829e9dD9Ad56fC2ca0E5C2569e17", + "crossChainControllerImpl": "0x93aF5EA45d7eDCD37EFd601C943592b71A2F3682", + "emergencyRegistry": "0x0000000000000000000000000000000000000000", + "gnosisAdapter": "0x0000000000000000000000000000000000000000", + "granularCCCGuardian": "0x0000000000000000000000000000000000000000", + "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "hlAdapter": "0x0000000000000000000000000000000000000000", + "lzAdapter": "0x0000000000000000000000000000000000000000", + "metisAdapter": "0x0000000000000000000000000000000000000000", + "mockDestination": "0x63Ba24d305dCBEd249E9808e4855387bd62424Cc", + "opAdapter": "0x0000000000000000000000000000000000000000", + "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "polAdapter": "0x0000000000000000000000000000000000000000", + "proxyAdmin": "0xb4b3048fD1a6e2e488b51A8a831181D528B9C5c5", + "proxyFactory": "0x8Ef21C75Ce360078cAD162565ED0c27617eCccE0", + "sameChainAdapter": "0x0000000000000000000000000000000000000000", + "scrollAdapter": "0x0000000000000000000000000000000000000000", + "wormholeAdapter": "0x0000000000000000000000000000000000000000", + "zkevmAdapter": "0x0000000000000000000000000000000000000000", + "zksyncAdapter": "0x53Cc59f9F3F4093ecBd2E9e366B35056022eCc8B" +} \ No newline at end of file diff --git a/deployments/zksync.json b/deployments/zksync.json new file mode 100644 index 0000000..c23c5a4 --- /dev/null +++ b/deployments/zksync.json @@ -0,0 +1,28 @@ +{ + "arbAdapter": "0x0000000000000000000000000000000000000000", + "baseAdapter": "0x0000000000000000000000000000000000000000", + "ccipAdapter": "0x0000000000000000000000000000000000000000", + "chainId": 324, + "clEmergencyOracle": "0x0000000000000000000000000000000000000000", + "create3Factory": "0x0000000000000000000000000000000000000000", + "crossChainController": "0x800813f4714BC7A0a95310e3fB9e4f18872CA92C", + "crossChainControllerImpl": "0x2b6D63bf3e0abC405C50e00A015c4EE47780a42f", + "emergencyRegistry": "0x0000000000000000000000000000000000000000", + "gnosisAdapter": "0x0000000000000000000000000000000000000000", + "granularCCCGuardian": "0xe0e23196D42b54F262a3DE952e6B34B197D1A228", + "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "hlAdapter": "0x0000000000000000000000000000000000000000", + "lzAdapter": "0x0000000000000000000000000000000000000000", + "metisAdapter": "0x0000000000000000000000000000000000000000", + "mockDestination": "0x0000000000000000000000000000000000000000", + "opAdapter": "0x0000000000000000000000000000000000000000", + "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "polAdapter": "0x0000000000000000000000000000000000000000", + "proxyAdmin": "0x158d6c497317367CEa3CBAb0BD84E6de236F060D", + "proxyFactory": "0x8Ef21C75Ce360078cAD162565ED0c27617eCccE0", + "sameChainAdapter": "0x0000000000000000000000000000000000000000", + "scrollAdapter": "0x0000000000000000000000000000000000000000", + "wormholeAdapter": "0x0000000000000000000000000000000000000000", + "zkevmAdapter": "0x0000000000000000000000000000000000000000", + "zksyncAdapter": "0x1BC5C10CAe378fDbd7D52ec4F9f34590a619c68E" +} \ No newline at end of file diff --git a/deployments/zksync_sepolia.json b/deployments/zksync_sepolia.json new file mode 100644 index 0000000..2ebb9fd --- /dev/null +++ b/deployments/zksync_sepolia.json @@ -0,0 +1,27 @@ +{ + "arbAdapter": "0x0000000000000000000000000000000000000000", + "baseAdapter": "0x0000000000000000000000000000000000000000", + "ccipAdapter": "0x0000000000000000000000000000000000000000", + "chainId": 300, + "clEmergencyOracle": "0x0000000000000000000000000000000000000000", + "create3Factory": "0x0000000000000000000000000000000000000000", + "crossChainController": "0x77430FCd47F62A9706CAca6300563c6B27885F5F", + "crossChainControllerImpl": "0xb8e9DFC71C1d232db103E7ae72bF0CF70c03F912", + "emergencyRegistry": "0x0000000000000000000000000000000000000000", + "gnosisAdapter": "0x0000000000000000000000000000000000000000", + "guardian": "0x6D603081563784dB3f83ef1F65Cc389D94365Ac9", + "hlAdapter": "0x0000000000000000000000000000000000000000", + "lzAdapter": "0x0000000000000000000000000000000000000000", + "metisAdapter": "0x0000000000000000000000000000000000000000", + "mockDestination": "0x3676a657F22Ea4A6Eb3A51Da7233A37E8D604967", + "opAdapter": "0x0000000000000000000000000000000000000000", + "owner": "0x6D603081563784dB3f83ef1F65Cc389D94365Ac9", + "polAdapter": "0x0000000000000000000000000000000000000000", + "proxyAdmin": "0x91123BA04bEDd58195C985B28F1F99d4a15E1910", + "proxyFactory": "0xcd1416eA758CFf55b7aBA279632446A4272800AB", + "sameChainAdapter": "0x0000000000000000000000000000000000000000", + "scrollAdapter": "0x0000000000000000000000000000000000000000", + "wormholeAdapter": "0x0000000000000000000000000000000000000000", + "zkevmAdapter": "0x0000000000000000000000000000000000000000", + "zksyncAdapter": "0x013D88537bFdb7984700D44a8c0427D13d352D90" +} \ No newline at end of file diff --git a/diffs/adi_add_zksync_path_to_adiethereum_before_adi_add_zksync_path_to_adiethereum_after.md b/diffs/adi_add_zksync_path_to_adiethereum_before_adi_add_zksync_path_to_adiethereum_after.md new file mode 100644 index 0000000..a850be3 --- /dev/null +++ b/diffs/adi_add_zksync_path_to_adiethereum_before_adi_add_zksync_path_to_adiethereum_after.md @@ -0,0 +1,14 @@ +## Raw diff + +```json +{ + "forwarderAdaptersByChain": { + "324": { + "from": "", + "to": { + "0x6aD9d4147467f08b165e1b6364584C5d28898b84": "0x1BC5C10CAe378fDbd7D52ec4F9f34590a619c68E" + } + } + } +} +``` \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 6f6ec18..6318554 100644 --- a/foundry.toml +++ b/foundry.toml @@ -11,6 +11,11 @@ metadata="none" solc = "0.8.19" ffi = true +[profile.default.zksync] +fallback_oz = true +mode = "3" +zksolc="1.4.1" + [rpc_endpoints] ethereum="${RPC_MAINNET}" ethereum_sepolia="${RPC_ETHEREUM_SEPOLIA}" @@ -38,6 +43,8 @@ scroll="${RPC_SCROLL}" scroll-testnet="${RPC_SCROLL_TESTNET}" celo="${RPC_CELO}" celo-testnet="${RPC_CELO_ALFAJORES}" +zksync="${RPC_ZK_SYNC}" +zksync-testnet="${RPC_ZK_SYNC_TESTNET}" [etherscan] ethereum={key="${ETHERSCAN_API_KEY_MAINNET}", chain=1 } @@ -66,5 +73,11 @@ scroll={key="${ETHERSCAN_API_KEY_SCROLL}", chain=534352, utl='https://api.scroll scroll-testnet={key="${ETHERSCAN_API_KEY_SCROLL}", chain=534351, url='https://api-sepolia.scrollscan.com/api/'} celo={key="${ETHERSCAN_API_KEY_CELO}", chain=42220, utl='https://api.celoscan.io/api'} celo-testnet={key="${ETHERSCAN_API_KEY_CELO}", chain=44787, url='https://api-alfajores.celoscan.io/api'} +zksync={key="${ETHERSCAN_API_KEY_ZK_SYNC}", chain=324} +zksync-testnet={key="${ETHERSCAN_API_KEY_ZK_SYNC}", chain=300, url='https://api-sepolia-era.zksync.network/api'} # See more config options https://github.com/gakonst/foundry/tree/master/config +[fuzz] +no_zksync_reserved_addresses = true +[invariant] +no_zksync_reserved_addresses = true diff --git a/lib/aave-delivery-infrastructure b/lib/aave-delivery-infrastructure index db38e62..cb7fc0c 160000 --- a/lib/aave-delivery-infrastructure +++ b/lib/aave-delivery-infrastructure @@ -1 +1 @@ -Subproject commit db38e626675873e71bb3c2feb9624c1440d10518 +Subproject commit cb7fc0c4132ae7b76b18e8622ac3cf1ac5d56e18 diff --git a/lib/aave-helpers b/lib/aave-helpers new file mode 160000 index 0000000..da9ab68 --- /dev/null +++ b/lib/aave-helpers @@ -0,0 +1 @@ +Subproject commit da9ab68b5730d0475192c3f3956884ab7e5d66a3 diff --git a/remappings.txt b/remappings.txt index 9e9fca2..ff70676 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,11 +1,11 @@ -solidity-utils/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/solidity-utils/src/ -ds-test/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/forge-std/lib/ds-test/src/ -forge-std/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/forge-std/src/ +solidity-utils/=lib/aave-delivery-infrastructure/lib/solidity-utils/src/ +forge-std/=lib/aave-helpers/lib/forge-std/src/ openzeppelin-contracts/=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts/ -aave-helpers/=lib/aave-delivery-infrastructure/lib/aave-helpers/src/ -aave-address-book/=lib/aave-delivery-infrastructure/lib/aave-helpers/lib/aave-address-book/src/ +aave-helpers/=lib/aave-helpers/src/ +aave-address-book/=lib/aave-helpers/lib/aave-address-book/src/ adi/=lib/aave-delivery-infrastructure/src/contracts/ adi-scripts/=lib/aave-delivery-infrastructure/scripts/ adi-tests/=lib/aave-delivery-infrastructure/tests/ +aave-v3-origin/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src/ diff --git a/scripts/BaseDeployerScript.sol b/scripts/BaseDeployerScript.sol index 0221c66..e739847 100644 --- a/scripts/BaseDeployerScript.sol +++ b/scripts/BaseDeployerScript.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import 'forge-std/Script.sol'; import 'adi-scripts/BaseScript.sol'; -import {ChainHelpers} from 'aave-helpers/ChainIds.sol'; +import {ChainHelpers} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; struct Addresses { address arbAdapter; diff --git a/scripts/InitialDeployments.s.sol b/scripts/InitialDeployments.s.sol index 867c939..9db9047 100644 --- a/scripts/InitialDeployments.s.sol +++ b/scripts/InitialDeployments.s.sol @@ -258,6 +258,24 @@ contract Celo is BaseInitialDeployment { } } +contract Zksync is BaseInitialDeployment { + function TRANSPARENT_PROXY_FACTORY() internal pure override returns (address) { + return 0x8Ef21C75Ce360078cAD162565ED0c27617eCccE0; + } + + function PROXY_ADMIN() internal pure override returns (address) { + return 0x158d6c497317367CEa3CBAb0BD84E6de236F060D; + } + + // function GUARDIAN() internal pure override returns (address) { + // return; + // } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ZK_SYNC; + } +} + contract Ethereum_testnet is BaseInitialDeployment { function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; diff --git a/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol b/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol index 85329e6..1c7a00c 100644 --- a/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol +++ b/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol @@ -202,3 +202,21 @@ contract Base is DeployGranularGuardian { return ChainIds.BASE; } } + +contract Zksync is DeployGranularGuardian { + function DEFAULT_ADMIN() internal pure override returns (address) { + return 0x04cE39789e11a49595cD0ECEf6f4Bd54ABF4d020; //GovernanceV3Zksync.EXECUTOR_LVL_1; + } + + function RETRY_GUARDIAN() internal pure override returns (address) { + return 0x2451337aD5fE8b563bEB3b9c4A2B8789294879Ec; // bgd guardian + } + + function SOLVE_EMERGENCY_GUARDIAN() internal pure override returns (address) { + return 0x4257bf0746D783f0D962913d7d8AFA408B62547E; + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ZK_SYNC; + } +} diff --git a/scripts/adapters/DeployZkSyncAdapter.s.sol b/scripts/adapters/DeployZkSyncAdapter.s.sol new file mode 100644 index 0000000..648cb41 --- /dev/null +++ b/scripts/adapters/DeployZkSyncAdapter.s.sol @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import 'adi-scripts/Adapters/DeployZkSyncAdapter.sol'; +import '../BaseDeployerScript.sol'; + +abstract contract DeployZkSyncAdapter is BaseDeployerScript, BaseZkSyncAdapter { + function _execute(Addresses memory addresses) internal virtual override { + if (TRANSACTION_NETWORK() == ChainIds.ZK_SYNC) { + addresses.zksyncAdapter = _deployWithoutCreate2( + BaseAdapterArgs({ + crossChainController: addresses.crossChainController, + providerGasLimit: PROVIDER_GAS_LIMIT(), + trustedRemotes: _getTrustedRemotes(), + isTestnet: isTestnet() + }) + ); + } else { + addresses.zksyncAdapter = _deployAdapter(addresses.crossChainController); + } + } +} + +contract Ethereum is DeployZkSyncAdapter { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ETHEREUM; + } + + function PROVIDER_GAS_LIMIT() internal view virtual override returns (uint256) { + return 650_000; + } + + function REFUND_ADDRESS() internal view override returns (address) { + Addresses memory remoteAddresses = _getAddresses(ChainIds.ZK_SYNC); + return remoteAddresses.crossChainController; + } + + function REMOTE_CCC_BY_NETWORK() internal pure override returns (RemoteCCC[] memory) { + return new RemoteCCC[](0); + } + + function BRIDGE_HUB() internal pure override returns (address) { + return 0x303a465B659cBB0ab36eE643eA362c509EEb5213; + } +} + +contract Zksync is DeployZkSyncAdapter { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ZK_SYNC; + } + + function REMOTE_CCC_BY_NETWORK() internal view override returns (RemoteCCC[] memory) { + RemoteCCC[] memory remoteCCCByNetwork = new RemoteCCC[](1); + remoteCCCByNetwork[0].chainId = ChainIds.ETHEREUM; + remoteCCCByNetwork[0].crossChainController = _getAddresses(ChainIds.ETHEREUM) + .crossChainController; + return remoteCCCByNetwork; + } + + function BRIDGE_HUB() internal pure override returns (address) { + return 0x303a465B659cBB0ab36eE643eA362c509EEb5213; // Set to mainnet address, but not used on zkSync + } +} + +contract Ethereum_testnet is DeployZkSyncAdapter { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ETHEREUM_SEPOLIA; + } + + function REFUND_ADDRESS() internal view override returns (address) { + Addresses memory remoteAddresses = _getAddresses(TestNetChainIds.ZK_SYNC_SEPOLIA); + return remoteAddresses.crossChainController; + } + + function REMOTE_CCC_BY_NETWORK() internal pure override returns (RemoteCCC[] memory) { + return new RemoteCCC[](0); + } + + function BRIDGE_HUB() internal pure override returns (address) { + return 0x35A54c8C757806eB6820629bc82d90E056394C92; + } + + function isTestnet() internal pure override returns (bool) { + return true; + } +} + +contract Zksync_testnet is DeployZkSyncAdapter { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ZK_SYNC_SEPOLIA; + } + + function REMOTE_CCC_BY_NETWORK() internal view override returns (RemoteCCC[] memory) { + RemoteCCC[] memory remoteCCCByNetwork = new RemoteCCC[](1); + remoteCCCByNetwork[0].chainId = TestNetChainIds.ETHEREUM_SEPOLIA; + remoteCCCByNetwork[0].crossChainController = _getAddresses(TestNetChainIds.ETHEREUM_SEPOLIA) + .crossChainController; + return remoteCCCByNetwork; + } + + function BRIDGE_HUB() internal pure override returns (address) { + return 0x35A54c8C757806eB6820629bc82d90E056394C92; // Set to mainnet address, but not used on zkSync + } + + function isTestnet() internal pure override returns (bool) { + return true; + } +} diff --git a/scripts/ccc/DeployCCC.s.sol b/scripts/ccc/DeployCCC.s.sol index 7574c32..e752447 100644 --- a/scripts/ccc/DeployCCC.s.sol +++ b/scripts/ccc/DeployCCC.s.sol @@ -8,7 +8,7 @@ import 'adi-scripts/CCC/DeployCrossChainController.sol'; abstract contract BaseCCCNetworkDeployment is BaseDeployerScript, BaseCCCDeploy { function _execute(Addresses memory addresses) internal override { - addresses.crossChainControllerImpl = _deployCCCImpl(); + addresses.crossChainControllerImpl = _deployWithoutCreate2(); //_deployCCCImpl(); address crossChainController; // if address is 0 means that ccc will not be emergency consumer if (CL_EMERGENCY_ORACLE() == address(0)) { @@ -144,6 +144,12 @@ contract Celo is BaseCCCNetworkDeployment { } } +contract Zksync is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ZK_SYNC; + } +} + contract Ethereum_testnet is BaseCCCNetworkDeployment { function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; diff --git a/scripts/ccc/Set_CCF_Sender_Adapters..ssol b/scripts/ccc/Set_CCF_Sender_Adapters.s.sol similarity index 80% rename from scripts/ccc/Set_CCF_Sender_Adapters..ssol rename to scripts/ccc/Set_CCF_Sender_Adapters.s.sol index 1234990..d217fc2 100644 --- a/scripts/ccc/Set_CCF_Sender_Adapters..ssol +++ b/scripts/ccc/Set_CCF_Sender_Adapters.s.sol @@ -4,6 +4,21 @@ pragma solidity ^0.8.0; import {ICrossChainForwarder} from 'adi/interfaces/ICrossChainForwarder.sol'; import '../BaseDeployerScript.sol'; +struct NetworkAddresses { + Addresses polygon; + Addresses avalanche; + Addresses binance; + Addresses optimism; + Addresses arbitrum; + Addresses metis; + Addresses base; + Addresses gnosis; + Addresses zkevm; + Addresses scroll; + Addresses celo; + Addresses zksync; +} + abstract contract BaseCCFSenderAdapters is BaseDeployerScript { function getBridgeAdaptersToEnable( Addresses memory addresses @@ -26,95 +41,103 @@ contract Ethereum is BaseCCFSenderAdapters { ) public view override returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( - 23 + 24 ); + NetworkAddresses memory networkAddresses = NetworkAddresses({ + polygon: _getAddresses(ChainIds.POLYGON), + avalanche: _getAddresses(ChainIds.AVALANCHE), + binance: _getAddresses(ChainIds.BNB), + optimism: _getAddresses(ChainIds.OPTIMISM), + arbitrum: _getAddresses(ChainIds.ARBITRUM), + metis: _getAddresses(ChainIds.METIS), + base: _getAddresses(ChainIds.BASE), + gnosis: _getAddresses(ChainIds.GNOSIS), + zkevm: _getAddresses(ChainIds.POLYGON_ZK_EVM), + scroll: _getAddresses(ChainIds.SCROLL), + celo: _getAddresses(ChainIds.CELO), + zksync: _getAddresses(ChainIds.ZK_SYNC) + }); + // polygon path - Addresses memory addressesPolygon = _getAddresses(ChainIds.POLYGON); bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.polAdapter, - destinationBridgeAdapter: addressesPolygon.polAdapter, - destinationChainId: addressesPolygon.chainId + destinationBridgeAdapter: networkAddresses.polygon.polAdapter, + destinationChainId: networkAddresses.polygon.chainId }); bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.ccipAdapter, - destinationBridgeAdapter: addressesPolygon.ccipAdapter, - destinationChainId: addressesPolygon.chainId + destinationBridgeAdapter: networkAddresses.polygon.ccipAdapter, + destinationChainId: networkAddresses.polygon.chainId }); bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.lzAdapter, - destinationBridgeAdapter: addressesPolygon.lzAdapter, - destinationChainId: addressesPolygon.chainId + destinationBridgeAdapter: networkAddresses.polygon.lzAdapter, + destinationChainId: networkAddresses.polygon.chainId }); bridgeAdaptersToEnable[3] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.hlAdapter, - destinationBridgeAdapter: addressesPolygon.hlAdapter, - destinationChainId: addressesPolygon.chainId + destinationBridgeAdapter: networkAddresses.polygon.hlAdapter, + destinationChainId: networkAddresses.polygon.chainId }); // avalanche path - Addresses memory addressesAvax = _getAddresses(ChainIds.AVALANCHE); bridgeAdaptersToEnable[4] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.ccipAdapter, - destinationBridgeAdapter: addressesAvax.ccipAdapter, - destinationChainId: addressesAvax.chainId + destinationBridgeAdapter: networkAddresses.avalanche.ccipAdapter, + destinationChainId: networkAddresses.avalanche.chainId }); bridgeAdaptersToEnable[5] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.lzAdapter, - destinationBridgeAdapter: addressesAvax.lzAdapter, - destinationChainId: addressesAvax.chainId + destinationBridgeAdapter: networkAddresses.avalanche.lzAdapter, + destinationChainId: networkAddresses.avalanche.chainId }); bridgeAdaptersToEnable[6] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.hlAdapter, - destinationBridgeAdapter: addressesAvax.hlAdapter, - destinationChainId: addressesAvax.chainId + destinationBridgeAdapter: networkAddresses.avalanche.hlAdapter, + destinationChainId: networkAddresses.avalanche.chainId }); // binance path - Addresses memory addressesBNB = _getAddresses(ChainIds.BNB); bridgeAdaptersToEnable[7] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.lzAdapter, - destinationBridgeAdapter: addressesBNB.lzAdapter, - destinationChainId: addressesBNB.chainId + destinationBridgeAdapter: networkAddresses.binance.lzAdapter, + destinationChainId: networkAddresses.binance.chainId }); bridgeAdaptersToEnable[8] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.hlAdapter, - destinationBridgeAdapter: addressesBNB.hlAdapter, - destinationChainId: addressesBNB.chainId + destinationBridgeAdapter: networkAddresses.binance.hlAdapter, + destinationChainId: networkAddresses.binance.chainId }); bridgeAdaptersToEnable[9] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.ccipAdapter, - destinationBridgeAdapter: addressesBNB.ccipAdapter, - destinationChainId: addressesBNB.chainId + destinationBridgeAdapter: networkAddresses.binance.ccipAdapter, + destinationChainId: networkAddresses.binance.chainId }); // optimism - Addresses memory addressesOp = _getAddresses(ChainIds.OPTIMISM); bridgeAdaptersToEnable[10] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.opAdapter, - destinationBridgeAdapter: addressesOp.opAdapter, - destinationChainId: addressesOp.chainId + destinationBridgeAdapter: networkAddresses.optimism.opAdapter, + destinationChainId: networkAddresses.optimism.chainId }); // arbitrum - Addresses memory addressesArb = _getAddresses(ChainIds.ARBITRUM); bridgeAdaptersToEnable[11] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.arbAdapter, - destinationBridgeAdapter: addressesArb.arbAdapter, - destinationChainId: addressesArb.chainId + destinationBridgeAdapter: networkAddresses.arbitrum.arbAdapter, + destinationChainId: networkAddresses.arbitrum.chainId }); // metis - Addresses memory addressesMetis = _getAddresses(ChainIds.METIS); bridgeAdaptersToEnable[12] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.metisAdapter, - destinationBridgeAdapter: addressesMetis.metisAdapter, - destinationChainId: addressesMetis.chainId + destinationBridgeAdapter: networkAddresses.metis.metisAdapter, + destinationChainId: networkAddresses.metis.chainId }); //base - Addresses memory addressesBase = _getAddresses(ChainIds.BASE); bridgeAdaptersToEnable[13] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.baseAdapter, - destinationBridgeAdapter: addressesBase.baseAdapter, - destinationChainId: addressesBase.chainId + destinationBridgeAdapter: networkAddresses.base.baseAdapter, + destinationChainId: networkAddresses.base.chainId }); // same chain path @@ -125,57 +148,59 @@ contract Ethereum is BaseCCFSenderAdapters { }); // gnosis - Addresses memory addressesGnosis = _getAddresses(ChainIds.GNOSIS); bridgeAdaptersToEnable[15] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.gnosisAdapter, - destinationBridgeAdapter: addressesGnosis.gnosisAdapter, - destinationChainId: addressesGnosis.chainId + destinationBridgeAdapter: networkAddresses.gnosis.gnosisAdapter, + destinationChainId: networkAddresses.gnosis.chainId }); bridgeAdaptersToEnable[16] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.lzAdapter, - destinationBridgeAdapter: addressesGnosis.lzAdapter, - destinationChainId: addressesGnosis.chainId + destinationBridgeAdapter: networkAddresses.gnosis.lzAdapter, + destinationChainId: networkAddresses.gnosis.chainId }); bridgeAdaptersToEnable[17] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.hlAdapter, - destinationBridgeAdapter: addressesGnosis.hlAdapter, - destinationChainId: addressesGnosis.chainId + destinationBridgeAdapter: networkAddresses.gnosis.hlAdapter, + destinationChainId: networkAddresses.gnosis.chainId }); // ZkEVM - Addresses memory addressesZkEVM = _getAddresses(ChainIds.POLYGON_ZK_EVM); bridgeAdaptersToEnable[18] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.zkevmAdapter, - destinationBridgeAdapter: addressesZkEVM.zkevmAdapter, - destinationChainId: addressesZkEVM.chainId + destinationBridgeAdapter: networkAddresses.zkevm.zkevmAdapter, + destinationChainId: networkAddresses.zkevm.chainId }); // Scroll - Addresses memory addressesScroll = _getAddresses(ChainIds.SCROLL); bridgeAdaptersToEnable[19] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.scrollAdapter, - destinationBridgeAdapter: addressesScroll.scrollAdapter, - destinationChainId: addressesScroll.chainId + destinationBridgeAdapter: networkAddresses.scroll.scrollAdapter, + destinationChainId: networkAddresses.scroll.chainId }); // Celo - Addresses memory addressesCelo = _getAddresses(ChainIds.CELO); bridgeAdaptersToEnable[20] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.wormholeAdapter, - destinationBridgeAdapter: addressesCelo.wormholeAdapter, - destinationChainId: addressesCelo.chainId + destinationBridgeAdapter: networkAddresses.celo.wormholeAdapter, + destinationChainId: networkAddresses.celo.chainId }); bridgeAdaptersToEnable[21] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.lzAdapter, - destinationBridgeAdapter: addressesCelo.lzAdapter, - destinationChainId: addressesCelo.chainId + destinationBridgeAdapter: networkAddresses.celo.lzAdapter, + destinationChainId: networkAddresses.celo.chainId }); bridgeAdaptersToEnable[22] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ currentChainBridgeAdapter: addresses.hlAdapter, - destinationBridgeAdapter: addressesCelo.hlAdapter, - destinationChainId: addressesCelo.chainId + destinationBridgeAdapter: networkAddresses.celo.hlAdapter, + destinationChainId: networkAddresses.celo.chainId }); + // ZkSync + bridgeAdaptersToEnable[23] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.zksyncAdapter, + destinationBridgeAdapter: networkAddresses.zksync.zksyncAdapter, + destinationChainId: networkAddresses.zksync.chainId + }); return bridgeAdaptersToEnable; } } diff --git a/scripts/ccc/Set_CCR_Confirmations.s.sol b/scripts/ccc/Set_CCR_Confirmations.s.sol index 0d636aa..f3f1d89 100644 --- a/scripts/ccc/Set_CCR_Confirmations.s.sol +++ b/scripts/ccc/Set_CCR_Confirmations.s.sol @@ -16,9 +16,9 @@ abstract contract BaseSetCCRConfirmations is BaseDeployerScript { function _execute(Addresses memory addresses) internal override { ConfirmationsByChain[] memory confirmationsByChain = getConfirmationsByChainIds(); ICrossChainReceiver.ConfirmationInput[] - memory confirmationsInput = new ICrossChainReceiver.ConfirmationInput[]( - confirmationsByChain.length - ); + memory confirmationsInput = new ICrossChainReceiver.ConfirmationInput[]( + confirmationsByChain.length + ); for (uint256 i = 0; i < confirmationsByChain.length; i++) { confirmationsInput[i] = ICrossChainReceiver.ConfirmationInput({ @@ -37,10 +37,10 @@ contract Ethereum is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](2); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.POLYGON, confirmations: 3}); @@ -56,10 +56,10 @@ contract Polygon is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 3}); @@ -74,10 +74,10 @@ contract Avalanche is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); @@ -92,10 +92,10 @@ contract Optimism is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); @@ -110,10 +110,10 @@ contract Arbitrum is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); @@ -128,10 +128,10 @@ contract Metis is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); @@ -146,10 +146,10 @@ contract Binance is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); @@ -164,10 +164,10 @@ contract Base is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); @@ -182,10 +182,10 @@ contract Gnosis is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); @@ -200,10 +200,10 @@ contract Zkevm is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); @@ -218,10 +218,10 @@ contract Scroll is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); @@ -236,10 +236,10 @@ contract Celo is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); @@ -248,16 +248,34 @@ contract Celo is BaseSetCCRConfirmations { } } +contract Zksync is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.ZK_SYNC; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); + + return chainIds; + } +} + contract Ethereum_testnet is Ethereum { function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](2); chainIds[0] = ConfirmationsByChain({chainId: TestNetChainIds.POLYGON_AMOY, confirmations: 1}); @@ -273,10 +291,10 @@ contract Polygon_testnet is Polygon { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -294,10 +312,10 @@ contract Avalanche_testnet is Avalanche { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -315,10 +333,10 @@ contract Optimism_testnet is Optimism { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -336,10 +354,10 @@ contract Arbitrum_testnet is Arbitrum { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -357,10 +375,10 @@ contract Metis_testnet is Metis { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -378,10 +396,10 @@ contract Binance_testnet is Binance { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -399,10 +417,10 @@ contract Base_testnet is Base { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -420,10 +438,10 @@ contract Gnosis_testnet is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -441,10 +459,10 @@ contract Scroll_testnet is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ @@ -462,10 +480,10 @@ contract Celo_testnet is BaseSetCCRConfirmations { } function getConfirmationsByChainIds() - public - virtual - override - returns (ConfirmationsByChain[] memory) + public + virtual + override + returns (ConfirmationsByChain[] memory) { ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); chainIds[0] = ConfirmationsByChain({ diff --git a/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol b/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol index 39b8d40..1a8aedc 100644 --- a/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol +++ b/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol @@ -16,9 +16,9 @@ abstract contract BaseSetCCRAdapters is BaseDeployerScript { address[] memory receiverBridgeAdaptersToAllow = getReceiverBridgeAdaptersToAllow(addresses); ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]( - receiverBridgeAdaptersToAllow.length - ); + memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]( + receiverBridgeAdaptersToAllow.length + ); for (uint256 i = 0; i < receiverBridgeAdaptersToAllow.length; i++) { bridgeAdapterConfig[i] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ bridgeAdapter: receiverBridgeAdaptersToAllow[i], @@ -313,6 +313,28 @@ contract Celo is BaseSetCCRAdapters { } } +contract Zksync is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.ZK_SYNC; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.zksyncAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + contract Ethereum_testnet is Ethereum { function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; diff --git a/scripts/helpers/Deploy_Mock_destination.s.sol b/scripts/helpers/Deploy_Mock_destination.s.sol index 23d8999..59f4e58 100644 --- a/scripts/helpers/Deploy_Mock_destination.s.sol +++ b/scripts/helpers/Deploy_Mock_destination.s.sol @@ -82,6 +82,12 @@ contract Scroll is BaseMockDestination { } } +contract Zksync is BaseMockDestination { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.ZK_SYNC; + } +} + contract Ethereum_testnet is BaseMockDestination { function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; diff --git a/scripts/payloads/ArbAdapterPayload.sol b/scripts/payloads/ArbAdapterPayload.sol deleted file mode 100644 index 494c89d..0000000 --- a/scripts/payloads/ArbAdapterPayload.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {SimpleReceiverAdapterUpdate} from 'aave-helpers/adi/SimpleReceiverAdapterUpdate.sol'; -import {ChainIds} from 'aave-helpers/ChainIds.sol'; - -/** - * @title Arbitrum bridge adapter update example - * @author BGD Labs @bgdlabs - * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/31 - */ -contract AaveV3Arbitrum_New_Adapter_Payload is SimpleReceiverAdapterUpdate { - constructor( - address crossChainController, - address newAdapter - ) - SimpleReceiverAdapterUpdate( - SimpleReceiverAdapterUpdate.ConstructorInput({ - ccc: crossChainController, - adapterToRemove: address(0), - newAdapter: newAdapter - }) - ) - {} - - function getChainsToReceive() public pure override returns (uint256[] memory) { - uint256[] memory chains = new uint256[](1); - chains[0] = ChainIds.ETHEREUM; - return chains; - } -} diff --git a/scripts/payloads/Deploy_ArbAdapter_Payload.s.sol b/scripts/payloads/Deploy_ArbAdapter_Payload.s.sol deleted file mode 100644 index f5e5d81..0000000 --- a/scripts/payloads/Deploy_ArbAdapter_Payload.s.sol +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {IBaseAdapter} from 'adi-scripts/Adapters/DeployArbAdapter.sol'; -import {Arbitrum, Addresses} from '../adapters/DeployArbAdapter.s.sol'; -import {Create2Utils, ArbitrumScript} from 'aave-helpers/ScriptUtils.sol'; -import {AaveV3Arbitrum_New_Adapter_Payload, ChainIds} from './ArbAdapterPayload.sol'; - -/** - * @dev Deploy Arbitrum - * deploy-command: make deploy-pk contract=scripts/payloads/Deploy_ArbAdapter_Payload.s.sol:DeployArbitrumPayload chain=arbitrum_sepolia - * verify-command: npx catapulta-verify -b broadcast/Deploy_ArbAdapter_Payload.s.sol/42161/run-latest.json - */ -contract DeployArbitrumPayload is Arbitrum { - function _execute(Addresses memory addresses) internal virtual override { - // deploy payloads - new AaveV3Arbitrum_New_Adapter_Payload( - addresses.crossChainController, - _computeAdapterAddress(addresses.crossChainController) - ); - } -} diff --git a/scripts/payloads/adapters/zksync/Base_Add_Zksync_Path.s.sol b/scripts/payloads/adapters/zksync/Base_Add_Zksync_Path.s.sol new file mode 100644 index 0000000..045d80d --- /dev/null +++ b/scripts/payloads/adapters/zksync/Base_Add_Zksync_Path.s.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import '../../../BaseDeployerScript.sol'; +import 'aave-helpers/adi/SimpleAddForwarderAdapter.sol'; + +abstract contract Base_Deploy_Add_ZkSync_Path_Payload is BaseDeployerScript { + function _getPayloadByteCode() internal virtual returns (bytes memory); + + function PAYLOAD_SALT() internal pure virtual returns (string memory) { + return 'Add ZkSync path to a.DI'; + } + + function DESTINATION_CHAIN_ID() internal pure virtual returns (uint256); + + function _deployPayload(AddForwarderAdapterArgs memory args) internal returns (address) { + bytes memory payloadCode = abi.encodePacked(_getPayloadByteCode(), abi.encode(args)); + + return _deployByteCode(payloadCode, PAYLOAD_SALT()); + } + + function _execute(Addresses memory addresses) internal virtual override { + Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID()); + + _deployPayload( + AddForwarderAdapterArgs({ + crossChainController: addresses.crossChainController, + currentChainBridgeAdapter: addresses.zksyncAdapter, + destinationChainBridgeAdapter: destinationAddresses.zksyncAdapter, + destinationChainId: DESTINATION_CHAIN_ID() + }) + ); + } +} diff --git a/scripts/payloads/adapters/zksync/Network_Deployments.s.sol b/scripts/payloads/adapters/zksync/Network_Deployments.s.sol new file mode 100644 index 0000000..ca12b01 --- /dev/null +++ b/scripts/payloads/adapters/zksync/Network_Deployments.s.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './Base_Add_Zksync_Path.s.sol'; + +contract Ethereum is Base_Deploy_Add_ZkSync_Path_Payload { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ETHEREUM; + } + + function _getPayloadByteCode() internal pure override returns (bytes memory) { + return type(SimpleAddForwarderAdapter).creationCode; + } + + function DESTINATION_CHAIN_ID() internal pure override returns (uint256) { + return ChainIds.ZK_SYNC; + } +} diff --git a/src/ccc_payloads/shuffle/ShuffleCCCUpdatePayload.sol b/src/ccc_payloads/shuffle/ShuffleCCCUpdatePayload.sol index d54ab80..42f879e 100644 --- a/src/ccc_payloads/shuffle/ShuffleCCCUpdatePayload.sol +++ b/src/ccc_payloads/shuffle/ShuffleCCCUpdatePayload.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import 'aave-helpers/adi/BaseCCCUpdate.sol'; import {IReinitialize} from 'adi/revisions/update_to_rev_3/IReinitialize.sol'; import {ICrossChainForwarder} from 'adi/interfaces/ICrossChainForwarder.sol'; -import {ChainIds} from 'aave-helpers/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; /** * @title Ethereum payload to update CrossChainController with new shuffle mechanism diff --git a/tests/ccc/shuffle/ShufflePayloadTests.t.sol b/tests/ccc/shuffle/ShufflePayloadTests.t.sol index 757fe7a..d4b0c3b 100644 --- a/tests/ccc/shuffle/ShufflePayloadTests.t.sol +++ b/tests/ccc/shuffle/ShufflePayloadTests.t.sol @@ -43,10 +43,6 @@ abstract contract BaseShufflePayloadTest is ADITestBase { vm ); } - - function test_samePayloadAddress() public { - assertEq(_payload, _getDeployedPayload()); - } } contract EthereumShufflePayloadTest is Ethereum, BaseShufflePayloadTest('ethereum', 20160500) { diff --git a/tests/payloads/ArbAdapterPayload.t.sol b/tests/payloads/ArbAdapterPayload.t.sol deleted file mode 100644 index 7f70614..0000000 --- a/tests/payloads/ArbAdapterPayload.t.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import {ADITestBase} from 'aave-helpers/adi/test/ADITestBase.sol'; -import {AaveV3Arbitrum_New_Adapter_Payload} from '../../scripts/payloads/ArbAdapterPayload.sol'; -import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol'; -import {Addresses, DeployArbitrumPayload, Create2Utils} from '../../scripts/payloads/Deploy_ArbAdapter_Payload.s.sol'; - -// provably here we should just define the blockNumber and network. And use base test that in theory could generate diffs -contract ArbAdapterUpdatePayloadTest is ADITestBase, DeployArbitrumPayload { - AaveV3Arbitrum_New_Adapter_Payload public payload; - - function setUp() public { - vm.createSelectFork(vm.rpcUrl('arbitrum'), 211127276); - address crossChainController = _getAddresses(TRANSACTION_NETWORK()).crossChainController; - address newAdapter = _deployAdapter(crossChainController); - - // deploy payload - payload = new AaveV3Arbitrum_New_Adapter_Payload(crossChainController, newAdapter); - } - - function test_defaultTest() public { - defaultTest( - 'test_adi_diffs', - GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER, - address(payload), - true, - vm - ); - } -} diff --git a/tests/payloads/zksync/AddZkSyncPathTest.t.sol b/tests/payloads/zksync/AddZkSyncPathTest.t.sol new file mode 100644 index 0000000..f39473b --- /dev/null +++ b/tests/payloads/zksync/AddZkSyncPathTest.t.sol @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import 'forge-std/console.sol'; +import {ADITestBase} from 'aave-helpers/adi/test/ADITestBase.sol'; +import {Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/zksync/Network_Deployments.s.sol'; +import {AddForwarderAdapterArgs} from 'aave-helpers/adi/SimpleAddForwarderAdapter.sol'; +import 'aave-helpers/adi/SimpleAddForwarderAdapter.sol'; + +abstract contract BaseAddZkSyncPathPayloadTest is ADITestBase { + address internal _payload; + address internal _crossChainController; + + string internal NETWORK; + uint256 internal immutable BLOCK_NUMBER; + + constructor(string memory network, uint256 blockNumber) { + NETWORK = network; + BLOCK_NUMBER = blockNumber; + } + + function _getDeployedPayload() internal virtual returns (address); + + function _getPayload() internal virtual returns (address); + + function _getCurrentNetworkAddresses() internal virtual returns (Addresses memory); + + function setUp() public { + vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER); + + Addresses memory addresses = _getCurrentNetworkAddresses(); + _crossChainController = addresses.crossChainController; + + _payload = _getPayload(); + } + + function test_defaultTest() public { + defaultTest( + string.concat('add_zksync_path_to_adi', NETWORK), + _crossChainController, + address(_payload), + false, + vm + ); + } + + function test_samePayloadAddress( + address currentChainAdapter, + address destinationChainAdapter, + address crossChainController, + uint256 destinationChainId + ) public { + SimpleAddForwarderAdapter deployedPayload = SimpleAddForwarderAdapter(_getDeployedPayload()); + SimpleAddForwarderAdapter predictedPayload = SimpleAddForwarderAdapter(_getPayload()); + + assertEq(predictedPayload.DESTINATION_CHAIN_ID(), deployedPayload.DESTINATION_CHAIN_ID()); + assertEq(predictedPayload.CROSS_CHAIN_CONTROLLER(), deployedPayload.CROSS_CHAIN_CONTROLLER()); + assertEq( + predictedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER(), + deployedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER() + ); + assertEq( + predictedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER(), + deployedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER() + ); + } +} + +contract EthereumAddZkSyncPathPayloadTest is + PayloadEthereumScript, + BaseAddZkSyncPathPayloadTest('ethereum', 20413186) +{ + function _getDeployedPayload() internal pure override returns (address) { + return 0x65Cf9DE21c5F4377BF7E4d1421cEde57d9D5962A; + } + + function _getCurrentNetworkAddresses() internal view override returns (Addresses memory) { + return _getAddresses(TRANSACTION_NETWORK()); + } + + function _getPayload() internal override returns (address) { + Addresses memory currentAddresses = _getCurrentNetworkAddresses(); + Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID()); + + AddForwarderAdapterArgs memory args = AddForwarderAdapterArgs({ + crossChainController: currentAddresses.crossChainController, + currentChainBridgeAdapter: 0x6aD9d4147467f08b165e1b6364584C5d28898b84, + destinationChainBridgeAdapter: 0x1BC5C10CAe378fDbd7D52ec4F9f34590a619c68E, + destinationChainId: DESTINATION_CHAIN_ID() + }); + return _deployPayload(args); + } +}