Skip to content

Commit

Permalink
add input length columns to txs (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
sslivkoff authored Jan 11, 2024
1 parent da6ce5e commit fef78ec
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/freeze/src/datasets/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ pub struct Transactions {
max_priority_fee_per_gas: Vec<Option<u64>>,
max_fee_per_gas: Vec<Option<u64>>,
success: Vec<bool>,
n_input_bytes: Vec<u32>,
n_input_zero_bytes: Vec<u32>,
n_input_nonzero_bytes: Vec<u32>,
block_hash: Vec<Vec<u8>>,
chain_id: Vec<u64>,
timestamp: Vec<u32>,
block_hash: Vec<Vec<u8>>,
}

#[async_trait::async_trait]
Expand All @@ -50,6 +53,9 @@ impl Dataset for Transactions {
"max_priority_fee_per_gas",
"max_fee_per_gas",
"success",
"n_input_bytes",
"n_input_zero_bytes",
"n_input_nonzero_bytes",
"chain_id",
])
}
Expand Down Expand Up @@ -196,6 +202,16 @@ pub(crate) fn process_transaction(
store!(schema, columns, input, tx.input.to_vec());
store!(schema, columns, gas_limit, tx.gas.as_u64());
store!(schema, columns, success, success);
if schema.has_column("n_input_bytes") |
schema.has_column("n_input_zero_bytes") |
schema.has_column("n_input_nonzero_bytes")
{
let n_input_bytes = tx.input.len() as u32;
let n_input_zero_bytes = tx.input.iter().filter(|&&x| x == 0).count() as u32;
store!(schema, columns, n_input_bytes, n_input_bytes);
store!(schema, columns, n_input_zero_bytes, n_input_zero_bytes);
store!(schema, columns, n_input_nonzero_bytes, n_input_bytes - n_input_zero_bytes);
}
store!(schema, columns, gas_used, receipt.and_then(|r| r.gas_used.map(|x| x.as_u64())));
store!(schema, columns, gas_price, tx.gas_price.map(|gas_price| gas_price.as_u64()));
store!(schema, columns, transaction_type, tx.transaction_type.map(|value| value.as_u32()));
Expand Down

0 comments on commit fef78ec

Please sign in to comment.