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

saving blocks + tx to Postgres + basic multi-storage-strategy #242

Closed
wants to merge 108 commits into from

Conversation

grooviegermanikus
Copy link
Collaborator

@grooviegermanikus grooviegermanikus commented Nov 13, 2023

Follow up comments in Postgres Block Persistence PR

  • note: LiteRPC is not configures to use the Postgres Block Storage neither the Multi-Storage-Strategy ATM
  • OOS: no read path / get_block
  • fix postgres types
  • small changes to Postgres query building
  • use Postgres "COPY IN" and dedicates writer connections to persist block+transactions
  • add Postgres optimizations/indizes Debug Statements
  • create epoch schemata automatically
  • improve multi-storage-strategy
  • add simple "integration" test using RPC poller
  • remove the in memory storage in favor of simplicity

Testing

Integration Test using RPC Polling

(pointing to a local postgres)

RPC_URL="https://api.testnet.rpcpool.com/TOKEN" RUST_LOG="info,storage_integration_tests=debug,solana_lite_rpc_history=trace" PG_CONFIG="host=localhost dbname=literpc3 user=literpc_app password=litelitesecret sslmode=disable" cargo test --test storage_integration_tests storage_test

Testing Storage interface

postgres_block_store.rs::test_save_block

Testrun on Dallas Box vs. Mainnet

image

2023-11-21T12:26:14.053297Z DEBUG solana_lite_rpc_history::block_stores::postgres_block_store: Saving block 231362699 to postgres took 0.75ms for block and 12.73ms for 455 transactions (1x500 chunks)
2023-11-21T12:26:14.053550Z DEBUG storage_integration_tests: Successfully stored block to postgres which took 16.53ms - remaining 0 queue elements
2023-11-21T12:26:15.613252Z DEBUG storage_integration_tests: Received block: 231362700 with 4021 txs
2023-11-21T12:26:15.619548Z DEBUG storage_integration_tests: Saw block: 231362700 @ confirmed with 4021 txs
2023-11-21T12:26:15.622187Z DEBUG solana_lite_rpc_history::postgres::postgres_block: Inserted block 231362700 with prev highest slot being 231362699, parent=231362699
2023-11-21T12:26:15.622226Z DEBUG solana_lite_rpc_history::postgres::postgres_block: Inserting block 231362700 row to schema rpc2a_epoch_535 postgres took 0.62ms
2023-11-21T12:26:15.664621Z DEBUG solana_lite_rpc_history::block_stores::postgres_block_store: Saving block 231362700 to postgres took 0.64ms for block and 42.35ms for 4021 transactions (4x1006 chunks)
2023-11-21T12:26:15.665578Z DEBUG storage_integration_tests: Successfully stored block to postgres which took 52.35ms - remaining 0 queue elements
2023-11-21T12:26:17.780265Z DEBUG storage_integration_tests: Received block: 231362648 with 3914 txs
2023-11-21T12:26:17.780313Z DEBUG solana_lite_rpc_history::block_stores::postgres_block_store: Checking block 231362648 if we can progress it to finalized ...
2023-11-21T12:26:17.783888Z DEBUG storage_integration_tests: Saw block: 231362648 @ finalized with 3914 txs
2023-11-21T12:26:17.791985Z WARN solana_lite_rpc_history::postgres::postgres_block: Block 231362648 already exists - not updated
2023-11-21T12:26:17.792029Z DEBUG solana_lite_rpc_history::block_stores::postgres_block_store: Block 231362648 already exists - skip update
2023-11-21T12:26:17.793151Z DEBUG storage_integration_tests: Successfully stored block to postgres which took 12.91ms - remaining 0 queue elements

what's next?

  • implement get_block
  • decouple streaming
  • add more soft realtime checks
  • improve integration testing
  • measure back pressure ingress-vs-write
  • measure end-to-end timings from channel.recv until DB update
  • extract multi-storage-strategy to a "router"-network-component
  • add read-cache for postgres+faithful
  • add metrics

@grooviegermanikus grooviegermanikus marked this pull request as draft November 21, 2023 15:29
@grooviegermanikus grooviegermanikus marked this pull request as ready for review November 27, 2023 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants