Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pinax-network/substreams-raw-blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
zolting committed Nov 21, 2024
2 parents 57cde27 + a36e450 commit 006bdba
Show file tree
Hide file tree
Showing 52 changed files with 339,352 additions and 3,375 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ version = "0.0.0"

[workspace.dependencies]
substreams = "0.6"
substreams-database-change = "2"
substreams-ethereum = "0.10"
substreams-antelope = "0.6"
substreams-solana = "0.14"
substreams-cosmos = "0.2"
substreams-bitcoin = "2.0"
prost = "0.13"
prost-types = "0.13"
serde_json = "1.0"
substreams-bitcoin = "2.0"
# substreams-near = "0.9"
3 changes: 1 addition & 2 deletions blocks/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
common = { path = "../../common" }
substreams-ethereum = { workspace = true }
substreams-database-change = { workspace = true }
# substreams-beacon = { workspace = true }
substreams = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
14 changes: 1 addition & 13 deletions blocks/beacon/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
.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: protogen
protogen:
substreams protogen --exclude-paths google
substreams protogen

.PHONY: parquet
parquet:
Expand Down
35 changes: 35 additions & 0 deletions blocks/beacon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# `Beacon` Raw Blockchain Data

> Cosmos
> [`sf.beacon.type.v1.Block`](https://buf.build/pinax/firehose-beacon/docs/main:sf.beacon.type.v1)
- [x] **Block**
- [x] **Blob**
- [x] **Deposit**
- [x] **Withdrawal**
- [x] **Attestation**
- [x] **AttesterSlashing**
- [x] **BlsToExecutionChange**
- [x] **ProposerSlashing**
- [x] **VoluntaryExit**

## Graph

```mermaid
graph TD;
map_events[map: map_events];
sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> map_events;
sf.beacon.type.v1.Block[source: sf.beacon.type.v1.Block] --> map_events;
```

## Modules

```bash
Name: map_events
Initial block: 0
Kind: map
Input: source: sf.substreams.v1.Clock
Input: source: sf.beacon.type.v1.Block
Output Type: proto:beacon.Events
Hash: fa22a8c409b87871edb85e753a7feda2e94bbdb9
```
194 changes: 0 additions & 194 deletions blocks/beacon/proto/beacon.rawblocks.proto

This file was deleted.

2 changes: 1 addition & 1 deletion blocks/beacon/src/attestations.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use common::utils::bytes_to_hex;

use crate::{
pb::{beacon::Attestation as RawAttestation, sf::beacon::r#type::v1::Attestation},
pb::{pinax::beacon::v1::Attestation as RawAttestation, sf::beacon::r#type::v1::Attestation},
structs::BlockTimestamp,
};

Expand Down
57 changes: 30 additions & 27 deletions blocks/beacon/src/attester_slashings.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
use common::utils::{bytes_to_hex, number_array_to_string};
use common::utils::bytes_to_hex;

use crate::{
pb::{beacon::AttesterSlashing as RawAttesterSlashing, sf::beacon::r#type::v1::AttesterSlashing},
pb::{
pinax::beacon::v1::AttesterSlashing as RawAttesterSlashing,
sf::beacon::r#type::v1::{AttesterSlashing, IndexedAttestation},
},
structs::BlockTimestamp,
};

pub fn collect_attester_slashings(attester_slashings: &Vec<AttesterSlashing>, timestamp: &BlockTimestamp) -> Vec<RawAttesterSlashing> {
let mut vec = Vec::<RawAttesterSlashing>::new();

for (index, attester_slashing) in attester_slashings.iter().enumerate() {
vec.push(RawAttesterSlashing {
block_time: Some(timestamp.time),
block_number: timestamp.number,
block_date: timestamp.date.clone(),
block_hash: timestamp.hash.clone(),
index: index as u64,
attestation_1_attesting_indices: number_array_to_string(&attester_slashing.attestation_1.as_ref().unwrap().attesting_indices),
attestation_1_slot: attester_slashing.attestation_1.as_ref().unwrap().data.as_ref().unwrap().slot,
attestation_1_committee_index: attester_slashing.attestation_1.as_ref().unwrap().data.as_ref().unwrap().committee_index,
attestation_1_beacon_block_root: bytes_to_hex(&attester_slashing.attestation_1.as_ref().unwrap().data.as_ref().unwrap().beacon_block_root),
attestation_1_source_epoch: attester_slashing.attestation_1.as_ref().unwrap().data.as_ref().unwrap().source.as_ref().unwrap().epoch,
attestation_1_source_root: bytes_to_hex(&attester_slashing.attestation_1.as_ref().unwrap().data.as_ref().unwrap().source.as_ref().unwrap().root),
attestation_1_target_epoch: attester_slashing.attestation_1.as_ref().unwrap().data.as_ref().unwrap().target.as_ref().unwrap().epoch,
attestation_1_target_root: bytes_to_hex(&attester_slashing.attestation_1.as_ref().unwrap().data.as_ref().unwrap().target.as_ref().unwrap().root),
attestation_1_signature: bytes_to_hex(&attester_slashing.attestation_1.as_ref().unwrap().signature),
attestation_2_attesting_indices: number_array_to_string(&attester_slashing.attestation_2.as_ref().unwrap().attesting_indices),
attestation_2_slot: attester_slashing.attestation_2.as_ref().unwrap().data.as_ref().unwrap().slot,
attestation_2_committee_index: attester_slashing.attestation_2.as_ref().unwrap().data.as_ref().unwrap().committee_index,
attestation_2_beacon_block_root: bytes_to_hex(&attester_slashing.attestation_2.as_ref().unwrap().data.as_ref().unwrap().beacon_block_root),
attestation_2_source_epoch: attester_slashing.attestation_2.as_ref().unwrap().data.as_ref().unwrap().source.as_ref().unwrap().epoch,
attestation_2_source_root: bytes_to_hex(&attester_slashing.attestation_2.as_ref().unwrap().data.as_ref().unwrap().source.as_ref().unwrap().root),
attestation_2_target_epoch: attester_slashing.attestation_2.as_ref().unwrap().data.as_ref().unwrap().target.as_ref().unwrap().epoch,
attestation_2_target_root: bytes_to_hex(&attester_slashing.attestation_2.as_ref().unwrap().data.as_ref().unwrap().target.as_ref().unwrap().root),
attestation_2_signature: bytes_to_hex(&attester_slashing.attestation_2.as_ref().unwrap().signature),
});
vec.push(parse_attester_slashings(index as u64, &attester_slashing.attestation_1.as_ref().unwrap(), timestamp));
vec.push(parse_attester_slashings(index as u64, &attester_slashing.attestation_2.as_ref().unwrap(), timestamp));
}
vec
}

pub fn parse_attester_slashings(index: u64, indexed_attestation: &IndexedAttestation, timestamp: &BlockTimestamp) -> RawAttesterSlashing {
let data = indexed_attestation.data.as_ref().unwrap();
let source = data.source.as_ref().unwrap();
let target = data.target.as_ref().unwrap();

RawAttesterSlashing {
block_time: Some(timestamp.time),
block_number: timestamp.number,
block_date: timestamp.date.clone(),
block_hash: timestamp.hash.clone(),
index,
attesting_indices: indexed_attestation.attesting_indices.clone(),
slot: data.slot,
committee_index: data.committee_index,
beacon_block_root: bytes_to_hex(&data.beacon_block_root),
source_epoch: source.epoch,
source_root: bytes_to_hex(&source.root),
target_epoch: target.epoch,
target_root: bytes_to_hex(&target.root),
signature: bytes_to_hex(&indexed_attestation.signature),
}
}
2 changes: 1 addition & 1 deletion blocks/beacon/src/blobs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use common::utils::bytes_to_hex;

use crate::{
pb::{beacon::Blob as RawBlob, sf::beacon::r#type::v1::Blob},
pb::{pinax::beacon::v1::Blob as RawBlob, sf::beacon::r#type::v1::Blob},
structs::BlockTimestamp,
utils::encode_hex_2d_array,
};
Expand Down
2 changes: 1 addition & 1 deletion blocks/beacon/src/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use common::utils::bytes_to_hex;

use crate::{
pb::{beacon::Block, sf::beacon::r#type::v1::Block as BeaconBlock},
pb::{pinax::beacon::v1::Block, sf::beacon::r#type::v1::Block as BeaconBlock},
structs::BlockTimestamp,
};

Expand Down
2 changes: 1 addition & 1 deletion blocks/beacon/src/bls_to_execution_changes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use common::utils::bytes_to_hex;

use crate::{
pb::{beacon::BlsToExecutionChange as RawBlsToExecutionChange, sf::beacon::r#type::v1::SignedBlsToExecutionChange},
pb::{pinax::beacon::v1::BlsToExecutionChange as RawBlsToExecutionChange, sf::beacon::r#type::v1::SignedBlsToExecutionChange},
structs::BlockTimestamp,
};

Expand Down
Loading

0 comments on commit 006bdba

Please sign in to comment.