Skip to content

Commit

Permalink
Merge branch 'dev' into sb-add-no-2fa-accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Aug 17, 2021
2 parents e5b3431 + 189d3b5 commit 1498d43
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 182 deletions.
111 changes: 63 additions & 48 deletions .github/workflows/loadtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,42 @@ env:
HF_ARGS: -e loadtest

jobs:
sqlproxy:
name: Provision SQLProxy
runs-on: [k8s, stage, deployer]
update:
name: Update Configs
runs-on: [k8s, deployer, stage]
steps:
- name: Update Config
uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: Update Config
token: ${{ secrets.GH_TOKEN }}
wait-for-completion-timeout: 5m
wait-for-completion-interval: 20s
inputs: |
{
"environment": "${{ env.ZKSYNC_ENV }}",
"ref": "master"
}
setup:
name: Setup and Provision SQLProxy
## stage selects the specific cluster
runs-on: [k8s, deployer, stage]
needs: [update]
container:
image: dysnix/kubectl:v1.19-gcloud
image: dysnix/kubectl:v1.20-gcloud

env:
KUBECONF: ${{ secrets.STAGE_KUBECONF }}
HF_DEPLOYS: -l name=sqlproxy
DEPLOY_APPS: -l name=sqlproxy

outputs:
image_tag: ${{ steps.set.outputs.shortRev }}

steps:
- uses: actions/checkout@v2
- id: set
run: echo "::set-output name=shortRev::$(git rev-parse --short HEAD)"
-
name: Clone helm-infra
uses: actions/checkout@v2
Expand All @@ -32,22 +56,24 @@ jobs:
name: Create ~/.kube/config
run: ./.github/scripts/write-kubeconf.sh
-
name: Setup helm and loadtest.env
run: |
.github/scripts/zksync-env.sh --kube loadtest > etc/env/loadtest.env
echo -n "ETH_SENDER_SENDER_OPERATOR_PRIVATE_KEY=" >> etc/env/loadtest.env
kubectl get secret -n loadtest server-env -o jsonpath='{.data.ETH_SENDER_SENDER_OPERATOR_PRIVATE_KEY}' | base64 -d >> etc/env/loadtest.env
-
name: Deploy SQLProxy
name: Provision SQLProxy
working-directory: helm-infra
run: |
UPDATE_REPOS=y helmfile $HF_ARGS repos
helmfile $HF_ARGS $HF_DEPLOYS sync
helmfile $HF_ARGS $DEPLOY_APPS sync
-
name: Create etc/env/loadtest.env
run: |
mkdir -p etc/env/
kubectl get cm -n ${ZKSYNC_ENV} server-env-custom -o json | jq -j '.data | to_entries | .[] | "\(.key)=\(.value)\n"' > etc/env/${ZKSYNC_ENV}.env
kubectl get secret -n ${ZKSYNC_ENV} secretenv-zksync -o go-template='{{range $k, $v := .data}}{{ printf "%s=%s\n" $k ($v | base64decode) }}{{end}}' \
>> etc/env/${ZKSYNC_ENV}.env
init:
dbsetup:
name: Cleanup the database, compile and update contracts
runs-on: [k8s, stage, deployer]
needs: sqlproxy
## stage selects the specific cluster
runs-on: [k8s, deployer, stage]
needs: [setup]
env:
RUSTUP_HOME: /usr/share/rust/.rustup
CARGO_HOME: /usr/share/rust/.cargo
Expand Down Expand Up @@ -87,35 +113,22 @@ jobs:
zk db insert contract
deploy:
name: Deploy the apps
runs-on: [k8s, stage, deployer]
needs: init
container:
image: dysnix/kubectl:v1.19-gcloud
env:
KUBECONF: ${{ secrets.STAGE_KUBECONF }}
IMAGE_TAG: ${{ needs.pre.outputs.shortRev }}
HF_DEPLOYS: -l name=server -l name=prover
name: Deploy apps
runs-on: [k8s, deployer, stage]
needs: [setup, dbsetup]
steps:
-
name: Create ~/.kube/config
run: .github/scripts/write-kubeconf.sh
-
name: Update contracts in the ConfigMap
run: .github/scripts/zksync-env.sh --update-from deployed_contracts.log
-
id: config
run: |
echo "::set-output name=shortRev::$(git rev-parse --short HEAD)"
-
name: Deploy apps
working-directory: helm-infra
run: |
UPDATE_REPOS=y helmfile $HF_ARGS repos
export IMAGE_TAG=${{ steps.config.outputs.shortRev }}
# Split apply into diff+sync (required for extra sync args), what for server to settle
helmfile $HF_ARGS $HF_DEPLOYS diff
helmfile $HF_ARGS $HF_DEPLOYS sync --args "--timeout 180s" && sleep 60
- name: Deploy
uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: Deploy
token: ${{ secrets.GH_TOKEN }}
wait-for-completion-timeout: 10m
wait-for-completion-interval: 1m
inputs: |
{
"environment": "${{ env.ZKSYNC_ENV }}",
"image_tag": "${{ needs.setup.outputs.image_tag }}"
}
loadtest:
name: Perform loadtest
Expand All @@ -138,15 +151,17 @@ jobs:

cleanup:
name: Cleanup loadtest environment
runs-on: [k8s, stage, deployer]
needs: loadtest
if: always()
## stage selects the specific cluster
runs-on: [k8s, deployer, stage]
needs: [dbsetup, loadtest]
container:
image: dysnix/kubectl:v1.19-gcloud
image: dysnix/kubectl:v1.20-gcloud
env:
KUBECONF: ${{ secrets.STAGE_KUBECONF }}

if: always()
steps:
- run: rm -f etc/env/${ZKSYNC_ENV}.env
-
name: Create ~/.kube/config
run: .github/scripts/write-kubeconf.sh
Expand Down
45 changes: 36 additions & 9 deletions contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export class Deployer {
});
const govRec = await govContract.deployTransaction.wait();
const govGasUsed = govRec.gasUsed;
const gasPrice = govContract.deployTransaction.gasPrice;
let gasPrice = govContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`CONTRACTS_GOVERNANCE_TARGET_ADDR=${govContract.address}`);
console.log(
Expand All @@ -149,7 +152,10 @@ export class Deployer {
});
const verRec = await verifierContract.deployTransaction.wait();
const verGasUsed = verRec.gasUsed;
const gasPrice = verifierContract.deployTransaction.gasPrice;
let gasPrice = verifierContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`CONTRACTS_VERIFIER_TARGET_ADDR=${verifierContract.address}`);
console.log(
Expand All @@ -171,7 +177,10 @@ export class Deployer {
});
const zksRec = await zksContract.deployTransaction.wait();
const zksGasUsed = zksRec.gasUsed;
const gasPrice = zksContract.deployTransaction.gasPrice;
let gasPrice = zksContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`CONTRACTS_CONTRACT_TARGET_ADDR=${zksContract.address}`);
console.log(
Expand Down Expand Up @@ -215,7 +224,10 @@ export class Deployer {
}
const txHash = deployFactoryTx.transactionHash;
const gasUsed = deployFactoryTx.gasUsed;
const gasPrice = deployFactoryContract.deployTransaction.gasPrice;
let gasPrice = deployFactoryContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`CONTRACTS_DEPLOY_FACTORY_ADDR=${deployFactoryContract.address}`);
console.log(`CONTRACTS_GOVERNANCE_ADDR=${this.addresses.Governance}`);
Expand Down Expand Up @@ -247,7 +259,10 @@ export class Deployer {
);
const zksRec = await nftFactoryContarct.deployTransaction.wait();
const zksGasUsed = zksRec.gasUsed;
const gasPrice = nftFactoryContarct.deployTransaction.gasPrice;
let gasPrice = nftFactoryContarct.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`CONTRACTS_NFT_FACTORY_ADDR=${nftFactoryContarct.address}`);
console.log(
Expand Down Expand Up @@ -282,7 +297,10 @@ export class Deployer {
);
const zksRec = await tokenGovernanceContract.deployTransaction.wait();
const zksGasUsed = zksRec.gasUsed;
const gasPrice = tokenGovernanceContract.deployTransaction.gasPrice;
let gasPrice = tokenGovernanceContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`\nCONTRACTS_LISTING_GOVERNANCE=${tokenGovernanceContract.address}\n`);
console.log(
Expand Down Expand Up @@ -315,7 +333,10 @@ export class Deployer {
);
const zksRec = await forcedExitContract.deployTransaction.wait();
const zksGasUsed = zksRec.gasUsed;
const gasPrice = forcedExitContract.deployTransaction.gasPrice;
let gasPrice = forcedExitContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`CONTRACTS_FORCED_EXIT_ADDR=${forcedExitContract.address}`);
console.log(
Expand All @@ -338,7 +359,10 @@ export class Deployer {
});
const zksRec = await additionalZkSyncContract.deployTransaction.wait();
const zksGasUsed = zksRec.gasUsed;
const gasPrice = additionalZkSyncContract.deployTransaction.gasPrice;
let gasPrice = additionalZkSyncContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`CONTRACTS_ADDITIONAL_ZKSYNC_ADDR=${additionalZkSyncContract.address}`);
console.log(
Expand Down Expand Up @@ -366,7 +390,10 @@ export class Deployer {
);
const zksRec = await regenesisMultisigContract.deployTransaction.wait();
const zksGasUsed = zksRec.gasUsed;
const gasPrice = regenesisMultisigContract.deployTransaction.gasPrice;
let gasPrice = regenesisMultisigContract.deployTransaction.gasPrice;
if (gasPrice == null) {
gasPrice = await this.deployWallet.provider.getGasPrice();
}
if (this.verbose) {
console.log(`MISC_REGENESIS_MULTISIG_ADDRESS=${regenesisMultisigContract.address}`);
console.log(
Expand Down
7 changes: 7 additions & 0 deletions core/bin/zksync_api/src/fee_ticker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ pub fn run_ticker_task(
CoinMarketCapAPI::new(client, base_url.parse().expect("Correct CoinMarketCap url"));

let ticker_api = TickerApi::new(db_pool.clone(), token_price_api);
let token_price_updater = ticker_api.clone();
tokio::spawn(token_price_updater.keep_price_updated());
let ticker_info = TickerInfo::new(db_pool);
let fee_ticker = FeeTicker::new(
ticker_api,
Expand All @@ -319,6 +321,9 @@ pub fn run_ticker_task(
.with_price_cache(price_cache)
.with_gas_price_cache(gas_price_cache);

let token_price_updater = ticker_api.clone();
tokio::spawn(token_price_updater.keep_price_updated());

let (ticker_balancer, tickers) = Balancer::new(
FeeTickerBuilder {
api: ticker_api,
Expand All @@ -330,9 +335,11 @@ pub fn run_ticker_task(
config.ticker.number_of_ticker_actors,
TICKER_CHANNEL_SIZE,
);

for ticker in tickers.into_iter() {
tokio::spawn(ticker.run());
}

tokio::spawn(ticker_balancer.run())
}
}
Expand Down
4 changes: 4 additions & 0 deletions core/bin/zksync_api/src/fee_ticker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ impl FeeTickerAPI for MockApiProvider {
}
unreachable!("incorrect token input")
}

async fn keep_price_updated(self) {
// Just do nothing
}
}

struct MockTickerInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::fee_ticker::PriceError;
use zksync_types::{Token, TokenLike, TokenPrice};
use zksync_utils::UnsignedRatioSerializeAsDecimal;

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct CoinMarketCapAPI {
client: reqwest::Client,
base_url: Url,
Expand Down
Loading

0 comments on commit 1498d43

Please sign in to comment.