Skip to content

Commit 94355b4

Browse files
committed
add test for fork deploy and read from process.env when using deploy scripts
1 parent 24550b8 commit 94355b4

15 files changed

+107
-59
lines changed

.github/workflows/bindings.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ concurrency:
1010

1111
jobs:
1212
verify-bindings:
13-
runs-on: ubuntu-latest
13+
runs-on: macos-latest
1414
steps:
1515
- uses: actions/checkout@v4
1616
with:
@@ -23,11 +23,10 @@ jobs:
2323
go-version: "1.21.3"
2424

2525
- name: Setup Foundry
26-
uses: foundry-rs/foundry-toolchain@v1
26+
uses: foundry-rs/foundry-toolchain@v1.2.0
2727

2828
- name: Install Bun
2929
uses: oven-sh/setup-bun@v2
30-
3130
- name: Install ABIGen
3231
run: |
3332
go install github.com/ethereum/go-ethereum/cmd/[email protected]
@@ -44,3 +43,15 @@ jobs:
4443
echo -e "Changes in Generated Bindings:\n$changes"
4544
exit 1
4645
fi
46+
- name: Upload ts bindings artifact on error
47+
if: failure()
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: ts-bindings
51+
path: ./src/evm/contracts/
52+
- name: Upload go bindings artifact on error
53+
if: failure()
54+
uses: actions/upload-artifact@v2
55+
with:
56+
name: go-bindings
57+
path: ./bindings/

.github/workflows/foundry.yml

+23
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,32 @@ jobs:
2020

2121
- name: Install Foundry
2222
uses: foundry-rs/foundry-toolchain@v1
23+
24+
- name: Install Bun
25+
uses: oven-sh/setup-bun@v2
26+
27+
- name: Generate Bindings
28+
run: |
29+
bun install --frozen-lockfile
30+
bun run build
2331
2432
- name: Check contract sizes
2533
run: forge build --sizes --deny-warnings
2634

2735
- name: Tests
2836
run: forge test --no-match-contract DispatcherDeployTest
37+
- name: set Owner Address
38+
run: echo "OwnerAddress=$(cast wallet address ${{ secrets.DUMMY_DEPLOYER_PRIVATE_KEY }})" >> $GITHUB_ENV
39+
- name: Fork Deploy Test
40+
run: npx vibc-core-deploy-test
41+
env:
42+
MODULE_ROOT_PATH: "./"
43+
RPC_URL: ${{ secrets.FORK_RPC_URL }}
44+
CHAIN_NAME: "fork-test-ci"
45+
DUMMY_DEPLOYER_PRIVATE_KEY: ${{ secrets.DUMMY_DEPLOYER_PRIVATE_KEY }}
46+
DAPP_PRIVATE_KEY_1: ${{ secrets.DAPP_PRIVATE_KEY_1 }}
47+
DAPP_PRIVATE_KEY_2: ${{ secrets.DAPP_PRIVATE_KEY_2 }}
48+
DAPP_PRIVATE_KEY_3: ${{ secrets.DAPP_PRIVATE_KEY_3 }}
49+
PolymerL2OutputOracleProxyAddress: "0xB901B810B30f4d8D179FA5e4dFA73B6EC81f2dB0"
50+
L2OutputOracleProxyAddress: "0xB901B810B30f4d8D179FA5e4dFA73B6EC81f2dB0"
51+
L1BlockAddress: "0x4200000000000000000000000000000000000015"

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ This file is read in-order, so each entry in this file should be in-order, where
5050
### Deploying via Command Line
5151
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:
5252

53-
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.
53+
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.
5454
2. Pass in optional command arguments:
5555
- RPC_URL - the rpc url to submit deploy txs to, can be a local fork as well
5656
- ACCOUNTS_SPECS_PATH - the path to the accounts spec file
@@ -89,8 +89,8 @@ const accountConfig = {
8989
name: "local",
9090
registry: [
9191
{
92-
name: "KEY_POLYMER",
93-
privateKey: process.env.KEY_POLYMER
92+
name: "KEY_DEPLOYER",
93+
privateKey: process.env.KEY_DEPLOYER
9494
},
9595
],
9696
};
@@ -138,8 +138,8 @@ const accountConfig = {
138138
name: "local",
139139
registry: [
140140
{
141-
name: "KEY_POLYMER",
142-
privateKey: process.env.KEY_POLYMER,
141+
name: "KEY_DEPLOYER",
142+
privateKey: process.env.KEY_DEPLOYER,
143143
},
144144
],
145145
};

bun.lockb

-168 Bytes
Binary file not shown.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@open-ibc/vibc-core-smart-contracts",
3-
"version": "2.1.12",
3+
"version": "2.1.13",
44
"main": "dist/index.js",
55
"bin": {
66
"verify-vibc-core-smart-contracts": "./dist/scripts/verify-contract-script.js",

specs/contracts.setup.spec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# args: args to make the function call with, need to be compatible with the signature
1111
- name: DispatcherClientSetup-Connection-0
1212
description: 'Setup client for dispatcher contracts'
13-
deployer: 'KEY_POLYMER'
13+
deployer: 'KEY_DEPLOYER'
1414
signature: "setClientForConnection(string,address)"
1515
address: '{{DispatcherProxy}}'
1616
factoryName: "Dispatcher"
@@ -20,7 +20,7 @@
2020

2121
- name: DispatcherClientSetup-Connection-1
2222
description: 'Setup client for dispatcher contracts'
23-
deployer: 'KEY_POLYMER'
23+
deployer: 'KEY_DEPLOYER'
2424
signature: "setClientForConnection(string,address)"
2525
address: '{{DispatcherProxy}}'
2626
factoryName: "Dispatcher"

specs/contracts.spec.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
- name: LightClient
2121
description: 'DummyLightClient'
2222
factoryName: 'DummyLightClient'
23-
deployer: 'KEY_POLYMER'
23+
deployer: 'KEY_DEPLOYER'
2424

2525
- name: Ibc
2626
description: 'IBC library'
2727
factoryName: 'Ibc'
28-
deployer: 'KEY_POLYMER'
28+
deployer: 'KEY_DEPLOYER'
2929

3030
- name: IbcUtils
3131
description: 'IBC utils library'
3232
factoryName: 'IbcUtils'
33-
deployer: 'KEY_POLYMER'
33+
deployer: 'KEY_DEPLOYER'
3434

3535
- name: Dispatcher
3636
description: 'IBC Core contract'
@@ -40,12 +40,12 @@
4040
address: '{{Ibc}}'
4141
- name: 'contracts/libs/IbcUtils.sol:IbcUtils'
4242
address: '{{IbcUtils}}'
43-
deployer: 'KEY_POLYMER'
43+
deployer: 'KEY_DEPLOYER'
4444

4545
- name: FeeVault
4646
description: 'FeeVault'
4747
factoryName: 'FeeVault'
48-
deployer: 'KEY_POLYMER'
48+
deployer: 'KEY_DEPLOYER'
4949

5050
- name: DispatcherProxy
5151
description: 'Dispatcher proxy contract'
@@ -58,20 +58,20 @@
5858
args:
5959
- 'polyibc.{{chain.chainName}}.'
6060
- '{{FeeVault}}'
61-
deployer: 'KEY_POLYMER'
61+
deployer: 'KEY_DEPLOYER'
6262

6363
- name: UC
6464
description: 'Universal Chanel IBC-middleware contract'
6565
factoryName: 'UniversalChannelHandler'
66-
deployer: 'KEY_POLYMER'
66+
deployer: 'KEY_DEPLOYER'
6767
libraries:
6868
- name: 'contracts/libs/IbcUtils.sol:IbcUtils'
6969
address: '{{IbcUtils}}'
7070

7171
- name: UCProxy
7272
description: 'Universal Chanel IBC-middleware proxy'
7373
factoryName: 'ERC1967Proxy'
74-
deployer: 'KEY_POLYMER'
74+
deployer: 'KEY_DEPLOYER'
7575
deployArgs:
7676
- '{{UC}}'
7777
- '$INITARGS'

specs/evm.accounts.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# These accounts are derived from a test mnemonic by Anvil/Hardhat and used for testing purposes only.
2-
- name: 'KEY_POLYMER'
3-
privateKey: '{{DEPLOYER_PRIVATE_KEY}}'
4-
2+
- name: 'KEY_DEPLOYER'
3+
privateKey: '{{ DUMMY_DEPLOYER_PRIVATE_KEY }}'
54

65
# Dapp accounts
76
- name: 'KEY_DAPP1'
87
privateKey: '{{ DAPP_PRIVATE_KEY_1 }}'
98
- name: 'KEY_DAPP2'
109
privateKey: '{{ DAPP_PRIVATE_KEY_2 }}'
1110
- name: 'KEY_DAPP3'
12-
privateKey: '{{ DAPP_PRIVATE_KEY_2 }}'
11+
privateKey: '{{ DAPP_PRIVATE_KEY_3 }}'

specs/update.spec.yaml

+34-18
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,36 @@
3535
# signature: signature of method to call for this tx
3636
# args: args to make the function call with, need to be compatible with the signature
3737

38-
- name: LightClient
38+
- name: OptimisticProofVerifier
39+
description: 'OptimisticProofVerifier'
40+
factoryName: 'OptimisticProofVerifier'
41+
deployer: 'KEY_DEPLOYER'
42+
deployArgs:
43+
- '{{PolymerL2OutputOracleProxyAddress}}'
44+
45+
- name: OptimisticLightClient
46+
description: 'OptimisticLightClient'
47+
factoryName: 'OptimisticLightClient'
48+
deployer: 'KEY_DEPLOYER'
49+
deployArgs:
50+
- 0
51+
- '{{OptimisticProofVerifier}}'
52+
- '{{L1BlockAddress}}'
53+
54+
- name: DummyLightClient
3955
description: 'DummyLightClient'
4056
factoryName: 'DummyLightClient'
41-
deployer: 'KEY_POLYMER'
57+
deployer: 'KEY_DEPLOYER'
4258

4359
- name: Ibc
4460
description: 'IBC library'
4561
factoryName: 'Ibc'
46-
deployer: 'KEY_POLYMER'
62+
deployer: 'KEY_DEPLOYER'
4763

4864
- name: IbcUtils
4965
description: 'IBC utils library'
5066
factoryName: 'IbcUtils'
51-
deployer: 'KEY_POLYMER'
67+
deployer: 'KEY_DEPLOYER'
5268

5369
- name: Dispatcher
5470
description: 'IBC Core contract'
@@ -58,12 +74,12 @@
5874
address: '{{Ibc}}'
5975
- name: 'contracts/libs/IbcUtils.sol:IbcUtils'
6076
address: '{{IbcUtils}}'
61-
deployer: 'KEY_POLYMER'
77+
deployer: 'KEY_DEPLOYER'
6278

6379
- name: FeeVault
6480
description: 'FeeVault'
6581
factoryName: 'FeeVault'
66-
deployer: 'KEY_POLYMER'
82+
deployer: 'KEY_DEPLOYER'
6783

6884
- name: DispatcherProxy
6985
description: 'Dispatcher proxy contract'
@@ -76,20 +92,20 @@
7692
args:
7793
- 'polyibc.{{chain.chainName}}.'
7894
- '{{FeeVault}}'
79-
deployer: 'KEY_POLYMER'
95+
deployer: 'KEY_DEPLOYER'
8096

8197
- name: UC
8298
description: 'Universal Chanel IBC-middleware contract'
8399
factoryName: 'UniversalChannelHandler'
84-
deployer: 'KEY_POLYMER'
100+
deployer: 'KEY_DEPLOYER'
85101
libraries:
86102
- name: 'contracts/libs/IbcUtils.sol:IbcUtils'
87103
address: '{{IbcUtils}}'
88104

89105
- name: UCProxy
90106
description: 'Universal Chanel IBC-middleware proxy'
91107
factoryName: 'ERC1967Proxy'
92-
deployer: 'KEY_POLYMER'
108+
deployer: 'KEY_DEPLOYER'
93109
deployArgs:
94110
- '{{UC}}'
95111
- '$INITARGS'
@@ -115,7 +131,7 @@
115131
# Contract Setup below
116132
- name: DispatcherUpgrade
117133
description: 'UUPS Upgrade for dispatcher contract implementation'
118-
deployer: 'KEY_POLYMER'
134+
deployer: 'KEY_DEPLOYER'
119135
signature: "upgradeTo(address)"
120136
address: '{{DispatcherProxy}}'
121137
factoryName: "Dispatcher"
@@ -124,7 +140,7 @@
124140

125141
- name: DispatcherUpgrade
126142
description: 'UUPS Upgrade for dispatcher contract implementation'
127-
deployer: 'KEY_POLYMER'
143+
deployer: 'KEY_DEPLOYER'
128144
signature: "upgradeTo(address)"
129145
address: '{{DispatcherProxy}}'
130146
factoryName: "Dispatcher"
@@ -133,7 +149,7 @@
133149

134150
- name: UCH Upgrade
135151
description: 'Upgrade for uch contract'
136-
deployer: 'KEY_POLYMER'
152+
deployer: 'KEY_DEPLOYER'
137153
signature: "upgradeTo(address)"
138154
address: '{{ UCProxy }}'
139155
factoryName: "UC"
@@ -142,20 +158,20 @@
142158

143159
- name: DispatcherClientSetup-Connection-0
144160
description: 'Setup client for dispatcher contracts'
145-
deployer: 'KEY_POLYMER'
161+
deployer: 'KEY_DEPLOYER'
146162
signature: "setClientForConnection(string,address)"
147163
address: '{{DispatcherProxy}}'
148164
factoryName: "Dispatcher"
149165
args:
150-
- 'connection-0'
151-
- '{{LightClient}}'
166+
- 'connection-1'
167+
- '{{DummyLightClient}}'
152168

153169
- name: DispatcherClientSetup-Connection-1
154170
description: 'Setup client for dispatcher contracts'
155-
deployer: 'KEY_POLYMER'
171+
deployer: 'KEY_DEPLOYER'
156172
signature: "setClientForConnection(string,address)"
157173
address: '{{DispatcherProxy}}'
158174
factoryName: "Dispatcher"
159175
args:
160-
- 'connection-2'
161-
- '{{LightClient}}'
176+
- 'connection-3'
177+
- '{{DummyLightClient}}'

specs/upgrade.spec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
- name: DispatcherUpgrade
2020
description: 'UUPS Upgrade for dispatcher contract implementation'
21-
deployer: 'KEY_POLYMER'
21+
deployer: 'KEY_DEPLOYER'
2222
signature: "upgradeTo(address)"
2323
address: '{{DispatcherProxy}}'
2424
factoryName: "Dispatcher"
@@ -27,7 +27,7 @@
2727

2828
- name: UCH Upgrade
2929
description: 'Upgrade for uch contract'
30-
deployer: 'KEY_POLYMER'
30+
deployer: 'KEY_DEPLOYER'
3131
signature: "upgradeTo(address)"
3232
address: '{{ UCProxy }}'
3333
factoryName: "UC"

src/deploy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export async function deployToChain(
187187
}
188188

189189
// @ts-ignore
190-
const env: StringToStringMap = { chain };
190+
const env: StringToStringMap = {...process.env , chain , };
191191
if (!forceDeployNewContracts) {
192192
// Only read from existing contract files if we want to deploy new ones
193193
await readDeploymentFilesIntoEnv(env, chain);

src/scripts/fork-deployment-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const main = async () => {
4444
env = await readDeploymentFilesIntoEnv(env, chain); // Read deployment files from non-forked chain to get live addresses
4545

4646
$.env = {
47-
...env,
4847
...process.env,
48+
...env,
4949
};
5050

5151
await $`cd ${MODULE_ROOT_PATH} && forge test --match-contract DispatcherDeployTest --fork-url ${anvilUrl} -vvvv `.pipe(

src/updateContract.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function updateContractsForChain(
4141

4242
// @ts-ignore
4343
let env = await readDeploymentFilesIntoEnv({}, chain); // Read from existing deployment files first, then overwrite with explicitly given contract addresses
44-
env = { chain, ...existingContractAddresses, ...env };
44+
env = {...process.env, chain, ...existingContractAddresses, ...env };
4545
if (!forceDeployNewContracts) {
4646
// Only read from existing contract files if we want to deploy new ones
4747
await readDeploymentFilesIntoEnv(env, chain);

0 commit comments

Comments
 (0)