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

[Consensus] Small enhancement to the invalid blocks metric #19515

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

akichidis
Copy link
Contributor

Description

Use the hostname whenever possible. Add the error type as well.

Test plan

CI


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Sep 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 9:30am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Sep 25, 2024 9:30am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 25, 2024 9:30am
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 25, 2024 9:30am

@@ -104,11 +108,12 @@ impl<C: CoreThreadDispatcher> NetworkService for AuthorityService<C> {

// Reject blocks failing validations.
if let Err(e) = self.block_verifier.verify(&signed_block) {
let error: &'static str = e.clone().into();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will derive the error enum name only, not parameters etc, so cardinality will be low.

Copy link
Member

@mwtian mwtian Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test for this pattern only returns the enum name in BlockVerifier? Totally optional.

Copy link
Contributor

@arun-koshy arun-koshy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

.with_label_values(&[
peer_hostname,
"handle_send_block",
"BlockSignatureMissmatchSender",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/missmatch/mismatch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or UnexpectedAuthority as the error below. Signature is not verified here. This is only checking the peer against indicated author of the block.

.with_label_values(&[
peer_hostname,
"handle_send_block",
"BlockSignatureMissmatchSender",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or UnexpectedAuthority as the error below. Signature is not verified here. This is only checking the peer against indicated author of the block.

@@ -104,11 +108,12 @@ impl<C: CoreThreadDispatcher> NetworkService for AuthorityService<C> {

// Reject blocks failing validations.
if let Err(e) = self.block_verifier.verify(&signed_block) {
let error: &'static str = e.clone().into();
Copy link
Member

@mwtian mwtian Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test for this pattern only returns the enum name in BlockVerifier? Totally optional.

@@ -159,11 +159,19 @@ impl BlockManager {
}
}
for (block_ref, block) in blocks_to_reject {
// It's safe to look up in the authority here since we know that the block has been already verified either via the synchronization methods.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// It's safe to look up in the authority here since we know that the block has been already verified either via the synchronization methods.

@@ -611,11 +611,25 @@ impl<C: NetworkClient, V: BlockVerifier, D: CoreThreadDispatcher> Synchronizer<C
if let Err(e) = block_verifier.verify(&signed_block) {
// TODO: we might want to use a different metric to track the invalid "served" blocks
// from the invalid "proposed" ones.

// It's important to check the validity of the index, otherwise the method will panic.
let hostname = if context.committee.is_valid_index(signed_block.author()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pass the peer_index to verify_blocks() instead? The peer is the culprit here since it should not serve invalid blocks to others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good point. I'll switch to using the peer_index. We need to keep in mind then that for an invalid block report on the metrics we can see either:

  1. the original author coming up
  2. or the peer to served an invalid block

there is no good way to distinguish anyways unless we always report both, but for now might be good enough

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For timestamp checks, only the block authority is available, which should be equivalent to the peer here since the block has been verified. Or are there other places where peer is unavailable? We can take the opportunity to see if it is possible to fix them. For a few errors, the indicated author can be arbitrary so counting them in metrics is not very useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are there other places where peer is unavailable?

There shouldn't. At least from all the synchronization paths peer is available.

Copy link
Member

@mwtian mwtian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a great improvement! Thanks!

@akichidis akichidis merged commit 15de3f2 into main Sep 26, 2024
48 checks passed
@akichidis akichidis deleted the akichidis/enhance-invalid-block-metric branch September 26, 2024 08:49
@@ -720,11 +722,16 @@ impl<C: NetworkClient, V: BlockVerifier, D: CoreThreadDispatcher> Synchronizer<C
for serialized_block in blocks {
let signed_block = bcs::from_bytes(&serialized_block).map_err(ConsensusError::MalformedBlock)?;
block_verifier.verify(&signed_block).tap_err(|err|{
let hostname = if context.committee.is_valid_index(signed_block.author()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use authority_index instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch! Fixed it here #19597

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