Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"yellowstone-grpc-client", # 11.0.1
"yellowstone-grpc-geyser", # 11.0.1
"yellowstone-grpc-proto", # 11.0.1
"yellowstone-proto",
]
exclude = [
"yellowstone-grpc-client-nodejs/napi", # 0.2.0
Expand Down Expand Up @@ -93,6 +94,7 @@ spl-token-2022-interface = "2.0.0"
# Yellowstone
yellowstone-grpc-client = { path = "yellowstone-grpc-client", version = "11.0.1" }
yellowstone-grpc-proto = { path = "yellowstone-grpc-proto", version = "11.0.1", default-features = false }
yellowstone-proto = { path = "yellowstone-proto" }

[workspace.lints.clippy]
clone_on_ref_ptr = "deny"
Expand Down
3 changes: 3 additions & 0 deletions yellowstone-grpc-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ solana-transaction-error = { workspace = true, optional = true }
# Solana Misc
spl-token-2022-interface = { workspace = true, optional = true }

# Yellowstone
yellowstone-proto = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }
prost_011 = { workspace = true }
Expand Down
28 changes: 28 additions & 0 deletions yellowstone-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "yellowstone-proto"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
publish.workspace = true

[dependencies]
bytes = { workspace = true }
prost = { workspace = true, optional = true }
prost-types = { workspace = true, optional = true }

# Solana SDK
solana-clock = { workspace = true }
solana-hash = { workspace = true }
solana-pubkey = { workspace = true }
solana-signature = { workspace = true }

[features]
default = []
prost = ["dep:prost", "dep:prost-types"]

[lints]
workspace = true
2 changes: 2 additions & 0 deletions yellowstone-proto/src/codec/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[cfg(feature = "prost")]
pub mod prost;
Empty file.
12 changes: 12 additions & 0 deletions yellowstone-proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub mod types;
pub mod codec;

pub use types::account::AccountInfo;
pub use types::entry::Entry;
pub use types::slot::SlotInfo;
pub use types::common::{CommitmentLevel, SlotStatus, Reward, RewardType};
pub use types::transaction::{
Transaction, TransactionInfo, TransactionStatusMeta, Message,
MessageHeader, CompiledInstruction, InnerInstruction, InnerInstructions,
MessageAddressTableLookup, TokenBalance, UiTokenAmount, ReturnData, TransactionError,
};
15 changes: 15 additions & 0 deletions yellowstone-proto/src/types/account.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use bytes::Bytes;
use solana_pubkey::Pubkey;
use solana_signature::Signature;

#[derive(Debug, Clone, PartialEq)]
pub struct AccountInfo {
pub pubkey: Pubkey,
pub lamports: u64,
pub owner: Pubkey,
pub executable: bool,
pub rent_epoch: u64,
pub data: Bytes,
pub write_version: u64,
pub txn_signature: Option<Signature>,
}
35 changes: 35 additions & 0 deletions yellowstone-proto/src/types/block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::time::SystemTime;

use solana_hash::Hash;

use crate::{AccountInfo, Entry, TransactionInfo, types::common::Reward};

#[derive(Debug, Clone, PartialEq)]
pub struct Rewards {
pub rewards: Vec<Reward>,
pub num_partitions: Option<u64>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct BlockMeta {
pub slot: u64,
pub blockhash: Hash,
pub rewards: Option<Rewards>,
pub block_time: Option<i64>,
pub block_height: Option<u64>,
pub parent_slot: u64,
pub parent_blockhash: Hash,
pub executed_transaction_count: u64,
pub entries_count: u64,
pub created_at: SystemTime,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Block {
pub meta: BlockMeta,
pub transactions: Vec<TransactionInfo>,
pub updated_account_count: u64,
pub accounts: Vec<AccountInfo>,
pub entries: Vec<Entry>,
pub created_at: SystemTime,
}
37 changes: 37 additions & 0 deletions yellowstone-proto/src/types/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use solana_pubkey::Pubkey;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum CommitmentLevel {
Processed,
Confirmed,
Finalized,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum SlotStatus {
Processed,
Confirmed,
Finalized,
FirstShredReceived,
Completed,
CreatedBank,
Dead,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum RewardType {
Unspecified,
Fee,
Rent,
Staking,
Voting,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Reward {
pub pubkey: Pubkey,
pub lamports: i64,
pub post_balance: u64,
pub reward_type: RewardType,
pub commission: Option<u8>,
}
13 changes: 13 additions & 0 deletions yellowstone-proto/src/types/entry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::time::SystemTime;
use solana_hash::Hash;

#[derive(Debug, Clone, PartialEq)]
pub struct Entry {
pub slot: u64,
pub index: usize,
pub num_hashes: u64,
pub hash: Hash,
pub executed_transaction_count: u64,
pub starting_transaction_index: u64,
pub created_at: SystemTime,
}
6 changes: 6 additions & 0 deletions yellowstone-proto/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub mod account;
pub mod transaction;
pub mod block;
pub mod entry;
pub mod slot;
pub mod common;
13 changes: 13 additions & 0 deletions yellowstone-proto/src/types/slot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::time::SystemTime;
use solana_clock::Slot;

use crate::types::common::SlotStatus;

#[derive(Debug, Clone, PartialEq)]
pub struct SlotInfo {
pub slot: Slot,
pub parent: Option<Slot>,
pub status: SlotStatus,
pub dead_error: Option<String>,
pub created_at: SystemTime,
}
110 changes: 110 additions & 0 deletions yellowstone-proto/src/types/transaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
use bytes::Bytes;
use solana_pubkey::Pubkey;
use solana_signature::Signature;
use crate::types::common::Reward;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MessageHeader {
pub num_required_signatures: u8,
pub num_readonly_signed_accounts: u8,
pub num_readonly_unsigned_accounts: u8,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CompiledInstruction {
pub program_id_index: u8,
pub accounts: Vec<u8>,
pub data: Bytes,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MessageAddressTableLookup {
pub account_key: Pubkey,
pub writable_indexes: Vec<u8>,
pub readonly_indexes: Vec<u8>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TransactionError {
pub err: Bytes,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct InnerInstruction {
pub program_id_index: u8,
pub accounts: Vec<u8>,
pub data: Bytes,
pub stack_height: Option<u32>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ReturnData {
pub program_id: Pubkey,
pub data: Bytes,
}

#[derive(Debug, Clone, PartialEq)]
pub struct UiTokenAmount {
pub ui_amount: f64,
pub decimals: u8,
pub amount: String,
pub ui_amount_string: String,
}

#[derive(Debug, Clone, PartialEq)]
pub struct TokenBalance {
pub account_index: u8,
pub mint: Pubkey,
pub ui_token_amount: UiTokenAmount,
pub owner: Pubkey,
pub program_id: Pubkey,
}

#[derive(Debug, Clone, PartialEq)]
pub struct InnerInstructions {
pub index: u8,
pub instructions: Vec<InnerInstruction>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Message {
pub header: MessageHeader,
pub account_keys: Vec<Pubkey>,
pub recent_blockhash: [u8; 32],
pub instructions: Vec<CompiledInstruction>,
pub versioned: bool,
pub address_table_lookups: Vec<MessageAddressTableLookup>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Transaction {
pub signatures: Vec<Signature>,
pub message: Message,
}

#[derive(Debug, Clone, PartialEq)]
pub struct TransactionStatusMeta {
pub err: Option<TransactionError>,
pub fee: u64,
pub pre_balances: Vec<u64>,
pub post_balances: Vec<u64>,
pub inner_instructions: Option<Vec<InnerInstructions>>,
pub log_messages: Option<Vec<String>>,
pub pre_token_balances: Vec<TokenBalance>,
pub post_token_balances: Vec<TokenBalance>,
pub rewards: Vec<Reward>,
pub loaded_writable_addresses: Vec<Pubkey>,
pub loaded_readonly_addresses: Vec<Pubkey>,
pub return_data: Option<ReturnData>,
pub compute_units_consumed: Option<u64>,
pub cost_units: Option<u64>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct TransactionInfo {
pub signature: Signature,
pub is_vote: bool,
pub transaction: Transaction,
pub meta: TransactionStatusMeta,
pub index: usize,
}