From 0d471845a14f9aa29dfc9df58ef2c2d1a87f8e39 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Tue, 29 Aug 2023 23:52:55 -0700 Subject: [PATCH 1/5] initial u256 conversions commit --- crates/cli/src/args.rs | 5 +++++ crates/freeze/src/datasets/balance_diffs.rs | 4 ++-- .../freeze/src/datasets/native_transfers.rs | 2 +- crates/freeze/src/datasets/traces.rs | 2 +- crates/freeze/src/datasets/transactions.rs | 4 +--- crates/freeze/src/types/schemas.rs | 21 ++++++++++++++++++- crates/python/src/collect_adapter.rs | 3 +++ crates/python/src/freeze_adapter.rs | 3 +++ 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/crates/cli/src/args.rs b/crates/cli/src/args.rs index 90b7b19f..cbebfaae 100644 --- a/crates/cli/src/args.rs +++ b/crates/cli/src/args.rs @@ -53,6 +53,11 @@ pub struct Args { #[arg(long, value_name="COLS", num_args(0..), verbatim_doc_comment, help_heading="Content Options")] pub columns: Option>, + /// Set output datatype(s) of U256 integers + /// [default: binary, string, f64] + #[arg(long, help_heading = "Content Options", verbatim_doc_comment)] + pub u256_types: Option>, + /// Use hex string encoding for binary columns #[arg(long, help_heading = "Content Options")] pub hex: bool, diff --git a/crates/freeze/src/datasets/balance_diffs.rs b/crates/freeze/src/datasets/balance_diffs.rs index a7962045..7809f25b 100644 --- a/crates/freeze/src/datasets/balance_diffs.rs +++ b/crates/freeze/src/datasets/balance_diffs.rs @@ -24,8 +24,8 @@ impl Dataset for BalanceDiffs { ("transaction_index", ColumnType::Binary), ("transaction_hash", ColumnType::Binary), ("address", ColumnType::Binary), - ("from_value", ColumnType::Binary), - ("to_value", ColumnType::Binary), + ("from_value", ColumnType::UInt256), + ("to_value", ColumnType::UInt256), ("chain_id", ColumnType::UInt64), ]) } diff --git a/crates/freeze/src/datasets/native_transfers.rs b/crates/freeze/src/datasets/native_transfers.rs index 5b9ed8c4..94115477 100644 --- a/crates/freeze/src/datasets/native_transfers.rs +++ b/crates/freeze/src/datasets/native_transfers.rs @@ -31,7 +31,7 @@ impl Dataset for NativeTransfers { ("transaction_hash", ColumnType::Binary), ("from_address", ColumnType::Binary), ("to_address", ColumnType::Binary), - ("value", ColumnType::Binary), + ("value", ColumnType::UInt256), ("chain_id", ColumnType::UInt64), ]) } diff --git a/crates/freeze/src/datasets/traces.rs b/crates/freeze/src/datasets/traces.rs index efa136ee..b7b33786 100644 --- a/crates/freeze/src/datasets/traces.rs +++ b/crates/freeze/src/datasets/traces.rs @@ -27,7 +27,7 @@ impl Dataset for Traces { HashMap::from_iter(vec![ ("action_from", ColumnType::Binary), ("action_to", ColumnType::Binary), - ("action_value", ColumnType::String), + ("action_value", ColumnType::UInt256), ("action_gas", ColumnType::UInt32), ("action_input", ColumnType::Binary), ("action_call_type", ColumnType::String), diff --git a/crates/freeze/src/datasets/transactions.rs b/crates/freeze/src/datasets/transactions.rs index c42bece8..67a788f7 100644 --- a/crates/freeze/src/datasets/transactions.rs +++ b/crates/freeze/src/datasets/transactions.rs @@ -28,9 +28,7 @@ impl Dataset for Transactions { ("nonce", ColumnType::Int32), ("from_address", ColumnType::Binary), ("to_address", ColumnType::Binary), - ("value", ColumnType::Decimal128), - ("value_str", ColumnType::String), - ("value_float", ColumnType::Float64), + ("value", ColumnType::UInt256), ("input", ColumnType::Binary), ("gas_limit", ColumnType::UInt32), ("gas_used", ColumnType::UInt32), diff --git a/crates/freeze/src/types/schemas.rs b/crates/freeze/src/types/schemas.rs index 83cbb5ff..42901c81 100644 --- a/crates/freeze/src/types/schemas.rs +++ b/crates/freeze/src/types/schemas.rs @@ -15,6 +15,12 @@ pub struct Table { /// sort order for rows pub sort_columns: Option>, + + /// representations to use for u256 columns + pub u256_types: HashSet, + + /// representation to use for binary columns + pub binary_type: ColumnEncoding, } impl Table { @@ -34,6 +40,16 @@ impl Table { } } +#[derive(Hash, Clone, Debug, Eq, PartialEq)] +pub enum U256Type { + Binary, + String, + F64, + Decimal128, + U64High, + U64Low, +} + /// datatype of column #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum ColumnType { @@ -41,6 +57,8 @@ pub enum ColumnType { UInt32, /// UInt64 column type UInt64, + /// U256 column type + UInt256, /// Int32 column type Int32, /// Int64 column type @@ -63,6 +81,7 @@ impl ColumnType { match *self { ColumnType::UInt32 => "uint32", ColumnType::UInt64 => "uint64", + ColumnType::UInt256 => "uint256", ColumnType::Int32 => "int32", ColumnType::Int64 => "int64", ColumnType::Float64 => "float64", @@ -104,7 +123,7 @@ impl Datatype { } columns.insert((*column.clone()).to_string(), *ctype); } - let schema = Table { datatype: *self, sort_columns: sort, columns }; + let schema = Table { datatype: *self, sort_columns: sort, columns, u256_types: u256_types, binary_type: ColumnEncoding }; Ok(schema) } } diff --git a/crates/python/src/collect_adapter.rs b/crates/python/src/collect_adapter.rs index a09176dd..75f9e204 100644 --- a/crates/python/src/collect_adapter.rs +++ b/crates/python/src/collect_adapter.rs @@ -16,6 +16,7 @@ use cryo_freeze::collect; include_columns = None, exclude_columns = None, columns = None, + u256_types = None, hex = false, sort = None, rpc = None, @@ -57,6 +58,7 @@ pub fn _collect( include_columns: Option>, exclude_columns: Option>, columns: Option>, + u256_types: Option>, hex: bool, sort: Option>, rpc: Option, @@ -95,6 +97,7 @@ pub fn _collect( include_columns, exclude_columns, columns, + u256_types, hex, sort, rpc, diff --git a/crates/python/src/freeze_adapter.rs b/crates/python/src/freeze_adapter.rs index 85a9c161..cdf2a75a 100644 --- a/crates/python/src/freeze_adapter.rs +++ b/crates/python/src/freeze_adapter.rs @@ -17,6 +17,7 @@ use cryo_cli::{run, Args}; include_columns = None, exclude_columns = None, columns = None, + u256_types = None, hex = false, sort = None, rpc = None, @@ -58,6 +59,7 @@ pub fn _freeze( include_columns: Option>, exclude_columns: Option>, columns: Option>, + u256_types: Option>, hex: bool, sort: Option>, rpc: Option, @@ -96,6 +98,7 @@ pub fn _freeze( include_columns, exclude_columns, columns, + u256_types, hex, sort, rpc, From ed390ad14f93980782557c96a73a074b432b15e4 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 30 Aug 2023 01:03:08 -0700 Subject: [PATCH 2/5] basic u256 input parsing --- crates/cli/src/parse/query.rs | 28 +++++++++++++++++++++++++++- crates/freeze/src/types/files.rs | 2 +- crates/freeze/src/types/mod.rs | 2 +- crates/freeze/src/types/schemas.rs | 16 +++++++++++++++- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/crates/cli/src/parse/query.rs b/crates/cli/src/parse/query.rs index 4504822b..7e44025b 100644 --- a/crates/cli/src/parse/query.rs +++ b/crates/cli/src/parse/query.rs @@ -1,4 +1,7 @@ -use std::{collections::HashMap, sync::Arc}; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; use ethers::prelude::*; use hex::FromHex; @@ -7,6 +10,7 @@ use cryo_freeze::{ColumnEncoding, Datatype, FileFormat, MultiQuery, ParseError, use super::{blocks, file_output, transactions}; use crate::args::Args; +use cryo_freeze::U256Type; pub(crate) async fn parse_query( args: &Args, @@ -81,6 +85,27 @@ fn parse_datatypes(raw_inputs: &Vec) -> Result, ParseError fn parse_schemas(args: &Args) -> Result, ParseError> { let datatypes = parse_datatypes(&args.datatype)?; let output_format = file_output::parse_output_format(args)?; + + let u256_types = if let Some(raw_u256_types) = &args.u256_types { + let mut u256_types: HashSet = HashSet::new(); + for raw in raw_u256_types.iter() { + // let g: f64 = raw; + let u256_type = match raw.to_lowercase() { + raw if raw == "binary" => U256Type::Binary, + raw if raw == "string" => U256Type::String, + raw if raw == "str" => U256Type::String, + raw if raw == "f64" => U256Type::F64, + raw if raw == "float" => U256Type::F64, + raw if raw == "float64" => U256Type::F64, + raw if raw == "decimal128" => U256Type::Decimal128, + _ => return Err(ParseError::ParseError("bad u256 type".to_string())), + }; + u256_types.insert(u256_type); + } + u256_types + } else { + HashSet::from_iter(vec![U256Type::Binary, U256Type::String, U256Type::F64]) + }; let binary_column_format = match args.hex | (output_format != FileFormat::Parquet) { true => ColumnEncoding::Hex, false => ColumnEncoding::Binary, @@ -92,6 +117,7 @@ fn parse_schemas(args: &Args) -> Result, ParseError> { .map(|datatype| { datatype .table_schema( + &u256_types, &binary_column_format, &args.include_columns, &args.exclude_columns, diff --git a/crates/freeze/src/types/files.rs b/crates/freeze/src/types/files.rs index bb6ec00e..17f09f89 100644 --- a/crates/freeze/src/types/files.rs +++ b/crates/freeze/src/types/files.rs @@ -44,7 +44,7 @@ impl FileFormat { } /// Encoding for binary data in a column -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone, Eq, PartialEq, Debug)] pub enum ColumnEncoding { /// Raw binary encoding Binary, diff --git a/crates/freeze/src/types/mod.rs b/crates/freeze/src/types/mod.rs index 0d369f8e..a1dfcc82 100644 --- a/crates/freeze/src/types/mod.rs +++ b/crates/freeze/src/types/mod.rs @@ -29,7 +29,7 @@ pub use conversions::{ToVecHex, ToVecU8}; pub use datatypes::*; pub use files::{ColumnEncoding, FileFormat, FileOutput}; pub use queries::{MultiQuery, RowFilter, SingleQuery}; -pub use schemas::{ColumnType, Table}; +pub use schemas::{ColumnType, Table, U256Type}; pub use sources::{RateLimiter, Source}; pub(crate) use summaries::FreezeSummaryAgg; pub use summaries::{FreezeChunkSummary, FreezeSummary}; diff --git a/crates/freeze/src/types/schemas.rs b/crates/freeze/src/types/schemas.rs index 42901c81..9038598d 100644 --- a/crates/freeze/src/types/schemas.rs +++ b/crates/freeze/src/types/schemas.rs @@ -40,13 +40,20 @@ impl Table { } } +/// representation of a U256 datum #[derive(Hash, Clone, Debug, Eq, PartialEq)] pub enum U256Type { + /// Binary representation Binary, + /// String representation String, + /// F64 representation F64, + /// Decimal128 representation Decimal128, + /// U64High representation U64High, + /// U64Low representation U64Low, } @@ -105,6 +112,7 @@ impl Datatype { /// get schema for a particular datatype pub fn table_schema( &self, + u256_types: &HashSet, binary_column_format: &ColumnEncoding, include_columns: &Option>, exclude_columns: &Option>, @@ -123,7 +131,13 @@ impl Datatype { } columns.insert((*column.clone()).to_string(), *ctype); } - let schema = Table { datatype: *self, sort_columns: sort, columns, u256_types: u256_types, binary_type: ColumnEncoding }; + let schema = Table { + datatype: *self, + sort_columns: sort, + columns, + u256_types: u256_types.clone(), + binary_type: binary_column_format.clone(), + }; Ok(schema) } } From a5c7b73f8a3231bc37d97ca4ada747f354bc6247 Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 30 Aug 2023 15:15:52 -0700 Subject: [PATCH 3/5] display u256 conversions in print_schema() --- crates/cli/src/summaries.rs | 15 +++++++++++--- crates/freeze/src/types/schemas.rs | 33 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/summaries.rs b/crates/cli/src/summaries.rs index 20521fbb..c83dde80 100644 --- a/crates/cli/src/summaries.rs +++ b/crates/cli/src/summaries.rs @@ -6,8 +6,8 @@ use std::time::SystemTime; use thousands::Separable; use cryo_freeze::{ - BlockChunk, Chunk, ChunkData, Datatype, FileOutput, FreezeSummary, MultiQuery, Source, Table, - TransactionChunk, + BlockChunk, Chunk, ChunkData, ColumnType, Datatype, FileOutput, FreezeSummary, MultiQuery, + Source, Table, TransactionChunk, }; const TITLE_R: u8 = 0; @@ -123,7 +123,16 @@ fn print_schema(name: &Datatype, schema: &Table) { print_header("schema for ".to_string() + name.dataset().name()); for column in schema.columns() { if let Some(column_type) = schema.column_type(column) { - print_bullet(column, column_type.as_str()); + if column_type == ColumnType::UInt256 { + for uint256_type in schema.u256_types.iter() { + print_bullet( + column.to_owned() + uint256_type.suffix().as_str(), + uint256_type.to_columntype().as_str(), + ); + } + } else { + print_bullet(column, column_type.as_str()); + } } } println!(); diff --git a/crates/freeze/src/types/schemas.rs b/crates/freeze/src/types/schemas.rs index 9038598d..62940bae 100644 --- a/crates/freeze/src/types/schemas.rs +++ b/crates/freeze/src/types/schemas.rs @@ -47,6 +47,8 @@ pub enum U256Type { Binary, /// String representation String, + /// F32 representation + F32, /// F64 representation F64, /// Decimal128 representation @@ -57,6 +59,34 @@ pub enum U256Type { U64Low, } +impl U256Type { + /// convert U256Type to Columntype + pub fn to_columntype(&self) -> ColumnType { + match self { + U256Type::Binary => ColumnType::Binary, + U256Type::String => ColumnType::String, + U256Type::F32 => ColumnType::Float32, + U256Type::F64 => ColumnType::Float64, + U256Type::Decimal128 => ColumnType::Decimal128, + U256Type::U64High => ColumnType::UInt64, + U256Type::U64Low => ColumnType::UInt64, + } + } + + /// get column name suffix of U256Type + pub fn suffix(&self) -> String { + match self { + U256Type::Binary => "_binary".to_string(), + U256Type::String => "_string".to_string(), + U256Type::F32 => "_f32".to_string(), + U256Type::F64 => "_f64".to_string(), + U256Type::U64High => "_u64_high".to_string(), + U256Type::U64Low => "_u64_low".to_string(), + U256Type::Decimal128 => "_decimal128".to_string(), + } + } +} + /// datatype of column #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum ColumnType { @@ -70,6 +100,8 @@ pub enum ColumnType { Int32, /// Int64 column type Int64, + /// Float32 column type + Float32, /// Float64 column type Float64, /// Decimal128 column type @@ -91,6 +123,7 @@ impl ColumnType { ColumnType::UInt256 => "uint256", ColumnType::Int32 => "int32", ColumnType::Int64 => "int64", + ColumnType::Float32 => "float32", ColumnType::Float64 => "float64", ColumnType::Decimal128 => "decimal128", ColumnType::String => "string", From bf048232f70d290ea4b5634ab08c78a2ab970c5b Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 30 Aug 2023 16:33:25 -0700 Subject: [PATCH 4/5] add raw data conversions from u256 --- crates/cli/src/args.rs | 2 +- crates/cli/src/parse/query.rs | 10 ++- crates/freeze/src/datasets/blocks.rs | 10 +-- .../freeze/src/types/dataframes/creation.rs | 73 +++++++++++++++++++ crates/freeze/src/types/schemas.rs | 18 ++--- 5 files changed, 96 insertions(+), 17 deletions(-) diff --git a/crates/cli/src/args.rs b/crates/cli/src/args.rs index cbebfaae..a35a13cc 100644 --- a/crates/cli/src/args.rs +++ b/crates/cli/src/args.rs @@ -55,7 +55,7 @@ pub struct Args { /// Set output datatype(s) of U256 integers /// [default: binary, string, f64] - #[arg(long, help_heading = "Content Options", verbatim_doc_comment)] + #[arg(long, num_args(1..), help_heading = "Content Options", verbatim_doc_comment)] pub u256_types: Option>, /// Use hex string encoding for binary columns diff --git a/crates/cli/src/parse/query.rs b/crates/cli/src/parse/query.rs index 7e44025b..a0700676 100644 --- a/crates/cli/src/parse/query.rs +++ b/crates/cli/src/parse/query.rs @@ -89,15 +89,21 @@ fn parse_schemas(args: &Args) -> Result, ParseError> { let u256_types = if let Some(raw_u256_types) = &args.u256_types { let mut u256_types: HashSet = HashSet::new(); for raw in raw_u256_types.iter() { - // let g: f64 = raw; let u256_type = match raw.to_lowercase() { raw if raw == "binary" => U256Type::Binary, raw if raw == "string" => U256Type::String, raw if raw == "str" => U256Type::String, + raw if raw == "f32" => U256Type::F32, + raw if raw == "float32" => U256Type::F32, raw if raw == "f64" => U256Type::F64, - raw if raw == "float" => U256Type::F64, raw if raw == "float64" => U256Type::F64, + raw if raw == "float" => U256Type::F64, + raw if raw == "u32" => U256Type::U32, + raw if raw == "uint32" => U256Type::U32, + raw if raw == "u64" => U256Type::U64, + raw if raw == "uint64" => U256Type::U64, raw if raw == "decimal128" => U256Type::Decimal128, + raw if raw == "d128" => U256Type::Decimal128, _ => return Err(ParseError::ParseError("bad u256 type".to_string())), }; u256_types.insert(u256_type); diff --git a/crates/freeze/src/datasets/blocks.rs b/crates/freeze/src/datasets/blocks.rs index 3856b53f..13c09436 100644 --- a/crates/freeze/src/datasets/blocks.rs +++ b/crates/freeze/src/datasets/blocks.rs @@ -9,9 +9,9 @@ use crate::{ types::{ conversions::{ToVecHex, ToVecU8}, BlockChunk, Blocks, CollectError, ColumnType, Dataset, Datatype, RowFilter, Source, Table, - TransactionChunk, + TransactionChunk, U256Type, }, - with_series, with_series_binary, + with_series, with_series_binary, with_series_u256, }; pub(crate) type BlockTxGasTuple = Result<(Block, Option>), CollectError>; @@ -321,7 +321,7 @@ pub(crate) struct TransactionColumns { nonce: Vec, from_address: Vec>, to_address: Vec>>, - value: Vec, + value: Vec, input: Vec>, gas_limit: Vec, gas_used: Vec, @@ -364,7 +364,7 @@ impl TransactionColumns { with_series!(cols, "nonce", self.nonce, schema); with_series_binary!(cols, "from_address", self.from_address, schema); with_series_binary!(cols, "to_address", self.to_address, schema); - with_series!(cols, "value", self.value, schema); + with_series_u256!(cols, "value", self.value, schema); with_series_binary!(cols, "input", self.input, schema); with_series!(cols, "gas_limit", self.gas_limit, schema); with_series!(cols, "gas_used", self.gas_used, schema); @@ -471,7 +471,7 @@ fn process_transaction( columns.nonce.push(tx.nonce.as_u64()); } if schema.has_column("value") { - columns.value.push(tx.value.to_string()); + columns.value.push(tx.value); } if schema.has_column("input") { columns.input.push(tx.input.to_vec()); diff --git a/crates/freeze/src/types/dataframes/creation.rs b/crates/freeze/src/types/dataframes/creation.rs index 0f099e6c..a239e7e8 100644 --- a/crates/freeze/src/types/dataframes/creation.rs +++ b/crates/freeze/src/types/dataframes/creation.rs @@ -21,3 +21,76 @@ macro_rules! with_series_binary { } }; } + +/// convert a Vec to variety of u256 Series representations +#[macro_export] +macro_rules! with_series_u256 { + ($all_series:expr, $name:expr, $value:expr, $schema:expr) => { + if $schema.has_column($name) { + // binary + if $schema.u256_types.contains(&U256Type::Binary) { + let name = $name.to_string() + U256Type::Binary.suffix().as_str(); + let name = name.as_str(); + + let converted: Vec> = $value.iter().map(|v| v.to_vec_u8()).collect(); + if let Some(ColumnType::Hex) = $schema.column_type($name) { + $all_series.push(Series::new(name, converted.to_vec_hex())); + } else { + $all_series.push(Series::new(name, converted)); + } + } + + // string + if $schema.u256_types.contains(&U256Type::String) { + let name = $name.to_string() + U256Type::String.suffix().as_str(); + let name = name.as_str(); + + let converted: Vec = $value.iter().map(|v| v.to_string()).collect(); + $all_series.push(Series::new(name, converted)); + } + + // float32 + if $schema.u256_types.contains(&U256Type::F32) { + let name = $name.to_string() + U256Type::F32.suffix().as_str(); + let name = name.as_str(); + + let converted: Vec> = + $value.iter().map(|v| v.to_string().parse::().ok()).collect(); + $all_series.push(Series::new(name, converted)); + } + + // float64 + if $schema.u256_types.contains(&U256Type::F64) { + let name = $name.to_string() + U256Type::F64.suffix().as_str(); + let name = name.as_str(); + + let converted: Vec> = + $value.iter().map(|v| v.to_string().parse::().ok()).collect(); + $all_series.push(Series::new(name, converted)); + } + + // u32 + if $schema.u256_types.contains(&U256Type::U32) { + let name = $name.to_string() + U256Type::U32.suffix().as_str(); + let name = name.as_str(); + + let converted: Vec = $value.iter().map(|v| v.as_u32()).collect(); + $all_series.push(Series::new(name, converted)); + } + + // u64 + if $schema.u256_types.contains(&U256Type::U64) { + let name = $name.to_string() + U256Type::U64.suffix().as_str(); + let name = name.as_str(); + + let converted: Vec = $value.iter().map(|v| v.as_u64()).collect(); + $all_series.push(Series::new(name, converted)); + } + + // decimal128 + if $schema.u256_types.contains(&U256Type::Decimal128) { + panic!("DECIMAL128 not implemented") + } + } + }; +} diff --git a/crates/freeze/src/types/schemas.rs b/crates/freeze/src/types/schemas.rs index 62940bae..2fbc3826 100644 --- a/crates/freeze/src/types/schemas.rs +++ b/crates/freeze/src/types/schemas.rs @@ -51,12 +51,12 @@ pub enum U256Type { F32, /// F64 representation F64, + /// U32 representation + U32, + /// U64 representation + U64, /// Decimal128 representation Decimal128, - /// U64High representation - U64High, - /// U64Low representation - U64Low, } impl U256Type { @@ -67,9 +67,9 @@ impl U256Type { U256Type::String => ColumnType::String, U256Type::F32 => ColumnType::Float32, U256Type::F64 => ColumnType::Float64, + U256Type::U32 => ColumnType::UInt32, + U256Type::U64 => ColumnType::UInt64, U256Type::Decimal128 => ColumnType::Decimal128, - U256Type::U64High => ColumnType::UInt64, - U256Type::U64Low => ColumnType::UInt64, } } @@ -80,9 +80,9 @@ impl U256Type { U256Type::String => "_string".to_string(), U256Type::F32 => "_f32".to_string(), U256Type::F64 => "_f64".to_string(), - U256Type::U64High => "_u64_high".to_string(), - U256Type::U64Low => "_u64_low".to_string(), - U256Type::Decimal128 => "_decimal128".to_string(), + U256Type::U32 => "_u32".to_string(), + U256Type::U64 => "_u64".to_string(), + U256Type::Decimal128 => "_d128".to_string(), } } } From 1e30664a0f983af605ca555499263e63ae23d91c Mon Sep 17 00:00:00 2001 From: sslivkoff Date: Wed, 30 Aug 2023 16:35:27 -0700 Subject: [PATCH 5/5] update readme to reflect possible u256 conversions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d357f3a3..e91c8ed1 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ An attempt is made to ensure that the dataset schemas conform to a common set of - By default, rows should contain enough information be order-able - Columns should be named by their JSON-RPC or ethers.rs defaults, except in cases where a much more explicit name is available - To make joins across tables easier, a given piece of information should use the same datatype and column name across tables when possible -- Large ints such as `u256` should allow multiple conversions. A `value` column of type `u256` should allow: `value_binary`, `value_string`, `value_f64`, `value_decimal128`, `value_u64_high`, and `value_u64_low` +- Large ints such as `u256` should allow multiple conversions. A `value` column of type `u256` should allow: `value_binary`, `value_string`, `value_f32`, `value_f64`, `value_u32`, `value_u64`, and `value_d128` - By default, columns related to non-identifying cryptographic signatures are omitted by default. For example, `state_root` of a block or `v`/`r`/`s` of a transaction - Integer values that can never be negative should be stored as unsigned integers