-
Notifications
You must be signed in to change notification settings - Fork 131
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
chore(consensus-types): Make slashings use math.Gwei #2038
Changes from all commits
e879eb4
0b80e54
f54531f
c8a646c
e4dbb2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,7 @@ type BeaconState[ | |
NextWithdrawalValidatorIndex math.ValidatorIndex | ||
|
||
// Slashing | ||
Slashings []uint64 | ||
Slashings []math.Gwei | ||
TotalSlashing math.Gwei | ||
} | ||
|
||
|
@@ -97,7 +97,7 @@ func (st *BeaconState[ | |
randaoMixes []common.Bytes32, | ||
nextWithdrawalIndex uint64, | ||
nextWithdrawalValidatorIndex math.ValidatorIndex, | ||
slashings []uint64, | ||
slashings []math.Gwei, | ||
totalSlashing math.Gwei, | ||
) (*BeaconState[ | ||
BeaconBlockHeaderT, | ||
|
@@ -378,7 +378,7 @@ func (st *BeaconState[ | |
} | ||
subIndx = hh.Index() | ||
for _, i := range st.Slashings { | ||
hh.AppendUint64(i) | ||
hh.AppendUint64(uint64(i)) | ||
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. q: should I use 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. 🧹 Nitpick (assertive) LGTM with a suggestion: Consider documenting overflow risk The casting of
These steps would help prevent potential issues if |
||
} | ||
hh.FillUpTo32() | ||
numItems = uint64(len(st.Slashings)) | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -100,7 +100,7 @@ func generateValidBeaconState() *types.BeaconState[ | |||||||
}, | ||||||||
Balances: []uint64{32000000000, 31000000000}, | ||||||||
RandaoMixes: generateRandomBytes32(65536), | ||||||||
Slashings: []uint64{1000000000, 2000000000}, | ||||||||
Slashings: []math.Gwei{1000000000, 2000000000}, | ||||||||
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. 🧹 Nitpick (assertive) LGTM! Consider updating The change from However, for consistency, consider updating the Suggested change for line 106: - TotalSlashing: 3000000000,
+ TotalSlashing: math.Gwei(3000000000), 📝 Committable suggestion
Suggested change
|
||||||||
NextWithdrawalIndex: 7, | ||||||||
NextWithdrawalValidatorIndex: 8, | ||||||||
TotalSlashing: 3000000000, | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ type BeaconStateMarshallable[ | |
randaoMixes []common.Bytes32, | ||
nextWithdrawalIndex uint64, | ||
nextWithdrawalValidatorIndex math.U64, | ||
slashings []uint64, totalSlashing math.U64, | ||
slashings []math.U64, totalSlashing math.U64, | ||
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 Inconsistency in the type of After reviewing the occurrences of
This inconsistency can lead to confusion and potential type-related issues. It is recommended to standardize the type used for 🔗 Analysis chainType change improves consistency, but differs from PR objective The change from However, there's a discrepancy between the PR objective and the actual change:
Please clarify if To ensure consistency across the codebase, let's check for other occurrences of This will help verify if the type change is consistent with other parts of the codebase. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for other occurrences of 'slashings' in Go files
rg --type go 'slashings.*\[?\]?(uint64|math\.U64|math\.Gwei)' -g '!mod/state-transition/pkg/core/state/types.go'
Length of output: 505 |
||
) (T, error) | ||
} | ||
|
||
|
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.
this is the main point of the PR. Make
Slashing
andTotalSlashing
share the same type