Skip to content

feat: add SAE last executed and last settled height metrics#5362

Open
JonathanOppenheimer wants to merge 17 commits into
masterfrom
JonathanOppenheimer/sae-lifecycle-frontier-metrics
Open

feat: add SAE last executed and last settled height metrics#5362
JonathanOppenheimer wants to merge 17 commits into
masterfrom
JonathanOppenheimer/sae-lifecycle-frontier-metrics

Conversation

@JonathanOppenheimer
Copy link
Copy Markdown
Contributor

@JonathanOppenheimer JonathanOppenheimer commented May 8, 2026

Why this should be merged

This PR adds two new SAE-specific metrics, last_executed_height and last_settled_height, registered under the sae namespace. Snowman already publishes last_accepted_height, but execution and settlement heights are SAE-only.

Once these guages are added, you can compute lag as shown below

avalanche_snowman_last_accepted_height - avalanche_<vm>_sae_last_executed_height
avalanche_snowman_last_accepted_height - avalanche_<vm>_sae_last_settled_height

This is the first PR in a planned series of PRs to add metrics, as outlined in the shared Notion document.

How this works

I tried to follow general Prometheus best practices here, and follow the AVM metrics pattern (as suggested to me by Stephen). We add a *saemetrics.Metrics field on the VM, and a separate *prometheus.Registry for registration.

How this was tested

I added three tests:

  • TestMetrics: calls MarkBlockExecuted(6) and MarkBlockSettled(7) and asserts both gauges hold the expected heights.
  • TestExecutionMetrics: asserts LastExecutedHeight advances.
  • TestSettlementMetric: asserts LastSettledHeight advances.

Need to be documented in RELEASES.md?

Yes

@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/sae-lifecycle-frontier-metrics branch from 160920e to a3a8190 Compare May 8, 2026 18:58
@JonathanOppenheimer JonathanOppenheimer changed the title Jonathan oppenheimer/sae lifecycle frontier metrics feat: add SAE last executed and last settled height metrics May 8, 2026
Comment thread vms/saevm/metrics/metrics_test.go Outdated
@JonathanOppenheimer JonathanOppenheimer self-assigned this May 8, 2026
@JonathanOppenheimer JonathanOppenheimer added evm Related to EVM functionality sae labels May 8, 2026
Comment thread vms/saevm/sae/vm.go Outdated
Comment on lines +60 to +61
metricRegistry *prometheus.Registry
metrics *saemetrics.Metrics
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is an intentional choice to have the metricRegistry as the *prometheus.Registry used for registration and /ext/metrics (and as already used for registerer for the bloom/gossip/p2p metrics) while metrics is used to record metrics updates.

Comment thread vms/saevm/sae/vm.go Outdated
@JonathanOppenheimer JonathanOppenheimer marked this pull request as ready for review May 8, 2026 19:47
@JonathanOppenheimer JonathanOppenheimer requested a review from ARR4N as a code owner May 8, 2026 19:47
Copilot AI review requested due to automatic review settings May 8, 2026 19:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SAE-specific Prometheus gauges to expose the VM’s async execution and settlement frontiers, enabling operators to compute lag vs Snowman’s last accepted height.

Changes:

  • Introduces sae_last_executed_height and sae_last_settled_height gauges (via a new vms/saevm/metrics package).
  • Wires the new metrics into SAE VM initialization, block execution, and settlement paths.
  • Adds unit/integration tests and updates Bazel deps and RELEASES.md.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vms/saevm/txgossip/txgossip_test.go Updates executor construction in tests to provide SAE metrics.
vms/saevm/txgossip/BUILD.bazel Adds metrics dependency for txgossip tests.
vms/saevm/saexec/saexec.go Threads SAE metrics through the executor.
vms/saevm/saexec/saexec_test.go Adds a test for last executed height metric (potentially timing-sensitive).
vms/saevm/saexec/execution.go Updates last executed height metric after successful execution.
vms/saevm/saexec/BUILD.bazel Adds metrics + Prometheus testutil deps.
vms/saevm/sae/vm.go Registers an SAE-prefixed registry and instantiates SAE metrics; passes registry to other subsystems.
vms/saevm/sae/vm_test.go Adds a settlement metric test.
vms/saevm/sae/consensus.go Updates last settled height metric when blocks settle during acceptance.
vms/saevm/sae/BUILD.bazel Adds deps for metrics + testutil.
vms/saevm/metrics/metrics.go New SAE metrics collectors and update helpers.
vms/saevm/metrics/metrics_test.go Unit test for the new metrics helpers.
vms/saevm/metrics/BUILD.bazel New Bazel targets for metrics package + tests.
RELEASES.md Documents the newly added gauges in pending release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vms/saevm/saexec/saexec_test.go Outdated
Comment thread vms/saevm/saexec/execution.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread vms/saevm/saexec/saexec.go
Comment thread RELEASES.md Outdated
…-metrics

Signed-off-by: Jonathan Oppenheimer <jonathan.oppenheimer@avalabs.org>
@JonathanOppenheimer JonathanOppenheimer requested a review from a team as a code owner May 18, 2026 14:53
Comment thread vms/saevm/sae/vm.go
Comment thread vms/saevm/metrics/metrics.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think making a "metrics" package makes sense. This metrics struct IMO should be unexported in whatever package has access to each metric. Do you agree?

Copy link
Copy Markdown
Contributor Author

@JonathanOppenheimer JonathanOppenheimer May 20, 2026

Choose a reason for hiding this comment

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

I modeled this after avalanchego/avm/metrics. I don't think it's as simple as unexporting it in whatever package has access to each metric -- sae and saeexec -- we need host it, and then export it somewhere. This package will also grow over time as we add more metrics, all of which not be as tightly coupled to an individual package.

What do you think?

I could at least unexport the gauge fields so callers can only go through MarkBlockExecuted/MarkBlockSettled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We talked in the office about this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Does this look better?

Comment thread RELEASES.md Outdated
Comment thread vms/saevm/saexec/metrics.go Outdated
JonathanOppenheimer and others added 3 commits May 22, 2026 12:50
Co-authored-by: Tsvetan Dimitrov <tsvetan.dimitrov23@gmail.com>
Signed-off-by: Jonathan Oppenheimer <147infiniti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

evm Related to EVM functionality sae

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants