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

[Perf] Avoid tx root derivation during block generation #2577

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from

Conversation

vicsn
Copy link
Contributor

@vicsn vicsn commented Nov 21, 2024

Motivation

Transaction, deployment and execution root derivation take up 90% of compute of block generation when excluding transaction verification. Fortunately, the ids can be cached at practically 0 cost.

If this is approved, I'll also apply the change to to_unconfirmed_id and potentially other calls to to_deployment_id and to_execution_id.

Test Plan

  • Local network succeeds.
  • Deployed network with traffic succeeds.

@vicsn vicsn changed the title Avoid tx root derivation during block generation [Perf] Avoid tx root derivation during block generation Nov 22, 2024
@@ -105,6 +105,16 @@ impl<N: Network> Deployment<N> {
Ok(u64::try_from(self.to_bytes_le()?.len())?)
}

/// Returns the number of program functions in the deployment.
pub fn len(&self) -> usize {
Copy link
Collaborator

@ljedrz ljedrz Nov 25, 2024

Choose a reason for hiding this comment

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

is len making it obvious that this refers to the number of functions in the program? otherwise num_functions might be a better pick; the same comment applies to is_empty

Copy link
Contributor Author

@vicsn vicsn Nov 25, 2024

Choose a reason for hiding this comment

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

Indeed its a bit of an odd naming without context, though it is not unnatural. The Deployment contains just one vector which equals the number of functions/verifying_keys/certificates.

I mainly did this to have consistent naming with Execution::len, where it refers to the number of transitions. This PR then uses both deployment.len() and execution.len() to determine at which "index" to insert an additional Fee transition.

I'd be keen to hear more reviewer's thoughts on this.

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.

2 participants