Skip to content

Conversation

aarongable
Copy link
Contributor

@aarongable aarongable commented Oct 18, 2025

Add metrics to the nonce server which give visibility into how many nonces it is currently tracking, and what distribution of nonce ages it actually sees. This should help us better understand the in-memory behavior of the nonce server, so we can better debug issues related to invalid nonce errors.

Also add much more detailed error messages throughout the nonce redemption pipeline. Have the nonce server's valid() helper method return individual error messages based on why the nonce was invalid. Have the nonce service itself return those error messages to the WFE, rather than simply returning "Valid: false". Finally, have the WFE suppress those detailed error messages when displaying BadNonce errors to the end-user, so they end up in our logs but not in user-facing API responses.

Finally, due to the refactoring of the nonce service's .valid() helper above, simplify some unnecessary layers of abstraction within the nonce package. Remove the distinction between the "NonceService" (which contained all nonce logic) and the "NonceServer" (which implemented the gRPC interface). Make the non-gRPC methods unexported, since they're really just helper methods. Simplify the inmem nonce service to look exactly like the other inmem services, forwarding calls to the real gRPC implementation rather than to the underlying NonceService.

@aarongable aarongable changed the title Lightly refactor nonce service to clean up abstraction Add visibility into nonce redemption failure causes Oct 18, 2025
@aarongable aarongable marked this pull request as ready for review October 21, 2025 23:02
@aarongable aarongable requested a review from a team as a code owner October 21, 2025 23:02
@aarongable aarongable requested a review from jprenken October 21, 2025 23:02
Copy link
Member

@beautifulentropy beautifulentropy left a comment

Choose a reason for hiding this comment

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

Style nits; otherwise it looks good. Nice job removing that unnecessary layer of abstraction 👍🏻

// the largest nonce we've actually handed out), then the age is negative.
age := float64(ns.latest-c) / float64(ns.latest-ns.earliest)

if c > ns.latest { // i.e. age < 0
Copy link
Member

Choose a reason for hiding this comment

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

Stylistically, we avoid inline comments.

Suggested change
if c > ns.latest { // i.e. age < 0
if c > ns.latest {
// i.e. age < 0

}

if c <= ns.earliest {
if c <= ns.earliest { // i.e. age >= 1
Copy link
Member

Choose a reason for hiding this comment

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

Same style comment as above.

Suggested change
if c <= ns.earliest { // i.e. age >= 1
if c <= ns.earliest {
// i.e. age >= 1

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.

4 participants