testingutils

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestingDutySlot       = 12
	TestingValidatorIndex = 1
)

Variables

View Source
var AggregatorMsgID = func() []byte {
	ret := types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleAggregator)
	return ret[:]
}()
View Source
var AggregatorRunner = func(keySet *TestKeySet) *ssv.Runner {
	return baseRunner(types.BNRoleAggregator, ssv.AggregatorValueCheck(NewTestingKeyManager(), types.NowTestNetwork), keySet)
}
View Source
var AttesterMsgID = func() []byte {
	ret := types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleAttester)
	return ret[:]
}()
View Source
var AttesterRunner = func(keySet *TestKeySet) *ssv.Runner {
	return baseRunner(types.BNRoleAttester, ssv.BeaconAttestationValueCheck(NewTestingKeyManager(), types.NowTestNetwork), keySet)
}
View Source
var AttesterRunner7Operators = func(keySet *TestKeySet) *ssv.Runner {
	return baseRunner(types.BNRoleAttester, ssv.BeaconAttestationValueCheck(NewTestingKeyManager(), types.NowTestNetwork), keySet)
}
View Source
var BaseInstance = func() *qbft.Instance {
	return baseInstance(TestingShare(Testing4SharesSet()), Testing4SharesSet(), []byte{1, 2, 3, 4})
}
View Source
var BaseValidator = func(keySet *TestKeySet) *ssv.Validator {
	ret := ssv.NewValidator(
		NewTestingNetwork(),
		NewTestingBeaconNode(),
		NewTestingStorage(),
		TestingShare(keySet),
		NewTestingKeyManager(),
	)
	ret.DutyRunners[types.BNRoleAttester] = AttesterRunner(keySet)
	ret.DutyRunners[types.BNRoleProposer] = ProposerRunner(keySet)
	ret.DutyRunners[types.BNRoleAggregator] = AggregatorRunner(keySet)
	ret.DutyRunners[types.BNRoleSyncCommittee] = SyncCommitteeRunner(keySet)
	ret.DutyRunners[types.BNRoleSyncCommitteeContribution] = SyncCommitteeContributionRunner(keySet)
	return ret
}
View Source
var CommitDataBytes = func(data []byte) []byte {
	d := &qbft.CommitData{
		Data: data,
	}
	ret, _ := d.Encode()
	return ret
}
View Source
var DecidedRunner = func(keySet *TestKeySet) *ssv.Runner {
	return decideRunner(TestAttesterConsensusDataByts, qbft.FirstHeight, keySet)
}
View Source
var DecidedRunnerUnknownDutyType = func(keySet *TestKeySet) *ssv.Runner {
	return decideRunner(TestConsensusUnkownDutyTypeDataByts, qbft.FirstHeight, keySet)
}
View Source
var DecidedRunnerWithHeight = func(height qbft.Height, keySet *TestKeySet) *ssv.Runner {
	return decideRunner(TestAttesterConsensusDataByts, height, keySet)
}
View Source
var DecidingMsgsForHeight = func(consensusData, msgIdentifier []byte, height qbft.Height, keySet *TestKeySet) []*qbft.SignedMessage {
	msgs := make([]*qbft.SignedMessage, 0)
	for h := qbft.Height(qbft.FirstHeight); h <= height; h++ {
		msgs = append(msgs, SignQBFTMsg(keySet.Shares[1], 1, &qbft.Message{
			MsgType:    qbft.ProposalMsgType,
			Height:     h,
			Round:      qbft.FirstRound,
			Identifier: msgIdentifier,
			Data:       ProposalDataBytes(consensusData, nil, nil),
		}))

		for i := uint64(1); i <= keySet.Threshold; i++ {
			msgs = append(msgs, SignQBFTMsg(keySet.Shares[types.OperatorID(i)], types.OperatorID(i), &qbft.Message{
				MsgType:    qbft.PrepareMsgType,
				Height:     h,
				Round:      qbft.FirstRound,
				Identifier: msgIdentifier,
				Data:       PrepareDataBytes(consensusData),
			}))
		}

		for i := uint64(1); i <= keySet.Threshold; i++ {
			msgs = append(msgs, SignQBFTMsg(keySet.Shares[types.OperatorID(i)], types.OperatorID(i), &qbft.Message{
				MsgType:    qbft.CommitMsgType,
				Height:     h,
				Round:      qbft.FirstRound,
				Identifier: msgIdentifier,
				Data:       CommitDataBytes(consensusData),
			}))
		}
	}
	return msgs
}
View Source
var InitMessageDataBytes = func(operators []types.OperatorID, threshold uint16, withdrawalCred []byte) []byte {
	m := &dkg.Init{
		OperatorIDs:           operators,
		Threshold:             threshold,
		WithdrawalCredentials: withdrawalCred,
	}
	byts, _ := m.Encode()
	return byts
}
View Source
var MultiSignQBFTMsg = func(sks []*bls.SecretKey, ids []types.OperatorID, msg *qbft.Message) *qbft.SignedMessage {
	if len(sks) == 0 || len(ids) != len(sks) {
		panic("sks != ids")
	}
	var signed *qbft.SignedMessage
	for i, sk := range sks {
		if signed == nil {
			signed = SignQBFTMsg(sk, ids[i], msg)
		} else {
			if err := signed.Aggregate(SignQBFTMsg(sk, ids[i], msg)); err != nil {
				panic(err.Error())
			}
		}
	}

	return signed
}
View Source
var PostConsensusAggregatorMsg = func(sk *bls.SecretKey, id types.OperatorID) *ssv.SignedPartialSignatureMessage {
	return postConsensusAggregatorMsg(sk, id, false, false, false, false)
}
View Source
var PostConsensusAttestationMsg = func(sk *bls.SecretKey, id types.OperatorID, height qbft.Height) *ssv.SignedPartialSignatureMessage {
	return postConsensusAttestationMsg(sk, id, height, false, false, false, false)
}
View Source
var PostConsensusAttestationMsgWithMsgMultiSigners = func(sk *bls.SecretKey, id types.OperatorID, height qbft.Height) *ssv.SignedPartialSignatureMessage {
	return postConsensusAttestationMsg(sk, id, height, false, false, true, false)
}
View Source
var PostConsensusAttestationMsgWithNoMsgSigners = func(sk *bls.SecretKey, id types.OperatorID, height qbft.Height) *ssv.SignedPartialSignatureMessage {
	return postConsensusAttestationMsg(sk, id, height, false, false, true, false)
}
View Source
var PostConsensusAttestationMsgWithWrongRoot = func(sk *bls.SecretKey, id types.OperatorID, height qbft.Height) *ssv.SignedPartialSignatureMessage {
	return postConsensusAttestationMsg(sk, id, height, true, false, false, false)
}
View Source
var PostConsensusAttestationMsgWithWrongSig = func(sk *bls.SecretKey, id types.OperatorID, height qbft.Height) *ssv.SignedPartialSignatureMessage {
	return postConsensusAttestationMsg(sk, id, height, false, true, false, false)
}
View Source
var PostConsensusProposerMsg = func(sk *bls.SecretKey, id types.OperatorID) *ssv.SignedPartialSignatureMessage {
	return postConsensusBeaconBlockMsg(sk, id, false, false, false, false)
}
View Source
var PostConsensusSyncCommitteeContributionMsg = func(sk *bls.SecretKey, id types.OperatorID, keySet *TestKeySet) *ssv.SignedPartialSignatureMessage {
	return postConsensusSyncCommitteeContributionMsg(sk, id, TestingValidatorIndex, keySet, false, false, false, false)
}
View Source
var PostConsensusSyncCommitteeMsg = func(sk *bls.SecretKey, id types.OperatorID) *ssv.SignedPartialSignatureMessage {
	return postConsensusSyncCommitteeMsg(sk, id, false, false, false, false)
}
View Source
var PreConsensusContributionProofMsg = func(sk *bls.SecretKey, id types.OperatorID) *ssv.SignedPartialSignatureMessage {
	return contributionProofMsg(sk, id, false, false, false, false)
}
View Source
var PreConsensusRandaoMsg = func(sk *bls.SecretKey, id types.OperatorID) *ssv.SignedPartialSignatureMessage {
	return randaoMsg(sk, id, false, false, false, false)
}
View Source
var PreConsensusSelectionProofMsg = func(sk *bls.SecretKey, id types.OperatorID) *ssv.SignedPartialSignatureMessage {
	return selectionProofMsg(sk, id, false, false, false, false)
}
View Source
var PrepareDataBytes = func(data []byte) []byte {
	d := &qbft.PrepareData{
		Data: data,
	}
	ret, _ := d.Encode()
	return ret
}
View Source
var ProposalDataBytes = func(data []byte, rcj, pj []*qbft.SignedMessage) []byte {
	d := &qbft.ProposalData{
		Data:                     data,
		RoundChangeJustification: rcj,
		PrepareJustification:     pj,
	}
	ret, _ := d.Encode()
	return ret
}
View Source
var ProposerMsgID = func() []byte {
	ret := types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleProposer)
	return ret[:]
}()
View Source
var ProposerRunner = func(keySet *TestKeySet) *ssv.Runner {
	return baseRunner(types.BNRoleProposer, ssv.BeaconBlockValueCheck(NewTestingKeyManager(), types.NowTestNetwork), keySet)
}
View Source
var ProtocolMsgDataBytes = func(stage stubdkg.Stage) []byte {
	d := &stubdkg.ProtocolMsg{
		Stage: stage,
	}

	ret, _ := d.Encode()
	return ret
}
View Source
var RoundChangeDataBytes = func(preparedValue []byte, preparedRound qbft.Round) []byte {
	return RoundChangePreparedDataBytes(preparedValue, preparedRound, nil)
}
View Source
var RoundChangePreparedDataBytes = func(preparedValue []byte, preparedRound qbft.Round, justif []*qbft.SignedMessage) []byte {
	d := &qbft.RoundChangeData{
		PreparedValue:            preparedValue,
		PreparedRound:            preparedRound,
		RoundChangeJustification: justif,
	}
	ret, _ := d.Encode()
	return ret
}
View Source
var SSVMsgAggregator = func(qbftMsg *qbft.SignedMessage, partialSigMsg *ssv.SignedPartialSignatureMessage) *types.SSVMessage {
	return ssvMsg(qbftMsg, partialSigMsg, types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleAggregator))
}
View Source
var SSVMsgAttester = func(qbftMsg *qbft.SignedMessage, partialSigMsg *ssv.SignedPartialSignatureMessage) *types.SSVMessage {
	return ssvMsg(qbftMsg, partialSigMsg, types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleAttester))
}
View Source
var SSVMsgProposer = func(qbftMsg *qbft.SignedMessage, partialSigMsg *ssv.SignedPartialSignatureMessage) *types.SSVMessage {
	return ssvMsg(qbftMsg, partialSigMsg, types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleProposer))
}
View Source
var SSVMsgSyncCommittee = func(qbftMsg *qbft.SignedMessage, partialSigMsg *ssv.SignedPartialSignatureMessage) *types.SSVMessage {
	return ssvMsg(qbftMsg, partialSigMsg, types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleSyncCommittee))
}
View Source
var SSVMsgSyncCommitteeContribution = func(qbftMsg *qbft.SignedMessage, partialSigMsg *ssv.SignedPartialSignatureMessage) *types.SSVMessage {
	return ssvMsg(qbftMsg, partialSigMsg, types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleSyncCommitteeContribution))
}
View Source
var SSVMsgWrongID = func(qbftMsg *qbft.SignedMessage, partialSigMsg *ssv.SignedPartialSignatureMessage) *types.SSVMessage {
	return ssvMsg(qbftMsg, partialSigMsg, types.NewMsgID(TestingWrongValidatorPubKey[:], types.BNRoleAttester))
}
View Source
var SevenOperatorsInstance = func() *qbft.Instance {
	return baseInstance(TestingShare(Testing7SharesSet()), Testing7SharesSet(), []byte{1, 2, 3, 4})
}
View Source
var SignDKGMsg = func(sk *ecdsa.PrivateKey, id types.OperatorID, msg *dkg.Message) *dkg.SignedMessage {
	domain := types.GetDefaultDomain()
	sigType := types.DKGSignatureType

	r, _ := types.ComputeSigningRoot(msg, types.ComputeSignatureDomain(domain, sigType))
	sig, _ := crypto.Sign(r, sk)

	return &dkg.SignedMessage{
		Message:   msg,
		Signer:    id,
		Signature: sig,
	}
}
View Source
var SignQBFTMsg = func(sk *bls.SecretKey, id types.OperatorID, msg *qbft.Message) *qbft.SignedMessage {
	domain := types.GetDefaultDomain()
	sigType := types.QBFTSignatureType

	r, _ := types.ComputeSigningRoot(msg, types.ComputeSignatureDomain(domain, sigType))
	sig := sk.SignByte(r)

	return &qbft.SignedMessage{
		Message:   msg,
		Signers:   []types.OperatorID{id},
		Signature: sig.Serialize(),
	}
}
View Source
var SyncCommitteeContributionMsgID = func() []byte {
	ret := types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleSyncCommitteeContribution)
	return ret[:]
}()
View Source
var SyncCommitteeContributionRunner = func(keySet *TestKeySet) *ssv.Runner {
	return baseRunner(types.BNRoleSyncCommitteeContribution, ssv.SyncCommitteeContributionValueCheck(NewTestingKeyManager(), types.NowTestNetwork), keySet)
}
View Source
var SyncCommitteeMsgID = func() []byte {
	ret := types.NewMsgID(TestingValidatorPubKey[:], types.BNRoleSyncCommittee)
	return ret[:]
}()
View Source
var SyncCommitteeRunner = func(keySet *TestKeySet) *ssv.Runner {
	return baseRunner(types.BNRoleSyncCommittee, ssv.SyncCommitteeValueCheck(NewTestingKeyManager(), types.NowTestNetwork), keySet)
}
View Source
var TenOperatorsInstance = func() *qbft.Instance {
	return baseInstance(TestingShare(Testing10SharesSet()), Testing10SharesSet(), []byte{1, 2, 3, 4})
}
View Source
var TestAggregatorConsensusData = &types.ConsensusData{
	Duty:              TestingAggregatorDuty,
	AggregateAndProof: TestingAggregateAndProof,
}
View Source
var TestAggregatorConsensusDataByts, _ = TestAggregatorConsensusData.Encode()
View Source
var TestAttesterConsensusData = &types.ConsensusData{
	Duty:            TestingAttesterDuty,
	AttestationData: TestingAttestationData,
}
View Source
var TestAttesterConsensusDataByts, _ = TestAttesterConsensusData.Encode()
View Source
var TestConsensusUnkownDutyTypeData = &types.ConsensusData{
	Duty:            TestingUnknownDutyType,
	AttestationData: TestingAttestationData,
}
View Source
var TestConsensusUnkownDutyTypeDataByts, _ = TestConsensusUnkownDutyTypeData.Encode()
View Source
var TestConsensusWrongDutyPKData = &types.ConsensusData{
	Duty:            TestingWrongDutyPK,
	AttestationData: TestingAttestationData,
}
View Source
var TestConsensusWrongDutyPKDataByts, _ = TestConsensusWrongDutyPKData.Encode()
View Source
var TestProposerConsensusData = &types.ConsensusData{
	Duty:      TestingProposerDuty,
	BlockData: TestingBeaconBlock,
}
View Source
var TestProposerConsensusDataByts, _ = TestProposerConsensusData.Encode()
View Source
var TestSyncCommitteeConsensusData = &types.ConsensusData{
	Duty:                   TestingSyncCommitteeDuty,
	SyncCommitteeBlockRoot: TestingSyncCommitteeBlockRoot,
}
View Source
var TestSyncCommitteeConsensusDataByts, _ = TestSyncCommitteeConsensusData.Encode()
View Source
var TestSyncCommitteeContributionConsensusDataByts, _ = TestSyncCommitteeContributionConsensusData.Encode()
View Source
var TestingAggregateAndProof = &spec.AggregateAndProof{
	AggregatorIndex: 1,
	SelectionProof:  spec.BLSSignature{},
	Aggregate: &spec.Attestation{
		AggregationBits: bitfield.NewBitlist(128),
		Signature:       spec.BLSSignature{},
		Data:            TestingAttestationData,
	},
}
View Source
var TestingAggregatorDuty = &types.Duty{
	Type:                    types.BNRoleAggregator,
	PubKey:                  TestingValidatorPubKey,
	Slot:                    12,
	ValidatorIndex:          TestingValidatorIndex,
	CommitteeIndex:          22,
	CommitteesAtSlot:        36,
	CommitteeLength:         128,
	ValidatorCommitteeIndex: 11,
}
View Source
var TestingAttestationData = &spec.AttestationData{
	Slot:            12,
	Index:           3,
	BeaconBlockRoot: 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},
	},
}
View Source
var TestingAttestationRoot, _ = hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565f") //[]byte{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}
View Source
var TestingAttesterDuty = &types.Duty{
	Type:                    types.BNRoleAttester,
	PubKey:                  TestingValidatorPubKey,
	Slot:                    TestingDutySlot,
	ValidatorIndex:          TestingValidatorIndex,
	CommitteeIndex:          3,
	CommitteesAtSlot:        36,
	CommitteeLength:         128,
	ValidatorCommitteeIndex: 11,
}
View Source
var TestingBeaconBlock = &altair.BeaconBlock{
	Slot:          12,
	ProposerIndex: 10,
	ParentRoot:    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},
	StateRoot:     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},
	Body: &altair.BeaconBlockBody{
		RANDAOReveal: spec.BLSSignature{},
		ETH1Data: &spec.ETH1Data{
			DepositRoot:  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},
			DepositCount: 100,
			BlockHash:    []byte{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},
		},
		Graffiti:          []byte{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},
		ProposerSlashings: []*spec.ProposerSlashing{},
		AttesterSlashings: []*spec.AttesterSlashing{},
		Attestations: []*spec.Attestation{
			{
				AggregationBits: bitfield.NewBitlist(122),
				Data:            TestingAttestationData,
				Signature:       spec.BLSSignature{},
			},
		},
		Deposits:       []*spec.Deposit{},
		VoluntaryExits: []*spec.SignedVoluntaryExit{},
		SyncAggregate: &altair.SyncAggregate{
			SyncCommitteeBits:      bitfield.NewBitvector512(),
			SyncCommitteeSignature: spec.BLSSignature{},
		},
	},
}
View Source
var TestingBeaconBlockRoot, _ = hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565f")
View Source
var TestingConfig = func(keySet *TestKeySet) *qbft.Config {
	return &qbft.Config{
		Signer:    NewTestingKeyManager(),
		SigningPK: keySet.Shares[1].GetPublicKey().Serialize(),
		Domain:    types.GetDefaultDomain(),
		ValueCheckF: func(data []byte) error {
			if bytes.Equal(data, TestingInvalidValueCheck) {
				return errors.New("invalid value")
			}
			return nil
		},
		ProposerF: func(state *qbft.State, round qbft.Round) types.OperatorID {
			return 1
		},
		Storage: NewTestingStorage(),
		Network: NewTestingNetwork(),
		Timer:   NewTestingTimer(),
	}
}
View Source
var TestingContributionProofRoots = func() []spec.Root {
	byts1, _ := hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565f")
	byts2, _ := hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb35653")
	byts3, _ := hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565d")

	ret := make([]spec.Root, 0)
	for _, byts := range [][]byte{byts1, byts2, byts3} {
		b := spec.Root{}
		copy(b[:], byts)
		ret = append(ret, b)
	}
	return ret
}()
View Source
var TestingContributionProofsSigned = func() []spec.BLSSignature {

	byts1, _ := hex.DecodeString("8cef237a0e3a1bba095e9534df220e0dccd3de740d50510c9b3cedb6a0c4ca5bd23b5ae672698260333fc47e532741c303efb98f0636a3515d615535c0e072ed470514c1fafda9335bc4919127a1fd3107b9990e3b857075e1f63a27bfd6b216")
	byts2, _ := hex.DecodeString("978f80611fb452449d413902487eec69a531bdab16ab51433582fdf9bb900d7b63de10fb048204591c06322ba3fa1cff0c83077ee0c17416dc718f6cca82c5c94115679646f5fa08410d794cd6974d562ffe522d70eb89f340064fe99bf7471d")
	byts3, _ := hex.DecodeString("addc5f3b2534b8c542b500c8a9e50fef49f18fbaafaf995a3ebe2a3d50836703f2d92cb5885d7b6cafdc6c09d889e6bc10d3470c51deb56d26996ea63f57a909a7a9bec0140ed79e683695b111ca36cbe4776d11ad50ad3d81e96290c064608c")

	ret := make([]spec.BLSSignature, 0)
	for _, byts := range [][]byte{byts1, byts2, byts3} {
		b := spec.BLSSignature{}
		copy(b[:], byts)
		ret = append(ret, b)
	}
	return ret
}()
View Source
var TestingContributionRoots = func() [][]byte {
	byts1, _ := hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565f")
	byts2, _ := hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565a")
	byts3, _ := hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb35656")
	return [][]byte{
		byts1, byts2, byts3,
	}
}()
View Source
var TestingDKGNode = func(keySet *TestKeySet) *dkg.Node {
	network := NewTestingNetwork()
	config := &dkg.Config{
		Protocol: func(network dkg.Network, operatorID types.OperatorID, identifier dkg.RequestID) dkg.KeyGenProtocol {
			ret := stubdkg.New(network, operatorID, identifier)
			ret.(*stubdkg.DKG).SetOperators(
				Testing4SharesSet().ValidatorPK.Serialize(),
				Testing4SharesSet().Shares,
			)
			return ret
		},
		Network:             network,
		Storage:             NewTestingStorage(),
		SignatureDomainType: types.GetDefaultDomain(),
		Signer:              NewTestingKeyManager(),
	}

	return dkg.NewNode(&dkg.Operator{
		OperatorID:       1,
		ETHAddress:       keySet.DKGOperators[1].ETHAddress,
		EncryptionPubKey: &keySet.DKGOperators[1].EncryptionKey.PublicKey,
	}, config)
}
View Source
var TestingInvalidValueCheck = []byte{1, 1, 1, 1}
View Source
var TestingProposerDuty = &types.Duty{
	Type:                    types.BNRoleProposer,
	PubKey:                  TestingValidatorPubKey,
	Slot:                    12,
	ValidatorIndex:          TestingValidatorIndex,
	CommitteeIndex:          3,
	CommitteesAtSlot:        36,
	CommitteeLength:         128,
	ValidatorCommitteeIndex: 11,
}
View Source
var TestingRandaoRoot, _ = hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565f")
View Source
var TestingSelectionProofRoot, _ = hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565f")
View Source
var TestingShare = func(keysSet *TestKeySet) *types.Share {
	return &types.Share{
		OperatorID:      1,
		ValidatorPubKey: keysSet.ValidatorPK.Serialize(),
		SharePubKey:     keysSet.Shares[1].GetPublicKey().Serialize(),
		DomainType:      types.GetDefaultDomain(),
		Quorum:          keysSet.Threshold,
		PartialQuorum:   keysSet.PartialThreshold,
		Committee:       keysSet.Committee(),
	}
}
View Source
var TestingSignedAggregateAndProofRoot, _ = hex.DecodeString("81451c58b079c5af84ebe4b92900d3e9c5a346678cb6dc3c4b7eea2c9cb3565f")
View Source
var TestingSyncCommitteeBlockRoot = spec.Root{}
View Source
var TestingSyncCommitteeContributionDuty = &types.Duty{
	Type:                    types.BNRoleSyncCommitteeContribution,
	PubKey:                  TestingValidatorPubKey,
	Slot:                    TestingDutySlot,
	ValidatorIndex:          TestingValidatorIndex,
	CommitteeIndex:          3,
	CommitteesAtSlot:        36,
	CommitteeLength:         128,
	ValidatorCommitteeIndex: 11,
}
View Source
var TestingSyncCommitteeContributions = []*altair.SyncCommitteeContribution{
	{
		Slot:              TestingDutySlot,
		BeaconBlockRoot:   TestingSyncCommitteeBlockRoot,
		SubcommitteeIndex: 0,
		AggregationBits:   bitfield.NewBitvector128(),
		Signature:         spec.BLSSignature{},
	},
	{
		Slot:              TestingDutySlot,
		BeaconBlockRoot:   TestingSyncCommitteeBlockRoot,
		SubcommitteeIndex: 1,
		AggregationBits:   bitfield.NewBitvector128(),
		Signature:         spec.BLSSignature{},
	},
	{
		Slot:              TestingDutySlot,
		BeaconBlockRoot:   TestingSyncCommitteeBlockRoot,
		SubcommitteeIndex: 2,
		AggregationBits:   bitfield.NewBitvector128(),
		Signature:         spec.BLSSignature{},
	},
}
View Source
var TestingSyncCommitteeDuty = &types.Duty{
	Type:                    types.BNRoleSyncCommittee,
	PubKey:                  TestingValidatorPubKey,
	Slot:                    TestingDutySlot,
	ValidatorIndex:          TestingValidatorIndex,
	CommitteeIndex:          3,
	CommitteesAtSlot:        36,
	CommitteeLength:         128,
	ValidatorCommitteeIndex: 11,
}
View Source
var TestingUnknownDutyType = &types.Duty{
	Type:                    100,
	PubKey:                  TestingValidatorPubKey,
	Slot:                    12,
	ValidatorIndex:          TestingValidatorIndex,
	CommitteeIndex:          22,
	CommitteesAtSlot:        36,
	CommitteeLength:         128,
	ValidatorCommitteeIndex: 11,
}
View Source
var TestingValidatorPubKey = func() spec.BLSPubKey {

	pk, _ := hex.DecodeString("8e80066551a81b318258709edaf7dd1f63cd686a0e4db8b29bbb7acfe65608677af5a527d9448ee47835485e02b50bc0")
	blsPK := spec.BLSPubKey{}
	copy(blsPK[:], pk)
	return blsPK
}()
View Source
var TestingWithdrawalCredentials, _ = hex.DecodeString("0x010000000000000000000000535953b5a6040074948cf185eaa7d2abbd66808f")
View Source
var TestingWrongDutyPK = &types.Duty{
	Type:                    types.BNRoleAttester,
	PubKey:                  TestingWrongValidatorPubKey,
	Slot:                    12,
	ValidatorIndex:          TestingValidatorIndex,
	CommitteeIndex:          3,
	CommitteesAtSlot:        36,
	CommitteeLength:         128,
	ValidatorCommitteeIndex: 11,
}
View Source
var TestingWrongValidatorPubKey = func() spec.BLSPubKey {

	pk, _ := hex.DecodeString("948fb44582ce25336fdb17122eac64fe5a1afc39174ce92d6013becac116766dc5a778c880dd47de7dfff6a0f86ba42b")
	blsPK := spec.BLSPubKey{}
	copy(blsPK[:], pk)
	return blsPK
}()
View Source
var ThirteenOperatorsInstance = func() *qbft.Instance {
	return baseInstance(TestingShare(Testing13SharesSet()), Testing13SharesSet(), []byte{1, 2, 3, 4})
}

Functions

func NewTestingBeaconNode

func NewTestingBeaconNode() *testingBeaconNode

func NewTestingKeyManager

func NewTestingKeyManager() *testingKeyManager

func NewTestingQBFTController

func NewTestingQBFTController(identifier []byte, share *types.Share, valCheck qbft.ProposedValueCheckF, proposerF qbft.ProposerF) *qbft.Controller

func NewTestingStorage

func NewTestingStorage() *testingStorage

func NewTestingTimer

func NewTestingTimer() qbft.Timer

Types

type TestKeySet

type TestKeySet struct {
	ValidatorSK                             *bls.SecretKey
	ValidatorPK                             *bls.PublicKey
	ShareCount, Threshold, PartialThreshold uint64
	Shares                                  map[types.OperatorID]*bls.SecretKey
	DKGOperators                            map[types.OperatorID]struct {
		SK            *ecdsa.PrivateKey
		ETHAddress    common.Address
		EncryptionKey *rsa.PrivateKey
	}
}

func Testing4SharesSet

func Testing4SharesSet() *TestKeySet

func Testing7SharesSet

func Testing7SharesSet() *TestKeySet

func Testing10SharesSet

func Testing10SharesSet() *TestKeySet

func Testing13SharesSet

func Testing13SharesSet() *TestKeySet

func (*TestKeySet) Committee

func (ks *TestKeySet) Committee() []*types.Operator

type TestQBFTTimer

type TestQBFTTimer struct {
}

func (*TestQBFTTimer) TimeoutForRound

func (t *TestQBFTTimer) TimeoutForRound(round qbft.Round)

type TestingNetwork

type TestingNetwork struct {
	BroadcastedMsgs []*types.SSVMessage
}

func NewTestingNetwork

func NewTestingNetwork() *TestingNetwork

func (*TestingNetwork) Broadcast

func (net *TestingNetwork) Broadcast(message types.Encoder) error

func (*TestingNetwork) BroadcastDKGMessage

func (net *TestingNetwork) BroadcastDKGMessage(msg *dkg.SignedMessage) error

BroadcastDKGMessage will broadcast a msg to the dkg network

func (*TestingNetwork) BroadcastDecided

func (net *TestingNetwork) BroadcastDecided(message types.Encoder) error

func (*TestingNetwork) StreamDKGOutput

func (net *TestingNetwork) StreamDKGOutput(output map[types.OperatorID]*dkg.SignedOutput) error

StreamDKGOutput will stream to any subscriber the result of the DKG

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL