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 13 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.
Can we maybe move this to genutil? Imho this makes more sense to have it there as its genesis related than in types.
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.
done
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.
No need for this declaration yet down below we do: t, err := dec.Token()
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.
expected string for the key type, got %s
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
validateChainID
function checks if thechain_id
is not empty and if its length does not exceedtypes.MaxChainIDLen
. However, it would be better to also check ifchain_id
is not a string of whitespace characters because the current implementation considers a string of spaces as a validchain_id
.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.
@yihuang, this is a great suggestion from the rabbit! We can do it one shot though by making it the first check so
and that covers both cases where it was an empty string and where it only contains whitespace
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.
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.
sounds good, done.
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.
If you wanna rigorously tighten the checks, you can do a substring match for the expected error e.g. require.Contains(t, err.Error(), "not a string")
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.
done, assert the error string.