-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix(x/staking): make metadata nullable #22556
Changes from all commits
5cc08df
a4a5a6b
f4d6a37
cc6c67b
accb7ec
09e8221
826779d
3313e2b
6edb300
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,7 +493,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { | |
sdk.ValAddress(addr).String(), | ||
valPubKeys[i], | ||
sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens), | ||
stakingtypes.NewDescription(nodeDirName, "", "", "", "", stakingtypes.Metadata{}), | ||
stakingtypes.NewDescription(nodeDirName, "", "", "", "", &stakingtypes.Metadata{}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Several test files need to be updated to use pointer metadata The
🔗 Analysis chainLGTM! Change aligns with making metadata nullable. The modification to use a pointer for metadata aligns with the PR objective of making the field nullable, which helps avoid the need for validator migrations. Let's verify that this change doesn't break existing tests: The search results show that there are several test files and simulation code using 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for existing test cases that might be affected by the metadata change
rg -l "NewDescription.*Metadata" --type go | while read -r file; do
echo "=== $file ==="
rg -A 5 "NewDescription.*Metadata" "$file"
done
Length of output: 6401 Script: #!/bin/bash
# Check the NewDescription function signature in the staking types
ast-grep --pattern 'func NewDescription($$$) Description'
Length of output: 708 |
||
stakingtypes.NewCommissionRates(commission, sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), | ||
sdkmath.OneInt(), | ||
) | ||
|
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.
💡 Codebase verification
Add test coverage for nil metadata scenarios in validator initialization
Based on the verification results, the current test suite lacks explicit test cases for validators with nil metadata or mixed metadata scenarios. The existing tests only cover cases where metadata is always initialized with an empty struct (
&types.Metadata{}
). To ensure robust handling of metadata:tests/integration/staking/keeper/genesis_test.go
for:🔗 Analysis chain
Verify test coverage for large validator set initialization.
The test appropriately verifies genesis initialization with a large validator set (200 validators) and maintains proper test coverage for the metadata changes. However, consider adding test cases that explicitly verify:
Let's verify if there are any existing test cases for nil metadata:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 109
Script:
Length of output: 4427
Script:
Length of output: 84
Script:
Length of output: 140
Script:
Length of output: 80
Script:
Length of output: 74
Script:
Length of output: 147