-
Notifications
You must be signed in to change notification settings - Fork 150
Boole hardening: partial-sig size cap, checked runner assertions, role-mapper lockstep test (#2978 items 3, 4, 7) #2989
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
83200f6
message/validation: make partial-signature size cap fork-aware (#2978…
momosh-ssv 98986ed
protocol/v2: checked runner type assertions in createRunner (#2978 it…
momosh-ssv 6efc025
observability: lockstep test for the two runner-role string mappers (…
momosh-ssv 947b954
address deep-review findings on #2989
momosh-ssv 0b6c0c5
message/validation: derive the size-cap fork lead from networkconfig'…
momosh-ssv 9a706e9
message/validation: key the partial-signature size cap off receivedAt
momosh-ssv 0a77e30
protocol/v2: cover typed-nil runners in createRunner
momosh-ssv 723c907
message/validation: test the fork-aware size cap through the validati…
momosh-ssv cdedff8
protocol/v2/message: sweep spec-known roles in the FromString round-t…
momosh-ssv 5b5d257
review nits: explain the sweep bound, the 217744-vs-217748 delta, and…
momosh-ssv 83498dd
message/validation: drop the fork-aware partial-sig cap for the stati…
momosh-ssv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package validation | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "testing" | ||
| "time" | ||
|
|
||
| spectypes "github.com/ssvlabs/ssv-spec/types" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/ssvlabs/ssv/networkconfig" | ||
| ) | ||
|
|
||
| // TestPartialSignatureSizeCapEnforcedInValidation drives validatePartialSignatureMessage | ||
| // itself (not just the constant) with payloads around the cap, guarding that the size gate | ||
| // stays wired into the validation path: an oversized payload is rejected as too big, while | ||
| // one at the cap passes the size gate and only fails later, at decoding. | ||
| func TestPartialSignatureSizeCapEnforcedInValidation(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| mv := &messageValidator{netCfg: networkconfig.TestNetwork} | ||
|
|
||
| t.Run("payload above the cap is rejected", func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| signedSSVMessage := &spectypes.SignedSSVMessage{ | ||
| SSVMessage: &spectypes.SSVMessage{Data: bytes.Repeat([]byte{1}, maxEncodedPartialSignatureSize+1)}, | ||
| } | ||
| _, err := mv.validatePartialSignatureMessage(context.Background(), signedSSVMessage, CommitteeInfo{}, "", "", time.Time{}) | ||
| require.ErrorIs(t, err, ErrSSVDataTooBig) | ||
|
|
||
| var valErr Error | ||
| require.ErrorAs(t, err, &valErr) | ||
| require.Equal(t, maxEncodedPartialSignatureSize, valErr.want) | ||
| }) | ||
|
|
||
| t.Run("payload at the cap passes the size gate", func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| signedSSVMessage := &spectypes.SignedSSVMessage{ | ||
| SSVMessage: &spectypes.SSVMessage{Data: bytes.Repeat([]byte{1}, maxEncodedPartialSignatureSize)}, | ||
| } | ||
| _, err := mv.validatePartialSignatureMessage(context.Background(), signedSSVMessage, CommitteeInfo{}, "", "", time.Time{}) | ||
| require.NotErrorIs(t, err, ErrSSVDataTooBig) | ||
| // The garbage payload fails at the next step, decoding — proof the size gate | ||
| // (not the content) made the difference between the two cases. | ||
| require.ErrorIs(t, err, ErrUndecodableMessageData) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.