-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from paradigmxyz/revamp_multidatatypes
revamp multidatatypes
- Loading branch information
Showing
16 changed files
with
208 additions
and
81 deletions.
There are no files selected for viewing
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
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
81 changes: 81 additions & 0 deletions
81
crates/freeze/src/multi_datasets/call_trace_derivatives.rs
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use crate::*; | ||
use ethers::prelude::*; | ||
use polars::prelude::*; | ||
use std::collections::HashMap; | ||
|
||
/// CallTraceDerivatives | ||
#[derive(Default)] | ||
pub struct CallTraceDerivatives( | ||
contracts::Contracts, | ||
native_transfers::NativeTransfers, | ||
traces::Traces, | ||
); | ||
|
||
type Result<T> = ::core::result::Result<T, CollectError>; | ||
|
||
impl ToDataFrames for CallTraceDerivatives { | ||
fn create_dfs( | ||
self, | ||
schemas: &HashMap<Datatype, Table>, | ||
chain_id: u64, | ||
) -> Result<HashMap<Datatype, DataFrame>> { | ||
let CallTraceDerivatives(contracts, native_transfers, traces) = self; | ||
let mut output = HashMap::new(); | ||
if schemas.contains_key(&Datatype::Contracts) { | ||
output.extend(contracts.create_dfs(schemas, chain_id)?); | ||
} | ||
if schemas.contains_key(&Datatype::NativeTransfers) { | ||
output.extend(native_transfers.create_dfs(schemas, chain_id)?); | ||
} | ||
if schemas.contains_key(&Datatype::Traces) { | ||
output.extend(traces.create_dfs(schemas, chain_id)?); | ||
} | ||
Ok(output) | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl CollectByBlock for CallTraceDerivatives { | ||
type Response = Vec<Trace>; | ||
|
||
async fn extract(request: Params, source: Source, _schemas: Schemas) -> Result<Self::Response> { | ||
source.fetcher.trace_block(request.block_number()?.into()).await | ||
} | ||
|
||
fn transform(response: Self::Response, columns: &mut Self, schemas: &Schemas) -> Result<()> { | ||
let traces = traces::filter_failed_traces(response); | ||
process_call_trace_derivatives(traces, columns, schemas) | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl CollectByTransaction for CallTraceDerivatives { | ||
type Response = Vec<Trace>; | ||
|
||
async fn extract(request: Params, source: Source, _schemas: Schemas) -> Result<Self::Response> { | ||
source.fetcher.trace_transaction(request.ethers_transaction_hash()?).await | ||
} | ||
|
||
fn transform(response: Self::Response, columns: &mut Self, schemas: &Schemas) -> Result<()> { | ||
let traces = traces::filter_failed_traces(response); | ||
process_call_trace_derivatives(traces, columns, schemas) | ||
} | ||
} | ||
|
||
fn process_call_trace_derivatives( | ||
response: Vec<Trace>, | ||
columns: &mut CallTraceDerivatives, | ||
schemas: &HashMap<Datatype, Table>, | ||
) -> Result<()> { | ||
let CallTraceDerivatives(contracts, native_transfers, traces) = columns; | ||
if schemas.contains_key(&Datatype::Contracts) { | ||
contracts::process_contracts(&response, contracts, schemas)?; | ||
} | ||
if schemas.contains_key(&Datatype::NativeTransfers) { | ||
native_transfers::process_native_transfers(&response, native_transfers, schemas)?; | ||
} | ||
if schemas.contains_key(&Datatype::Traces) { | ||
traces::process_traces(&response, traces, schemas)?; | ||
} | ||
Ok(()) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod blocks_and_transactions; | ||
mod call_trace_derivatives; | ||
mod state_diffs; | ||
|
||
pub use blocks_and_transactions::*; | ||
pub use call_trace_derivatives::*; | ||
pub use state_diffs::*; |
1 change: 0 additions & 1 deletion
1
crates/freeze/src/datasets/state_diffs.rs → .../freeze/src/multi_datasets/state_diffs.rs
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
Oops, something went wrong.