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

blockstream store to disk #339

Open
wants to merge 180 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
3c34866
put block sequence invariants in a debugging task
grooviegermanikus Jan 22, 2024
b919309
add to main
grooviegermanikus Jan 22, 2024
f16adc8
switch to blockhash instead of slot
grooviegermanikus Jan 22, 2024
3960491
update dependencies
grooviegermanikus Jan 22, 2024
1dd9ef3
WIP use autoconnect_task
grooviegermanikus Jan 22, 2024
b372c6d
merge into stream
grooviegermanikus Jan 22, 2024
3df4972
handle shutdown
grooviegermanikus Jan 22, 2024
a899c0d
cleanup
grooviegermanikus Jan 22, 2024
009d273
use autoconnect also for blockmeta
grooviegermanikus Jan 22, 2024
4055183
use new autoconnect
grooviegermanikus Jan 22, 2024
b372bc4
deploy experimental
grooviegermanikus Jan 22, 2024
c56ec56
enable experimental
grooviegermanikus Jan 22, 2024
c28b54c
reverrt fly log
grooviegermanikus Jan 22, 2024
2105ed7
wire up slot
grooviegermanikus Jan 23, 2024
fbcd730
small renamings
grooviegermanikus Jan 23, 2024
0ddd4db
use autoconnect for blocks too
grooviegermanikus Jan 23, 2024
c7e7b67
remove staging region
grooviegermanikus Jan 23, 2024
da0fdee
cleanup task
grooviegermanikus Jan 23, 2024
4f6952c
FIX panic in multiplex
grooviegermanikus Jan 23, 2024
fa9ca19
improve log
grooviegermanikus Jan 23, 2024
0fc9b5b
handle timeout in slot stream
grooviegermanikus Jan 23, 2024
d44379b
comment on task termination
grooviegermanikus Jan 24, 2024
e681727
cleanup
grooviegermanikus Jan 24, 2024
a64e699
handle poll_vote_accounts_and_cluster_info errors
grooviegermanikus Jan 24, 2024
62f89f4
handle poll_vote_accounts_and_cluster_info errors
grooviegermanikus Jan 24, 2024
15f3dfa
remove debug code
grooviegermanikus Jan 24, 2024
ba40c70
add logic to store finalized meta and merge with full processed block
grooviegermanikus Jan 24, 2024
ae17f20
add debug stream tasks
grooviegermanikus Jan 24, 2024
cdeb2e2
check previous_blockhash
grooviegermanikus Jan 24, 2024
0d1e81c
improve shutdown
grooviegermanikus Jan 24, 2024
e9f2280
log liveness
grooviegermanikus Jan 24, 2024
b4512e6
stream BlockMeta
grooviegermanikus Jan 25, 2024
9aed98a
add error log
grooviegermanikus Jan 29, 2024
8874da7
Merge remote-tracking branch 'origin/main' into improvement/check-blo…
grooviegermanikus Jan 31, 2024
ff30ecc
remove failing check
grooviegermanikus Jan 31, 2024
d494163
clippy+fmt
grooviegermanikus Jan 31, 2024
c1fbd0b
merge from main
grooviegermanikus Feb 6, 2024
b76a6ef
reduce log level to "warn"
grooviegermanikus Feb 6, 2024
63b682e
fmt
grooviegermanikus Feb 6, 2024
40eee04
use tagged geyser-grpc-connector
grooviegermanikus Feb 6, 2024
7f210b4
fix cargo fmt
grooviegermanikus Feb 6, 2024
9bad056
remove obsolete cleanup_without_recv_blocks
grooviegermanikus Feb 7, 2024
d3df98e
fix clippy
grooviegermanikus Feb 7, 2024
175918e
fmt glitch
grooviegermanikus Feb 7, 2024
f8c622d
listen to blocks, serialize
grooviegermanikus Feb 7, 2024
6ffb7b0
roundtrip
grooviegermanikus Feb 7, 2024
f3e0ea3
wip
grooviegermanikus Feb 9, 2024
9dc675f
use dump helper
grooviegermanikus Feb 26, 2024
09efd94
move grpc dumper to literpc
grooviegermanikus Feb 26, 2024
17d847d
add decription for args
grooviegermanikus Feb 26, 2024
372c67c
use write_all
grooviegermanikus Feb 26, 2024
96d7dc2
fmt
grooviegermanikus Feb 26, 2024
1bb3546
clippy
grooviegermanikus Feb 26, 2024
8908d7b
claify error
grooviegermanikus Feb 26, 2024
05a9726
Merge remote-tracking branch 'origin/main' into feature/blockstream_s…
grooviegermanikus Feb 26, 2024
8139f3d
pass commitment_config
grooviegermanikus Feb 26, 2024
857dea8
ignore local test
grooviegermanikus Feb 26, 2024
da14a8f
Merge remote-tracking branch 'origin/main' into feature/blockstream_s…
grooviegermanikus Mar 4, 2024
f36b92d
move bin to exapmles
grooviegermanikus Mar 4, 2024
66654c6
move grpc block dumper to examples crate
grooviegermanikus Mar 4, 2024
fb65ae4
clippy
grooviegermanikus Mar 4, 2024
fdf93b4
cleanup lib from cargo.toml
grooviegermanikus Mar 4, 2024
1519c5f
fix STOARGE issue with pre pg16
grooviegermanikus Mar 4, 2024
a059b3b
fix STORAGE DDL
grooviegermanikus Mar 4, 2024
2b27887
optimize block column ordering
grooviegermanikus Mar 4, 2024
3af5531
reorder columns
grooviegermanikus Mar 4, 2024
d8300da
add autovacuum settings
grooviegermanikus Mar 4, 2024
6eac0e1
fix typo
grooviegermanikus Mar 4, 2024
b71e7d5
wire blockstore
grooviegermanikus Mar 4, 2024
4ab483e
WIP: expose postgres on get_blocks RPC
grooviegermanikus Mar 4, 2024
dbee46d
very basic get_blocks logic
grooviegermanikus Mar 4, 2024
0283a6a
add postgres block importer to main
grooviegermanikus Mar 4, 2024
9a6ba06
clippy
grooviegermanikus Mar 4, 2024
06e03ae
db config
grooviegermanikus Mar 4, 2024
c6581fd
fix ddl
grooviegermanikus Mar 4, 2024
1ce9a47
reset connection (discard)
grooviegermanikus Mar 4, 2024
f104fce
pg connection
grooviegermanikus Mar 4, 2024
94b3b63
postgres version check
grooviegermanikus Mar 4, 2024
b212a7f
demo: life without sessioncache
grooviegermanikus Mar 5, 2024
e4c5b8f
remove clone
grooviegermanikus Mar 5, 2024
32d02e6
working version without pool
grooviegermanikus Mar 5, 2024
2f212b1
use dedicated create_transaction_ids method
grooviegermanikus Mar 5, 2024
404aea1
varchar(88)
grooviegermanikus Mar 5, 2024
0c80c55
move recent_blockhash
grooviegermanikus Mar 5, 2024
00049b9
compress text using lz4
grooviegermanikus Mar 5, 2024
0da6df2
fix version check
grooviegermanikus Mar 5, 2024
f7c6a80
fix create table error
grooviegermanikus Mar 5, 2024
816701d
use varchar(44) for blockhash
grooviegermanikus Mar 5, 2024
9beab6a
comment on join
grooviegermanikus Mar 6, 2024
38970bc
make pg_config env more flexible
grooviegermanikus Mar 6, 2024
2fe0b41
fix chunk logging
grooviegermanikus Mar 6, 2024
6c6a04c
increase timeout after lot of reconnects on hetzner
grooviegermanikus Mar 6, 2024
a4dffa2
remove iteration timer
grooviegermanikus Mar 6, 2024
b5d03a3
handle block stream closed
grooviegermanikus Mar 6, 2024
f9ca0f8
compare testnet and local
grooviegermanikus Mar 6, 2024
21d80a0
add rpc custom error mapping
grooviegermanikus Mar 6, 2024
a56f098
flip mapper args
grooviegermanikus Mar 6, 2024
45da593
map more errors
grooviegermanikus Mar 6, 2024
9e27816
complete rpc error mapping
grooviegermanikus Mar 6, 2024
357d150
add index for transaction in block
grooviegermanikus Mar 6, 2024
32ae398
bridge test
grooviegermanikus Mar 7, 2024
3582bac
test with recent slot
grooviegermanikus Mar 7, 2024
881b2ff
cleanup
grooviegermanikus Mar 7, 2024
c8add5d
truncate transactions
grooviegermanikus Mar 7, 2024
dda7958
mapper test
grooviegermanikus Mar 7, 2024
9634150
mapped UiConfirmedBlock
grooviegermanikus Mar 7, 2024
07c80d8
investigate transaction versioning
grooviegermanikus Mar 7, 2024
8dba74b
add comments on mapping todos
grooviegermanikus Mar 7, 2024
52862dd
mapper test
grooviegermanikus Mar 7, 2024
bfe1abe
wip tests
grooviegermanikus Mar 7, 2024
a25132c
green test versioned
grooviegermanikus Mar 8, 2024
c88bf9c
map legacy + v0
grooviegermanikus Mar 8, 2024
b95fdc9
track message_version
grooviegermanikus Mar 8, 2024
a2c9cef
soft fail on sql errors
grooviegermanikus Mar 8, 2024
693f344
brush up migrations
grooviegermanikus Mar 8, 2024
a5ef43b
map fee, pre_balances, post_balances
grooviegermanikus Mar 8, 2024
1fbaf65
map serializied inner instructions
grooviegermanikus Mar 8, 2024
9a150ca
fix create idx
grooviegermanikus Mar 8, 2024
da46fd2
map inner_instructions
grooviegermanikus Mar 8, 2024
7969cc1
remove extra let
grooviegermanikus Mar 8, 2024
7875709
map log_messages, writable_accounts, readable_accounts
grooviegermanikus Mar 8, 2024
3b07979
comment on mapping improvements
grooviegermanikus Mar 11, 2024
2b9c9d3
move integration test
grooviegermanikus Mar 11, 2024
06ce41f
fix mapping test
grooviegermanikus Mar 11, 2024
acc9724
move mapping tests
grooviegermanikus Mar 11, 2024
0041940
move mapping tests
grooviegermanikus Mar 11, 2024
f6c0e02
cleanup tests
grooviegermanikus Mar 11, 2024
5709cbc
cleanup tests
grooviegermanikus Mar 11, 2024
7b5fdd9
fix inner_instructions mapping
grooviegermanikus Mar 11, 2024
3a24ae6
cleanup tests
grooviegermanikus Mar 11, 2024
eff3bba
serialize to jsonb/jsonb[]
grooviegermanikus Mar 11, 2024
34b9eb4
map pre_token_balances+post_token_balances
grooviegermanikus Mar 11, 2024
4a37c77
split query dto
grooviegermanikus Mar 11, 2024
fe4bf63
Revert "split query dto"
grooviegermanikus Mar 11, 2024
caebac1
add prometheus literpc_blockstore_postgres to postgres_session
grooviegermanikus Mar 12, 2024
0ba567c
format (+ add set statement_timeout)
grooviegermanikus Mar 12, 2024
524bd95
workaround to map signatures without require full tx_with_meta
grooviegermanikus Mar 12, 2024
5bc10fd
debug stmt for slow execute()
grooviegermanikus Mar 13, 2024
52e56f3
track timings without buckets
grooviegermanikus Mar 13, 2024
408ff5a
weak signature compression
grooviegermanikus Mar 13, 2024
dc672aa
increase autovacuum delays
grooviegermanikus Mar 13, 2024
db888d0
increase autovacuum delays
grooviegermanikus Mar 13, 2024
2742251
set min_freeze_age=0
grooviegermanikus Mar 13, 2024
fdce38a
fix inner instruction mapping for rpc
grooviegermanikus Mar 13, 2024
f8c6c34
run optimize on every loop
grooviegermanikus Mar 13, 2024
970caef
rename
grooviegermanikus Mar 13, 2024
6d66f78
optimizer impl
grooviegermanikus Mar 13, 2024
b85f586
lock table in insert
grooviegermanikus Mar 13, 2024
5bb47eb
unique index fillfactor=80
grooviegermanikus Mar 13, 2024
a9f6f80
use crazy create table returning pattern
grooviegermanikus Mar 13, 2024
e2a945d
set lock_timeout
grooviegermanikus Mar 13, 2024
69f2947
use mapping table
grooviegermanikus Mar 13, 2024
60d0bfb
add tracing
grooviegermanikus Mar 13, 2024
37fbc34
fmt
grooviegermanikus Mar 13, 2024
ece0ad4
increase work_mem:
grooviegermanikus Mar 13, 2024
e30c57a
ONLY 1 write_session
grooviegermanikus Mar 13, 2024
e112402
format elapsed times as 0.00ms
grooviegermanikus Mar 14, 2024
2268cd0
refactor chunk logic
grooviegermanikus Mar 14, 2024
5018824
print explain plan
grooviegermanikus Mar 14, 2024
dac6d7b
add regex
grooviegermanikus Mar 14, 2024
c43d0f0
MODEL CHANGE: change pkey to (slot,transaction_id)
grooviegermanikus Mar 14, 2024
e8c2f04
improve write_speed test
grooviegermanikus Mar 14, 2024
49bd29f
fix test
grooviegermanikus Mar 14, 2024
2db819a
fix logging of timings
grooviegermanikus Mar 14, 2024
43ca986
comment out execute_explain (citus does not like it)
grooviegermanikus Mar 14, 2024
6666dda
add metric literpc_blockstore_save_block
grooviegermanikus Mar 14, 2024
d137e12
remove confusing 'remaining 4 queue elements' log which happend due t…
grooviegermanikus Mar 14, 2024
647734e
set PARALLEL_WRITE_SESSIONS to 4
grooviegermanikus Mar 14, 2024
dfed888
detect CITUS extension
grooviegermanikus Mar 14, 2024
2932997
PARALLEL_WRITE_SESSIONS from 4 to 1
grooviegermanikus Mar 14, 2024
48ab0d6
distribute by transaction_id instead of slot
grooviegermanikus Mar 14, 2024
3f67375
add semikolon to pl sql
grooviegermanikus Mar 14, 2024
10bf2e1
distribute by blocks.slot + transaction_ids.transaction_id
grooviegermanikus Mar 14, 2024
979e3d4
fix sql
grooviegermanikus Mar 14, 2024
3f02f6c
cannot distribute transaction_ids
grooviegermanikus Mar 14, 2024
a594a40
remove RETURNING from insert (citus does not like it)
grooviegermanikus Mar 15, 2024
05ab3eb
comment on work_mem
grooviegermanikus Mar 15, 2024
590b61d
fix insert block check
grooviegermanikus Mar 15, 2024
fbbb2d5
add sigature as join to transaction_id JOIN not supported by citus
grooviegermanikus Mar 15, 2024
2cfd044
cache epoch schema lookups
grooviegermanikus Mar 15, 2024
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
120 changes: 119 additions & 1 deletion Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ members = [
"accounts",
"accounts-on-demand",
#examples
"examples/custom-tpu-send-transactions"
"examples/custom-tpu-send-transactions",
"examples/dump-blocks-from-grpc-to-disk",
"examples/query-blockstore",
]

[workspace.package]
Expand Down
7 changes: 6 additions & 1 deletion blockstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ solana-rpc-client-api = {workspace = true}
native-tls = { workspace = true }
postgres-native-tls = { workspace = true }
anyhow = { workspace = true }
log = {workspace = true}
log = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["std", "env-filter"] }
chrono = {workspace = true}
serde = { workspace = true }
Expand All @@ -34,10 +35,14 @@ base64 = {workspace = true}
itertools = {workspace = true}
rangetools = {workspace = true}
tokio-postgres = { version = "0.7.8", features = ["with-chrono-0_4"] }
postgres-types = { version = "0.2.6", features = ["derive", "with-serde_json-1"] }
prometheus = { workspace = true }
futures = {workspace = true}
futures-util = {workspace = true}
bytes = "1.5.0"
rand = "0.8.5"
lazy_static = "1.4.0"
regex = "1.10.3"

[dev-dependencies]
tracing-subscriber = { workspace = true }
12 changes: 6 additions & 6 deletions blockstore/examples/bench_postgres_simple_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ use itertools::Itertools;
/// test program to query postgres the simples possible way
///
use log::info;
use solana_lite_rpc_blockstore::block_stores::postgres::BlockstorePostgresSessionConfig;
use solana_lite_rpc_blockstore::block_stores::postgres::PostgresSession;
use solana_lite_rpc_blockstore::block_stores::postgres::PostgresSessionConfig;

#[tokio::main(flavor = "multi_thread", worker_threads = 16)]
pub async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();

let pg_session_config = PostgresSessionConfig::new_for_tests();
let pg_session_config = BlockstorePostgresSessionConfig::new_for_tests();

let single_session = PostgresSession::new(pg_session_config.clone())
.await
.unwrap();
// run one query
query_database_simple(single_session).await;
query_database_simple(&single_session).await;
info!("single query test ... done");

// run parallel queries
Expand All @@ -26,7 +26,7 @@ pub async fn main() -> anyhow::Result<()> {
Ok(())
}

async fn parallel_queries(pg_session_config: PostgresSessionConfig) {
async fn parallel_queries(pg_session_config: BlockstorePostgresSessionConfig) {
let many_sessions = vec![
PostgresSession::new(pg_session_config.clone())
.await
Expand Down Expand Up @@ -56,15 +56,15 @@ async fn parallel_queries(pg_session_config: PostgresSessionConfig) {

let futures = (0..many_sessions.len())
.map(|si| {
let session = many_sessions[si].clone();
let session = &many_sessions[si];
query_database_simple(session)
})
.collect_vec();

futures_util::future::join_all(futures).await;
}

async fn query_database_simple(postgres_session: PostgresSession) {
async fn query_database_simple(postgres_session: &PostgresSession) {
let statement = "SELECT 1";

let started = tokio::time::Instant::now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use solana_transaction_status::{TransactionDetails, UiTransactionEncoding};
use std::ops::RangeInclusive;
use std::sync::Arc;

#[derive(Clone)]
pub struct FaithfulBlockStore {
faithful_rpc_client: Arc<RpcClient>, // to fetch legacy blocks from faithful_history
}
Expand Down
20 changes: 11 additions & 9 deletions blockstore/src/block_stores/multiple_strategy_block_store.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::block_stores::faithful_history::faithful_block_store::FaithfulBlockStore;
use crate::block_stores::postgres::postgres_block_store_query::PostgresQueryBlockStore;
use anyhow::{bail, Context, Result};
use log::{debug, trace};

use log::{debug, info, trace};
use solana_lite_rpc_core::structures::produced_block::ProducedBlock;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;

use solana_sdk::slot_history::Slot;
use std::ops::{Deref, RangeInclusive};
use std::sync::Arc;

#[derive(Debug, Clone)]
pub enum BlockSource {
Expand All @@ -18,7 +18,6 @@ pub enum BlockSource {

#[derive(Debug, Clone)]
pub struct BlockStorageData {
// note: commitment_config is the actual commitment level
pub block: ProducedBlock,
// meta data
pub result_source: BlockSource,
Expand All @@ -32,6 +31,7 @@ impl Deref for BlockStorageData {
}

// you might need to add a read-cache instead
// #[derive(Clone)]
pub struct MultipleStrategyBlockStorage {
block_storage_query: PostgresQueryBlockStore,
// note supported ATM
Expand All @@ -40,10 +40,12 @@ pub struct MultipleStrategyBlockStorage {
}

impl MultipleStrategyBlockStorage {
pub fn new(
block_storage_query: PostgresQueryBlockStore,
_faithful_rpc_client: Option<Arc<RpcClient>>,
) -> Self {
pub fn new(block_storage_query: PostgresQueryBlockStore) -> Self {
info!(
"Initializing MultipleStrategyBlockStorage {} faithful history storage",
"without"
);

Self {
block_storage_query,
// faithful_history not used ATM
Expand Down Expand Up @@ -108,7 +110,7 @@ impl MultipleStrategyBlockStorage {
.block_storage_query
.query_block(slot)
.await
.context(format!("block {} not found although it was in range", slot));
.context(format!("query block {} from postgres", slot));

return lookup.map(|b| BlockStorageData {
block: b,
Expand Down
Loading