Skip to content

Commit

Permalink
Merge pull request #229 from EspressoSystems/rollup-hotshot-genesis-b…
Browse files Browse the repository at this point in the history
…lock-number

Remember rollup genesis hotshot block number
  • Loading branch information
jbearer authored Sep 25, 2023
2 parents 5a67e00 + 516e8cd commit e6147f8
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ESPRESSO_ZKEVM_1_GENESIS_BLOCK_NUMBER=16
ESPRESSO_ZKEVM_1_FAUCET_PORT=18111
ESPRESSO_ZKEVM_1_FAUCET_WEB3_PROVIDER_URL_WS=ws://zkevm-1-permissionless-node:$ESPRESSO_ZKEVM_1_L2_PORT_WS
ESPRESSO_ZKEVM_1_FAUCET_WEB3_PROVIDER_URL_HTTP=http://zkevm-1-permissionless-node:$ESPRESSO_ZKEVM_1_L2_PORT
ESPRESSO_ZKEVM_1_GENESIS_HOTSHOT_BLOCK_NUMBER="UNSET"

# zkevm-preconfirmations-node 1
ESPRESSO_ZKEVM_1_PRECONFIRMATIONS_L2_PORT=18127
Expand Down Expand Up @@ -98,6 +99,7 @@ ESPRESSO_ZKEVM_2_GENESIS_BLOCK_NUMBER=30
ESPRESSO_ZKEVM_2_FAUCET_PORT=28111
ESPRESSO_ZKEVM_2_FAUCET_WEB3_PROVIDER_URL_WS=ws://zkevm-2-permissionless-node:$ESPRESSO_ZKEVM_2_L2_PORT_WS
ESPRESSO_ZKEVM_2_FAUCET_WEB3_PROVIDER_URL_HTTP=http://zkevm-2-permissionless-node:$ESPRESSO_ZKEVM_2_L2_PORT
ESPRESSO_ZKEVM_2_GENESIS_HOTSHOT_BLOCK_NUMBER="UNSET"

# zkevm-preconfirmations-node 2
ESPRESSO_ZKEVM_2_PRECONFIRMATIONS_L2_PORT=28127
Expand Down
6 changes: 6 additions & 0 deletions permissionless-docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ services:
- ZKEVM_NODE_ETHERMAN_GLOBALEXITROOTMANAGERADDR=$ESPRESSO_ZKEVM_1_GER_ADDRESS
- ZKEVM_NODE_ETHERMAN_HOTSHOTQUERYSERVICEURL=$ESPRESSO_ZKEVM_1_ADAPTOR_QUERY_URL
- ZKEVM_NODE_ETHERMAN_HOTSHOTADDR=$ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS
- ZKEVM_NODE_ETHERMAN_GENESISHOTSHOTBLOCKNUMBER=$ESPRESSO_ZKEVM_1_GENESIS_HOTSHOT_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_GENBLOCKNUMBER=$ESPRESSO_ZKEVM_1_GENESIS_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_IGNOREGENBLOCKNUMBERCHECK=$ESPRESSO_ZKEVM_IGNORE_GEN_BLOCK_NUMBER_CHECK
- ZKEVM_NODE_MTCLIENT_URI=$ESPRESSO_ZKEVM_1_MTCLIENT_URI
Expand Down Expand Up @@ -210,6 +211,7 @@ services:
- ZKEVM_NODE_ETHERMAN_GLOBALEXITROOTMANAGERADDR=$ESPRESSO_ZKEVM_1_GER_ADDRESS
- ZKEVM_NODE_ETHERMAN_HOTSHOTQUERYSERVICEURL=$ESPRESSO_ZKEVM_1_ADAPTOR_QUERY_URL
- ZKEVM_NODE_ETHERMAN_HOTSHOTADDR=$ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS
- ZKEVM_NODE_ETHERMAN_GENESISHOTSHOTBLOCKNUMBER=$ESPRESSO_ZKEVM_1_GENESIS_HOTSHOT_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_GENBLOCKNUMBER=$ESPRESSO_ZKEVM_1_GENESIS_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_PRECONFIRMATIONSSYNCINTERVAL=$ESPRESSO_ZKEVM_1_PRECONFIRMATIONS_SYNC_INTERVAL
- ZKEVM_NODE_SYNCHRONIZER_IGNOREGENBLOCKNUMBERCHECK=$ESPRESSO_ZKEVM_IGNORE_GEN_BLOCK_NUMBER_CHECK
Expand Down Expand Up @@ -291,6 +293,7 @@ services:
condition: service_healthy
profiles:
- "zkevm1"
stop_grace_period: 1s

# Polygon zkevm-node 2
zkevm-2-aggregator:
Expand Down Expand Up @@ -447,6 +450,7 @@ services:
- ZKEVM_NODE_ETHERMAN_GLOBALEXITROOTMANAGERADDR=$ESPRESSO_ZKEVM_2_GER_ADDRESS
- ZKEVM_NODE_ETHERMAN_HOTSHOTQUERYSERVICEURL=$ESPRESSO_ZKEVM_2_ADAPTOR_QUERY_URL
- ZKEVM_NODE_ETHERMAN_HOTSHOTADDR=$ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS
- ZKEVM_NODE_ETHERMAN_GENESISHOTSHOTBLOCKNUMBER=$ESPRESSO_ZKEVM_2_GENESIS_HOTSHOT_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_GENBLOCKNUMBER=$ESPRESSO_ZKEVM_2_GENESIS_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_IGNOREGENBLOCKNUMBERCHECK=$ESPRESSO_ZKEVM_IGNORE_GEN_BLOCK_NUMBER_CHECK
- ZKEVM_NODE_MTCLIENT_URI=$ESPRESSO_ZKEVM_2_MTCLIENT_URI
Expand Down Expand Up @@ -499,6 +503,7 @@ services:
- ZKEVM_NODE_ETHERMAN_GLOBALEXITROOTMANAGERADDR=$ESPRESSO_ZKEVM_2_GER_ADDRESS
- ZKEVM_NODE_ETHERMAN_HOTSHOTQUERYSERVICEURL=$ESPRESSO_ZKEVM_2_ADAPTOR_QUERY_URL
- ZKEVM_NODE_ETHERMAN_HOTSHOTADDR=$ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS
- ZKEVM_NODE_ETHERMAN_GENESISHOTSHOTBLOCKNUMBER=$ESPRESSO_ZKEVM_2_GENESIS_HOTSHOT_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_GENBLOCKNUMBER=$ESPRESSO_ZKEVM_2_GENESIS_BLOCK_NUMBER
- ZKEVM_NODE_SYNCHRONIZER_PRECONFIRMATIONSSYNCINTERVAL=$ESPRESSO_ZKEVM_2_PRECONFIRMATIONS_SYNC_INTERVAL
- ZKEVM_NODE_SYNCHRONIZER_IGNOREGENBLOCKNUMBERCHECK=$ESPRESSO_ZKEVM_IGNORE_GEN_BLOCK_NUMBER_CHECK
Expand Down Expand Up @@ -579,3 +584,4 @@ services:
condition: service_healthy
profiles:
- "zkevm2"
stop_grace_period: 1s
4 changes: 4 additions & 0 deletions polygon-zkevm-adaptor/src/demo_with_sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ impl SequencerZkEvmDemo {
"ESPRESSO_ZKEVM_1_GENESIS_BLOCK_NUMBER",
l1.gen_block_number.to_string(),
)
.env(
"ESPRESSO_ZKEVM_1_GENESIS_HOTSHOT_BLOCK_NUMBER",
l1.genesis_hotshot_block_number.to_string(),
)
.arg("up")
.args(L2_SERVICES)
.arg("-V")
Expand Down
4 changes: 4 additions & 0 deletions polygon-zkevm-adaptor/src/polygon_zkevm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ impl ZkEvmNode {
"ESPRESSO_ZKEVM_1_GENESIS_BLOCK_NUMBER",
l1.gen_block_number.to_string(),
)
.env(
"ESPRESSO_ZKEVM_1_GENESIS_HOTSHOT_BLOCK_NUMBER",
format!("{:?}", l1.genesis_hotshot_block_number),
)
.arg("up")
.args(L2_SERVICES)
.arg("-V")
Expand Down
24 changes: 19 additions & 5 deletions zkevm-contract-bindings/src/bin/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ struct ZkEvmDeploymentOutput {
ger_address: Address,
/// The address of the verifier contract.
verifier_address: Address,
/// The block number when the rollup contract was deployed.
/// The L1 block number when the rollup contract was deployed.
genesis_block_number: u64,
/// The hotshot block number where the rollup contract was deployed.
genesis_hotshot_block_number: u64,
}

with_prefix!(prefix_zkevm_1 "ESPRESSO_ZKEVM_1_");
Expand Down Expand Up @@ -267,6 +269,17 @@ async fn deploy_zkevm(
.await;
assert_eq!(rollup.address(), precalc_rollup_address);

let hotshot = HotShot::new(input.hotshot_address, deployer.clone());
let genesis_hotshot_block_number = hotshot
.block_height()
.block(receipt.block_number.unwrap())
.await?
.as_u64();
tracing::info!(
"HotShot genesis block number: {}",
genesis_hotshot_block_number
);

// Remember the genesis block number where the rollup contract was deployed.
let genesis_block_number = receipt.block_number.unwrap().as_u64();

Expand Down Expand Up @@ -307,6 +320,7 @@ async fn deploy_zkevm(
ger_address: global_exit_root.address(),
verifier_address: verifier.address(),
genesis_block_number,
genesis_hotshot_block_number,
})
}

Expand Down Expand Up @@ -386,14 +400,14 @@ async fn deploy(opts: Options) -> Result<()> {
tracing::info!("Using deployer account {:?}", deployer.inner().address());

// Deploy the hotshot contract.
let hotshot_address = if opts.hotshot_address.is_none() {
let hotshot_address = if let Some(hotshot_address) = opts.hotshot_address {
tracing::info!("Using existing HotShot contract at {:?}", hotshot_address);
hotshot_address
} else {
tracing::info!("Deploying HotShot contract");
let hotshot = HotShot::deploy(deployer.clone(), ())?.send().await?;
tracing::info!("Deployed HotShot at {:?}", hotshot.address());
hotshot.address()
} else {
tracing::info!("Using existing HotShot contract");
opts.hotshot_address.unwrap()
};

// Deploy the contracts for the first zkevm-node.
Expand Down
18 changes: 18 additions & 0 deletions zkevm-contract-bindings/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pub struct TestPolygonContracts {
pub verifier: VerifierRollupHelperMock<EthMiddleware>,
pub matic: ERC20PermitMock<EthMiddleware>,
pub gen_block_number: u64,
pub genesis_hotshot_block_number: u64,
pub clients: TestClients,
pub provider: Provider<Http>,
}
Expand Down Expand Up @@ -213,6 +214,13 @@ impl TestPolygonContracts {
block_num += 1;
};

let genesis_hotshot_block_number = hotshot
.block_height()
.block(gen_block_number)
.await
.unwrap()
.as_u64();

Self {
hotshot,
rollup,
Expand All @@ -224,6 +232,7 @@ impl TestPolygonContracts {
verifier: VerifierRollupHelperMock::new(verifier_address, deployer.clone()),
matic: ERC20PermitMock::new(matic_address, deployer.clone()),
gen_block_number,
genesis_hotshot_block_number,
clients,
provider,
}
Expand Down Expand Up @@ -308,6 +317,14 @@ impl TestPolygonContracts {
// Remember the genesis block number where the rollup contract was deployed.
let gen_block_number = receipt.block_number.unwrap().as_u64();

// Remember the hotshot block number where the rollup contract was deployed.
let genesis_hotshot_block_number = hotshot
.block_height()
.block(gen_block_number)
.await
.unwrap()
.as_u64();

let network_id_mainnet = 0;
bridge
.initialize(
Expand Down Expand Up @@ -371,6 +388,7 @@ impl TestPolygonContracts {
verifier,
matic,
gen_block_number,
genesis_hotshot_block_number,
clients,
provider,
}
Expand Down
2 changes: 1 addition & 1 deletion zkevm-node

0 comments on commit e6147f8

Please sign in to comment.