diff --git a/blocks/cosmos/Cargo.toml b/blocks/cosmos/Cargo.toml index 8380ade..5b94b62 100644 --- a/blocks/cosmos/Cargo.toml +++ b/blocks/cosmos/Cargo.toml @@ -9,7 +9,6 @@ crate-type = ["cdylib"] [dependencies] common = { path = "../../common" } substreams-cosmos = { workspace = true } -substreams-database-change = { workspace = true } substreams = { workspace = true } sha2 = "0.10.8" serde_json = { workspace = true } diff --git a/blocks/cosmos/Makefile b/blocks/cosmos/Makefile index 244a234..4697d7e 100644 --- a/blocks/cosmos/Makefile +++ b/blocks/cosmos/Makefile @@ -8,31 +8,17 @@ all: .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 substreams.yaml -e mainnet.injective.streamingfast.io:443 map_events -s 80000000 -o json - .PHONY: gui gui: substreams gui substreams.yaml -e mainnet.injective.streamingfast.io:443 map_events -s 80000000 - .PHONY: protogen protogen: - substreams protogen --exclude-paths google,sf + substreams protogen .PHONY: parquet parquet: diff --git a/blocks/cosmos/README.md b/blocks/cosmos/README.md index 2b01a94..f72aa9c 100644 --- a/blocks/cosmos/README.md +++ b/blocks/cosmos/README.md @@ -13,17 +13,23 @@ - [x] **Validator Updates** - [x] **Consensus Param Updates** +## Graph + ```mermaid graph TD; - raw[sf.cosmos.type.v2.Block]; - raw --> blocks; - raw --> transactions; - raw --> transaction_messages; - raw --> events; - raw --> misbehaviors; - raw --> validator_updates; - raw --> consensus_param_updates; - - events --> block_events; - events --> transaction_events; + map_events[map: map_events]; + sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> map_events; + sf.cosmos.type.v2.Block[source: sf.cosmos.type.v2.Block] --> map_events; +``` + +## Modules + +```bash +Name: map_events +Initial block: 0 +Kind: map +Input: source: sf.substreams.v1.Clock +Input: source: sf.cosmos.type.v2.Block +Output Type: proto:cosmos.Events +Hash: def06497ee4c721b6799dc719ea4240c887cb48c ``` diff --git a/blocks/cosmos/proto/cosmos.rawblocks.proto b/blocks/cosmos/proto/cosmos.rawblocks.proto deleted file mode 100644 index 36835f0..0000000 --- a/blocks/cosmos/proto/cosmos.rawblocks.proto +++ /dev/null @@ -1,122 +0,0 @@ -syntax = "proto3"; - -package cosmos.rawblocks; - -import "google/protobuf/timestamp.proto"; - -message Events { - repeated Block blocks = 1; - repeated Transaction transactions = 2; - repeated TransactionEvent transaction_events = 3; - repeated BlockEvent block_events = 4; - repeated Misbehavior misbehaviors = 5; - repeated ValidatorUpdate validator_updates = 6; - repeated ConsensusParamUpdate consensus_param_updates = 7; - repeated TransactionMessage transaction_messages = 8; -} - -message Block { - google.protobuf.Timestamp time = 1; - uint64 number = 2; - string date = 3; - string hash = 4; - uint64 version_consensus_block = 5; - uint64 version_consensus_app = 6; - string chain_id = 7; - string last_block_id = 8; - string last_commit_hash = 9; - string data_hash = 10; - string validators_hash = 11; - string next_validators_hash = 12; - string consensus_hash = 13; - string app_hash = 14; - string last_results_hash = 15; - string evidence_hash = 16; - string proposer_address = 17; - uint64 total_transactions = 18; - uint64 successful_transactions = 19; - uint64 failed_transactions = 20; -} - -message Transaction { - google.protobuf.Timestamp block_time = 1; - uint64 block_number = 2; - string block_date = 3; - string block_hash = 4; - uint32 index = 5; - string hash = 6; - uint32 code = 7; - string data = 8; - string log = 9; - string info = 10; - int64 gas_wanted = 11; - int64 gas_used = 12; - string codespace = 13; -} - -message TransactionEvent { - google.protobuf.Timestamp block_time = 1; - uint64 block_number = 2; - string block_date = 3; - string block_hash = 4; - string tx_hash = 5; - uint32 index = 6; - string type = 7; - // Should be Array(Tuple(Text, Text)) when supported by sink-files - string attributes = 8; -} - -message BlockEvent { - google.protobuf.Timestamp block_time = 1; - uint64 block_number = 2; - string block_date = 3; - string block_hash = 4; - uint32 index = 5; - string type = 6; - string attributes = 7; -} - - -message Misbehavior { - google.protobuf.Timestamp block_time = 1; - uint64 block_number = 2; - string block_date = 3; - string block_hash = 4; - uint32 index = 5; - string type = 6; - string validator_address = 7; - int64 validator_power = 8; - int64 height = 9; - google.protobuf.Timestamp time = 10; - int64 total_voting_power = 11; -} - -message ValidatorUpdate { - google.protobuf.Timestamp block_time = 1; - uint64 block_number = 2; - string block_date = 3; - string block_hash = 4; - uint32 index = 5; - string public_key = 6; - int64 power = 7; -} - -message ConsensusParamUpdate { - google.protobuf.Timestamp block_time = 1; - uint64 block_number = 2; - string block_date = 3; - string block_hash = 4; - string json = 5; -} - -message TransactionMessage { - google.protobuf.Timestamp block_time = 1; - uint64 block_number = 2; - string block_date = 3; - string block_hash = 4; - string tx_hash = 5; - uint32 index = 6; - string type = 7; - string value = 8; -} - diff --git a/blocks/cosmos/schema.sql b/blocks/cosmos/schema.sql deleted file mode 100644 index 952154d..0000000 --- a/blocks/cosmos/schema.sql +++ /dev/null @@ -1,207 +0,0 @@ -CREATE TABLE IF NOT EXISTS cursors -( - id String, - cursor String, - block_num Int64, - block_id String -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (id) - ORDER BY (id); - -CREATE TABLE IF NOT EXISTS blocks -( - -- clock -- - time DateTime64(3, 'UTC'), - number UInt64, - date Date, - hash String COMMENT 'Cosmos Hash', - - -- header -- - version_consensus_block UInt64, - version_consensus_app UInt64, - chain_id String, - last_block_id String, - last_commit_hash String, - data_hash String, - validators_hash String, - next_validators_hash String, - consensus_hash String, - app_hash String, - last_results_hash String, - evidence_hash String, - proposer_address String, - - -- counters -- - total_transactions UInt64, - successful_transactions UInt64, - failed_transactions UInt64, -) - -ENGINE = ReplacingMergeTree() -PRIMARY KEY (number) -ORDER BY (number) -COMMENT 'Cosmos block header'; - -CREATE TABLE IF NOT EXISTS transactions ( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_number UInt64, - block_date Date, - block_hash String COMMENT 'Cosmos Hash', - - -- transaction -- - `index` UInt32 COMMENT 'Transaction index in block', - `hash` String COMMENT 'Transaction hash', - code UInt32, - `data` String, - `log` String, - info String, - gas_wanted Int64, - gas_used Int64, - codespace String -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (hash) - ORDER BY (hash) - COMMENT 'Cosmos transaction'; - -CREATE TABLE IF NOT EXISTS tx_events ( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_number UInt64, - block_date Date, - block_hash String COMMENT 'Cosmos Hash', - - -- event -- - tx_hash String COMMENT 'Transaction hash', - `index` UInt32 COMMENT 'Event index in transaction', - `type` String, - attributes Array(Tuple(String, String)) -- Array of key-value pairs -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (tx_hash, `index`) - ORDER BY (tx_hash, `index`) - COMMENT 'Cosmos transaction event'; - -CREATE TABLE IF NOT EXISTS block_events ( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_number UInt64, - block_date Date, - block_hash String COMMENT 'Cosmos Hash', - - -- event -- - `index` UInt32 COMMENT 'Event index in block', - `type` String, - attributes Array(Tuple(String, String)) -- Array of key-value pairs -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (block_number, `index`) - ORDER BY (block_number, `index`) - COMMENT 'Cosmos block event'; -CREATE TABLE IF NOT EXISTS misbehaviors ( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_number UInt64, - block_date Date, - block_hash String COMMENT 'Cosmos Hash', - - -- misbehavior -- - `index` UInt32 COMMENT 'Misbehavior index in block', - `type` LowCardinality(String), - validator_address String, - validator_power Int64, - height Int64 COMMENT 'Misbehavior height', - `time` DateTime64(3, 'UTC') COMMENT 'Misbehavior time', - total_voting_power Int64 -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (block_number, `index`) - ORDER BY (block_number, `index`) - COMMENT 'Cosmos misbehavior'; - -CREATE TABLE IF NOT EXISTS validator_updates ( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_number UInt64, - block_date Date, - block_hash String COMMENT 'Cosmos Hash', - - -- validator update -- - `index` UInt32 COMMENT 'Validator update index in block', - public_key String, - power Int64 -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (block_number, `index`) - ORDER BY (block_number, `index`) - COMMENT 'Cosmos validator update'; -CREATE TABLE IF NOT EXISTS consensus_param_updates ( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_number UInt64, - block_date Date, - block_hash String COMMENT 'Cosmos Hash', - - -- consensus params -- - `json` String -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (block_number) - ORDER BY (block_number) - COMMENT 'Cosmos consensus parameter updates'; - -CREATE TABLE IF NOT EXISTS transaction_messages ( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_number UInt64, - block_date Date, - block_hash String COMMENT 'Cosmos Hash', - - -- transaction message -- - tx_hash String, - `index` UInt32 COMMENT 'Message index in transaction', - `type` String COMMENT 'Message type', - `value` String COMMENT 'Message value as hex' -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (tx_hash, `index`) - ORDER BY (tx_hash, `index`) - COMMENT 'Cosmos transaction messages'; - -ALTER TABLE blocks ADD PROJECTION IF NOT EXISTS blocks_by_block_height ( - SELECT * ORDER BY date, number -); - -ALTER TABLE transactions ADD PROJECTION IF NOT EXISTS transactions_by_hash ( - SELECT * ORDER BY block_date, block_number -); - -ALTER TABLE tx_events ADD PROJECTION IF NOT EXISTS tx_events_by_tx_hash ( - SELECT * ORDER BY block_date, block_number, tx_hash -); - -ALTER TABLE block_events ADD PROJECTION IF NOT EXISTS block_events_by_block_number ( - SELECT * ORDER BY block_date, block_number -); - -ALTER TABLE validator_updates ADD PROJECTION IF NOT EXISTS validator_updates_by_block_number ( - SELECT * ORDER BY block_date, block_number -); - -ALTER TABLE consensus_param_updates ADD PROJECTION IF NOT EXISTS consensus_param_updates_by_block_number ( - SELECT * ORDER BY block_date, block_number -); - -ALTER TABLE transaction_messages ADD PROJECTION IF NOT EXISTS transaction_messages_by_tx_hash ( - SELECT * ORDER BY block_date, block_number, tx_hash -); - -ALTER TABLE blocks MATERIALIZE PROJECTION blocks_by_block_height; -ALTER TABLE transactions MATERIALIZE PROJECTION transactions_by_hash; -ALTER TABLE tx_events MATERIALIZE PROJECTION tx_events_by_tx_hash; -ALTER TABLE block_events MATERIALIZE PROJECTION block_events_by_block_number; -ALTER TABLE validator_updates MATERIALIZE PROJECTION validator_updates_by_block_number; -ALTER TABLE consensus_param_updates MATERIALIZE PROJECTION consensus_param_updates_by_block_number; -ALTER TABLE transaction_messages MATERIALIZE PROJECTION transaction_messages_by_tx_hash; diff --git a/blocks/cosmos/src/blocks.rs b/blocks/cosmos/src/blocks.rs index 539fa71..c2fe33c 100644 --- a/blocks/cosmos/src/blocks.rs +++ b/blocks/cosmos/src/blocks.rs @@ -2,7 +2,7 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_cosmos::Block; -use crate::{pb::cosmos::Block as RawBlock, size::get_size}; +use crate::{pb::pinax::cosmos::Block as RawBlock, size::get_size}; pub fn collect_block(block: &Block, timestamp: &BlockTimestamp) -> RawBlock { let header = block.header.as_ref().unwrap(); diff --git a/blocks/cosmos/src/collect_events.rs b/blocks/cosmos/src/collect_events.rs deleted file mode 100644 index c9482e7..0000000 --- a/blocks/cosmos/src/collect_events.rs +++ /dev/null @@ -1,42 +0,0 @@ -use common::utils::build_timestamp; -use substreams::pb::substreams::Clock; -use substreams_cosmos::Block; - -use crate::{ - blocks::collect_block, - consensus_param_updates::collect_consensus_params, - misbehaviors::collect_misbehaviors, - pb::cosmos::{Events as RawEvents, Transaction as RawTransaction, TransactionEvent as RawTransactionEvent, TransactionMessage}, - transaction_messages::collect_tx_transaction_messages, - transactions::collect_transaction, - tx_and_block_events::{collect_block_events, collect_transaction_events}, - utils::compute_tx_hash, - validator_updates::collect_validator_updates, -}; - -pub fn collect_events(block: &Block, clock: &Clock) -> RawEvents { - let timestamp = build_timestamp(&clock); - - let mut transactions: Vec = vec![]; - let mut transaction_events: Vec = vec![]; - let mut transaction_messages: Vec = vec![]; - - for (i, tx_result) in block.tx_results.iter().enumerate() { - let tx_hash = compute_tx_hash(block.txs.get(i).unwrap()); - - transactions.push(collect_transaction(tx_result, &tx_hash, ×tamp, i)); - transaction_events.extend(collect_transaction_events(tx_result, &tx_hash, ×tamp)); - transaction_messages.extend(collect_tx_transaction_messages(block, i, &tx_hash, ×tamp)); - } - - RawEvents { - blocks: vec![collect_block(block, ×tamp)], - transactions, - transaction_events, - block_events: collect_block_events(block, ×tamp), - misbehaviors: collect_misbehaviors(block, ×tamp), - validator_updates: collect_validator_updates(block, ×tamp), - consensus_param_updates: collect_consensus_params(block, ×tamp), - transaction_messages, - } -} diff --git a/blocks/cosmos/src/consensus_param_updates.rs b/blocks/cosmos/src/consensus_param_updates.rs index e15dfc6..6276a2e 100644 --- a/blocks/cosmos/src/consensus_param_updates.rs +++ b/blocks/cosmos/src/consensus_param_updates.rs @@ -2,10 +2,10 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_cosmos::Block; -use crate::pb::cosmos::ConsensusParamUpdate as RawConsensusParamUpdate; +use crate::pb::pinax::cosmos::ConsensusParamUpdate; -pub fn collect_consensus_params(block: &Block, timestamp: &BlockTimestamp) -> Vec { - let mut vec: Vec = vec![]; +pub fn collect_consensus_params(block: &Block, timestamp: &BlockTimestamp) -> Vec { + let mut vec: Vec = vec![]; if let Some(consensus_params) = &block.consensus_param_updates { let mut json = serde_json::json!({}); @@ -37,7 +37,7 @@ pub fn collect_consensus_params(block: &Block, timestamp: &BlockTimestamp) -> Ve }); } - vec.push(RawConsensusParamUpdate { + vec.push(ConsensusParamUpdate { block_time: Some(timestamp.time), block_number: timestamp.number, block_date: timestamp.date.clone(), diff --git a/blocks/cosmos/src/lib.rs b/blocks/cosmos/src/lib.rs index f55bf33..0abb9d4 100644 --- a/blocks/cosmos/src/lib.rs +++ b/blocks/cosmos/src/lib.rs @@ -1,5 +1,4 @@ mod blocks; -mod collect_events; mod consensus_param_updates; mod map_events; mod misbehaviors; diff --git a/blocks/cosmos/src/map_events.rs b/blocks/cosmos/src/map_events.rs index 7bc41db..2db8560 100644 --- a/blocks/cosmos/src/map_events.rs +++ b/blocks/cosmos/src/map_events.rs @@ -1,9 +1,44 @@ -use substreams::{errors::Error, pb::substreams::Clock}; +use common::utils::build_timestamp; +use substreams::errors::Error; +use substreams::pb::substreams::Clock; use substreams_cosmos::Block; -use crate::{collect_events::collect_events, pb::cosmos::Events}; +use crate::{ + blocks::collect_block, + consensus_param_updates::collect_consensus_params, + misbehaviors::collect_misbehaviors, + pb::pinax::cosmos::{Events, Transaction, TransactionEvent, TransactionMessage}, + transaction_messages::collect_tx_transaction_messages, + transactions::collect_transaction, + tx_and_block_events::{collect_block_events, collect_transaction_events}, + utils::compute_tx_hash, + validator_updates::collect_validator_updates, +}; #[substreams::handlers::map] pub fn map_events(clock: Clock, block: Block) -> Result { - Ok(collect_events(&block, &clock)) + let timestamp = build_timestamp(&clock); + + let mut transactions: Vec = vec![]; + let mut transaction_events: Vec = vec![]; + let mut transaction_messages: Vec = vec![]; + + for (i, tx_result) in block.tx_results.iter().enumerate() { + let tx_hash = compute_tx_hash(block.txs.get(i).unwrap()); + + transactions.push(collect_transaction(tx_result, &tx_hash, ×tamp, i)); + transaction_events.extend(collect_transaction_events(tx_result, &tx_hash, ×tamp)); + transaction_messages.extend(collect_tx_transaction_messages(&block, i, &tx_hash, ×tamp)); + } + + Ok(Events { + blocks: vec![collect_block(&block, ×tamp)], + transactions, + transaction_events, + block_events: collect_block_events(&block, ×tamp), + misbehaviors: collect_misbehaviors(&block, ×tamp), + validator_updates: collect_validator_updates(&block, ×tamp), + consensus_param_updates: collect_consensus_params(&block, ×tamp), + transaction_messages, + }) } diff --git a/blocks/cosmos/src/misbehaviors.rs b/blocks/cosmos/src/misbehaviors.rs index f48b0d8..cd87a4e 100644 --- a/blocks/cosmos/src/misbehaviors.rs +++ b/blocks/cosmos/src/misbehaviors.rs @@ -2,14 +2,14 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_cosmos::Block; -use crate::pb::cosmos::Misbehavior as RawMisbehavior; +use crate::pb::pinax::cosmos::Misbehavior; -pub fn collect_misbehaviors(block: &Block, timestamp: &BlockTimestamp) -> Vec { - let mut vec: Vec = vec![]; +pub fn collect_misbehaviors(block: &Block, timestamp: &BlockTimestamp) -> Vec { + let mut vec: Vec = vec![]; for (index, misbehavior) in block.misbehavior.iter().enumerate() { let validator = misbehavior.validator.as_ref().unwrap(); - vec.push(RawMisbehavior { + vec.push(Misbehavior { block_time: Some(timestamp.time), block_number: timestamp.number, block_date: timestamp.date.clone(), diff --git a/blocks/cosmos/src/pb/mod.rs b/blocks/cosmos/src/pb/mod.rs index 7115018..99610c3 100644 --- a/blocks/cosmos/src/pb/mod.rs +++ b/blocks/cosmos/src/pb/mod.rs @@ -1,41 +1,8 @@ // @generated -// @@protoc_insertion_point(attribute:cosmos) -pub mod cosmos { - include!("cosmos.rs"); - // @@protoc_insertion_point(cosmos) -} -pub mod sf { - // @@protoc_insertion_point(attribute:sf.substreams) - pub mod substreams { - include!("sf.substreams.rs"); - // @@protoc_insertion_point(sf.substreams) - pub mod index { - // @@protoc_insertion_point(attribute:sf.substreams.index.v1) - pub mod v1 { - include!("sf.substreams.index.v1.rs"); - // @@protoc_insertion_point(sf.substreams.index.v1) - } - } - pub mod rpc { - // @@protoc_insertion_point(attribute:sf.substreams.rpc.v2) - pub mod v2 { - include!("sf.substreams.rpc.v2.rs"); - // @@protoc_insertion_point(sf.substreams.rpc.v2) - } - } - pub mod sink { - pub mod service { - // @@protoc_insertion_point(attribute:sf.substreams.sink.service.v1) - pub mod v1 { - include!("sf.substreams.sink.service.v1.rs"); - // @@protoc_insertion_point(sf.substreams.sink.service.v1) - } - } - } - // @@protoc_insertion_point(attribute:sf.substreams.v1) - pub mod v1 { - include!("sf.substreams.v1.rs"); - // @@protoc_insertion_point(sf.substreams.v1) - } +pub mod pinax { + // @@protoc_insertion_point(attribute:pinax.cosmos) + pub mod cosmos { + include!("pinax.cosmos.rs"); + // @@protoc_insertion_point(pinax.cosmos) } } diff --git a/blocks/cosmos/src/pb/cosmos.rs b/blocks/cosmos/src/pb/pinax.cosmos.rs similarity index 100% rename from blocks/cosmos/src/pb/cosmos.rs rename to blocks/cosmos/src/pb/pinax.cosmos.rs diff --git a/blocks/cosmos/src/pb/sf.substreams.index.v1.rs b/blocks/cosmos/src/pb/sf.substreams.index.v1.rs deleted file mode 100644 index 6f309bb..0000000 --- a/blocks/cosmos/src/pb/sf.substreams.index.v1.rs +++ /dev/null @@ -1,9 +0,0 @@ -// @generated -// This file is @generated by prost-build. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Keys { - #[prost(string, repeated, tag="1")] - pub keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -// @@protoc_insertion_point(module) diff --git a/blocks/cosmos/src/pb/sf.substreams.rpc.v2.rs b/blocks/cosmos/src/pb/sf.substreams.rpc.v2.rs deleted file mode 100644 index ab38ad2..0000000 --- a/blocks/cosmos/src/pb/sf.substreams.rpc.v2.rs +++ /dev/null @@ -1,341 +0,0 @@ -// @generated -// This file is @generated by prost-build. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Request { - #[prost(int64, tag="1")] - pub start_block_num: i64, - #[prost(string, tag="2")] - pub start_cursor: ::prost::alloc::string::String, - #[prost(uint64, tag="3")] - pub stop_block_num: u64, - /// With final_block_only, you only receive blocks that are irreversible: - /// 'final_block_height' will be equal to current block and no 'undo_signal' will ever be sent - #[prost(bool, tag="4")] - pub final_blocks_only: bool, - /// Substreams has two mode when executing your module(s) either development mode or production - /// mode. Development and production modes impact the execution of Substreams, important aspects - /// of execution include: - /// * The time required to reach the first byte. - /// * The speed that large ranges get executed. - /// * The module logs and outputs sent back to the client. - /// - /// By default, the engine runs in developer mode, with richer and deeper output. Differences - /// between production and development modes include: - /// * Forward parallel execution is enabled in production mode and disabled in development mode - /// * The time required to reach the first byte in development mode is faster than in production mode. - /// - /// Specific attributes of development mode include: - /// * The client will receive all of the executed module's logs. - /// * It's possible to request specific store snapshots in the execution tree (via `debug_initial_store_snapshot_for_modules`). - /// * Multiple module's output is possible. - /// - /// With production mode`, however, you trade off functionality for high speed enabling forward - /// parallel execution of module ahead of time. - #[prost(bool, tag="5")] - pub production_mode: bool, - #[prost(string, tag="6")] - pub output_module: ::prost::alloc::string::String, - #[prost(message, optional, tag="7")] - pub modules: ::core::option::Option, - /// Available only in developer mode - #[prost(string, repeated, tag="10")] - pub debug_initial_store_snapshot_for_modules: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Response { - #[prost(oneof="response::Message", tags="1, 2, 3, 4, 5, 10, 11")] - pub message: ::core::option::Option, -} -/// Nested message and enum types in `Response`. -pub mod response { - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Message { - /// Always sent first - #[prost(message, tag="1")] - Session(super::SessionInit), - /// Progress of data preparation, before sending in the stream of `data` events. - #[prost(message, tag="2")] - Progress(super::ModulesProgress), - #[prost(message, tag="3")] - BlockScopedData(super::BlockScopedData), - #[prost(message, tag="4")] - BlockUndoSignal(super::BlockUndoSignal), - #[prost(message, tag="5")] - FatalError(super::Error), - /// Available only in developer mode, and only if `debug_initial_store_snapshot_for_modules` is set. - #[prost(message, tag="10")] - DebugSnapshotData(super::InitialSnapshotData), - /// Available only in developer mode, and only if `debug_initial_store_snapshot_for_modules` is set. - #[prost(message, tag="11")] - DebugSnapshotComplete(super::InitialSnapshotComplete), - } -} -/// BlockUndoSignal informs you that every bit of data -/// with a block number above 'last_valid_block' has been reverted -/// on-chain. Delete that data and restart from 'last_valid_cursor' -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BlockUndoSignal { - #[prost(message, optional, tag="1")] - pub last_valid_block: ::core::option::Option, - #[prost(string, tag="2")] - pub last_valid_cursor: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BlockScopedData { - #[prost(message, optional, tag="1")] - pub output: ::core::option::Option, - #[prost(message, optional, tag="2")] - pub clock: ::core::option::Option, - #[prost(string, tag="3")] - pub cursor: ::prost::alloc::string::String, - /// Non-deterministic, allows substreams-sink to let go of their undo data. - #[prost(uint64, tag="4")] - pub final_block_height: u64, - #[prost(message, repeated, tag="10")] - pub debug_map_outputs: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag="11")] - pub debug_store_outputs: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SessionInit { - #[prost(string, tag="1")] - pub trace_id: ::prost::alloc::string::String, - #[prost(uint64, tag="2")] - pub resolved_start_block: u64, - #[prost(uint64, tag="3")] - pub linear_handoff_block: u64, - #[prost(uint64, tag="4")] - pub max_parallel_workers: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InitialSnapshotComplete { - #[prost(string, tag="1")] - pub cursor: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InitialSnapshotData { - #[prost(string, tag="1")] - pub module_name: ::prost::alloc::string::String, - #[prost(message, repeated, tag="2")] - pub deltas: ::prost::alloc::vec::Vec, - #[prost(uint64, tag="4")] - pub sent_keys: u64, - #[prost(uint64, tag="3")] - pub total_keys: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct MapModuleOutput { - #[prost(string, tag="1")] - pub name: ::prost::alloc::string::String, - #[prost(message, optional, tag="2")] - pub map_output: ::core::option::Option<::prost_types::Any>, - /// DebugOutputInfo is available in non-production mode only - #[prost(message, optional, tag="10")] - pub debug_info: ::core::option::Option, -} -/// StoreModuleOutput are produced for store modules in development mode. -/// It is not possible to retrieve store models in production, with parallelization -/// enabled. If you need the deltas directly, write a pass through mapper module -/// that will get them down to you. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct StoreModuleOutput { - #[prost(string, tag="1")] - pub name: ::prost::alloc::string::String, - #[prost(message, repeated, tag="2")] - pub debug_store_deltas: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="10")] - pub debug_info: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OutputDebugInfo { - #[prost(string, repeated, tag="1")] - pub logs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - /// LogsTruncated is a flag that tells you if you received all the logs or if they - /// were truncated because you logged too much (fixed limit currently is set to 128 KiB). - #[prost(bool, tag="2")] - pub logs_truncated: bool, - #[prost(bool, tag="3")] - pub cached: bool, -} -/// ModulesProgress is a message that is sent every 500ms -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ModulesProgress { - /// List of jobs running on tier2 servers - #[prost(message, repeated, tag="2")] - pub running_jobs: ::prost::alloc::vec::Vec, - /// Execution statistics for each module - #[prost(message, repeated, tag="3")] - pub modules_stats: ::prost::alloc::vec::Vec, - /// Stages definition and completed block ranges - #[prost(message, repeated, tag="4")] - pub stages: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="5")] - pub processed_bytes: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ProcessedBytes { - #[prost(uint64, tag="1")] - pub total_bytes_read: u64, - #[prost(uint64, tag="2")] - pub total_bytes_written: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Error { - #[prost(string, tag="1")] - pub module: ::prost::alloc::string::String, - #[prost(string, tag="2")] - pub reason: ::prost::alloc::string::String, - #[prost(string, repeated, tag="3")] - pub logs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - /// FailureLogsTruncated is a flag that tells you if you received all the logs or if they - /// were truncated because you logged too much (fixed limit currently is set to 128 KiB). - #[prost(bool, tag="4")] - pub logs_truncated: bool, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct Job { - #[prost(uint32, tag="1")] - pub stage: u32, - #[prost(uint64, tag="2")] - pub start_block: u64, - #[prost(uint64, tag="3")] - pub stop_block: u64, - #[prost(uint64, tag="4")] - pub processed_blocks: u64, - #[prost(uint64, tag="5")] - pub duration_ms: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Stage { - #[prost(string, repeated, tag="1")] - pub modules: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(message, repeated, tag="2")] - pub completed_ranges: ::prost::alloc::vec::Vec, -} -/// ModuleStats gathers metrics and statistics from each module, running on tier1 or tier2 -/// All the 'count' and 'time_ms' values may include duplicate for each stage going over that module -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ModuleStats { - /// name of the module - #[prost(string, tag="1")] - pub name: ::prost::alloc::string::String, - /// total_processed_blocks is the sum of blocks sent to that module code - #[prost(uint64, tag="2")] - pub total_processed_block_count: u64, - /// total_processing_time_ms is the sum of all time spent running that module code - #[prost(uint64, tag="3")] - pub total_processing_time_ms: u64, - /// // external_calls are chain-specific intrinsics, like "Ethereum RPC calls". - #[prost(message, repeated, tag="4")] - pub external_call_metrics: ::prost::alloc::vec::Vec, - /// total_store_operation_time_ms is the sum of all time spent running that module code waiting for a store operation (ex: read, write, delete...) - #[prost(uint64, tag="5")] - pub total_store_operation_time_ms: u64, - /// total_store_read_count is the sum of all the store Read operations called from that module code - #[prost(uint64, tag="6")] - pub total_store_read_count: u64, - /// total_store_write_count is the sum of all store Write operations called from that module code (store-only) - #[prost(uint64, tag="10")] - pub total_store_write_count: u64, - /// total_store_deleteprefix_count is the sum of all store DeletePrefix operations called from that module code (store-only) - /// note that DeletePrefix can be a costly operation on large stores - #[prost(uint64, tag="11")] - pub total_store_deleteprefix_count: u64, - /// store_size_bytes is the uncompressed size of the full KV store for that module, from the last 'merge' operation (store-only) - #[prost(uint64, tag="12")] - pub store_size_bytes: u64, - /// total_store_merging_time_ms is the time spent merging partial stores into a full KV store for that module (store-only) - #[prost(uint64, tag="13")] - pub total_store_merging_time_ms: u64, - /// store_currently_merging is true if there is a merging operation (partial store to full KV store) on the way. - #[prost(bool, tag="14")] - pub store_currently_merging: bool, - /// highest_contiguous_block is the highest block in the highest merged full KV store of that module (store-only) - #[prost(uint64, tag="15")] - pub highest_contiguous_block: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExternalCallMetric { - #[prost(string, tag="1")] - pub name: ::prost::alloc::string::String, - #[prost(uint64, tag="2")] - pub count: u64, - #[prost(uint64, tag="3")] - pub time_ms: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct StoreDelta { - #[prost(enumeration="store_delta::Operation", tag="1")] - pub operation: i32, - #[prost(uint64, tag="2")] - pub ordinal: u64, - #[prost(string, tag="3")] - pub key: ::prost::alloc::string::String, - #[prost(bytes="vec", tag="4")] - pub old_value: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="5")] - pub new_value: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `StoreDelta`. -pub mod store_delta { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] - #[repr(i32)] - pub enum Operation { - Unset = 0, - Create = 1, - Update = 2, - Delete = 3, - } - impl Operation { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Operation::Unset => "UNSET", - Operation::Create => "CREATE", - Operation::Update => "UPDATE", - Operation::Delete => "DELETE", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSET" => Some(Self::Unset), - "CREATE" => Some(Self::Create), - "UPDATE" => Some(Self::Update), - "DELETE" => Some(Self::Delete), - _ => None, - } - } - } -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct BlockRange { - #[prost(uint64, tag="2")] - pub start_block: u64, - #[prost(uint64, tag="3")] - pub end_block: u64, -} -// @@protoc_insertion_point(module) diff --git a/blocks/cosmos/src/pb/sf.substreams.rs b/blocks/cosmos/src/pb/sf.substreams.rs deleted file mode 100644 index 246b1c5..0000000 --- a/blocks/cosmos/src/pb/sf.substreams.rs +++ /dev/null @@ -1,15 +0,0 @@ -// @generated -// This file is @generated by prost-build. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct FieldOptions { - /// this option informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a file, putting its content as bytes in this field. - /// must be applied to a `bytes` or `string` field - #[prost(bool, tag="1")] - pub load_from_file: bool, - /// this option informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a folder, zipping its content and putting the zip content as bytes in this field. - /// must be applied to a `bytes` field - #[prost(bool, tag="2")] - pub zip_from_folder: bool, -} -// @@protoc_insertion_point(module) diff --git a/blocks/cosmos/src/pb/sf.substreams.sink.service.v1.rs b/blocks/cosmos/src/pb/sf.substreams.sink.service.v1.rs deleted file mode 100644 index ba96cb4..0000000 --- a/blocks/cosmos/src/pb/sf.substreams.sink.service.v1.rs +++ /dev/null @@ -1,228 +0,0 @@ -// @generated -// This file is @generated by prost-build. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DeployRequest { - #[prost(message, optional, tag="1")] - pub substreams_package: ::core::option::Option, - #[prost(bool, tag="2")] - pub development_mode: bool, - #[prost(message, repeated, tag="3")] - pub parameters: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Parameter { - #[prost(string, tag="1")] - pub key: ::prost::alloc::string::String, - #[prost(string, tag="2")] - pub value: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DeployResponse { - #[prost(enumeration="DeploymentStatus", tag="1")] - pub status: i32, - /// deployment_id is a short name (max 8 characters) that uniquely identifies your deployment - #[prost(string, tag="2")] - pub deployment_id: ::prost::alloc::string::String, - #[prost(map="string, string", tag="3")] - pub services: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, - #[prost(string, tag="4")] - pub reason: ::prost::alloc::string::String, - #[prost(string, tag="5")] - pub motd: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpdateRequest { - #[prost(message, optional, tag="1")] - pub substreams_package: ::core::option::Option, - #[prost(string, tag="2")] - pub deployment_id: ::prost::alloc::string::String, - #[prost(bool, tag="3")] - pub reset: bool, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpdateResponse { - #[prost(enumeration="DeploymentStatus", tag="1")] - pub status: i32, - #[prost(map="string, string", tag="2")] - pub services: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, - #[prost(string, tag="3")] - pub reason: ::prost::alloc::string::String, - #[prost(string, tag="4")] - pub motd: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InfoRequest { - #[prost(string, tag="1")] - pub deployment_id: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InfoResponse { - #[prost(enumeration="DeploymentStatus", tag="1")] - pub status: i32, - #[prost(map="string, string", tag="2")] - pub services: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, - #[prost(string, tag="3")] - pub reason: ::prost::alloc::string::String, - #[prost(message, optional, tag="4")] - pub package_info: ::core::option::Option, - #[prost(message, optional, tag="5")] - pub progress: ::core::option::Option, - #[prost(string, tag="6")] - pub motd: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct SinkProgress { - #[prost(uint64, tag="1")] - pub last_processed_block: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PackageInfo { - #[prost(string, tag="1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag="2")] - pub version: ::prost::alloc::string::String, - #[prost(string, tag="3")] - pub output_module_name: ::prost::alloc::string::String, - #[prost(string, tag="4")] - pub output_module_hash: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ListRequest { -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListResponse { - #[prost(message, repeated, tag="1")] - pub deployments: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DeploymentWithStatus { - #[prost(string, tag="1")] - pub id: ::prost::alloc::string::String, - #[prost(enumeration="DeploymentStatus", tag="2")] - pub status: i32, - #[prost(string, tag="3")] - pub reason: ::prost::alloc::string::String, - #[prost(message, optional, tag="4")] - pub package_info: ::core::option::Option, - #[prost(message, optional, tag="5")] - pub progress: ::core::option::Option, - #[prost(string, tag="6")] - pub motd: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RemoveRequest { - #[prost(string, tag="1")] - pub deployment_id: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct RemoveResponse { - #[prost(enumeration="DeploymentStatus", tag="1")] - pub previous_status: i32, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PauseRequest { - #[prost(string, tag="1")] - pub deployment_id: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct PauseResponse { - #[prost(enumeration="DeploymentStatus", tag="1")] - pub previous_status: i32, - #[prost(enumeration="DeploymentStatus", tag="2")] - pub new_status: i32, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct StopRequest { - #[prost(string, tag="1")] - pub deployment_id: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct StopResponse { - #[prost(enumeration="DeploymentStatus", tag="1")] - pub previous_status: i32, - #[prost(enumeration="DeploymentStatus", tag="2")] - pub new_status: i32, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ResumeRequest { - #[prost(string, tag="1")] - pub deployment_id: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ResumeResponse { - #[prost(enumeration="DeploymentStatus", tag="1")] - pub previous_status: i32, - #[prost(enumeration="DeploymentStatus", tag="2")] - pub new_status: i32, -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum DeploymentStatus { - Unknown = 0, - Running = 1, - Failing = 2, - Paused = 3, - Stopped = 4, - Starting = 5, - Pausing = 6, - Stopping = 7, - Removing = 8, - Resuming = 9, -} -impl DeploymentStatus { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - DeploymentStatus::Unknown => "UNKNOWN", - DeploymentStatus::Running => "RUNNING", - DeploymentStatus::Failing => "FAILING", - DeploymentStatus::Paused => "PAUSED", - DeploymentStatus::Stopped => "STOPPED", - DeploymentStatus::Starting => "STARTING", - DeploymentStatus::Pausing => "PAUSING", - DeploymentStatus::Stopping => "STOPPING", - DeploymentStatus::Removing => "REMOVING", - DeploymentStatus::Resuming => "RESUMING", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNKNOWN" => Some(Self::Unknown), - "RUNNING" => Some(Self::Running), - "FAILING" => Some(Self::Failing), - "PAUSED" => Some(Self::Paused), - "STOPPED" => Some(Self::Stopped), - "STARTING" => Some(Self::Starting), - "PAUSING" => Some(Self::Pausing), - "STOPPING" => Some(Self::Stopping), - "REMOVING" => Some(Self::Removing), - "RESUMING" => Some(Self::Resuming), - _ => None, - } - } -} -// @@protoc_insertion_point(module) diff --git a/blocks/cosmos/src/pb/sf.substreams.v1.rs b/blocks/cosmos/src/pb/sf.substreams.v1.rs deleted file mode 100644 index b126937..0000000 --- a/blocks/cosmos/src/pb/sf.substreams.v1.rs +++ /dev/null @@ -1,325 +0,0 @@ -// @generated -// This file is @generated by prost-build. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Modules { - #[prost(message, repeated, tag="1")] - pub modules: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag="2")] - pub binaries: ::prost::alloc::vec::Vec, -} -/// Binary represents some code compiled to its binary form. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Binary { - #[prost(string, tag="1")] - pub r#type: ::prost::alloc::string::String, - #[prost(bytes="vec", tag="2")] - pub content: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Module { - #[prost(string, tag="1")] - pub name: ::prost::alloc::string::String, - #[prost(uint32, tag="4")] - pub binary_index: u32, - #[prost(string, tag="5")] - pub binary_entrypoint: ::prost::alloc::string::String, - #[prost(message, repeated, tag="6")] - pub inputs: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="7")] - pub output: ::core::option::Option, - #[prost(uint64, tag="8")] - pub initial_block: u64, - #[prost(message, optional, tag="9")] - pub block_filter: ::core::option::Option, - #[prost(oneof="module::Kind", tags="2, 3, 10")] - pub kind: ::core::option::Option, -} -/// Nested message and enum types in `Module`. -pub mod module { - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct BlockFilter { - #[prost(string, tag="1")] - pub module: ::prost::alloc::string::String, - #[prost(oneof="block_filter::Query", tags="2, 3")] - pub query: ::core::option::Option, - } - /// Nested message and enum types in `BlockFilter`. - pub mod block_filter { - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Query { - #[prost(string, tag="2")] - QueryString(::prost::alloc::string::String), - /// QueryFromStore query_from_store_keys = 3; - #[prost(message, tag="3")] - QueryFromParams(super::QueryFromParams), - } - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct QueryFromParams { - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct KindMap { - #[prost(string, tag="1")] - pub output_type: ::prost::alloc::string::String, - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct KindStore { - /// The `update_policy` determines the functions available to mutate the store - /// (like `set()`, `set_if_not_exists()` or `sum()`, etc..) in - /// order to ensure that parallel operations are possible and deterministic - /// - /// Say a store cumulates keys from block 0 to 1M, and a second store - /// cumulates keys from block 1M to 2M. When we want to use this - /// store as a dependency for a downstream module, we will merge the - /// two stores according to this policy. - #[prost(enumeration="kind_store::UpdatePolicy", tag="1")] - pub update_policy: i32, - #[prost(string, tag="2")] - pub value_type: ::prost::alloc::string::String, - } - /// Nested message and enum types in `KindStore`. - pub mod kind_store { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] - #[repr(i32)] - pub enum UpdatePolicy { - Unset = 0, - /// Provides a store where you can `set()` keys, and the latest key wins - Set = 1, - /// Provides a store where you can `set_if_not_exists()` keys, and the first key wins - SetIfNotExists = 2, - /// Provides a store where you can `add_*()` keys, where two stores merge by summing its values. - Add = 3, - /// Provides a store where you can `min_*()` keys, where two stores merge by leaving the minimum value. - Min = 4, - /// Provides a store where you can `max_*()` keys, where two stores merge by leaving the maximum value. - Max = 5, - /// Provides a store where you can `append()` keys, where two stores merge by concatenating the bytes in order. - Append = 6, - /// Provides a store with both `set()` and `sum()` functions. - SetSum = 7, - } - impl UpdatePolicy { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - UpdatePolicy::Unset => "UPDATE_POLICY_UNSET", - UpdatePolicy::Set => "UPDATE_POLICY_SET", - UpdatePolicy::SetIfNotExists => "UPDATE_POLICY_SET_IF_NOT_EXISTS", - UpdatePolicy::Add => "UPDATE_POLICY_ADD", - UpdatePolicy::Min => "UPDATE_POLICY_MIN", - UpdatePolicy::Max => "UPDATE_POLICY_MAX", - UpdatePolicy::Append => "UPDATE_POLICY_APPEND", - UpdatePolicy::SetSum => "UPDATE_POLICY_SET_SUM", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UPDATE_POLICY_UNSET" => Some(Self::Unset), - "UPDATE_POLICY_SET" => Some(Self::Set), - "UPDATE_POLICY_SET_IF_NOT_EXISTS" => Some(Self::SetIfNotExists), - "UPDATE_POLICY_ADD" => Some(Self::Add), - "UPDATE_POLICY_MIN" => Some(Self::Min), - "UPDATE_POLICY_MAX" => Some(Self::Max), - "UPDATE_POLICY_APPEND" => Some(Self::Append), - "UPDATE_POLICY_SET_SUM" => Some(Self::SetSum), - _ => None, - } - } - } - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct KindBlockIndex { - #[prost(string, tag="1")] - pub output_type: ::prost::alloc::string::String, - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct Input { - #[prost(oneof="input::Input", tags="1, 2, 3, 4")] - pub input: ::core::option::Option, - } - /// Nested message and enum types in `Input`. - pub mod input { - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct Source { - /// ex: "sf.ethereum.type.v1.Block" - #[prost(string, tag="1")] - pub r#type: ::prost::alloc::string::String, - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct Map { - /// ex: "block_to_pairs" - #[prost(string, tag="1")] - pub module_name: ::prost::alloc::string::String, - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct Store { - #[prost(string, tag="1")] - pub module_name: ::prost::alloc::string::String, - #[prost(enumeration="store::Mode", tag="2")] - pub mode: i32, - } - /// Nested message and enum types in `Store`. - pub mod store { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] - #[repr(i32)] - pub enum Mode { - Unset = 0, - Get = 1, - Deltas = 2, - } - impl Mode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Mode::Unset => "UNSET", - Mode::Get => "GET", - Mode::Deltas => "DELTAS", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSET" => Some(Self::Unset), - "GET" => Some(Self::Get), - "DELTAS" => Some(Self::Deltas), - _ => None, - } - } - } - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct Params { - #[prost(string, tag="1")] - pub value: ::prost::alloc::string::String, - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Input { - #[prost(message, tag="1")] - Source(Source), - #[prost(message, tag="2")] - Map(Map), - #[prost(message, tag="3")] - Store(Store), - #[prost(message, tag="4")] - Params(Params), - } - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] - pub struct Output { - #[prost(string, tag="1")] - pub r#type: ::prost::alloc::string::String, - } - #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Kind { - #[prost(message, tag="2")] - KindMap(KindMap), - #[prost(message, tag="3")] - KindStore(KindStore), - #[prost(message, tag="10")] - KindBlockIndex(KindBlockIndex), - } -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Package { - /// Needs to be one so this file can be used _directly_ as a - /// buf `Image` andor a ProtoSet for grpcurl and other tools - #[prost(message, repeated, tag="1")] - pub proto_files: ::prost::alloc::vec::Vec<::prost_types::FileDescriptorProto>, - #[prost(uint64, tag="5")] - pub version: u64, - #[prost(message, optional, tag="6")] - pub modules: ::core::option::Option, - #[prost(message, repeated, tag="7")] - pub module_meta: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag="8")] - pub package_meta: ::prost::alloc::vec::Vec, - /// Source network for Substreams to fetch its data from. - #[prost(string, tag="9")] - pub network: ::prost::alloc::string::String, - #[prost(message, optional, tag="10")] - pub sink_config: ::core::option::Option<::prost_types::Any>, - #[prost(string, tag="11")] - pub sink_module: ::prost::alloc::string::String, - /// image is the bytes to a JPEG, WebP or PNG file. Max size is 2 MiB - #[prost(bytes="vec", tag="12")] - pub image: ::prost::alloc::vec::Vec, - #[prost(map="string, message", tag="13")] - pub networks: ::std::collections::HashMap<::prost::alloc::string::String, NetworkParams>, - #[prost(map="string, string", tag="14")] - pub block_filters: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct NetworkParams { - #[prost(map="string, uint64", tag="1")] - pub initial_blocks: ::std::collections::HashMap<::prost::alloc::string::String, u64>, - #[prost(map="string, string", tag="2")] - pub params: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PackageMetadata { - #[prost(string, tag="1")] - pub version: ::prost::alloc::string::String, - #[prost(string, tag="2")] - pub url: ::prost::alloc::string::String, - #[prost(string, tag="3")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag="4")] - pub doc: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ModuleMetadata { - /// Corresponds to the index in `Package.metadata.package_meta` - #[prost(uint64, tag="1")] - pub package_index: u64, - #[prost(string, tag="2")] - pub doc: ::prost::alloc::string::String, -} -/// Clock is a pointer to a block with added timestamp -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Clock { - #[prost(string, tag="1")] - pub id: ::prost::alloc::string::String, - #[prost(uint64, tag="2")] - pub number: u64, - #[prost(message, optional, tag="3")] - pub timestamp: ::core::option::Option<::prost_types::Timestamp>, -} -/// BlockRef is a pointer to a block to which we don't know the timestamp -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BlockRef { - #[prost(string, tag="1")] - pub id: ::prost::alloc::string::String, - #[prost(uint64, tag="2")] - pub number: u64, -} -// @@protoc_insertion_point(module) diff --git a/blocks/cosmos/src/transaction_messages.rs b/blocks/cosmos/src/transaction_messages.rs index ead7e40..e88a9ac 100644 --- a/blocks/cosmos/src/transaction_messages.rs +++ b/blocks/cosmos/src/transaction_messages.rs @@ -2,7 +2,7 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_cosmos::Block; -use crate::pb::cosmos::TransactionMessage; +use crate::pb::pinax::cosmos::TransactionMessage; pub fn collect_tx_transaction_messages(block: &Block, tx_index: usize, tx_hash: &str, timestamp: &BlockTimestamp) -> Vec { let mut vec: Vec = vec![]; diff --git a/blocks/cosmos/src/transactions.rs b/blocks/cosmos/src/transactions.rs index 14f1524..177302f 100644 --- a/blocks/cosmos/src/transactions.rs +++ b/blocks/cosmos/src/transactions.rs @@ -2,10 +2,10 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_cosmos::pb::TxResults; -use crate::pb::cosmos::Transaction as RawTransaction; +use crate::pb::pinax::cosmos::Transaction; -pub fn collect_transaction(tx_result: &TxResults, tx_hash: &str, timestamp: &BlockTimestamp, index: usize) -> RawTransaction { - RawTransaction { +pub fn collect_transaction(tx_result: &TxResults, tx_hash: &str, timestamp: &BlockTimestamp, index: usize) -> Transaction { + Transaction { block_time: Some(timestamp.time), block_number: timestamp.number, block_date: timestamp.date.clone(), diff --git a/blocks/cosmos/src/tx_and_block_events.rs b/blocks/cosmos/src/tx_and_block_events.rs index 69b13ad..c7835b6 100644 --- a/blocks/cosmos/src/tx_and_block_events.rs +++ b/blocks/cosmos/src/tx_and_block_events.rs @@ -2,15 +2,15 @@ use common::structs::BlockTimestamp; use substreams_cosmos::{pb::TxResults, Block}; use crate::{ - pb::cosmos::{BlockEvent as RawBlockEvent, TransactionEvent as RawTransactionEvent}, + pb::pinax::cosmos::{BlockEvent, TransactionEvent}, utils::build_attributes_array_string, }; -pub fn collect_block_events(block: &Block, timestamp: &BlockTimestamp) -> Vec { - let mut vec: Vec = vec![]; +pub fn collect_block_events(block: &Block, timestamp: &BlockTimestamp) -> Vec { + let mut vec: Vec = vec![]; for (index, event) in block.events.iter().enumerate() { - vec.push(RawBlockEvent { + vec.push(BlockEvent { block_time: Some(timestamp.time), block_number: timestamp.number, block_date: timestamp.date.clone(), @@ -24,11 +24,11 @@ pub fn collect_block_events(block: &Block, timestamp: &BlockTimestamp) -> Vec Vec { - let mut vec: Vec = vec![]; +pub fn collect_transaction_events(tx_result: &TxResults, tx_hash: &str, timestamp: &BlockTimestamp) -> Vec { + let mut vec: Vec = vec![]; for (event_index, event) in tx_result.events.iter().enumerate() { - vec.push(RawTransactionEvent { + vec.push(TransactionEvent { block_time: Some(timestamp.time), block_number: timestamp.number, block_date: timestamp.date.clone(), diff --git a/blocks/cosmos/src/validator_updates.rs b/blocks/cosmos/src/validator_updates.rs index 4989501..479741e 100644 --- a/blocks/cosmos/src/validator_updates.rs +++ b/blocks/cosmos/src/validator_updates.rs @@ -2,10 +2,10 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_cosmos::{pb::public_key, Block}; -use crate::pb::cosmos::ValidatorUpdate as RawValidatorUpdate; +use crate::pb::pinax::cosmos::ValidatorUpdate; -pub fn collect_validator_updates(block: &Block, timestamp: &BlockTimestamp) -> Vec { - let mut vec: Vec = vec![]; +pub fn collect_validator_updates(block: &Block, timestamp: &BlockTimestamp) -> Vec { + let mut vec: Vec = vec![]; for (index, validator_update) in block.validator_updates.iter().enumerate() { let public_key = match validator_update.pub_key.as_ref().unwrap().sum.as_ref().unwrap() { @@ -13,7 +13,7 @@ pub fn collect_validator_updates(block: &Block, timestamp: &BlockTimestamp) -> V public_key::Sum::Secp256k1(bytes) => bytes, }; - vec.push(RawValidatorUpdate { + vec.push(ValidatorUpdate { block_time: Some(timestamp.time), block_number: timestamp.number, block_date: timestamp.date.clone(), diff --git a/blocks/solana/schema.sql b/blocks/solana/schema.sql deleted file mode 100644 index 057c1e6..0000000 --- a/blocks/solana/schema.sql +++ /dev/null @@ -1,345 +0,0 @@ -------------------------------------------------- --- Meta tables to store Substreams information -- -------------------------------------------------- -CREATE TABLE IF NOT EXISTS cursors -( - id String, - cursor String, - block_num Int64, - block_id String -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (id) - ORDER BY (id); - -------------------------------------------------- --- Solana block header -- -------------------------------------------------- -CREATE TABLE IF NOT EXISTS blocks -( - -- clock -- - time DateTime64(3, 'UTC'), - date Date, - hash String COMMENT 'Hash', - - -- block -- - slot UInt64, - height UInt64, - previous_block_hash String COMMENT 'Hash', - parent_slot UInt64, - - -- counters -- - total_transactions UInt64, - successful_transactions UInt64, - failed_transactions UInt64, - total_vote_transactions UInt64, - total_non_vote_transactions UInt64, - successful_vote_transactions UInt64, - successful_non_vote_transactions UInt64, - failed_vote_transactions UInt64, - failed_non_vote_transactions UInt64 -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (hash) - ORDER BY (hash) - COMMENT 'Solana block header'; - -CREATE TABLE IF NOT EXISTS rewards -( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_date Date, - block_hash String, - - -- block -- - block_slot UInt64, - block_height UInt64, - block_previous_block_hash String, - block_parent_slot UInt64, - - -- reward -- - pubkey String COMMENT 'Reward destination', - lamports Int64, - pre_balance UInt64, - post_balance UInt64, - reward_type LowCardinality(String), - commission String -) - ENGINE = ReplacingMergeTree() - PRIMARY KEY (block_hash, pubkey, reward_type) - ORDER BY (block_hash, pubkey, reward_type) - COMMENT 'Solana rewards'; - -CREATE TABLE IF NOT EXISTS transactions -( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_hash String, - block_date Date, - - -- block -- - block_slot UInt64, - block_height UInt64, - block_previous_block_hash String, - block_parent_slot UInt64, - - -- transaction -- - id String, - `index` UInt32, - fee UInt64, - required_signatures UInt32, - required_signed_accounts UInt32, - required_unsigned_accounts UInt32, - `signature` String, - success Bool, - error String, - recent_block_hash String, - account_keys Array(String), - log_messages String, -- Should be Array(String) - pre_balances Array(UInt64), - post_balances Array(UInt64), - signatures Array(String), - signer String, - signers Array(String) -) - - ENGINE = ReplacingMergeTree() - PRIMARY KEY (id) - ORDER BY (id) - COMMENT 'Solana transactions'; - - -CREATE TABLE IF NOT EXISTS instruction_calls -( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_hash String, - block_date Date, - - -- block -- - block_slot UInt64, - block_height UInt64, - block_previous_block_hash String, - block_parent_slot UInt64, - - -- transaction -- - tx_id String, - tx_index UInt32, - tx_signer String, - tx_success Bool, - log_messages String, -- Should be Array(String) - - -- instruction -- - outer_instruction_index UInt32, - inner_instruction_index Int32, - inner_executing_account String, - outer_executing_account String, - executing_account String, - is_inner Bool, - `data` String, - account_arguments Array(String), - inner_instructions Array(Tuple(String, String, Array(String))) -- (data String, executing_account String, account_arguments Array(String)) - -- inner_instructions String -) - - ENGINE = ReplacingMergeTree() - PRIMARY KEY (tx_id, outer_instruction_index, inner_instruction_index) - ORDER BY (tx_id, outer_instruction_index, inner_instruction_index) - COMMENT 'Solana instruction calls'; - -CREATE TABLE IF NOT EXISTS account_activity -( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_hash String, - block_date Date, - - -- block -- - block_slot UInt64, - block_height UInt64, - block_previous_block_hash String, - block_parent_slot UInt64, - - `address` String, - tx_index UInt32, - tx_id String, - tx_success Bool, - signed Bool, - writable Bool, - token_mint_address String, - - pre_balance UInt64, - post_balance UInt64, - balance_change Int128, - pre_token_balance Nullable(Float64), -- Decimal(38,18) when sink will support it - post_token_balance Nullable(Float64), -- Decimal(38,18) when sink will support it - token_balance_change Nullable(Float64), -- Decimal(38,17) when sink will support it - token_balance_owner String -) - - ENGINE = ReplacingMergeTree() - PRIMARY KEY (tx_id, `address`) - ORDER BY (tx_id, `address`) - COMMENT 'Solana account activity'; - -CREATE TABLE IF NOT EXISTS vote_transactions -( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_hash String, - block_date Date, - - -- block -- - block_slot UInt64, - block_height UInt64, - block_previous_block_hash String, - block_parent_slot UInt64, - - -- transaction -- - id String, - `index` UInt32, - fee UInt64, - required_signatures UInt32, - required_signed_accounts UInt32, - required_unsigned_accounts UInt32, - `signature` String, - success Bool, - error String, - recent_block_hash String, - account_keys Array(String), - log_messages String, -- Should be Array(String) - pre_balances Array(UInt64), - post_balances Array(UInt64), - signatures Array(String), - signer String, - signers Array(String) -) - - ENGINE = ReplacingMergeTree() - PRIMARY KEY (id) - ORDER BY (id) - COMMENT 'Solana vote transactions'; - - -CREATE TABLE IF NOT EXISTS vote_instruction_calls -( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_hash String, - block_date Date, - - -- block -- - block_slot UInt64, - block_height UInt64, - block_previous_block_hash String, - block_parent_slot UInt64, - - -- transaction -- - tx_id String, - tx_index UInt32, - tx_signer String, - tx_success Bool, - log_messages String, -- Should be Array(String) - - -- instruction -- - outer_instruction_index UInt32, - inner_instruction_index Int32, - inner_executing_account String, - outer_executing_account String, - executing_account String, - is_inner Bool, - `data` String, - account_arguments Array(String), - inner_instructions Array(Tuple(String, String, Array(String))) -- (data String, executing_account String, account_arguments Array(String)) -) - - ENGINE = ReplacingMergeTree() - PRIMARY KEY (tx_id, outer_instruction_index, inner_instruction_index) - ORDER BY (tx_id, outer_instruction_index, inner_instruction_index) - COMMENT 'Solana vote instruction calls'; - -CREATE TABLE IF NOT EXISTS vote_account_activity -( - -- clock -- - block_time DateTime64(3, 'UTC'), - block_hash String, - block_date Date, - - -- block -- - block_slot UInt64, - block_height UInt64, - block_previous_block_hash String, - block_parent_slot UInt64, - - `address` String, - tx_index UInt32, - tx_id String, - tx_success Bool, - signed Bool, - writable Bool, - token_mint_address String, - - pre_balance UInt64, - post_balance UInt64, - balance_change Int128, - pre_token_balance Nullable(Float64), -- Decimal(38,18) when sink will support it - post_token_balance Nullable(Float64), -- Decimal(38,18) when sink will support it - token_balance_change Nullable(Float64), -- Decimal(38,17) when sink will support it - token_balance_owner String -) - - ENGINE = ReplacingMergeTree() - PRIMARY KEY (tx_id, `address`) - ORDER BY (tx_id, `address`) - COMMENT 'Solana vote account activity'; - --- Projections -- --- https://clickhouse.com/docs/en/sql-reference/statements/alter/projection -- -ALTER TABLE blocks ADD PROJECTION IF NOT EXISTS blocks_by_block_height ( - SELECT * ORDER BY date, height -); - -ALTER TABLE rewards ADD PROJECTION IF NOT EXISTS rewards_by_block_height ( - SELECT * ORDER BY block_date, block_height -); - -ALTER TABLE transactions ADD PROJECTION IF NOT EXISTS transactions_by_block_height ( - SELECT * ORDER BY block_date, block_height -); - -ALTER TABLE instruction_calls ADD PROJECTION IF NOT EXISTS instruction_calls_by_block_height ( - SELECT * ORDER BY block_date, block_height -); - -ALTER TABLE account_activity ADD PROJECTION IF NOT EXISTS account_activity_by_block_height ( - SELECT * ORDER BY block_date, block_height -); - -ALTER TABLE vote_transactions ADD PROJECTION IF NOT EXISTS vote_transactions_by_block_height ( - SELECT * ORDER BY block_date, block_height -); - -ALTER TABLE vote_instruction_calls ADD PROJECTION IF NOT EXISTS vote_instruction_calls_by_block_height ( - SELECT * ORDER BY block_date, block_height -); - -ALTER TABLE vote_account_activity ADD PROJECTION IF NOT EXISTS vote_account_activity_by_block_height ( - SELECT * ORDER BY block_date, block_height -); - - -ALTER TABLE blocks MATERIALIZE PROJECTION blocks_by_block_height; - -ALTER TABLE rewards MATERIALIZE PROJECTION rewards_by_block_height; - -ALTER TABLE transactions MATERIALIZE PROJECTION transactions_by_block_height; - -ALTER TABLE instruction_calls MATERIALIZE PROJECTION instruction_calls_by_block_height; - -ALTER TABLE account_activity MATERIALIZE PROJECTION account_activity_by_block_height; - -ALTER TABLE vote_transactions MATERIALIZE PROJECTION vote_transactions_by_block_height; - -ALTER TABLE vote_instruction_calls MATERIALIZE PROJECTION vote_instruction_calls_by_block_height; - -ALTER TABLE vote_account_activity MATERIALIZE PROJECTION vote_account_activity_by_block_height; diff --git a/common/Cargo.toml b/common/Cargo.toml index 6b15cca..114475a 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -5,7 +5,6 @@ version = { workspace = true } [dependencies] substreams = { workspace = true } -substreams-database-change = { workspace = true } substreams-ethereum = { workspace = true } serde_json = { workspace = true } prost-types = { workspace = true } diff --git a/common/src/blocks.rs b/common/src/blocks.rs deleted file mode 100644 index 976c848..0000000 --- a/common/src/blocks.rs +++ /dev/null @@ -1,21 +0,0 @@ -use substreams::pb::substreams::Clock; -use substreams_database_change::pb::database::TableChange; - -use crate::utils::{add_prefix_to_hex, block_time_to_date}; - -pub fn insert_timestamp(row: &mut TableChange, clock: &Clock, is_block: bool, with_prefix: bool) { - let timestamp = clock.clone().timestamp.unwrap(); - let block_date = block_time_to_date(timestamp.to_string().as_str()); - let seconds = timestamp.seconds; - let nanos = timestamp.nanos; - let milliseconds = seconds * 1000 + i64::from(nanos) / 1_000_000; - let block_time = milliseconds.to_string(); - let block_number = clock.number.to_string(); - let block_hash = if with_prefix { add_prefix_to_hex(&clock.id) } else { clock.id.to_string() }; - let prefix = if is_block { "" } else { "block_" }; - - row.change(format!("{}date", prefix).as_str(), ("", block_date.as_str())) - .change(format!("{}time", prefix).as_str(), ("", block_time.as_str())) - .change(format!("{}number", prefix).as_str(), ("", block_number.as_str())) - .change(format!("{}hash", prefix).as_str(), ("", block_hash.as_str())); -} diff --git a/common/src/lib.rs b/common/src/lib.rs index addf0fe..87c7bbf 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,4 +1,3 @@ -pub mod blocks; pub mod keys; pub mod structs; pub mod utils; diff --git a/proto/cosmos.proto b/proto/cosmos.proto index 056c193..31bcbbb 100644 --- a/proto/cosmos.proto +++ b/proto/cosmos.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package cosmos; +package pinax.cosmos; import "google/protobuf/timestamp.proto";