From 46f4c7cb26ff04211631b090a6f25966c2f7170d Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 10 Jan 2024 20:37:03 -0800 Subject: [PATCH 1/2] add input length columns to txs --- crates/freeze/src/datasets/transactions.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/freeze/src/datasets/transactions.rs b/crates/freeze/src/datasets/transactions.rs index c72c61cb..afec6a29 100644 --- a/crates/freeze/src/datasets/transactions.rs +++ b/crates/freeze/src/datasets/transactions.rs @@ -22,9 +22,12 @@ pub struct Transactions { max_priority_fee_per_gas: Vec>, max_fee_per_gas: Vec>, success: Vec, + n_input_bytes: Vec, + n_input_zero_bytes: Vec, + n_input_nonzero_bytes: Vec, + block_hash: Vec>, chain_id: Vec, timestamp: Vec, - block_hash: Vec>, } #[async_trait::async_trait] @@ -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", ]) } @@ -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())); From b5fa5ca016e01e7b336165ace9d8446b32668f58 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 10 Jan 2024 20:52:07 -0800 Subject: [PATCH 2/2] add n_rlp_bytes column to txs dataset --- crates/freeze/src/datasets/transactions.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/freeze/src/datasets/transactions.rs b/crates/freeze/src/datasets/transactions.rs index afec6a29..54f3b8b1 100644 --- a/crates/freeze/src/datasets/transactions.rs +++ b/crates/freeze/src/datasets/transactions.rs @@ -25,6 +25,7 @@ pub struct Transactions { n_input_bytes: Vec, n_input_zero_bytes: Vec, n_input_nonzero_bytes: Vec, + n_rlp_bytes: Vec, block_hash: Vec>, chain_id: Vec, timestamp: Vec, @@ -212,6 +213,7 @@ pub(crate) fn process_transaction( 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, n_rlp_bytes, tx.rlp().len() as u32); 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()));