Skip to content

Commit

Permalink
update schema sql
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Jul 25, 2024
1 parent 3a3d582 commit 01b7616
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 67 deletions.
8 changes: 8 additions & 0 deletions blocks/evm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ run:
gui:
substreams gui -e eth.substreams.pinax.network:443 ch_out -s 20000000 -t 20000010

.PHONY: sql-setup
sql-setup:
substreams-sink-sql setup clickhouse://default:default@localhost:9000/default substreams.yaml

.PHONY: sql-run
sql-run:
substreams-sink-sql run clickhouse://default:default@localhost:9000/default substreams.yaml -e eth.substreams.pinax.network:443 1:10000 --final-blocks-only --undo-buffer-size 1000 --plaintext

.PHONY: deploy
deploy:
graph build
Expand Down
59 changes: 59 additions & 0 deletions blocks/evm/schema-temp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

CREATE TABLE IF NOT EXISTS calls
(
block_hash String,
block_num UInt64,
timestamp DateTime,
tx_index UInt32,
tx_hash String,
index UInt32,
parent_index UInt32,
depth UInt32,
caller String,
address String,
value Float64,
gas_limit UInt64,
gas_consumed UInt64,
return_data String,
input String,
selfdestruct UInt8,
executed_code UInt8,
begin_ordinal UInt64,
end_ordinal UInt64
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (tx_hash, index)
ORDER BY (tx_hash, index);

CREATE TABLE IF NOT EXISTS transactions
(
block_hash String,
block_num UInt64,
timestamp DateTime,
tx_index UInt32,
tx_hash String,
to String,
nonce UInt64,
gas_price Float64,
gas_limit UInt64,
value Float64,
input String,
v String,
r String,
s String,
gas_used UInt64,
type Int32,
max_fee_per_gas Float64,
max_priority_fee_per_gas Float64,
from String,
return_data String,
public_key String,
begin_ordinal UInt64,
end_ordinal UInt64
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (tx_hash)
ORDER BY (tx_hash);

-- trace_type
-- status
69 changes: 5 additions & 64 deletions blocks/evm/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS blocks
receipts_root String,
miner String,
difficulty Int64,
total_difficulty Decimal(38, 0),
total_difficulty Int128,
size String,
mix_hash String,
extra_data String,
Expand All @@ -41,8 +41,8 @@ CREATE TABLE IF NOT EXISTS blocks
parent_beacon_root String
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (hash)
ORDER BY (hash);
PRIMARY KEY (date, time, number, hash)
ORDER BY (date, time, number, hash);

CREATE TABLE IF NOT EXISTS logs
(
Expand All @@ -54,9 +54,9 @@ CREATE TABLE IF NOT EXISTS logs
topic1 String,
topic2 String,
topic3 String,
data String
data String,
tx_hash String,
index UInt32,
log_index UInt32,
tx_index UInt32,
block_date Date,
tx_from String,
Expand All @@ -66,62 +66,3 @@ CREATE TABLE IF NOT EXISTS logs
ENGINE = ReplacingMergeTree()
PRIMARY KEY (tx_hash, log_index)
ORDER BY (tx_hash, log_index);

CREATE TABLE IF NOT EXISTS calls
(
block_hash String,
block_num UInt64,
timestamp DateTime,
tx_index UInt32,
tx_hash String,
index UInt32,
parent_index UInt32,
depth UInt32,
caller String,
address String,
value Float64,
gas_limit UInt64,
gas_consumed UInt64,
return_data String,
input String,
selfdestruct UInt8,
executed_code UInt8,
begin_ordinal UInt64,
end_ordinal UInt64
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (tx_hash, index)
ORDER BY (tx_hash, index);

CREATE TABLE IF NOT EXISTS transactions
(
block_hash String,
block_num UInt64,
timestamp DateTime,
tx_index UInt32,
tx_hash String,
to String,
nonce UInt64,
gas_price Float64,
gas_limit UInt64,
value Float64,
input String,
v String,
r String,
s String,
gas_used UInt64,
type Int32,
max_fee_per_gas Float64,
max_priority_fee_per_gas Float64,
from String,
return_data String,
public_key String,
begin_ordinal UInt64,
end_ordinal UInt64
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (tx_hash)
ORDER BY (tx_hash);

-- trace_type
-- status
3 changes: 2 additions & 1 deletion blocks/evm/substreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package:
doc: Raw Blocks for EVM

imports:
entities: https://github.com/streamingfast/substreams-sink-entity-changes/releases/download/v1.3.2/substreams-sink-entity-changes-v1.3.2.spkg
database_change: https://github.com/streamingfast/substreams-sink-database-changes/releases/download/v1.3.1/substreams-database-change-v1.3.1.spkg
sql: https://github.com/streamingfast/substreams-sink-sql/releases/download/protodefs-v1.0.7/substreams-sink-sql-protodefs-v1.0.7.spkg

Expand All @@ -24,6 +23,8 @@ modules:
output:
type: proto:sf.substreams.sink.database.v1.DatabaseChanges

network: mainnet

sink:
module: ch_out
type: sf.substreams.sink.sql.v1.Service
Expand Down
4 changes: 2 additions & 2 deletions common/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pub fn block_keys(clock: &Clock) -> HashMap<String, String> {
let block_date = block_time_to_date(block_time.as_str()).to_string();

HashMap::from([
("block_date".to_string(), block_date),
("block_time".to_string(), block_time),
("block_number".to_string(), block_number),
("block_hash".to_string(), block_hash),
("block_date".to_string(), block_date)
("block_hash".to_string(), block_hash)
])
}

0 comments on commit 01b7616

Please sign in to comment.