diff --git a/.github/workflows/bindings.yml b/.github/workflows/bindings.yml index d405dc19..e12b3718 100644 --- a/.github/workflows/bindings.yml +++ b/.github/workflows/bindings.yml @@ -10,7 +10,7 @@ concurrency: jobs: verify-bindings: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4 with: @@ -23,11 +23,10 @@ jobs: go-version: "1.21.3" - name: Setup Foundry - uses: foundry-rs/foundry-toolchain@v1 + uses: foundry-rs/foundry-toolchain@v1.2.0 - name: Install Bun uses: oven-sh/setup-bun@v2 - - name: Install ABIGen run: | go install github.com/ethereum/go-ethereum/cmd/abigen@v1.13.5 @@ -44,3 +43,15 @@ jobs: echo -e "Changes in Generated Bindings:\n$changes" exit 1 fi + - name: Upload ts bindings artifact on error + if: failure() + uses: actions/upload-artifact@v2 + with: + name: ts-bindings + path: ./src/evm/contracts/ + - name: Upload go bindings artifact on error + if: failure() + uses: actions/upload-artifact@v2 + with: + name: go-bindings + path: ./bindings/ diff --git a/.github/workflows/foundry.yml b/.github/workflows/foundry.yml index c3025828..a407f49b 100644 --- a/.github/workflows/foundry.yml +++ b/.github/workflows/foundry.yml @@ -26,3 +26,17 @@ jobs: - name: Tests run: forge test --no-match-contract DispatcherDeployTest + + - name: Fork Deploy Test + run: npm run build && npx + env: + MODULE_ROOT_PATH: "./" + RPC_URL: ${{ secrets.FORK_RPC_URL }} + CHAIN_NAME: fork-test-ci + DUMMY_DEPLOYER_PRIVATE_KEY: ${{ secrets.DUMMY_DEPLOYER_PRIVATE_KEY }} + DAPP_PRIVATE_KEY_1: ${{ secrets.DAPP_PRIVATE_KEY_1 }} + DAPP_PRIVATE_KEY_2: ${{ secrets.DAPP_PRIVATE_KEY_2 }} + DAPP_PRIVATE_KEY_3: ${{ secrets.DAPP_PRIVATE_KEY_3 }} + PolymerL2OutputOracleProxyAddress: 0xB901B810B30f4d8D179FA5e4dFA73B6EC81f2dB0 + L2OutputOracleProxyAddress: 0xB901B810B30f4d8D179FA5e4dFA73B6EC81f2dB0 + L1BlockAddress: 0x4200000000000000000000000000000000000015 \ No newline at end of file diff --git a/README.md b/README.md index d03635ea..bb7d6dc1 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ This file is read in-order, so each entry in this file should be in-order, where ### Deploying via Command Line This npm package exposes two commands - one to deploy new contacts (which automatically creates persisted deployment files), and one to send transactions to contracts from persisted artifact files. The following steps are needed to deploy contracts via the command line: -1. Ensure that your deployer account and constructor arguments are configured. This can either be done through adding contract spec yaml files located in the specs/ from the root of where this npm module is installed from (requires adding a `specs/evm.accounts.yaml` file and either a `specs/contracts.spec.yaml` or `specs/upgrade.spec.yaml`), or by setting the KEY_POLYMER, RPC_URL, DEPLOYMENT_CHAIN_ID, CHAIN_NAME environment variables. For examples of contract and account spec files, see the `/specs` folder in this repo. +1. Ensure that your deployer account and constructor arguments are configured. This can either be done through adding contract spec yaml files located in the specs/ from the root of where this npm module is installed from (requires adding a `specs/evm.accounts.yaml` file and either a `specs/contracts.spec.yaml` or `specs/upgrade.spec.yaml`), or by setting the KEY_DEPLOYER, RPC_URL, DEPLOYMENT_CHAIN_ID, CHAIN_NAME environment variables. For examples of contract and account spec files, see the `/specs` folder in this repo. 2. Pass in optional command arguments: - RPC_URL - the rpc url to submit deploy txs to, can be a local fork as well - ACCOUNTS_SPECS_PATH - the path to the accounts spec file @@ -89,8 +89,8 @@ const accountConfig = { name: "local", registry: [ { - name: "KEY_POLYMER", - privateKey: process.env.KEY_POLYMER + name: "KEY_DEPLOYER", + privateKey: process.env.KEY_DEPLOYER }, ], }; @@ -138,8 +138,8 @@ const accountConfig = { name: "local", registry: [ { - name: "KEY_POLYMER", - privateKey: process.env.KEY_POLYMER, + name: "KEY_DEPLOYER", + privateKey: process.env.KEY_DEPLOYER, }, ], }; diff --git a/bun.lockb b/bun.lockb index 857130d5..824697f6 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/specs/contracts.setup.spec.yaml b/specs/contracts.setup.spec.yaml index 61f4ce85..033bd683 100644 --- a/specs/contracts.setup.spec.yaml +++ b/specs/contracts.setup.spec.yaml @@ -10,7 +10,7 @@ # args: args to make the function call with, need to be compatible with the signature - name: DispatcherClientSetup-Connection-0 description: 'Setup client for dispatcher contracts' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "setClientForConnection(string,address)" address: '{{DispatcherProxy}}' factoryName: "Dispatcher" @@ -20,7 +20,7 @@ - name: DispatcherClientSetup-Connection-1 description: 'Setup client for dispatcher contracts' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "setClientForConnection(string,address)" address: '{{DispatcherProxy}}' factoryName: "Dispatcher" diff --git a/specs/contracts.spec.yaml b/specs/contracts.spec.yaml index b8bf9330..fdca6212 100644 --- a/specs/contracts.spec.yaml +++ b/specs/contracts.spec.yaml @@ -20,17 +20,17 @@ - name: LightClient description: 'DummyLightClient' factoryName: 'DummyLightClient' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: Ibc description: 'IBC library' factoryName: 'Ibc' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: IbcUtils description: 'IBC utils library' factoryName: 'IbcUtils' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: Dispatcher description: 'IBC Core contract' @@ -40,12 +40,12 @@ address: '{{Ibc}}' - name: 'contracts/libs/IbcUtils.sol:IbcUtils' address: '{{IbcUtils}}' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: FeeVault description: 'FeeVault' factoryName: 'FeeVault' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: DispatcherProxy description: 'Dispatcher proxy contract' @@ -58,12 +58,12 @@ args: - 'polyibc.{{chain.chainName}}.' - '{{FeeVault}}' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: UC description: 'Universal Chanel IBC-middleware contract' factoryName: 'UniversalChannelHandler' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' libraries: - name: 'contracts/libs/IbcUtils.sol:IbcUtils' address: '{{IbcUtils}}' @@ -71,7 +71,7 @@ - name: UCProxy description: 'Universal Chanel IBC-middleware proxy' factoryName: 'ERC1967Proxy' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' deployArgs: - '{{UC}}' - '$INITARGS' diff --git a/specs/evm.accounts.yaml b/specs/evm.accounts.yaml index 1f097779..43033c46 100644 --- a/specs/evm.accounts.yaml +++ b/specs/evm.accounts.yaml @@ -1,7 +1,6 @@ # These accounts are derived from a test mnemonic by Anvil/Hardhat and used for testing purposes only. -- name: 'KEY_POLYMER' - privateKey: '{{DEPLOYER_PRIVATE_KEY}}' - +- name: 'KEY_DEPLOYER' + privateKey: '{{ DUMMY_DEPLOYER_PRIVATE_KEY }}' # Dapp accounts - name: 'KEY_DAPP1' @@ -9,4 +8,4 @@ - name: 'KEY_DAPP2' privateKey: '{{ DAPP_PRIVATE_KEY_2 }}' - name: 'KEY_DAPP3' - privateKey: '{{ DAPP_PRIVATE_KEY_2 }}' + privateKey: '{{ DAPP_PRIVATE_KEY_3 }}' diff --git a/specs/update.spec.yaml b/specs/update.spec.yaml index ee65134a..43f0d771 100644 --- a/specs/update.spec.yaml +++ b/specs/update.spec.yaml @@ -35,20 +35,36 @@ # signature: signature of method to call for this tx # args: args to make the function call with, need to be compatible with the signature -- name: LightClient +- name: OptimisticProofVerifier + description: 'OptimisticProofVerifier' + factoryName: 'OptimisticProofVerifier' + deployer: 'KEY_DEPLOYER' + deployArgs: + - '{{PolymerL2OutputOracleProxyAddress}}' + +- name: OptimisticLightClient + description: 'OptimisticLightClient' + factoryName: 'OptimisticLightClient' + deployer: 'KEY_DEPLOYER' + deployArgs: + - 0 + - '{{OptimisticProofVerifier}}' + - '{{L1BlockAddress}}' + +- name: DummyLightClient description: 'DummyLightClient' factoryName: 'DummyLightClient' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: Ibc description: 'IBC library' factoryName: 'Ibc' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: IbcUtils description: 'IBC utils library' factoryName: 'IbcUtils' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: Dispatcher description: 'IBC Core contract' @@ -58,12 +74,12 @@ address: '{{Ibc}}' - name: 'contracts/libs/IbcUtils.sol:IbcUtils' address: '{{IbcUtils}}' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: FeeVault description: 'FeeVault' factoryName: 'FeeVault' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: DispatcherProxy description: 'Dispatcher proxy contract' @@ -76,12 +92,12 @@ args: - 'polyibc.{{chain.chainName}}.' - '{{FeeVault}}' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: UC description: 'Universal Chanel IBC-middleware contract' factoryName: 'UniversalChannelHandler' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' libraries: - name: 'contracts/libs/IbcUtils.sol:IbcUtils' address: '{{IbcUtils}}' @@ -89,7 +105,7 @@ - name: UCProxy description: 'Universal Chanel IBC-middleware proxy' factoryName: 'ERC1967Proxy' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' deployArgs: - '{{UC}}' - '$INITARGS' @@ -115,7 +131,7 @@ # Contract Setup below - name: DispatcherUpgrade description: 'UUPS Upgrade for dispatcher contract implementation' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "upgradeTo(address)" address: '{{DispatcherProxy}}' factoryName: "Dispatcher" @@ -124,7 +140,7 @@ - name: DispatcherUpgrade description: 'UUPS Upgrade for dispatcher contract implementation' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "upgradeTo(address)" address: '{{DispatcherProxy}}' factoryName: "Dispatcher" @@ -133,7 +149,7 @@ - name: UCH Upgrade description: 'Upgrade for uch contract' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "upgradeTo(address)" address: '{{ UCProxy }}' factoryName: "UC" @@ -142,7 +158,7 @@ - name: DispatcherClientSetup-Connection-0 description: 'Setup client for dispatcher contracts' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "setClientForConnection(string,address)" address: '{{DispatcherProxy}}' factoryName: "Dispatcher" @@ -152,7 +168,7 @@ - name: DispatcherClientSetup-Connection-1 description: 'Setup client for dispatcher contracts' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "setClientForConnection(string,address)" address: '{{DispatcherProxy}}' factoryName: "Dispatcher" diff --git a/specs/upgrade.spec.yaml b/specs/upgrade.spec.yaml index 96cead6d..f2972c09 100644 --- a/specs/upgrade.spec.yaml +++ b/specs/upgrade.spec.yaml @@ -18,7 +18,7 @@ - name: DispatcherUpgrade description: 'UUPS Upgrade for dispatcher contract implementation' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "upgradeTo(address)" address: '{{DispatcherProxy}}' factoryName: "Dispatcher" @@ -27,7 +27,7 @@ - name: UCH Upgrade description: 'Upgrade for uch contract' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' signature: "upgradeTo(address)" address: '{{ UCProxy }}' factoryName: "UC" diff --git a/src/deploy.ts b/src/deploy.ts index 90e3db5a..eb1b469d 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -187,7 +187,7 @@ export async function deployToChain( } // @ts-ignore - const env: StringToStringMap = { chain }; + const env: StringToStringMap = {...process.env , chain , }; if (!forceDeployNewContracts) { // Only read from existing contract files if we want to deploy new ones await readDeploymentFilesIntoEnv(env, chain); diff --git a/src/scripts/fork-deployment-test.ts b/src/scripts/fork-deployment-test.ts index 2568e577..308a6151 100644 --- a/src/scripts/fork-deployment-test.ts +++ b/src/scripts/fork-deployment-test.ts @@ -44,8 +44,8 @@ const main = async () => { env = await readDeploymentFilesIntoEnv(env, chain); // Read deployment files from non-forked chain to get live addresses $.env = { - ...env, ...process.env, + ...env, }; await $`cd ${MODULE_ROOT_PATH} && forge test --match-contract DispatcherDeployTest --fork-url ${anvilUrl} -vvvv `.pipe( diff --git a/src/updateContract.ts b/src/updateContract.ts index c534b2f6..586705cd 100644 --- a/src/updateContract.ts +++ b/src/updateContract.ts @@ -41,7 +41,7 @@ export async function updateContractsForChain( // @ts-ignore let env = await readDeploymentFilesIntoEnv({}, chain); // Read from existing deployment files first, then overwrite with explicitly given contract addresses - env = { chain, ...existingContractAddresses, ...env }; + env = {...process.env, chain, ...existingContractAddresses, ...env }; if (!forceDeployNewContracts) { // Only read from existing contract files if we want to deploy new ones await readDeploymentFilesIntoEnv(env, chain); diff --git a/test/Fork/Dispatcher.deploy.t.sol b/test/Fork/Dispatcher.deploy.t.sol index f9f623db..472495f9 100644 --- a/test/Fork/Dispatcher.deploy.t.sol +++ b/test/Fork/Dispatcher.deploy.t.sol @@ -42,7 +42,7 @@ struct ChainAddresses { IUniversalChannelHandler uch; ILightClient dummyLightClient; ILightClient optimisticLightClient; - bytes32 ownerKey; // Owner Address of dispatcher + address owner; // Owner Address of dispatcher } contract DispatcherDeployTest is ChannelHandShakeUpgradeUtil, UpgradeTestUtils { @@ -57,17 +57,16 @@ contract DispatcherDeployTest is ChannelHandShakeUpgradeUtil, UpgradeTestUtils { IUniversalChannelHandler(vm.envAddress("UCProxy")), ILightClient(vm.envAddress("DummyLightClient")), ILightClient(vm.envAddress("OptimisticLightClient")), - vm.envBytes32("OWNER_KEY") + vm.envAddress("OwnerAddress") ); opLightClient = addresses.optimisticLightClient; // Need to set this so that when we call load_proof, it loads // the proof to the right address - address owner = vm.addr(uint256(addresses.ownerKey)); mars = Mars(payable(targetMarsAddress)); dispatcherProxy = addresses.dispatcherProxy; - vm.prank(owner); + vm.prank(addresses.owner); // For now, we need to change the portPrefix to that of the one which was used to generate the proof. We also // have to set that for the connectionHop to light client mapping. @@ -80,7 +79,7 @@ contract DispatcherDeployTest is ChannelHandShakeUpgradeUtil, UpgradeTestUtils { connectionHops0 = ["connection-0", "connection-3"]; connectionHops1 = ["connection-2", "connection-1"]; - vm.startPrank(owner); // Only sender should have permission + vm.startPrank(addresses.owner); // Only sender should have permission dispatcherProxy.setClientForConnection("connection-0", opLightClient); dispatcherProxy.setClientForConnection("connection-2", opLightClient); diff --git a/test/Fork/contract-spec.yaml b/test/Fork/contract-spec.yaml index b8bf9330..fdca6212 100644 --- a/test/Fork/contract-spec.yaml +++ b/test/Fork/contract-spec.yaml @@ -20,17 +20,17 @@ - name: LightClient description: 'DummyLightClient' factoryName: 'DummyLightClient' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: Ibc description: 'IBC library' factoryName: 'Ibc' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: IbcUtils description: 'IBC utils library' factoryName: 'IbcUtils' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: Dispatcher description: 'IBC Core contract' @@ -40,12 +40,12 @@ address: '{{Ibc}}' - name: 'contracts/libs/IbcUtils.sol:IbcUtils' address: '{{IbcUtils}}' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: FeeVault description: 'FeeVault' factoryName: 'FeeVault' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: DispatcherProxy description: 'Dispatcher proxy contract' @@ -58,12 +58,12 @@ args: - 'polyibc.{{chain.chainName}}.' - '{{FeeVault}}' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' - name: UC description: 'Universal Chanel IBC-middleware contract' factoryName: 'UniversalChannelHandler' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' libraries: - name: 'contracts/libs/IbcUtils.sol:IbcUtils' address: '{{IbcUtils}}' @@ -71,7 +71,7 @@ - name: UCProxy description: 'Universal Chanel IBC-middleware proxy' factoryName: 'ERC1967Proxy' - deployer: 'KEY_POLYMER' + deployer: 'KEY_DEPLOYER' deployArgs: - '{{UC}}' - '$INITARGS'