Skip to content

Commit

Permalink
replaces tables with repeated
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Nov 21, 2024
1 parent f4cadab commit 21e41d6
Show file tree
Hide file tree
Showing 20 changed files with 298 additions and 612 deletions.
1 change: 0 additions & 1 deletion blocks/antelope/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ crate-type = ["cdylib"]
[dependencies]
common = { path = "../../common" }
substreams-antelope = { workspace = true }
substreams-database-change = { workspace = true }
substreams = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
45 changes: 6 additions & 39 deletions blocks/antelope/Makefile
Original file line number Diff line number Diff line change
@@ -1,63 +1,30 @@
.PHONY: all
all:
make build
make pack
make graph
make info

.PHONY: build
build:
cargo build --target wasm32-unknown-unknown --release

.PHONY: pack
pack:
substreams pack

.PHONY: graph
graph:
substreams graph

.PHONY: info
info:
substreams info

.PHONY: run
run:
substreams run -e eos.substreams.pinax.network:443 ch_out -s 386946801 -t 386946802 -o json
substreams graph

.PHONY: gui
gui:
substreams gui -e eos.substreams.pinax.network:443 ch_out -s 386946801 -t 386946802
substreams gui -e eos.substreams.pinax.network:443 map_events -s 386946801 -t 386946802

.PHONY: protogen
protogen:
substreams protogen --exclude-paths google,sf
substreams protogen

.PHONY: parquet-eos
parquet-eos:
substreams-sink-files run eos.substreams.pinax.network:443 substreams.yaml map_events './out' 386841287:386841787 --encoder parquet --file-block-count 100 --development-mode
.PHONY: parquet
parquet:
substreams-sink-files run eos.substreams.pinax.network:443 substreams.yaml map_events './out' 386841287:386841787 --encoder parquet --file-block-count 100 --development-mode

.PHONY: parquet-wax
parquet-wax:
substreams-sink-files run wax.substreams.pinax.network:443 substreams.yaml map_events './out' 32233917:32234417 --encoder parquet --file-block-count 100 --development-mode

# Antelope blocks
.PHONY: sql-run-eos
sql-run-eos:
substreams-sink-sql run clickhouse://default:default@localhost:9000/eos substreams.yaml -e eos.substreams.pinax.network:443 386841287:387014085 --final-blocks-only --undo-buffer-size 1 --on-module-hash-mistmatch=warn --batch-block-flush-interval 1 --development-mode

.PHONY: sql-run-eos-test
sql-run-eos-test:
substreams-sink-sql run clickhouse://default:default@localhost:9000/eos substreams.yaml -e eos.substreams.pinax.network:443 386946800:386946810 --final-blocks-only --undo-buffer-size 1 --on-module-hash-mistmatch=warn --batch-block-flush-interval 1 --development-mode

.PHONY: sql-run-eos-blocks
sql-run-eos-blocks:
substreams-sink-sql run clickhouse://default:default@localhost:9000/eos substreams.yaml -e eos.substreams.pinax.network:443 2: --final-blocks-only --undo-buffer-size 1 --on-module-hash-mistmatch=warn --batch-block-flush-interval 100 --params ch_out=blocks

.PHONY: sql-run-wax
sql-run-wax:
substreams-sink-sql run clickhouse://default:default@localhost:9000/wax substreams.yaml -e wax.substreams.pinax.network:443 322339177:322511977 --final-blocks-only --undo-buffer-size 1 --on-module-hash-mistmatch=warn --batch-block-flush-interval 100 --development-mode

.PHONY: deploy
deploy:
graph build
Expand Down
28 changes: 0 additions & 28 deletions blocks/antelope/src/account_ram_deltas.rs

This file was deleted.

23 changes: 23 additions & 0 deletions blocks/antelope/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,42 @@ pub fn collect_tx_actions(block: &Block, transaction: &TransactionTrace, timesta
let action = trace.action.clone().unwrap_or_default();
let receipt = trace.receipt.clone().unwrap_or_default();

// auth sequence
let auth_sequence = receipt.auth_sequence.iter().map(|seq| seq.sequence).collect::<Vec<u64>>();
let auth_sequence_account_name = receipt.auth_sequence.iter().map(|seq| seq.clone().account_name).collect::<Vec<String>>();

// ram deltas
let account_ram_deltas = trace.account_ram_deltas.iter().map(|account_ram| account_ram.delta).collect::<Vec<i64>>();
let account_ram_deltas_account = trace.account_ram_deltas.iter().map(|account_ram| account_ram.clone().account).collect::<Vec<String>>();

actions.push(Action {
// block
block_time: Some(timestamp.time.clone()),
block_number: timestamp.number,
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// tranasction
tx_hash: transaction.id.clone(),
tx_success,

// receipt
abi_sequence: receipt.abi_sequence,
code_sequence: receipt.code_sequence,
digest: receipt.digest,
global_sequence: receipt.global_sequence,
receipt_receiver: receipt.receiver,
recv_sequence: receipt.recv_sequence,

// auth sequence
auth_sequence,
auth_sequence_account_name,

// account ram deltas
account_ram_deltas,
account_ram_deltas_account,

// action
account: action.account,
name: action.name,
json_data: action.json_data,
Expand Down
30 changes: 0 additions & 30 deletions blocks/antelope/src/auth_sequences.rs

This file was deleted.

75 changes: 0 additions & 75 deletions blocks/antelope/src/authority.rs

This file was deleted.

28 changes: 0 additions & 28 deletions blocks/antelope/src/authorizations.rs

This file was deleted.

15 changes: 10 additions & 5 deletions blocks/antelope/src/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
use crate::{pb::antelope::Block as EventsBlock, size::collect_size};
use crate::{pb::antelope::Block as EventsBlock, size::compute_block_size};
use common::structs::BlockTimestamp;
use substreams::Hex;
use substreams_antelope::Block;

// https://github.com/pinax-network/firehose-antelope/blob/534ca5bf2aeda67e8ef07a1af8fc8e0fe46473ee/proto/sf/antelope/type/v1/type.proto#L21
pub fn collect_block(block: &Block, timestamp: &BlockTimestamp) -> EventsBlock {
let header = block.header.clone().unwrap_or_default();
let header = block.header.as_ref().expect("missing block header");
let blockroot_merkle = block.blockroot_merkle.clone().unwrap_or_default();
let size = collect_size(block);
let size = compute_block_size(block);

EventsBlock {
// clock
time: Some(timestamp.time),
number: timestamp.number,
date: timestamp.date.clone(),
hash: timestamp.hash.clone(),
parent_hash: header.previous,
producer: header.producer,

// block
parent_hash: header.previous.clone(),
producer: header.producer.clone(),
confirmed: header.confirmed,
schedule_version: header.schedule_version,
version: block.version,
Expand All @@ -26,6 +29,8 @@ pub fn collect_block(block: &Block, timestamp: &BlockTimestamp) -> EventsBlock {
action_mroot: Hex::encode(&header.action_mroot.to_vec()),
blockroot_merkle_active_nodes: blockroot_merkle.active_nodes.iter().map(|row| Hex::encode(row)).collect::<Vec<String>>(),
blockroot_merkle_node_count: blockroot_merkle.node_count,

// counters
size: size.size,
total_transactions: size.total_transactions,
successful_transactions: size.successful_transactions,
Expand Down
22 changes: 0 additions & 22 deletions blocks/antelope/src/creation_tree.rs

This file was deleted.

5 changes: 5 additions & 0 deletions blocks/antelope/src/db_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ pub fn collect_tx_db_ops(transaction: &TransactionTrace, timestamp: &BlockTimest

for (index, db_op) in transaction.db_ops.iter().enumerate() {
db_ops.push(DbOp {
// block
block_time: Some(timestamp.time.clone()),
block_number: timestamp.number,
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// transaction
tx_hash: transaction.id.clone(),
tx_success,

// database operation
index: index as u32,
operation: operation_to_string(db_op.operation),
operation_code: db_op.operation as u32,
Expand Down
Loading

0 comments on commit 21e41d6

Please sign in to comment.