-
Notifications
You must be signed in to change notification settings - Fork 840
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: add --use-cached-genesis-state-hash paramater #6758
feat: add --use-cached-genesis-state-hash paramater #6758
Conversation
b0dcb3d
to
ef29f33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! This implementation looks good, but we'd like to see more test coverage. Suggest adding tests to cover the changes added to BesuControllerBuilder.
@jflo I added a unit test that already covers all the code of the BesuControllerBuilder.build() method. Could you check it and suggest more places that need modification? |
sure, need to cover the added lines after 577, including assertions that the genesis hash is not recomputed when the command line option is passed. Likely need to add a test case to BesuControllerBuilderTest that does so. |
First, I renamed the parameter names. Next, I added unit tests in BesuControllerBuilderTest. There are two new unit tests. The first one addresses the scenario where the node is started for the first time. At this point, the value for The second test addresses the scenario where the node is started for the second time. By then, the In the unit tests, it's not directly tested whether a specific Therefore, the unit tests include statements within the branch conditions around the Additionally, for simulating the node's second start, the value of I hope you can review the current code to see if it meets the requirements. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nailed it. thanks!
08f8132
to
24026d4
Compare
Just now, I rebased the code to the latest because this branch has conflicts that must be resolved in "besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java". And I dropped the unit test about BesuControllerBuilder because BesuControllerBuilderTest.java has been deleted in there. |
562779e
to
299deba
Compare
Signed-off-by: lyfsn <dev.wangyu@proton.me>
299deba
to
de1e917
Compare
@lyfsn I'd like to get this merged in! but only you can update the branch |
@macfarla Perhaps it was my mistake. When submitting the PR, I might have accidentally set something that prevented you from updating the code. Is there still a way to change this setting now? |
it is repo/branch permissions on your repo. You can allow other users to push to your branch Anyway I'm going to keep an eye on CI now because it's up to date so stay tuned! |
PR description
When Besu starts, it reads the entire contents of the genesis file (besu.json) and traverses all accounts in memory to calculate the genesis state hash. This value is then compared with the contents of the database.
For custom or test networks with potentially large genesis files containing many accounts, this process can significantly lengthen startup times and increase memory usage due to the in-memory calculation of the genesis state hash.
In our testing environment, a genesis file around 1GB requires 16GB of memory and approximately 2 minutes to start the node.
In contrast, other clients like Nethermind do not read the genesis file if a genesis state hash is present in the database, resulting in significantly faster startup times, often just tens of seconds.
Other clients such as Geth, Erigon, and Reth separate initialization operations from node runtime operations, avoiding resource consumption for reading the genesis file during startup, thus achieving quick startup times.
Besu's practice of verifying the genesis file at every startup is largely to ensure user configurations are correct.
Therefore, we propose adding an option for advanced users who are certain they have not modified their genesis file and understand the implications of this option. This trade-off sacrifices some security for faster node startup times, a trade-off we believe advanced users will find acceptable.
With this option, our tests show a startup time of under 30 seconds for a 1GB genesis file, marking a significant improvement.
CLI Options and Configuration Profiles
We have introduced a new CLI option:
--use-cached-genesis-state-hash
: When this option is used to start the node, if the genesis state hash value is already stored in the database, the node will directly utilize this value for startup.Thanks for sending a pull request! Have you done the following?
doc-change-required
label to this PR if updates are required.Most advanced CI tests are deferred until PR approval, but you could:
./gradlew build
./gradlew acceptanceTest
./gradlew integrationTest
./gradlew ethereum:referenceTests:referenceTests