Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accounts db #416

Draft
wants to merge 11 commits into
base: 2_0_16
Choose a base branch
from
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
218 changes: 61 additions & 157 deletions Cargo.lock

Large diffs are not rendered by default.

45 changes: 23 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,26 @@ members = [
]

[workspace.package]
version = "0.2.4"
version = "0.3.0"
authors = ["gmgalactus <[email protected]>", "GroovieGermanikus <[email protected]>"]
repository = "https://github.com/blockworks-foundation/lite-rpc"
license = "AGPL"
edition = "2021"

[workspace.dependencies]

solana-lite-rpc-services = { path = "services", version="0.3.0" }
solana-lite-rpc-core = { path = "core", version="0.3.0" }
solana-lite-rpc-util = { path = "util", version="0.3.0" }
solana-lite-rpc-cluster-endpoints = { path = "cluster-endpoints", version="0.3.0" }
solana-lite-rpc-blockstore = { path = "blockstore", version="0.3.0" }
solana-lite-rpc-stakevote = { path = "stake_vote", version="0.3.0" }
solana-lite-rpc-prioritization-fees = { path = "prioritization_fees", version="0.3.0" }
solana-lite-rpc-address-lookup-tables = { path = "address-lookup-tables", version="0.3.0" }
solana-lite-rpc-accounts = { path = "accounts", version = "0.3.0"}
solana-lite-rpc-accounts-on-demand = { path = "accounts-on-demand", version = "0.3.0"}
bench = { path = "bench", version="0.3.0" }

solana-sdk = "~2.0.16"
solana-rpc-client = "~2.0.16"
solana-rpc-client-api = "~2.0.16"
Expand All @@ -42,6 +55,11 @@ solana-ledger = "~2.0.16"
solana-program = "~2.0.16"
solana-accounts-db = "~2.0.16"
solana-address-lookup-table-program = "~2.0.16"

yellowstone-grpc-proto = { git = "https://github.com/rpcpool/yellowstone-grpc.git", tag = "v2.0.0+solana.2.0.16" }
geyser-grpc-connector = { git = "https://github.com/blockworks-foundation/geyser-grpc-connector.git", tag = "v0.11.0+yellowstone.2.0.0+solana.2.0" }


itertools = "0.10.5"
rangetools = "0.1.4"
serde = { version = "1.0.160", features = ["derive"] }
Expand All @@ -51,6 +69,7 @@ bs58 = "0.4.0"
base64 = "0.21.0"
borsh = "0.10.3"
thiserror = "1.0.40"
async-trait = "0.1.68"
futures = "0.3.28"
futures-util = "0.3.28"
bytes = "1.4.0"
Expand All @@ -71,31 +90,13 @@ dotenv = "0.15.0"
async-channel = "1.8.0"
merge-streams = "0.1.2"
jemallocator = "0.5"

quinn = "0.10.2"
quinn-proto = "0.10.5"
rustls = { version = "0.21.7", default-features = false, features = ["quic"] }
tonic = "0.12"
tonic-health = "0.12"
rcgen = "0.9.3"

solana-lite-rpc-services = {path = "services", version="0.2.4"}
solana-lite-rpc-core = {path = "core", version="0.2.4"}
solana-lite-rpc-util = {path = "util", version="0.2.4"}
solana-lite-rpc-cluster-endpoints = {path = "cluster-endpoints", version="0.2.4"}
solana-lite-rpc-blockstore = {path = "blockstore", version="0.2.4"}
solana-lite-rpc-stakevote = {path = "stake_vote", version="0.2.4"}
solana-lite-rpc-prioritization-fees = {path = "prioritization_fees", version="0.2.4"}
solana-lite-rpc-address-lookup-tables = {path = "address-lookup-tables", version="0.2.4"}
solana-lite-rpc-accounts = {path = "accounts", version = "0.2.4"}
solana-lite-rpc-accounts-on-demand = {path = "accounts-on-demand", version = "0.2.4"}
bench = { path = "bench", version="0.2.4" }

yellowstone-grpc-proto = { git = "https://github.com/rpcpool/yellowstone-grpc.git", tag = "v2.0.0+solana.2.0.16" }
geyser-grpc-connector = { git = "https://github.com/blockworks-foundation/geyser-grpc-connector.git", branch = "2.0.16" } # FIXME use tag instead of branch


async-trait = "0.1.68"
tonic-health = "0.10"

[patch.crates-io.curve25519-dalek]
git = "https://github.com/anza-xyz/curve25519-dalek.git"
rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464"
rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax = docker/dockerfile:1.2
FROM rust:1.75.0 as base
FROM rust:1.81.0 as base
RUN cargo install [email protected] --locked
RUN rustup component add rustfmt
RUN apt-get update && apt-get install -y clang cmake ssh
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-benchrunner
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax = docker/dockerfile:1.2
FROM rust:1.75.0 as base
FROM rust:1.81.0 as base
RUN cargo install [email protected] --locked
RUN rustup component add rustfmt
RUN apt-get update && apt-get install -y clang cmake ssh
Expand Down
2 changes: 1 addition & 1 deletion accounts-on-demand/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "solana-lite-rpc-accounts-on-demand"
version = "0.2.4"
version = "0.3.0"
edition = "2021"
description = "Library which implements accounts on demand service in lite-rpc. Whenever account is not available it will fetch from rpc and create a geyser stream to update it automatically."
rust-version = "1.73.0"
Expand Down
2 changes: 1 addition & 1 deletion accounts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "solana-lite-rpc-accounts"
version = "0.2.4"
version = "0.3.0"
edition = "2021"
description = "Library which implements accounts in lite-rpc"
rust-version = "1.73.0"
Expand Down
32 changes: 16 additions & 16 deletions accounts/src/account_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ use anyhow::bail;
use itertools::Itertools;
use prometheus::{opts, register_int_gauge, IntGauge};
use solana_account_decoder::{UiAccount, UiDataSliceConfig};
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_rpc_client_api::{
config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
response::RpcKeyedAccount,
};
use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey, slot_history::Slot};
use tokio::sync::broadcast::Sender;

use solana_lite_rpc_core::types::BlockInfoStream;
use solana_lite_rpc_core::{
commitment_utils::Commitment,
Expand All @@ -13,13 +21,6 @@ use solana_lite_rpc_core::{
},
AnyhowJoinHandle,
};
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_rpc_client_api::{
config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
response::RpcKeyedAccount,
};
use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey, slot_history::Slot};
use tokio::sync::broadcast::Sender;

use crate::account_store_interface::{AccountLoadingError, AccountStorageInterface};

Expand Down Expand Up @@ -190,20 +191,19 @@ impl AccountService {
loop {
match blockinfo_stream.recv().await {
Ok(block_info) => {
if block_info.commitment_config.is_processed() {
// processed commitment is not processed in this loop
continue;
}
let commitment = Commitment::from(block_info.commitment_config);
let updated_accounts = this
.account_store
.process_slot_data(block_info.slot, commitment)
.await;

if block_info.commitment_config.is_finalized() {
ACCOUNT_UPDATES_FINALIZED.add(updated_accounts.len() as i64)
} else {
ACCOUNT_UPDATES_CONFIRMED.add(updated_accounts.len() as i64);
match commitment {
Commitment::Processed => {}
Commitment::Confirmed => {
ACCOUNT_UPDATES_CONFIRMED.add(updated_accounts.len() as i64);
}
Commitment::Finalized => {
ACCOUNT_UPDATES_FINALIZED.add(updated_accounts.len() as i64)
}
}

for data in updated_accounts {
Expand Down
3 changes: 2 additions & 1 deletion accounts/src/account_store_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use solana_rpc_client_api::filter::RpcFilterType;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::slot_history::Slot;

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum AccountLoadingError {
AccountNotFound,
ConfigDoesnotContainRequiredFilters,
OperationTimeOut,
FailedToSpawnTask(String),
}

#[async_trait]
Expand Down
8 changes: 5 additions & 3 deletions accounts/src/inmemory_account_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ impl AccountDataByCommitment {
.unwrap_or(true);

let mut updated = false;
if !self.processed_accounts.contains_key(&data.updated_slot) {

if let std::collections::btree_map::Entry::Vacant(e) =
self.processed_accounts.entry(data.updated_slot)
{
// processed not present for the slot
self.processed_accounts
.insert(data.updated_slot, data.clone());
e.insert(data.clone());
updated = true;
}

Expand Down
2 changes: 2 additions & 0 deletions accounts/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod account_service;
pub mod account_store_interface;
pub mod inmemory_account_store;

pub mod store;
Loading
Loading