-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TestingKeyManager: Slashing by Slot (#449)
* Use slots instead of data root to do slashing check * Adjust ValCheck SpecTest to use slashable slots * Adjust test cases * Add test case for a valid BeaconVote with a slot that is different than the slashable slot
- Loading branch information
1 parent
8f8c8d7
commit b072467
Showing
13 changed files
with
110 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
This file contains 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 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 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 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 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 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 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 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 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
47 changes: 47 additions & 0 deletions
47
ssv/spectest/tests/valcheck/valcheckattestations/valid_non_slashable_slot.go
This file contains 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,47 @@ | ||
package valcheckattestations | ||
|
||
import ( | ||
"encoding/hex" | ||
|
||
"github.com/attestantio/go-eth2-client/spec/phase0" | ||
spec "github.com/attestantio/go-eth2-client/spec/phase0" | ||
"github.com/ssvlabs/ssv-spec/ssv/spectest/tests" | ||
"github.com/ssvlabs/ssv-spec/ssv/spectest/tests/valcheck" | ||
"github.com/ssvlabs/ssv-spec/types" | ||
"github.com/ssvlabs/ssv-spec/types/testingutils" | ||
) | ||
|
||
// ValidNonSlashableSlot tests a valid AttestationData with a slot that is not slashable | ||
func ValidNonSlashableSlot() tests.SpecTest { | ||
data := &types.BeaconVote{ | ||
BlockRoot: spec.Root{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2}, | ||
Source: &spec.Checkpoint{ | ||
Epoch: 0, | ||
Root: spec.Root{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2}, | ||
}, | ||
Target: &spec.Checkpoint{ | ||
Epoch: 1, | ||
Root: spec.Root{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2}, | ||
}, | ||
} | ||
|
||
input, _ := data.Encode() | ||
|
||
keySet := testingutils.Testing4SharesSet() | ||
sharePKBytes := keySet.Shares[1].Serialize() | ||
shareString := hex.EncodeToString(sharePKBytes) | ||
|
||
return &valcheck.SpecTest{ | ||
Name: "attestation valid with non slashable slot", | ||
Network: types.BeaconTestNetwork, | ||
RunnerRole: types.RoleCommittee, | ||
DutySlot: testingutils.TestingDutySlot + 1, | ||
Input: input, | ||
SlashableSlots: map[string][]phase0.Slot{ | ||
shareString: { | ||
testingutils.TestingDutySlot, | ||
}, | ||
}, | ||
ShareValidatorsPK: []types.ShareValidatorPK{sharePKBytes}, | ||
} | ||
} |
Oops, something went wrong.