Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into slumber-zks-557-implem…
Browse files Browse the repository at this point in the history
…ent-listener-for-pg-notification
  • Loading branch information
slumber committed Mar 30, 2021
2 parents 824071f + 2a5a5d1 commit a350d6c
Show file tree
Hide file tree
Showing 116 changed files with 4,653 additions and 618 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: start-services
run: |
docker-compose -f docker-compose-runner.yml down
docker-compose pull
docker-compose -f docker-compose-runner.yml pull
docker-compose -f docker-compose-runner.yml up --build -d geth postgres zk
ci_run sccache --start-server
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- name: start-services
run: |
docker-compose -f docker-compose-runner.yml down
docker-compose pull
docker-compose -f docker-compose-runner.yml pull
docker-compose -f docker-compose-runner.yml up --build -d geth postgres zk
ci_run sccache --start-server
Expand All @@ -118,31 +118,20 @@ jobs:
- name: integration-server
run: ci_run zk test i server

- name: Show logs
run: |
ci_run cat server.log
ci_run cat dummy_prover.log
- name: integration-api
run: ci_run zk test i api

- name: Show logs
run: |
ci_run cat server.log
ci_run cat dummy_prover.log
- name: integration-zcli
run: ci_run zk test i zcli

- name: Show logs
run: |
ci_run cat server.log
ci_run cat dummy_prover.log
- name: integration-rust-sdk
run: ci_run zk test i rust-sdk

- name: integration-withdrawal-helpers
run: ci_run zk test i withdrawal-helpers

- name: Show logs
if: always()
run: |
ci_run cat server.log
ci_run cat dummy_prover.log
Expand All @@ -163,7 +152,7 @@ jobs:
- name: start-services
run: |
docker-compose -f docker-compose-runner.yml down
docker-compose pull
docker-compose -f docker-compose-runner.yml pull
docker-compose -f docker-compose-runner.yml up --build -d zk
ci_run sccache --start-server
Expand Down
69 changes: 24 additions & 45 deletions .github/workflows/deploy-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
-
id: print
run: echo "::set-output name=shortRev::$(git rev-parse --short HEAD)"
-
-
uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ github.ref }}
regex: '^refs\/tags\/(v[0-9]+\.[0-9]+\.[0-9](-?\w*)?)$'
regex: '^refs\/tags\/(v[0-9]+\.[0-9]+\.[0-9](-?.*)?)$'
-
name: Map runtime environment data
uses: kanga333/[email protected]
Expand All @@ -29,67 +29,46 @@ jobs:
{
"mainnet": {
"KUBECONF": "KUBECONF_MAINNET",
"HFENV": "zksync-prod"
"HFENV": "zksync-prod",
"RUNNER": "mainnet"
},
"rinkeby": {
"KUBECONF": "$KUBECONF_TESTNET",
"HFENV": "zksync-${{ github.event.deployment.environment }}"
"KUBECONF": "KUBECONF_TESTNET",
"HFENV": "zksync-${{ github.event.deployment.environment }}",
"RUNNER": "testnet"
},
"ropsten": {
"KUBECONF": "$KUBECONF_TESTNET",
"HFENV": "zksync-${{ github.event.deployment.environment }}"
"KUBECONF": "KUBECONF_TESTNET",
"HFENV": "zksync-${{ github.event.deployment.environment }}",
"RUNNER": "testnet"
},
".*": {
"KUBECONF": "KUBECONF_STAGE",
"HFENV": "zksync-${{ github.event.deployment.environment }}"
"HFENV": "zksync-${{ github.event.deployment.environment }}",
"RUNNER": "stage"
}
}
-
name: Cancel deployment (deployment tag missmatch)
if: ${{ steps.regex-match.outputs.group1 == '' }}
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ github.token }}
state: failure
deployment_id: ${{ github.event.deployment.id }}

outputs:
shortRev: ${{ steps.print.outputs.shortRev }}
kubeConf: ${{ env.KUBECONF }}
hfEnv: ${{ env.HFENV }}
runner: ${{ env.RUNNER }}
isTag: ${{ steps.regex-match.outputs.group1 != '' }}

build-images:
name: Build and Push Docker Images
runs-on: [self-hosted, MAIN]
needs: pre
if: ${{ needs.pre.outputs.isTag == 'true' }}

# Required services
services:
postgres:
image: postgres:10.4
ports:
- 5432:5432

steps:
- uses: actions/checkout@v2

- name: setup-env
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo CI=1 >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
- name: init
run: |
cargo sqlx --version || cargo install --version=0.2.0 sqlx-cli
zk
zk run yarn
cp etc/tokens/{test,localhost}.json
zk run verify-keys unpack
zk db basic-setup
- name: update-images
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
zk docker push rust
zk docker push nginx
deploy:
name: Deploy Apps
runs-on: [k8s, deployer, "${{ github.event.deployment.environment }}"]
needs: [pre, build-images]
runs-on: [k8s, deployer, "${{ needs.pre.outputs.runner }}"]
needs: pre
if: ${{ needs.pre.outputs.isTag == 'true' }}

container:
image: dysnix/kubectl:v1.16-gcloud
Expand Down
28 changes: 18 additions & 10 deletions .github/workflows/deploy-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,35 @@ jobs:
ref: master
token: ${{ secrets.GH_TOKEN }}
-
name: Deploy apps
working-directory: helm-infra
run: |
## copy helm plugins over (from dysnix/kubectl, don't forget)!!!
cp -r /dysnix/kubectl/.local /dysnix/kubectl/.cache ~
UPDATE_REPOS=y helmfile -e $HFENV repos
helmfile -e $HFENV $DEPLOY_APPS apply --args "timeout 180s"
uses: chrnorm/deployment-action@releases/v1
name: Create GitHub deployment
id: deployment
with:
token: "${{ github.token }}"
environment: stage
# TODO fix stage and resume deploy to stage
# -
# name: Deploy apps
# working-directory: helm-infra
# run: |
# copy helm plugins over (from dysnix/kubectl, don't forget)!!!
# cp -r /dysnix/kubectl/.local /dysnix/kubectl/.cache ~
#
# UPDATE_REPOS=y helmfile -e $HFENV repos
# helmfile -e $HFENV $DEPLOY_APPS apply --args "timeout 180s"
-
name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ github.token }}
state: success
deployment_id: ${{ github.event.deployment.id }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
-
name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ github.token }}
state: failure
deployment_id: ${{ github.event.deployment.id }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"core/bin/zksync_core",
"core/bin/zksync_eth_sender",
"core/bin/zksync_witness_generator",
"core/bin/zksync_forced_exit_requests",

# Libraries
"core/lib/circuit",
Expand Down
2 changes: 2 additions & 0 deletions changelog/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ All notable changes to the core components will be documented in this file.

- Added a stressing dev fee ticker scenario to the loadtest.
- Added a `--sloppy` mode to the `dev-fee-ticker-server` to simulate bad networks with the random delays and fails.
- Added `forced_exit_requests` functionality, which allows users to pay for ForcedExits from L1. Note that a few env
variables were added that control the behaviour of the tool.
- Possibility to use CREATE2 ChangePubKey and Transfer in a single batch.

### Fixed
Expand Down
51 changes: 51 additions & 0 deletions contracts/contracts/ForcedExit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

pragma solidity ^0.7.0;

pragma experimental ABIEncoderV2;

import "./Utils.sol";
import "./Ownable.sol";
import "./ReentrancyGuard.sol";

contract ForcedExit is Ownable, ReentrancyGuard {
// This is the role of the zkSync server
// that will be able to withdraw the funds
address payable public receiver;

bool public enabled = true;

constructor(address _master, address _receiver) Ownable(_master) {
initializeReentrancyGuard();

// The master is the default receiver
receiver = payable(_receiver);
}

event FundsReceived(uint256 _amount);

function setReceiver(address payable _newReceiver) external {
requireMaster(msg.sender);

receiver = _newReceiver;
}

function withdrawPendingFunds(address payable _to) external nonReentrant {
require(
msg.sender == receiver || msg.sender == getMaster(),
"Only the receiver or master can withdraw funds from the smart contract"
);

uint256 balance = address(this).balance;

(bool success, ) = _to.call{value: balance}("");
require(success, "ETH withdraw failed");
}

// We have to use fallback instead of `receive` since the ethabi
// library can't decode the receive function:
// https://github.com/rust-ethereum/ethabi/issues/185
fallback() external payable {
emit FundsReceived(msg.value);
}
}
14 changes: 14 additions & 0 deletions contracts/contracts/dev-contracts/SelfDestruct.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

pragma solidity ^0.7.0;

pragma experimental ABIEncoderV2;

contract SelfDestruct {
function destroy(address payable to) external {
selfdestruct(to);
}

// Need this to send some funds to the contract
receive() external payable {}
}
4 changes: 4 additions & 0 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ async function main() {
if (args.contract === 'Proxies' || args.contract == null) {
await deployer.deployProxiesAndGatekeeper({ gasPrice, nonce: args.nonce });
}

if (args.contract === 'ForcedExit' || args.contract == null) {
await deployer.deployForcedExit({ gasPrice, nonce: args.nonce });
}
}

main()
Expand Down
Loading

0 comments on commit a350d6c

Please sign in to comment.