-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZK-611: contract deployment environments #47
Changes from 16 commits
c8451a9
a411d21
b0e5051
e0fccb8
89ba603
270ae11
4f8bb50
a6418b1
aceb2fa
646b869
1ec47d5
db2ccdc
b86184f
805bacf
7e8c84c
5329a34
b331a54
506daac
d5db6b6
4a932a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
--- | ||
name: "[TESTNET] Deploy contracts" | ||
name: "Manually Deploy contracts" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: "Environment to deploy to" | ||
required: true | ||
default: "testnet-dev" | ||
type: choice | ||
options: | ||
- "testnet-dev" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update this PR with latest changes. I have modified the environments to be |
||
- "testnet-stage" | ||
- "mainnet-prod" | ||
|
||
jobs: | ||
deploy-contracts: | ||
name: Deploy contracts on testnet | ||
name: Deploy contracts on ${{ github.event.inputs.environment }} | ||
runs-on: [self-hosted, Linux, X64, medium] | ||
steps: | ||
- name: GIT | Checkout | ||
|
@@ -34,12 +44,27 @@ jobs: | |
- name: Install deps | ||
run: make deps | ||
|
||
# for "testnet-dev" we use default owner address, as it's not important | ||
- name: Set environment-specific variables | ||
run: | | ||
if [ "${{ github.event.inputs.environment }}" == "testnet-dev" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just as in the previous comment - change the env name |
||
echo "PRIVATE_KEY=${{ secrets.CI_TESTNET_DEPLOYER_PRIVATE_KEY }}" >> $GITHUB_ENV | ||
elif [ "${{ github.event.inputs.environment }}" == "testnet-stage" ]; then | ||
echo "OWNER_ADDRESS=${{ vars.CI_TESTNET_STAGE_OWNER_ADDRESS }}" >> $GITHUB_ENV | ||
echo "PRIVATE_KEY=${{ secrets.CI_TESTNET_DEPLOYER_PRIVATE_KEY }}" >> $GITHUB_ENV | ||
elif [ "${{ github.event.inputs.environment }}" == "mainnet-prod" ]; then | ||
echo "OWNER_ADDRESS=${{ vars.MAINNET_PROD_OWNER_ADDRESS }}" >> $GITHUB_ENV | ||
echo "PRIVATE_KEY=${{ secrets.CI_MAINNET_DEPLOYER_PRIVATE_KEY }}" >> $GITHUB_ENV | ||
else | ||
echo "Invalid environment selected!" >&2 | ||
exit 1 | ||
fi | ||
|
||
- name: Compile eth contracts | ||
run: make compile-contracts | ||
|
||
- name: Deploy contracts | ||
run: | | ||
PRIVATE_KEY=${{ secrets.CI_TESTNET_DEPLOYER_PRIVATE_KEY }} \ | ||
NETWORK=https://rpc.alephzero-testnet.gelato.digital \ | ||
make deploy-contracts | ||
|
||
|
@@ -85,6 +110,19 @@ jobs: | |
|
||
cat contract_spec_with_block_numbers.json | ||
|
||
- name: Determine address to store | ||
run: | | ||
if [ "${{ github.event.inputs.environment }}" == "testnet-dev" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change env name here as well |
||
echo "ADDRESSES_S3_PATH=testnet/dev.json" >> $GITHUB_ENV | ||
elif [ "${{ github.event.inputs.environment }}" == "testnet-stage" ]; then | ||
echo "ADDRESSES_S3_PATH=testnet/stage.json" >> $GITHUB_ENV | ||
elif [ "${{ github.event.inputs.environment }}" == "mainnet-prod" ]; then | ||
echo "ADDRESSES_S3_PATH=mainnet/prod.json" >> $GITHUB_ENV | ||
else | ||
echo "Invalid environment selected!" >&2 | ||
exit 1 | ||
fi | ||
|
||
# yamllint disable rule:line-length | ||
- name: Store addresses in S3 bucket | ||
shell: bash | ||
|
@@ -93,7 +131,8 @@ jobs: | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.CONTRACTS_ZKOS_ADDRESSES_TESTNET_DEV_RW_AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: ${{ secrets.CONTRACTS_S3BUCKET_REGION }} | ||
run: | | ||
aws s3 cp contract_spec_with_block_numbers.json s3://${{ secrets.CONTRACTS_S3BUCKET_NAME }}/zkos/addresses/testnet/l2_dev.json | ||
aws s3 cp contract_spec_with_block_numbers.json s3://${{ secrets.CONTRACTS_S3BUCKET_NAME }}/zkos/addresses/${{ env.ADDRESSES_S3_PATH }} | ||
aws s3 cp broadcast/Shielder.s.sol/**/run-latest.json s3://${{ secrets.CONTRACTS_S3BUCKET_NAME }}/zkos/addresses/${{ env.ADDRESSES_S3_PATH }} | ||
|
||
- name: Store artifact in S3 bucket | ||
shell: bash | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,9 @@ contract DeployShielderScript is Script { | |
function run() external { | ||
uint256 privateKey = vm.envUint("PRIVATE_KEY"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we could rename it to DEPLOYER_PRIVATE_KEY for consistency with the Actions env vars? |
||
|
||
address owner = vm.addr(privateKey); | ||
console2.log("Using", owner, "as broadcaster"); | ||
address owner = vm.envAddress("OWNER_ADDRESS"); | ||
address broadcaster = vm.addr(privateKey); | ||
console2.log("Using", broadcaster, "as broadcaster"); | ||
|
||
vm.startBroadcast(privateKey); | ||
|
||
|
@@ -34,7 +35,9 @@ contract DeployShielderScript is Script { | |
Shielder shielder = Shielder(proxy); | ||
|
||
console2.log("Shielder deployed at:", address(shielder)); | ||
shielder.unpause(); | ||
if (owner == broadcaster) { | ||
shielder.unpause(); | ||
} | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was NOT working