Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ethers= "1.0.2"
hex = "0.4.3"
libflate = "1.2.0"
openssl = { version = "0.10", features = ["vendored"] }
once_cell = "1"

# Logging and Metrics
chrono = "0.4.22"
Expand Down
19 changes: 12 additions & 7 deletions src/l1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use ethers::{
};

use eyre::Result;
use once_cell::sync::Lazy;
use tokio::{spawn, task::JoinHandle, time::sleep};

use crate::{
Expand All @@ -26,6 +27,15 @@ use crate::{
derive::stages::attributes::UserDeposited,
};

static CONFIG_UPDATE_TOPIC: Lazy<H256> =
Lazy::new(|| H256::from_slice(&keccak256("ConfigUpdate(uint256,uint8,bytes)")));

static TRANSACTION_DEPOSITED_TOPIC: Lazy<H256> = Lazy::new(|| {
H256::from_slice(&keccak256(
"TransactionDeposited(address,address,uint256,bytes)",
))
});

/// Handles watching the L1 chain and monitoring for new blocks, deposits,
/// and batcher transactions. The monitoring loop is spawned in a seperate
/// task and communication happens via the internal channels. When ChainWatcher
Expand Down Expand Up @@ -284,11 +294,9 @@ impl InnerWatcher {

if last_update_block < self.current_block {
let to_block = last_update_block + 1000;
let update_event = "ConfigUpdate(uint256,uint8,bytes)";
let update_topic = H256::from_slice(&keccak256(update_event));
let filter = Filter::new()
.address(self.config.chain.system_config_contract)
.topic0(update_topic)
.topic0(*CONFIG_UPDATE_TOPIC)
.from_block(last_update_block + 1)
.to_block(to_block);

Expand Down Expand Up @@ -376,14 +384,11 @@ impl InnerWatcher {
match self.deposits.remove(&block_num) {
Some(deposits) => Ok(deposits),
None => {
let deposit_event = "TransactionDeposited(address,address,uint256,bytes)";
let deposit_topic = H256::from_slice(&keccak256(deposit_event));

let end_block = self.head_block.min(block_num + 1000);

let deposit_filter = Filter::new()
.address(self.config.chain.deposit_contract)
.topic0(deposit_topic)
.topic0(*TRANSACTION_DEPOSITED_TOPIC)
.from_block(block_num)
.to_block(end_block);

Expand Down