Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: parse chain-id from big genesis file could be slow #18204
perf: parse chain-id from big genesis file could be slow #18204
Changes from 26 commits
192261b
7c59903
ee9b00a
567ee2d
55be3ec
9c220f5
c74ba3b
7680cdd
1035e32
4677221
be3a3f7
7cd0787
c84599c
df3e2a3
3d7ef1a
b09130e
d52f3b6
1ad9a8f
63b604c
a4cc48a
7a58af1
5147d1c
5d99b23
ba767d9
2d3ba07
310b580
5145bac
1bb078f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
The new code introduces a more efficient way of parsing the
chain_id
from the genesis JSON file. Instead of loading the entire file into memory, it uses a streaming JSON parser to parse the file until thechain_id
field is found. This approach significantly reduces memory usage and processing time. However, the use ofpanic
for error handling is not recommended. It would be better to return the error to the caller and let it decide how to handle the error. This would make the code more robust and easier to debug.Committable suggestion (Beta)
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.
The test cases for
TestParseChainIDFromGenesis
are well-structured and cover a variety of scenarios, including successful parsing, missingchain_id
, invalid JSON, andchain_id
that is too long, empty, or contains only whitespace. This is a good practice as it ensures that the function behaves as expected in different situations. However, there is a minor issue with the error message checking. The test cases are checking for a substring of the error message, which might lead to false positives if the error messages are changed in the future. It would be better to compare the entire error message to ensure accuracy.