Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qbft/messages_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ssv/spectest/all_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ var AllTests = []tests.TestF{

valcheckattestations.Slashable,
valcheckattestations.SourceHigherThanTarget,
valcheckattestations.FarFutureTarget,
valcheckattestations.UnmatchedEpochs,
valcheckattestations.BeaconVoteDataNil,
valcheckattestations.Valid,
valcheckattestations.MinoritySlashable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"Network": "now_test_network",
"RunnerRole": 0,
"DutySlot": "12",
"Input": "AQIDBAUGBwgJCgECAwQFBgcICQoBAgMEBQYHCAkKAQIAAAAAAAAAAAECAwQFBgcICQoBAgMEBQYHCAkKAQIDBAUGBwgJCgECgJaYAAAAAAABAgMEBQYHCAkKAQIDBAUGBwgJCgECAwQFBgcICQoBAg==",
"Input": "AQIDBAUGBwgJCgECAwQFBgcICQoBAgMEBQYHCAkKAQIAAAAAAAAAAAECAwQFBgcICQoBAgMEBQYHCAkKAQIDBAUGBwgJCgECAgAAAAAAAAABAgMEBQYHCAkKAQIDBAUGBwgJCgECAwQFBgcICQoBAg==",
"SlashableSlots": null,
"omitempty": null,
"ExpectedError": "attestation data target epoch is into far future",
"ExpectedError": "attestation data source/target epoch does not match expected",
"AnyError": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func WrongBeaconVote() tests.SpecTest {
Input: []interface{}{
testingutils.TestingCommitteeDuty(testingutils.ValidatorIndexList(30), testingutils.ValidatorIndexList(30), version),
testingutils.TestingProposalMessageWithIdentifierAndFullData(
ks.OperatorKeys[1], types.OperatorID(1), testingutils.CommitteeMsgID(ks), testingutils.TestWrongBeaconVoteByts,
ks.OperatorKeys[1], types.OperatorID(1), testingutils.CommitteeMsgID(ks), testingutils.TestSlashableBeaconVoteByts,
qbft.Height(testingutils.TestingDutySlotV(version))),
},
OutputMessages: []*types.PartialSignatureMessages{},
Expand Down
6 changes: 3 additions & 3 deletions ssv/spectest/tests/runner/consensus/invalid_decided_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func InvalidDecidedValue() tests.SpecTest {
[]types.OperatorID{1, 2, 3},
qbft.Height(testingutils.TestingDutySlotV(version)),
testingutils.CommitteeMsgID(ks),
testingutils.TestWrongBeaconVoteByts,
testingutils.TestSlashableBeaconVoteByts,
),
},
OutputMessages: []*types.PartialSignatureMessages{},
Expand All @@ -189,7 +189,7 @@ func InvalidDecidedValue() tests.SpecTest {
[]types.OperatorID{1, 2, 3},
qbft.Height(testingutils.TestingDutySlotV(version)),
testingutils.CommitteeMsgID(ks),
testingutils.TestWrongBeaconVoteByts,
testingutils.TestSlashableBeaconVoteByts,
),
},
OutputMessages: []*types.PartialSignatureMessages{},
Expand All @@ -207,7 +207,7 @@ func InvalidDecidedValue() tests.SpecTest {
[]types.OperatorID{1, 2, 3},
qbft.Height(testingutils.TestingDutySlotV(version)),
testingutils.CommitteeMsgID(ks),
testingutils.TestWrongBeaconVoteByts,
testingutils.TestSlashableBeaconVoteByts,
),
},
OutputMessages: []*types.PartialSignatureMessages{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func InvalidDecidedValue() tests.SpecTest {
[]types.OperatorID{1, 2, 3},
qbft.Height(testingutils.TestingDutySlot),
testingutils.CommitteeMsgID(ks),
testingutils.TestWrongBeaconVoteByts,
testingutils.TestSlashableBeaconVoteByts,
),
testingutils.SignPartialSigSSVMessage(ks, testingutils.SSVMsgCommittee(ks, nil, testingutils.PostConsensusAttestationMsg(ks.Shares[1], 1, version))),
},
Expand All @@ -182,7 +182,7 @@ func InvalidDecidedValue() tests.SpecTest {
[]types.OperatorID{1, 2, 3},
qbft.Height(testingutils.TestingDutySlot),
testingutils.CommitteeMsgID(ks),
testingutils.TestWrongBeaconVoteByts,
testingutils.TestSlashableBeaconVoteByts,
),
testingutils.SignPartialSigSSVMessage(ks, testingutils.SSVMsgCommittee(ks, nil, testingutils.PostConsensusSyncCommitteeMsg(ks.Shares[1], 1, version))),
},
Expand All @@ -201,7 +201,7 @@ func InvalidDecidedValue() tests.SpecTest {
[]types.OperatorID{1, 2, 3},
qbft.Height(testingutils.TestingDutySlot),
testingutils.CommitteeMsgID(ks),
testingutils.TestWrongBeaconVoteByts,
testingutils.TestSlashableBeaconVoteByts,
),
testingutils.SignPartialSigSSVMessage(ks, testingutils.SSVMsgCommittee(ks, nil, testingutils.PostConsensusAttestationAndSyncCommitteeMsg(ks.Shares[1], 1, version))),
},
Expand Down
3 changes: 1 addition & 2 deletions ssv/spectest/tests/valcheck/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ func (test *SpecTest) valCheckF(signer types.BeaconSigner) qbft.ProposedValueChe
}
switch test.RunnerRole {
case types.RoleCommittee:
return ssv.BeaconVoteValueCheckF(signer, test.DutySlot, shareValidatorsPK,
testingutils.TestingDutyEpoch)
return ssv.BeaconVoteValueCheckF(signer, test.DutySlot, shareValidatorsPK, &testingutils.TestBeaconVote)
case types.RoleProposer:
return ssv.ProposerValueCheckF(signer, test.Network, pubKeyBytes, testingutils.TestingValidatorIndex, nil)
case types.RoleAggregator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
"github.com/ssvlabs/ssv-spec/types/testingutils"
)

// FarFutureTarget tests AttestationData.Target.Epoch higher than expected
func FarFutureTarget() tests.SpecTest {
// UnmatchedEpochs tests AttestationData.Target.Epoch unmatched with expected
func UnmatchedEpochs() 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: 10000000,
Epoch: 2,
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},
},
}
Expand All @@ -30,6 +30,6 @@ func FarFutureTarget() tests.SpecTest {
RunnerRole: types.RoleCommittee,
DutySlot: testingutils.TestingDutySlot,
Input: input,
ExpectedError: "attestation data target epoch is into far future",
ExpectedError: "attestation data source/target epoch does not match expected",
}
}
10 changes: 5 additions & 5 deletions ssv/value_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ func BeaconVoteValueCheckF(
signer types.BeaconSigner,
slot phase0.Slot,
sharePublicKeys []types.ShareValidatorPK,
estimatedCurrentEpoch phase0.Epoch,
expectedAttestationData *types.BeaconVote,
) qbft.ProposedValueCheckF {
return func(data []byte) error {
bv := types.BeaconVote{}
if err := bv.Decode(data); err != nil {
return errors.Wrap(err, "failed decoding beacon vote")
}

if bv.Target.Epoch > estimatedCurrentEpoch+1 {
return errors.New("attestation data target epoch is into far future")
}

if bv.Source.Epoch >= bv.Target.Epoch {
return errors.New("attestation data source >= target")
}

if bv.Source.Epoch != expectedAttestationData.Source.Epoch || bv.Target.Epoch != expectedAttestationData.Target.Epoch {
return errors.New("attestation data source/target epoch does not match expected")
}

attestationData := &phase0.AttestationData{
Slot: slot,
// Consensus data is unaware of CommitteeIndex
Expand Down
2 changes: 1 addition & 1 deletion types/beacon_types_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 2 additions & 15 deletions types/testingutils/beacon_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,7 @@ var TestBeaconVote = types.BeaconVote{
}
var TestBeaconVoteByts, _ = TestBeaconVote.Encode()

var TestBeaconVoteNextEpoch = types.BeaconVote{
BlockRoot: TestingBlockRoot,
Source: &phase0.Checkpoint{
Epoch: 0,
Root: TestingBlockRoot,
},
Target: &phase0.Checkpoint{
Epoch: 1,
Root: TestingBlockRoot,
},
}
var TestBeaconVoteNextEpochByts, _ = TestBeaconVoteNextEpoch.Encode()

var TestWrongBeaconVote = types.BeaconVote{
var TestSlashableBeaconVote = types.BeaconVote{
BlockRoot: phase0.Root{1, 2, 3, 4},
Source: &phase0.Checkpoint{
Epoch: 2,
Expand All @@ -47,4 +34,4 @@ var TestWrongBeaconVote = types.BeaconVote{
Root: phase0.Root{1, 2, 3, 5},
},
}
var TestWrongBeaconVoteByts, _ = TestWrongBeaconVote.Encode()
var TestSlashableBeaconVoteByts, _ = TestSlashableBeaconVote.Encode()
4 changes: 2 additions & 2 deletions types/testingutils/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ var ConstructBaseRunnerWithShareMap = func(role types.RunnerRole, shareMap map[p
switch role {
case types.RoleCommittee:
valCheck = ssv.BeaconVoteValueCheckF(km, TestingDutySlot,
sharePubKeys, TestingDutyEpoch)
sharePubKeys, &TestBeaconVote)
case types.RoleProposer:
valCheck = ssv.ProposerValueCheckF(km, types.BeaconTestNetwork,
(types.ValidatorPK)(shareInstance.ValidatorPubKey), shareInstance.ValidatorIndex, shareInstance.SharePubKey)
Expand Down Expand Up @@ -272,7 +272,7 @@ var ConstructBaseRunner = func(role types.RunnerRole, keySet *TestKeySet) (ssv.R
switch role {
case types.RoleCommittee:
valCheck = ssv.BeaconVoteValueCheckF(km, TestingDutySlot,
[]types.ShareValidatorPK{share.SharePubKey}, TestingDutyEpoch)
[]types.ShareValidatorPK{share.SharePubKey}, &TestBeaconVote)
case types.RoleProposer:
valCheck = ssv.ProposerValueCheckF(km, types.BeaconTestNetwork,
(types.ValidatorPK)(TestingValidatorPubKey), TestingValidatorIndex, share.SharePubKey)
Expand Down