-
Notifications
You must be signed in to change notification settings - Fork 45
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
Eng 766. List bottom up checkpoint status. #748
base: main
Are you sure you want to change the base?
Changes from 17 commits
d33c46e
940d90f
14552d5
1cb48d8
57996a9
c2492fb
500535e
24ca1b5
66ed3c5
5c1b797
06e9337
59c2685
e9861e3
0b9b2c4
7a6ae82
f330ab7
d953d59
b61682c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2022-2024 Protocol Labs | ||
// SPDX-License-Identifier: MIT | ||
//! List the bottom up checkpoint status | ||
|
||
use std::fmt::Debug; | ||
use std::str::FromStr; | ||
|
||
use async_trait::async_trait; | ||
use clap::Args; | ||
use fvm_shared::clock::ChainEpoch; | ||
use ipc_api::subnet_id::SubnetID; | ||
|
||
use crate::commands::get_ipc_provider; | ||
use crate::{CommandLineHandler, GlobalArguments}; | ||
|
||
const DEFAULT_LIMIT_UNSUBMITTED: usize = 10; | ||
|
||
/// The command to list bottom up checkpoint status. | ||
pub(crate) struct Status; | ||
|
||
#[async_trait] | ||
impl CommandLineHandler for Status { | ||
type Arguments = StatusArgs; | ||
|
||
async fn handle(global: &GlobalArguments, arguments: &Self::Arguments) -> anyhow::Result<()> { | ||
log::debug!("bottom up checkpoint status with args: {:?}", arguments); | ||
|
||
let provider = get_ipc_provider(global)?; | ||
let subnet = SubnetID::from_str(&arguments.subnet)?; | ||
|
||
let last_checkpointed_height = provider.last_bottom_up_checkpoint_height(&subnet).await?; | ||
let checkpoint = provider | ||
.get_bottom_up_bundle(&subnet, last_checkpointed_height) | ||
.await?; | ||
let period = provider.checkpoint_period(&subnet).await?; | ||
let chain_head = provider.get_chain_head_height(&subnet).await?; | ||
|
||
println!("subnet chain head height: {}", chain_head); | ||
println!( | ||
"last submitted checkpoint (@ subnet height {}): {:?}", | ||
last_checkpointed_height, checkpoint | ||
); | ||
|
||
let limit_unsubmitted = arguments | ||
.limit_unsubmitted | ||
.unwrap_or(DEFAULT_LIMIT_UNSUBMITTED); | ||
|
||
let start = last_checkpointed_height + 1; | ||
let ending = limit_unsubmitted as ChainEpoch * period + start; | ||
let mut checkpoints_ahead = 0; | ||
for h in start..=ending { | ||
let c = provider.get_bottom_up_bundle(&subnet, h).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be cleaner to make this return an Option? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is handled in previous PR: #743 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you query the whole bundle at every height to see if there is a potential checkpoint, right? Can't this be queried with the events API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is indeed a PR that I changed the query from |
||
if c.checkpoint.block_height != 0 { | ||
checkpoints_ahead += 1; | ||
} | ||
} | ||
println!( | ||
"there are at least {} unsubmitted checkpoints (limiting query to: {})", | ||
checkpoints_ahead, limit_unsubmitted | ||
); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
#[command(about = "Summarise the bottom up checkpointing status of a subnet")] | ||
pub(crate) struct StatusArgs { | ||
#[arg(long, help = "The subnet to inspect")] | ||
pub subnet: String, | ||
#[arg( | ||
long, | ||
help = "Limit unsubmitted checkpoints to print (looking forward from last submitted), default: 10" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it doesn't necessarily limit the number of checkpoints to print, only the number of checkpoint periods to look ahead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also find it confusing that the title and the docs say that it "lists checkpoint statuses", but I don't see any listing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. basically just display a bunch of metrics/fields related to bottom up checkpointing. |
||
)] | ||
pub limit_unsubmitted: Option<usize>, | ||
} |
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 would be nice to explain what's happening.
For example I don't know if
last_checkpointed_height
is a) height in the subnet of the last created checkpoint or b) the last submitted checkpoint in the parent.