Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/super-worst-case-mload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Super Circuit aggregation worst_case_mload
on:
workflow_dispatch:
pull_request:
types: [synchronize, opened, reopened, labeled]

jobs:
test:
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'ci-super-worst-case-mload')
timeout-minutes: 7200
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ["${{github.run_id}}", self-hosted, r6a.48xlarge]
steps:
- uses: actions/checkout@v2

- name: Setup
run: cp .env.example .env

- name: Build docker images
run: |
docker compose down -v --remove-orphans || true
docker compose build bootnode dev

- name: Super Circuit aggregation worst_case_mload
if: always()
run: |
docker compose -f docker-compose.yml -f docker-compose-perf.yml run --use-aliases --no-TTY --rm --entrypoint bash dev -c 'COORDINATOR_AGGREGATE_PROOF=true COORDINATOR_CIRCUIT_NAME=super ./scripts/heavy_ci.sh worst_case_mload'
./scripts/ci_commit_errors.sh super-ag-worst_case_mload
29 changes: 20 additions & 9 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[workspace]
members = [
"coordinator",
"prover"
"prover",
"dev"
]

[profile.release]
opt-level = 3
lto = "thin"

[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/pinkiebell/halo2.git", rev = "5fc8ce89ef3235d8eefeb8994173ac706e89e4ec", package = "halo2_proofs" }
halo2_proofs = { git = "https://github.com/pinkiebell/halo2.git", rev = "2f530b040fc6297a40af6cc8f374cceeb87a628a", package = "halo2_proofs" }
2 changes: 2 additions & 0 deletions coordinator/src/shared_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ impl SharedState {
to: Option<Address>,
value: U256,
calldata: Vec<u8>,
gas_limit: Option<U256>,
) -> Result<H256, String> {
send_transaction_to_l2(
&self.ro.http_client,
Expand All @@ -669,6 +670,7 @@ impl SharedState {
to,
value,
calldata,
gas_limit,
)
.await
}
Expand Down
22 changes: 13 additions & 9 deletions coordinator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub async fn send_transaction_to_l2(
to: Option<Address>,
value: U256,
calldata: Vec<u8>,
gas_limit: Option<U256>,
) -> Result<H256, String> {
let wallet_addr: Address = wallet.address();
let nonce: U256 = jsonrpc_request_client(
Expand Down Expand Up @@ -137,15 +138,18 @@ pub async fn send_transaction_to_l2(
tx = tx.to(to.unwrap())
}

let estimate: U256 = jsonrpc_request_client(
RPC_REQUEST_TIMEOUT,
client,
node_uri,
"eth_estimateGas",
[&tx],
)
.await
.expect("estimateGas");
let estimate: U256 = match gas_limit {
Some(limit) => limit,
None => jsonrpc_request_client(
RPC_REQUEST_TIMEOUT,
client,
node_uri,
"eth_estimateGas",
[&tx],
)
.await
.expect("estimateGas"),
};
let tx = tx.gas(estimate).into();

let sig = wallet.sign_transaction(&tx).await.unwrap();
Expand Down
10 changes: 6 additions & 4 deletions coordinator/tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ async fn hop_cross_chain_message() {
.expect("calldata");

let tx_hash = shared_state
.transaction_to_l2(Some(hop), amount, calldata)
.transaction_to_l2(Some(hop), amount, calldata, None)
.await
.expect("tx_hash");
shared_state.mine().await;
Expand All @@ -368,7 +368,7 @@ async fn hop_cross_chain_message() {
.encode_input(&[chain_id.into_token()])
.expect("calldata");
let tx_hash_commit = shared_state
.transaction_to_l2(Some(hop), U256::zero(), calldata)
.transaction_to_l2(Some(hop), U256::zero(), calldata, None)
.await
.expect("tx_hash_commit");
shared_state.mine().await;
Expand Down Expand Up @@ -535,6 +535,7 @@ async fn zero_eth_transfer() {
Some(shared_state.ro.l2_wallet.address()),
U256::zero(),
vec![],
None,
)
.await
.expect("tx_hash");
Expand All @@ -553,7 +554,7 @@ async fn keccak() {
0x20, 0x00,
];
let deploy_tx_hash = shared_state
.transaction_to_l2(None, U256::zero(), bytecode)
.transaction_to_l2(None, U256::zero(), bytecode, None)
.await
.expect("tx_hash");
shared_state.mine().await;
Expand All @@ -563,7 +564,7 @@ async fn keccak() {
let deploy_receipt = wait_for_tx!(deploy_tx_hash, &shared_state.config.lock().await.l2_rpc_url);
let contract_addr = deploy_receipt.contract_address;
let tx_hash = shared_state
.transaction_to_l2(contract_addr, U256::zero(), vec![])
.transaction_to_l2(contract_addr, U256::zero(), vec![], None)
.await
.expect("tx_hash");
shared_state.mine().await;
Expand Down Expand Up @@ -673,6 +674,7 @@ async fn test_pi_commitment() {
Some(shared_state.ro.l2_wallet.address()),
U256::zero(),
vec![],
None,
)
.await
.expect("tx_hash");
Expand Down
17 changes: 17 additions & 0 deletions coordinator/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ macro_rules! wait_for_tx {
}};
}

#[macro_export]
macro_rules! wait_for_tx_no_panic {
($tx_hash:expr, $url:expr) => {{
let mut resp: Option<TransactionReceipt> = None;

while (resp.is_none()) {
resp = match jsonrpc_request($url, "eth_getTransactionReceipt", [$tx_hash]).await {
Ok(val) => Some(val),
Err(_) => None,
};
}

let receipt = resp.unwrap();
receipt
}};
}

#[macro_export]
macro_rules! finalize_chain {
($shared_state:expr) => {
Expand Down
3 changes: 2 additions & 1 deletion coordinator/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ macro_rules! deploy_l2 {
let shared_state = await_state!();

let tx_hash = shared_state
.transaction_to_l2(None, U256::zero(), $DEPLOY_CODE)
.transaction_to_l2(None, U256::zero(), $DEPLOY_CODE, None)
.await
.expect("tx_hash");
shared_state.mine().await;
Expand All @@ -82,6 +82,7 @@ macro_rules! deploy_l2 {
Some(Address::from_str($ADDRESS).unwrap()),
U256::zero(),
calldata,
None,
)
.await
.expect("tx_hash");
Expand Down
79 changes: 79 additions & 0 deletions coordinator/tests/worst_case.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
mod common;

use crate::common::get_shared_state;
use ethers_core::types::Address;
use ethers_core::types::Block;
use ethers_core::types::TransactionReceipt;
use ethers_core::types::H256;
use ethers_core::types::U256;
use std::str::FromStr;
use zkevm_common::json_rpc::jsonrpc_request;

#[tokio::test]
async fn worst_case_smod() {
let shared_state = await_state!();
let latest_block: Block<H256> = shared_state
.request_l2("eth_getBlockByNumber", ("latest", false))
.await
.unwrap();
let block_gas_limit = latest_block.gas_limit;
let tx_hash = shared_state
.transaction_to_l2(
Some(Address::from_str("0x0000000000000000000000000000000000100001").unwrap()),
U256::zero(),
vec![],
Some(block_gas_limit),
)
.await
.expect("tx_hash");
shared_state.mine().await;
let receipt = wait_for_tx_no_panic!(tx_hash, &shared_state.config.lock().await.l2_rpc_url);
assert_eq!(receipt.gas_used.expect("gas_used"), block_gas_limit);
finalize_chain!(shared_state);
}

#[tokio::test]
async fn worst_case_mload() {
let shared_state = await_state!();
let latest_block: Block<H256> = shared_state
.request_l2("eth_getBlockByNumber", ("latest", false))
.await
.unwrap();
let block_gas_limit = latest_block.gas_limit;
let tx_hash = shared_state
.transaction_to_l2(
Some(Address::from_str("0x0000000000000000000000000000000000100002").unwrap()),
U256::zero(),
vec![],
Some(block_gas_limit),
)
.await
.expect("tx_hash");
shared_state.mine().await;
let receipt = wait_for_tx_no_panic!(tx_hash, &shared_state.config.lock().await.l2_rpc_url);
assert_eq!(receipt.gas_used.expect("gas_used"), block_gas_limit);
finalize_chain!(shared_state);
}

#[tokio::test]
async fn worst_case_keccak_0_32() {
let shared_state = await_state!();
let latest_block: Block<H256> = shared_state
.request_l2("eth_getBlockByNumber", ("latest", false))
.await
.unwrap();
let block_gas_limit = latest_block.gas_limit;
let tx_hash = shared_state
.transaction_to_l2(
Some(Address::from_str("0x0000000000000000000000000000000000100003").unwrap()),
U256::zero(),
vec![],
Some(block_gas_limit),
)
.await
.expect("tx_hash");
shared_state.mine().await;
let receipt = wait_for_tx_no_panic!(tx_hash, &shared_state.config.lock().await.l2_rpc_url);
assert_eq!(receipt.gas_used.expect("gas_used"), block_gas_limit);
finalize_chain!(shared_state);
}
14 changes: 14 additions & 0 deletions dev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "zkevm_dev"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
eth-types = { git = "https://github.com/pinkiebell/zkevm-circuits.git", branch = "zkevm-chain" }
serde = { version = "1.0.136", features = ["derive"] }
serde_json = { version = "1.0.78", features = ["preserve_order"] }

[features]
default = []
autogen = []
Loading