-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
225 additions
and
99 deletions.
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 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 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 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 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 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,57 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use std::num::NonZeroUsize; | ||
|
||
use prometheus::Registry; | ||
use sui_types::digests::CheckpointDigest; | ||
use tracing::info; | ||
|
||
use sui_archival::reader::{ArchiveReader, ArchiveReaderMetrics}; | ||
use sui_config::node::ArchiveReaderConfig; | ||
use sui_config::object_storage_config::{ObjectStoreConfig, ObjectStoreType}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub(crate) struct ArchivalCheckpointInfo { | ||
pub next_checkpoint_after_epoch: u64, | ||
#[allow(unused)] | ||
pub chain_identifier: CheckpointDigest, | ||
} | ||
|
||
pub(crate) async fn read_archival_checkpoint_info( | ||
archive_bucket: Option<String>, | ||
epoch: u64, | ||
) -> Result<ArchivalCheckpointInfo, anyhow::Error> { | ||
let archive_store_config = ObjectStoreConfig { | ||
object_store: Some(ObjectStoreType::GCS), | ||
bucket: archive_bucket, | ||
object_store_connection_limit: 50, | ||
no_sign_request: false, | ||
..Default::default() | ||
}; | ||
let archive_reader_config = ArchiveReaderConfig { | ||
remote_store_config: archive_store_config, | ||
download_concurrency: NonZeroUsize::new(50).unwrap(), | ||
use_for_pruning_watermark: false, | ||
}; | ||
let metrics = ArchiveReaderMetrics::new(&Registry::default()); | ||
let archive_reader = ArchiveReader::new(archive_reader_config, &metrics)?; | ||
archive_reader.sync_manifest_once().await?; | ||
let manifest = archive_reader.get_manifest().await?; | ||
let next_checkpoint_after_epoch = manifest.next_checkpoint_after_epoch(epoch); | ||
info!( | ||
"Read from archives: next checkpoint sequence after epoch {} is: {}", | ||
epoch, next_checkpoint_after_epoch | ||
); | ||
let cp_summaries = archive_reader | ||
.get_summaries_for_list_no_verify(vec![0]) | ||
.await?; | ||
let first_cp = cp_summaries | ||
.first() | ||
.ok_or_else(|| anyhow::anyhow!("No checkpoint found"))?; | ||
let chain_identifier = *first_cp.digest(); | ||
Ok(ArchivalCheckpointInfo { | ||
next_checkpoint_after_epoch, | ||
chain_identifier, | ||
}) | ||
} |
This file contains 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 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.