Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add traces #89

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
91 changes: 36 additions & 55 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion common/eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ test = false

anyhow = "1"
hex = "0.4"
web3 = "0.18.0"
web3 = { git = "https://github.com/BohuTANG/rust-web3"}

[dev-dependencies]
2 changes: 1 addition & 1 deletion ethetl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.82"
ticker = "0.1.0"
tokio = { version = "1.19.2", features = ["full"] }
web3 = "0.18.0"
web3 = { git = "https://github.com/BohuTANG/rust-web3"}


[dev-dependencies]
Expand Down
11 changes: 10 additions & 1 deletion ethetl/src/contexts/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct ProgressValue {
pub logs: usize,
pub token_transfers: usize,
pub ens: usize,
pub traces: usize,
}

#[derive(Debug)]
Expand All @@ -40,6 +41,7 @@ pub struct Progress {
logs: AtomicUsize,
token_transfers: AtomicUsize,
ens: AtomicUsize,
traces: AtomicUsize,
}

impl Progress {
Expand All @@ -52,6 +54,7 @@ impl Progress {
logs: AtomicUsize::new(0),
token_transfers: AtomicUsize::new(0),
ens: AtomicUsize::new(0),
traces: AtomicUsize::new(0),
})
}

Expand Down Expand Up @@ -83,6 +86,10 @@ impl Progress {
self.ens.fetch_add(v, Ordering::Relaxed);
}

pub fn incr_traces(&self, v: usize) {
self.traces.fetch_add(v, Ordering::Relaxed);
}

pub fn value(&self) -> Arc<ProgressValue> {
Arc::new(ProgressValue {
blocks: self.blocks.load(Ordering::Relaxed),
Expand All @@ -91,6 +98,7 @@ impl Progress {
logs: self.logs.load(Ordering::Relaxed),
token_transfers: self.token_transfers.load(Ordering::Relaxed),
ens: self.ens.load(Ordering::Relaxed),
traces: self.traces.load(Ordering::Relaxed),
})
}

Expand All @@ -110,14 +118,15 @@ impl Progress {
if value.blocks > 0 {
let percent = ((value.blocks as f32 / all as f32) * 100_f32) as usize;
log::info!(
"block {:?} processed/{}, {:?} transactions processed, {:?} receipts processed, {:?} logs processed, {:?} token_transfers processed, {:?} ens processed. Progress is {:.2}",
"block {:?} processed/{}, {:?} transactions processed, {:?} receipts processed, {:?} logs processed, {:?} token_transfers processed, {:?} ens processed, {:?} traces processed. Progress is {:.2}",
value.blocks,
all,
value.txs,
value.receipts,
value.logs,
value.token_transfers,
value.ens,
value.traces,
percent.percent(),
);
}
Expand Down
2 changes: 2 additions & 0 deletions ethetl/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ mod blocks;
mod contracts;
mod receipts;
mod syncing;
mod traces;

pub use block_number::BlockNumber;
pub use blocks::BlockFetcher;
pub use contracts::ContractFetcher;
pub use receipts::ReceiptFetcher;
pub use syncing::Syncing;
pub use traces::Traces;
Loading