-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add EigenZkvm's abi and impl the settlement's EigenZkvm interfa…
…tes (#16) * feat: add EigenZkvm's abi and impl the settlement's EigenZkvm interfates * feat: determine contract data structure, prepare for testing * feat: add L2Watcher to fetch latest l2 block, refactor the settler's loop, add verify_worker and proof_worker * fix: update prover.pb, fix prover-service, add log for verify_worker * fix: add test for proof parser, fix parse_public_input, fix zkvm contract client * style: fix fmt * fix: fix the param and gas of the verify_batches, add log
- Loading branch information
1 parent
e2372c9
commit 63120f8
Showing
21 changed files
with
1,074 additions
and
238 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[ethereum_settlement_config] | ||
provider_url = "http://localhost:8545" | ||
provider_url = "http://localhost:8547" | ||
|
||
[ethereum_settlement_config.local_wallet] | ||
private_key = "0x76af8cc59ecfabf983d423e2054b07c11212cabc532062da0bd8067c59cf4a40" | ||
private_key = "0xbe825d459385bbb3ba169ac8d59bd05b099b190d8a89aace7e5bc3518e2f1a9c" | ||
chain_id = 12345 | ||
|
||
[ethereum_settlement_config.l1_contracts_addr] | ||
bridge = "0x732200433EE79cCBf5842F9b5aD8fda6BF569F01" | ||
global_exit = "0xAC97e12d0Ae20B2E0BF94e8Bd5752494577fC799" | ||
zkvm = "0x12bfb8B59144b96bE5E74ECbC9896667261c004A" | ||
bridge = "0xF93a9C25d4fa383ffCC8b9411A3813bFd131e2e8" | ||
global_exit = "0xeA7ad75F6F685FdF0B8Bf6C6c254011018697D2d" | ||
zkvm = "0x83C27Cb6C2Aa253A6C501E61F0d35E545FC0C68E" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,87 @@ | ||
use crate::db::keys; | ||
use crate::db::Database; | ||
use anyhow::{anyhow, bail, Result}; | ||
use ethers_providers::{Http, Middleware, Provider}; | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
use tokio::sync::broadcast; | ||
use tokio::{select, time}; | ||
|
||
const L2_WATCHER_INTERVAL: Duration = Duration::from_secs(1); | ||
pub struct L2Watcher { | ||
pub db: Arc<Box<dyn Database>>, | ||
pub l2provider: Provider<Http>, | ||
// stop_rx: broadcast::Receiver<()>, | ||
stop_tx: broadcast::Sender<()>, | ||
// pub ticker: time::Interval, | ||
} | ||
|
||
impl L2Watcher { | ||
pub fn new(db: Arc<Box<dyn Database>>, l2provider: Provider<Http>) -> Self { | ||
let (stop_tx, _) = broadcast::channel(1); | ||
|
||
L2Watcher { | ||
db, | ||
l2provider, | ||
// stop_rx, | ||
stop_tx, | ||
// ticker: time::interval(L2_WATCHER_INTERVAL), | ||
} | ||
} | ||
|
||
pub async fn start(&mut self) -> Result<()> { | ||
// TODO: restart | ||
let mut ticker = time::interval(L2_WATCHER_INTERVAL); | ||
let mut stop_rx = self.stop_tx.subscribe(); | ||
let db = self.db.clone(); | ||
let l2provider = self.l2provider.clone(); | ||
let mut stop_fetch_tx = self.stop_tx.subscribe(); | ||
|
||
tokio::spawn(async move { | ||
loop { | ||
select! { | ||
_ = stop_rx.recv() => { | ||
log::info!("L2Watcher stopped"); | ||
break; | ||
} | ||
_ = ticker.tick() => { | ||
if let Err(e) = Self::fetch_latest_block(&db, &l2provider, &mut stop_fetch_tx).await{ | ||
log::error!("L2Watcher failed to fetch latest block, try again later, err: {:?}", e); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
log::info!("L2Watcher started"); | ||
Ok(()) | ||
} | ||
|
||
pub async fn stop(&self) -> Result<()> { | ||
self.stop_tx | ||
.send(()) | ||
.map_err(|e| anyhow!("Failed to stop the L2Watcher: {:?}", e)) | ||
.map(|_| log::info!("Exit signal successfully sent")) | ||
} | ||
|
||
pub async fn fetch_latest_block( | ||
db: &Arc<Box<dyn Database>>, | ||
l2provider: &Provider<Http>, | ||
stop_rx: &mut broadcast::Receiver<()>, | ||
) -> Result<()> { | ||
select! { | ||
result = l2provider.get_block_number() => { | ||
result | ||
.map_err(|e| anyhow!("{:?}", e)) | ||
.map(|number| { | ||
log::info!("L2Watcher fetched block({})", number); | ||
db.put(keys::KEY_LAST_SEQUENCE_FINALITY_BLOCK_NUMBER.to_vec(), number.as_u64().to_be_bytes().to_vec()) | ||
}) | ||
}, | ||
_ = stop_rx.recv() => { | ||
log::info!("Early exit signal received during block fetch."); | ||
bail!("Early exit signal received during block fetch."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
// TODO: Fix me | ||
#![allow(dead_code)] | ||
|
||
pub(crate) mod libmdbx; | ||
mod mem; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.