Skip to content

Commit f985e41

Browse files
authored
fix(zk_toolbox): increase confirmations in testing (#2878)
## What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> Increase confirmations in testing. ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> Should make CI workflows less flaky. ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`.
1 parent 9ab7200 commit f985e41

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

infrastructure/zk/src/docker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Command} from 'commander';
1+
import { Command } from 'commander';
22
import * as utils from 'utils';
33

44
const IMAGES = [
@@ -31,7 +31,7 @@ async function dockerCommand(
3131
dockerOrg: string = 'matterlabs'
3232
) {
3333
// Generating all tags for containers. We need 2 tags here: SHA and SHA+TS
34-
const {stdout: COMMIT_SHORT_SHA}: { stdout: string } = await utils.exec('git rev-parse --short HEAD');
34+
const { stdout: COMMIT_SHORT_SHA }: { stdout: string } = await utils.exec('git rev-parse --short HEAD');
3535
// COMMIT_SHORT_SHA returns with newline, so we need to trim it
3636
const imageTagShaTS: string = process.env.IMAGE_TAG_SUFFIX
3737
? process.env.IMAGE_TAG_SUFFIX
@@ -126,7 +126,7 @@ async function _build(image: string, tagList: string[], dockerOrg: string, platf
126126
}
127127
buildArgs += extraArgs;
128128

129-
console.log("Build args: ", buildArgs);
129+
console.log('Build args: ', buildArgs);
130130

131131
const buildCommand =
132132
`DOCKER_BUILDKIT=1 docker buildx build ${tagsToBuild}` +

zk_toolbox/crates/common/src/ethereum.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use ethers::{
1010
};
1111
use types::TokenInfo;
1212

13-
use crate::{logger, wallets::Wallet};
13+
use crate::wallets::Wallet;
1414

1515
pub fn create_ethers_client(
1616
private_key: H256,
@@ -89,35 +89,30 @@ pub async fn mint_token(
8989
chain_id: u64,
9090
amount: u128,
9191
) -> anyhow::Result<()> {
92-
let client = Arc::new(create_ethers_client(
93-
main_wallet.private_key.unwrap(),
94-
l1_rpc,
95-
Some(chain_id),
96-
)?);
92+
let client = Arc::new(
93+
create_ethers_client(main_wallet.private_key.unwrap(), l1_rpc, Some(chain_id))?
94+
.nonce_manager(main_wallet.address),
95+
);
9796

9897
let contract = TokenContract::new(token_address, client);
99-
// contract
98+
99+
let mut pending_calls = vec![];
100100
for address in addresses {
101-
if let Err(err) = mint(&contract, address, amount).await {
102-
logger::warn(format!("Failed to mint {err}"))
103-
}
101+
pending_calls.push(contract.mint(address, amount.into()));
104102
}
105103

106-
Ok(())
107-
}
104+
let mut pending_txs = vec![];
105+
for call in &pending_calls {
106+
pending_txs.push(
107+
call.send()
108+
.await?
109+
// It's safe to set such low number of confirmations and low interval for localhost
110+
.confirmations(3)
111+
.interval(Duration::from_millis(30)),
112+
);
113+
}
114+
115+
futures::future::join_all(pending_txs).await;
108116

109-
async fn mint<T: Middleware + 'static>(
110-
contract: &TokenContract<T>,
111-
address: Address,
112-
amount: u128,
113-
) -> anyhow::Result<()> {
114-
contract
115-
.mint(address, amount.into())
116-
.send()
117-
.await?
118-
// It's safe to set such low number of confirmations and low interval for localhost
119-
.confirmations(1)
120-
.interval(Duration::from_millis(30))
121-
.await?;
122117
Ok(())
123118
}

0 commit comments

Comments
 (0)