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

feat: calculate state root in background #12933

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

keefel
Copy link

@keefel keefel commented Nov 28, 2024

Description

This PR adds an option to calculate the state root in the background, improving block insertion performance during live sync.

Rationale

Calculating the state root during live sync takes a lot of time, resulting in poor performance. This feature allows for background calculation of the state root and merges calculations for multiple blocks to update the trie simultaneously. Our tests show that enabling this feature can improve performance from 50 mgasps to 400 mgasps.

Without this feature:
image

With this feature enabled:
image

Example

NA

Changes

Notable changes:

  • Calculate the state root in the background.
  • Merge the calculation of the state root for multiple blocks.

Potential Impacts

  • The persistent database should align with the background calculation of the state root.
  • When unwinding blocks, you can only unwind to the block where the state root has been calculated.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

thanks for this,

the way this is implemented isn't something we want to include as is.

the node's main loop can already be customized, although we definitely need to make this more convenient.

and it'd be nice to reuse the existing engine/tree logic but make it customizable.
so what I'd like to do instead is narrow down what needs to be configurable.
it looks like you want a modified on_new_payload function essentially?

so what I'd try instead is making this part configurable via some trait based (trait Handler) approach, basically a type that's responsible for this

before you spend more time on these features, I'd recommend opening an issue for this feature so we can come up with an appropriate solution for this

@keefel
Copy link
Author

keefel commented Dec 6, 2024

thanks for this,

the way this is implemented isn't something we want to include as is.

the node's main loop can already be customized, although we definitely need to make this more convenient.

and it'd be nice to reuse the existing engine/tree logic but make it customizable. so what I'd like to do instead is narrow down what needs to be configurable. it looks like you want a modified on_new_payload function essentially?

so what I'd try instead is making this part configurable via some trait based (trait Handler) approach, basically a type that's responsible for this

before you spend more time on these features, I'd recommend opening an issue for this feature so we can come up with an appropriate solution for this

Thank you for your response. I will open an issue for this feature.

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