Skip to content

fix: metrics validator label to use address instead of pk struct formatting#1201

Merged
karlem merged 4 commits intomainfrom
fix-validator-label
Nov 15, 2024
Merged

fix: metrics validator label to use address instead of pk struct formatting#1201
karlem merged 4 commits intomainfrom
fix-validator-label

Conversation

@LePremierHomme
Copy link
Copy Markdown
Contributor

@LePremierHomme LePremierHomme commented Nov 14, 2024

Closes #1190

I used address instead of the public key hex encoding. Can change that if wanted.

@LePremierHomme LePremierHomme requested a review from a team as a code owner November 14, 2024 14:13
@LePremierHomme LePremierHomme changed the title fix(metrics): validator label to use address instead of pk formatting fix: metrics validator label to use address instead of pk struct formatting Nov 14, 2024
Copy link
Copy Markdown
Contributor

@raulk raulk left a comment

Choose a reason for hiding this comment

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

It's unfortunate we have to do this conversion. Two things:

  1. We should make record_metrics() fallible by returning a Result<()>. Then we can avoid having panicking code, and the higher level component would log errors in the error event type. @karlem could you drop a link to an example where we use that event type?
  2. Would add a TODO so we try to propagate the FVM address in the validator context.

@raulk
Copy link
Copy Markdown
Contributor

raulk commented Nov 15, 2024

@LePremierHomme nit: the "closing" keyword is not supported by GitHub to link the issue, but "closes", "close", "closed" are. https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

@LePremierHomme
Copy link
Copy Markdown
Contributor Author

  1. We should make record_metrics() fallible by returning a Result<()>. Then we can avoid having packing code, and the higher level component would log errors in the error event type. @karlem could you drop a link to an example where we use that event type?

Not sure I understand the purpose of having it fallible. To propagate encoding errors?

  1. Would add a TODO so we try to propagate the FVM address in the validator context.

The public key is what's used as the validator key for comparisons. I guess it would be better to just derive Address as a view, or fix it as an additional field in the context. It seems to be currently needed just for the metrics, so I could also just change CheckpointSigned to contain the address instead of the public key.

@karlem
Copy link
Copy Markdown
Contributor

karlem commented Nov 15, 2024

We should make record_metrics() fallible by returning a Result<()>. This way, we can avoid having packing code, and the higher-level component would log errors using the error event type. @karlem, could you provide a link to an example where we use this event type?

In general, I agree—failing to record a metric should not cause a panic that shuts down the whole node. Here's an example of how to emit a tracing error:

emit(TracingError {
.

However, given point 2:

Would add a TODO so we try to propagate the FVM address in the validator context.

I would suggest we include this change in the current PR. It’s a simple modification—see here:

ValidatorContext::new(sk, broadcaster)
.

By including the address in the event directly, we can skip the conversion altogether and eliminate the need to make record_metrics() fallible. At least for now!

@karlem
Copy link
Copy Markdown
Contributor

karlem commented Nov 15, 2024

@LePremierHomme , the address is already being converted in run.rs. I suggest including it in the ValidatorContext and then using it directly in the event.

@raulk
Copy link
Copy Markdown
Contributor

raulk commented Nov 15, 2024

SGTM!

@raulk
Copy link
Copy Markdown
Contributor

raulk commented Nov 15, 2024

Thank you, @karlem! 🙏

@LePremierHomme
Copy link
Copy Markdown
Contributor Author

Changed ValidatorContext to hold the to_address conversion made during app start.

As for making record_metrics() fallible: none of the current implementations contain fallible code, and I think it’s unlikely that they will.
Any thoughts on that? @karlem @raulk

Copy link
Copy Markdown
Contributor

@karlem karlem left a comment

Choose a reason for hiding this comment

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

@LePremierHomme I think it's fine like this now. Since we do not cause panic in the record_metrics.

@karlem karlem merged commit d33333a into main Nov 15, 2024
@karlem karlem deleted the fix-validator-label branch November 15, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

Metrics validator label in expanded formet

3 participants