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

Don't compute staged ledger hash on every RPC call #16568

Merged
merged 4 commits into from
Feb 5, 2025

Conversation

georgeee
Copy link
Member

@georgeee georgeee commented Feb 4, 2025

Problem: RPC get_staged_ledger_aux_and_pending_coinbases_at_hash computes staged ledger hash on every call, which is unnecessary expensive.

Solution: use staged ledger hash from breadcrumb on each invocation of RPC.

Explain how you tested your changes:

  • One of the tests involves the new method of breadcrumb

Checklist:

  • Dependency versions are unchanged
    • Notify Velocity team if dependencies must change in CI
  • Modified the current draft of release notes with details on what is completed or incomplete within this project
  • Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • All tests pass (CI will check this if you didn't)
  • Serialized types are in stable-versioned modules
  • Does this close issues? None

Problem: RPC get_staged_ledger_aux_and_pending_coinbases_at_hash
computes staged ledger hash on every call, which is unnecessary expensive.

Solution: compute hash once and store it in the breadcrumb, then use on
each invocation of RPC.
@georgeee georgeee requested a review from a team as a code owner February 4, 2025 18:57
Copy link
Member

@svv232 svv232 left a comment

Choose a reason for hiding this comment

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

nice find!

@svv232
Copy link
Member

svv232 commented Feb 4, 2025

!ci-build-me

For the genesis block staged ledger hash is computed differently than
for other blocks, and it needs to be accounted for.
@georgeee
Copy link
Member Author

georgeee commented Feb 5, 2025

!ci-build-me

Comment on lines 13 to +16
; staged_ledger : Staged_ledger.t
; just_emitted_a_proof : bool
; transition_receipt_time : Time.t option
; staged_ledger_hash : Staged_ledger_hash.t
Copy link
Member

Choose a reason for hiding this comment

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

nit it feels a little odd that the staged ledger and the hash are decoupled, but i understand why you don't want to stick a new field into the staged ledger.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, staged ledger is a mutable structure, we'd need to think carefully about semantics of use

Breadcrumb doesn't enforce immutability of underlying staged ledger in any way, but it's being assumed by convention

@georgeee georgeee merged commit 1daa6ed into compatible Feb 5, 2025
47 checks passed
@georgeee georgeee deleted the georgeee/no-staged-ledger-hash-in-rpc branch February 5, 2025 18:37
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