This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
validator: Add --enable-bigtable-ledger-upload flag
#12040
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
67da0e6
Add --enable-bigtable-ledger-upload flag
mvines ba9a56b
Relocate BigTable uploader to ledger/ crate
mvines ca4191d
Cargo.lock
mvines b5f96b4
Add BigTableUploadService
mvines b234abc
Add BigTableUploadService
mvines 5820fa8
Add exit flag for bigtable upload operations
mvines 7a1409c
Remove dead code
mvines d422717
Request correct access
mvines 3af90dd
Add LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY
mvines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| use solana_ledger::blockstore::Blockstore; | ||
| use solana_runtime::commitment::BlockCommitmentCache; | ||
| use std::{ | ||
| sync::atomic::{AtomicBool, Ordering}, | ||
| sync::{Arc, RwLock}, | ||
| thread::{self, Builder, JoinHandle}, | ||
| }; | ||
| use tokio::runtime; | ||
|
|
||
| // Delay uploading the largest confirmed root for this many slots. This is done in an attempt to | ||
| // ensure that the `CacheBlockTimeService` has had enough time to add the block time for the root | ||
| // before it's uploaded to BigTable. | ||
| // | ||
| // A more direct connection between CacheBlockTimeService and BigTableUploadService would be | ||
| // preferable... | ||
| const LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY: usize = 100; | ||
|
|
||
| pub struct BigTableUploadService { | ||
| thread: JoinHandle<()>, | ||
| } | ||
|
|
||
| impl BigTableUploadService { | ||
| pub fn new( | ||
| runtime_handle: runtime::Handle, | ||
| bigtable_ledger_storage: solana_storage_bigtable::LedgerStorage, | ||
| blockstore: Arc<Blockstore>, | ||
| block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>, | ||
| exit: Arc<AtomicBool>, | ||
| ) -> Self { | ||
| info!("Starting BigTable upload service"); | ||
| let thread = Builder::new() | ||
| .name("bigtable-upload".to_string()) | ||
| .spawn(move || { | ||
| Self::run( | ||
| runtime_handle, | ||
| bigtable_ledger_storage, | ||
| blockstore, | ||
| block_commitment_cache, | ||
| exit, | ||
| ) | ||
| }) | ||
| .unwrap(); | ||
|
|
||
| Self { thread } | ||
| } | ||
|
|
||
| fn run( | ||
| runtime: runtime::Handle, | ||
| bigtable_ledger_storage: solana_storage_bigtable::LedgerStorage, | ||
| blockstore: Arc<Blockstore>, | ||
| block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>, | ||
| exit: Arc<AtomicBool>, | ||
| ) { | ||
| let mut start_slot = 0; | ||
| loop { | ||
| if exit.load(Ordering::Relaxed) { | ||
| break; | ||
| } | ||
|
|
||
| let end_slot = block_commitment_cache | ||
| .read() | ||
| .unwrap() | ||
| .highest_confirmed_root() | ||
| .saturating_sub(LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY as u64); | ||
|
|
||
| if end_slot <= start_slot { | ||
| std::thread::sleep(std::time::Duration::from_secs(1)); | ||
| continue; | ||
| } | ||
|
|
||
| let result = runtime.block_on(solana_ledger::bigtable_upload::upload_confirmed_blocks( | ||
| blockstore.clone(), | ||
| bigtable_ledger_storage.clone(), | ||
| start_slot, | ||
| Some(end_slot), | ||
| true, | ||
| exit.clone(), | ||
| )); | ||
|
|
||
| match result { | ||
| Ok(()) => start_slot = end_slot, | ||
| Err(err) => { | ||
| warn!("bigtable: upload_confirmed_blocks: {}", err); | ||
| std::thread::sleep(std::time::Duration::from_secs(2)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub fn join(self) -> thread::Result<()> { | ||
| self.thread.join() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's slightly awkward that
BigTableUploadServiceis plumbed intoRpcServicelike this. Moving it up a level intoValidatorwould require moving the tokio Runtime andsolana_storage_bigtable::LedgerStorage::newas well and I didn't like that code churn in this PR. That's my excuse at least