Remove spec import alias.

Specification imports for phase0 were aliased as 'spec'.  Due to the
mechanism decided upon to manage structs that vary beteween hard forks
this is no longer useful, so this removes the alias in preparation for
the Altair hard fork.
This commit is contained in:
Jim McDonald 2021-07-18 07:34:43 +01:00
parent 4598f9f639
commit 41afb240c2
No known key found for this signature in database
GPG Key ID: 89CEB61B2AD2A5E7
75 changed files with 721 additions and 721 deletions

View File

@ -22,7 +22,7 @@ import (
eth2client "github.com/attestantio/go-eth2-client"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/prysmaticlabs/go-bitfield"
)
@ -75,18 +75,18 @@ func (m *ErroringSlotDurationProvider) SlotDuration(ctx context.Context) (time.D
// FarFutureEpochProvider is a mock for eth2client.FarFutureEpochProvider.
type FarFutureEpochProvider struct {
farFutureEpoch spec.Epoch
farFutureEpoch phase0.Epoch
}
// NewFarFutureEpochProvider returns a mock far future epoch provider with the provided value.
func NewFarFutureEpochProvider(farFutureEpoch spec.Epoch) eth2client.FarFutureEpochProvider {
func NewFarFutureEpochProvider(farFutureEpoch phase0.Epoch) eth2client.FarFutureEpochProvider {
return &FarFutureEpochProvider{
farFutureEpoch: farFutureEpoch,
}
}
// FarFutureEpoch is a mock.
func (m *FarFutureEpochProvider) FarFutureEpoch(ctx context.Context) (spec.Epoch, error) {
func (m *FarFutureEpochProvider) FarFutureEpoch(ctx context.Context) (phase0.Epoch, error) {
return m.farFutureEpoch, nil
}
@ -129,7 +129,7 @@ func NewProposerDutiesProvider() eth2client.ProposerDutiesProvider {
}
// ProposerDuties is a mock.
func (m *ProposerDutiesProvider) ProposerDuties(ctx context.Context, epoch spec.Epoch, validatorIndices []spec.ValidatorIndex) ([]*api.ProposerDuty, error) {
func (m *ProposerDutiesProvider) ProposerDuties(ctx context.Context, epoch phase0.Epoch, validatorIndices []phase0.ValidatorIndex) ([]*api.ProposerDuty, error) {
return make([]*api.ProposerDuty, 0), nil
}
@ -142,7 +142,7 @@ func NewAttesterDutiesProvider() eth2client.AttesterDutiesProvider {
}
// AttesterDuties is a mock.
func (m *AttesterDutiesProvider) AttesterDuties(ctx context.Context, epoch spec.Epoch, validatorIndices []spec.ValidatorIndex) ([]*api.AttesterDuty, error) {
func (m *AttesterDutiesProvider) AttesterDuties(ctx context.Context, epoch phase0.Epoch, validatorIndices []phase0.ValidatorIndex) ([]*api.AttesterDuty, error) {
return make([]*api.AttesterDuty, 0), nil
}
@ -168,7 +168,7 @@ func NewAttestationsSubmitter() eth2client.AttestationsSubmitter {
}
// SubmitAttestations is a mock.
func (m *AttestationsSubmitter) SubmitAttestations(ctx context.Context, attestation []*spec.Attestation) error {
func (m *AttestationsSubmitter) SubmitAttestations(ctx context.Context, attestation []*phase0.Attestation) error {
return nil
}
@ -181,7 +181,7 @@ func NewErroringAttestationsSubmitter() eth2client.AttestationsSubmitter {
}
// SubmitAttestations is a mock.
func (m *ErroringAttestationsSubmitter) SubmitAttestations(ctx context.Context, attestations []*spec.Attestation) error {
func (m *ErroringAttestationsSubmitter) SubmitAttestations(ctx context.Context, attestations []*phase0.Attestation) error {
return errors.New("error")
}
@ -194,7 +194,7 @@ func NewBeaconBlockSubmitter() eth2client.BeaconBlockSubmitter {
}
// SubmitBeaconBlock is a mock.
func (m *BeaconBlockSubmitter) SubmitBeaconBlock(ctx context.Context, bloc *spec.SignedBeaconBlock) error {
func (m *BeaconBlockSubmitter) SubmitBeaconBlock(ctx context.Context, bloc *phase0.SignedBeaconBlock) error {
return nil
}
@ -207,7 +207,7 @@ func NewErroringBeaconBlockSubmitter() eth2client.BeaconBlockSubmitter {
}
// SubmitBeaconBlock is a mock.
func (m *ErroringBeaconBlockSubmitter) SubmitBeaconBlock(ctx context.Context, bloc *spec.SignedBeaconBlock) error {
func (m *ErroringBeaconBlockSubmitter) SubmitBeaconBlock(ctx context.Context, bloc *phase0.SignedBeaconBlock) error {
return errors.New("error")
}
@ -220,7 +220,7 @@ func NewAggregateAttestationsSubmitter() eth2client.AggregateAttestationsSubmitt
}
// SubmitAggregateAttestations is a mock.
func (m *AggregateAttestationsSubmitter) SubmitAggregateAttestations(ctx context.Context, aggregateAndProofs []*spec.SignedAggregateAndProof) error {
func (m *AggregateAttestationsSubmitter) SubmitAggregateAttestations(ctx context.Context, aggregateAndProofs []*phase0.SignedAggregateAndProof) error {
return nil
}
@ -233,7 +233,7 @@ func NewErroringAggregateAttestationsSubmitter() eth2client.AggregateAttestation
}
// SubmitAggregateAttestations is a mock.
func (m *ErroringAggregateAttestationsSubmitter) SubmitAggregateAttestations(ctx context.Context, aggregateAndProofs []*spec.SignedAggregateAndProof) error {
func (m *ErroringAggregateAttestationsSubmitter) SubmitAggregateAttestations(ctx context.Context, aggregateAndProofs []*phase0.SignedAggregateAndProof) error {
return errors.New("error")
}
@ -272,7 +272,7 @@ func NewBeaconBlockProposalProvider() eth2client.BeaconBlockProposalProvider {
}
// BeaconBlockProposal is a mock.
func (m *BeaconBlockProposalProvider) BeaconBlockProposal(ctx context.Context, slot spec.Slot, randaoReveal spec.BLSSignature, graffiti []byte) (*spec.BeaconBlock, error) {
func (m *BeaconBlockProposalProvider) BeaconBlockProposal(ctx context.Context, slot phase0.Slot, randaoReveal phase0.BLSSignature, graffiti []byte) (*phase0.BeaconBlock, error) {
// Graffiti should be 32 bytes.
fixedGraffiti := make([]byte, 32)
copy(fixedGraffiti, graffiti)
@ -280,35 +280,35 @@ func (m *BeaconBlockProposalProvider) BeaconBlockProposal(ctx context.Context, s
// Build a beacon block.
// Create a few attestations.
attestations := make([]*spec.Attestation, 4)
attestations := make([]*phase0.Attestation, 4)
for i := uint64(0); i < 4; i++ {
aggregationBits := bitfield.NewBitlist(128)
aggregationBits.SetBitAt(i, true)
attestations[i] = &spec.Attestation{
attestations[i] = &phase0.Attestation{
AggregationBits: aggregationBits,
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: slot - 1,
Index: spec.CommitteeIndex(i),
BeaconBlockRoot: spec.Root([32]byte{
Index: phase0.CommitteeIndex(i),
BeaconBlockRoot: phase0.Root([32]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
}),
Source: &spec.Checkpoint{
Source: &phase0.Checkpoint{
Epoch: 0,
Root: spec.Root([32]byte{
Root: phase0.Root([32]byte{
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
}),
},
Target: &spec.Checkpoint{
Target: &phase0.Checkpoint{
Epoch: 1,
Root: spec.Root([32]byte{
Root: phase0.Root([32]byte{
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
}),
},
},
Signature: spec.BLSSignature([96]byte{
Signature: phase0.BLSSignature([96]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
@ -319,21 +319,21 @@ func (m *BeaconBlockProposalProvider) BeaconBlockProposal(ctx context.Context, s
}
}
block := &spec.BeaconBlock{
block := &phase0.BeaconBlock{
Slot: slot,
ProposerIndex: 1,
ParentRoot: spec.Root([32]byte{
ParentRoot: phase0.Root([32]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
}),
StateRoot: spec.Root([32]byte{
StateRoot: phase0.Root([32]byte{
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
}),
Body: &spec.BeaconBlockBody{
Body: &phase0.BeaconBlockBody{
RANDAOReveal: randaoReveal,
ETH1Data: &spec.ETH1Data{
DepositRoot: spec.Root([32]byte{
ETH1Data: &phase0.ETH1Data{
DepositRoot: phase0.Root([32]byte{
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
}),
@ -344,11 +344,11 @@ func (m *BeaconBlockProposalProvider) BeaconBlockProposal(ctx context.Context, s
},
},
Graffiti: fixedGraffiti,
ProposerSlashings: []*spec.ProposerSlashing{},
AttesterSlashings: []*spec.AttesterSlashing{},
ProposerSlashings: []*phase0.ProposerSlashing{},
AttesterSlashings: []*phase0.AttesterSlashing{},
Attestations: attestations,
Deposits: []*spec.Deposit{},
VoluntaryExits: []*spec.SignedVoluntaryExit{},
Deposits: []*phase0.Deposit{},
VoluntaryExits: []*phase0.SignedVoluntaryExit{},
},
}
@ -364,9 +364,9 @@ func NewSignedBeaconBlockProvider() eth2client.SignedBeaconBlockProvider {
}
// SignedBeaconBlock is a mock.
func (m *SignedBeaconBlockProvider) SignedBeaconBlock(ctx context.Context, stateID string) (*spec.SignedBeaconBlock, error) {
return &spec.SignedBeaconBlock{
Message: &spec.BeaconBlock{
func (m *SignedBeaconBlockProvider) SignedBeaconBlock(ctx context.Context, stateID string) (*phase0.SignedBeaconBlock, error) {
return &phase0.SignedBeaconBlock{
Message: &phase0.BeaconBlock{
Slot: 123,
},
}, nil
@ -381,24 +381,24 @@ func NewAttestationDataProvider() eth2client.AttestationDataProvider {
}
// AttestationData is a mock.
func (m *AttestationDataProvider) AttestationData(ctx context.Context, slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error) {
return &spec.AttestationData{
func (m *AttestationDataProvider) AttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) {
return &phase0.AttestationData{
Slot: slot,
Index: committeeIndex,
BeaconBlockRoot: spec.Root([32]byte{
BeaconBlockRoot: phase0.Root([32]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
}),
Source: &spec.Checkpoint{
Source: &phase0.Checkpoint{
Epoch: 1,
Root: spec.Root([32]byte{
Root: phase0.Root([32]byte{
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
}),
},
Target: &spec.Checkpoint{
Target: &phase0.Checkpoint{
Epoch: 2,
Root: spec.Root([32]byte{
Root: phase0.Root([32]byte{
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
}),
@ -415,7 +415,7 @@ func NewErroringAttestationDataProvider() eth2client.AttestationDataProvider {
}
// AttestationData is a mock.
func (m *ErroringAttestationDataProvider) AttestationData(ctx context.Context, slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error) {
func (m *ErroringAttestationDataProvider) AttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) {
return nil, errors.New("mock error")
}
@ -428,7 +428,7 @@ func NewNilAttestationDataProvider() eth2client.AttestationDataProvider {
}
// AttestationData is a mock.
func (m *NilAttestationDataProvider) AttestationData(ctx context.Context, slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error) {
func (m *NilAttestationDataProvider) AttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) {
return nil, nil
}
@ -447,7 +447,7 @@ func NewSleepyAttestationDataProvider(wait time.Duration, next eth2client.Attest
}
// AttestationData is a mock.
func (m *SleepyAttestationDataProvider) AttestationData(ctx context.Context, slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error) {
func (m *SleepyAttestationDataProvider) AttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) {
time.Sleep(m.wait)
return m.next.AttestationData(ctx, slot, committeeIndex)
}
@ -461,7 +461,7 @@ func NewAggregateAttestationProvider() eth2client.AggregateAttestationProvider {
}
// AggregateAttestation is a mock.
func (m *AggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot spec.Slot, attestationDataRoot spec.Root) (*spec.Attestation, error) {
func (m *AggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot phase0.Slot, attestationDataRoot phase0.Root) (*phase0.Attestation, error) {
aggregationBits := bitfield.NewBitlist(128)
aggregationBits.SetBitAt(1, true)
aggregationBits.SetBitAt(3, true)
@ -469,31 +469,31 @@ func (m *AggregateAttestationProvider) AggregateAttestation(ctx context.Context,
aggregationBits.SetBitAt(12, true)
aggregationBits.SetBitAt(65, true)
aggregationBits.SetBitAt(77, true)
return &spec.Attestation{
return &phase0.Attestation{
AggregationBits: aggregationBits,
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: slot,
Index: 1,
BeaconBlockRoot: spec.Root([32]byte{
BeaconBlockRoot: phase0.Root([32]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
}),
Source: &spec.Checkpoint{
Source: &phase0.Checkpoint{
Epoch: 1,
Root: spec.Root([32]byte{
Root: phase0.Root([32]byte{
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
}),
},
Target: &spec.Checkpoint{
Target: &phase0.Checkpoint{
Epoch: 2,
Root: spec.Root([32]byte{
Root: phase0.Root([32]byte{
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
}),
},
},
Signature: spec.BLSSignature([96]byte{
Signature: phase0.BLSSignature([96]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
@ -513,7 +513,7 @@ func NewErroringAggregateAttestationProvider() eth2client.AggregateAttestationPr
}
// AggregateAttestation is a mock.
func (m *ErroringAggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot spec.Slot, attestationDataRoot spec.Root) (*spec.Attestation, error) {
func (m *ErroringAggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot phase0.Slot, attestationDataRoot phase0.Root) (*phase0.Attestation, error) {
return nil, errors.New("mock error")
}
@ -526,7 +526,7 @@ func NewNilAggregateAttestationProvider() eth2client.AggregateAttestationProvide
}
// AggregateAttestation is a mock.
func (m *NilAggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot spec.Slot, attestationDataRoot spec.Root) (*spec.Attestation, error) {
func (m *NilAggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot phase0.Slot, attestationDataRoot phase0.Root) (*phase0.Attestation, error) {
return nil, nil
}
@ -545,7 +545,7 @@ func NewSleepyAggregateAttestationProvider(wait time.Duration, next eth2client.A
}
// AggregateAttestation is a mock.
func (m *SleepyAggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot spec.Slot, attestationDataRoot spec.Root) (*spec.Attestation, error) {
func (m *SleepyAggregateAttestationProvider) AggregateAttestation(ctx context.Context, slot phase0.Slot, attestationDataRoot phase0.Root) (*phase0.Attestation, error) {
time.Sleep(m.wait)
return m.next.AggregateAttestation(ctx, slot, attestationDataRoot)
}
@ -559,8 +559,8 @@ func NewBeaconProposerDomainProvider() eth2client.BeaconProposerDomainProvider {
}
// BeaconProposerDomain is a mock.
func (m *BeaconProposerDomainProvider) BeaconProposerDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{0x00, 0x00, 0x00, 0x00}, nil
func (m *BeaconProposerDomainProvider) BeaconProposerDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{0x00, 0x00, 0x00, 0x00}, nil
}
// ErroringBeaconProposerDomainProvider is a mock for eth2client.BeaconProposerDomainProvider.
@ -572,8 +572,8 @@ func NewErroringBeaconProposerDomainProvider() eth2client.BeaconProposerDomainPr
}
// BeaconProposerDomain is a mock.
func (m *ErroringBeaconProposerDomainProvider) BeaconProposerDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{}, errors.New("error")
func (m *ErroringBeaconProposerDomainProvider) BeaconProposerDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{}, errors.New("error")
}
// BeaconAttesterDomainProvider is a mock for eth2client.BeaconAttesterDomainProvider.
@ -585,8 +585,8 @@ func NewBeaconAttesterDomainProvider() eth2client.BeaconAttesterDomainProvider {
}
// BeaconAttesterDomain is a mock.
func (m *BeaconAttesterDomainProvider) BeaconAttesterDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{0x01, 0x00, 0x00, 0x00}, nil
func (m *BeaconAttesterDomainProvider) BeaconAttesterDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{0x01, 0x00, 0x00, 0x00}, nil
}
// ErroringBeaconAttesterDomainProvider is a mock for eth2client.BeaconAttesterDomainProvider.
@ -598,8 +598,8 @@ func NewErroringBeaconAttesterDomainProvider() eth2client.BeaconAttesterDomainPr
}
// BeaconAttesterDomain is a mock.
func (m *ErroringBeaconAttesterDomainProvider) BeaconAttesterDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{}, errors.New("error")
func (m *ErroringBeaconAttesterDomainProvider) BeaconAttesterDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{}, errors.New("error")
}
// RANDAODomainProvider is a mock for eth2client.RANDAODomainProvider.
@ -611,8 +611,8 @@ func NewRANDAODomainProvider() eth2client.RANDAODomainProvider {
}
// RANDAODomain is a mock.
func (m *RANDAODomainProvider) RANDAODomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{0x02, 0x00, 0x00, 0x00}, nil
func (m *RANDAODomainProvider) RANDAODomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{0x02, 0x00, 0x00, 0x00}, nil
}
// ErroringRANDAODomainProvider is a mock for eth2client.RANDAODomainProvider.
@ -624,8 +624,8 @@ func NewErroringRANDAODomainProvider() eth2client.RANDAODomainProvider {
}
// RANDAODomain is a mock.
func (m *ErroringRANDAODomainProvider) RANDAODomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{}, errors.New("error")
func (m *ErroringRANDAODomainProvider) RANDAODomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{}, errors.New("error")
}
// DepositDomainProvider is a mock for eth2client.DepositDomainProvider.
@ -637,8 +637,8 @@ func NewDepositDomainProvider() eth2client.DepositDomainProvider {
}
// DepositDomain is a mock.
func (m *DepositDomainProvider) DepositDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{0x03, 0x00, 0x00, 0x00}, nil
func (m *DepositDomainProvider) DepositDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{0x03, 0x00, 0x00, 0x00}, nil
}
// ErroringDepositDomainProvider is a mock for eth2client.DepositDomainProvider.
@ -650,8 +650,8 @@ func NewErroringDepositDomainProvider() eth2client.DepositDomainProvider {
}
// DepositDomain is a mock.
func (m *ErroringDepositDomainProvider) DepositDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{}, errors.New("error")
func (m *ErroringDepositDomainProvider) DepositDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{}, errors.New("error")
}
// VoluntaryExitDomainProvider is a mock for eth2client.VoluntaryExitDomainProvider.
@ -663,8 +663,8 @@ func NewVoluntaryExitDomainProvider() eth2client.VoluntaryExitDomainProvider {
}
// VoluntaryExitDomain is a mock.
func (m *VoluntaryExitDomainProvider) VoluntaryExitDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{0x04, 0x00, 0x00, 0x00}, nil
func (m *VoluntaryExitDomainProvider) VoluntaryExitDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{0x04, 0x00, 0x00, 0x00}, nil
}
// ErroringVoluntaryExitDomainProvider is a mock for eth2client.VoluntaryExitDomainProvider.
@ -676,8 +676,8 @@ func NewErroringVoluntaryExitDomainProvider() eth2client.VoluntaryExitDomainProv
}
// VoluntaryExitDomain is a mock.
func (m *ErroringVoluntaryExitDomainProvider) VoluntaryExitDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{}, errors.New("error")
func (m *ErroringVoluntaryExitDomainProvider) VoluntaryExitDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{}, errors.New("error")
}
// SelectionProofDomainProvider is a mock for eth2client.SelectionProofDomainProvider.
@ -689,8 +689,8 @@ func NewSelectionProofDomainProvider() eth2client.SelectionProofDomainProvider {
}
// SelectionProofDomain is a mock.
func (m *SelectionProofDomainProvider) SelectionProofDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{0x05, 0x00, 0x00, 0x00}, nil
func (m *SelectionProofDomainProvider) SelectionProofDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{0x05, 0x00, 0x00, 0x00}, nil
}
// ErroringSelectionProofDomainProvider is a mock for eth2client.SelectionProofDomainProvider.
@ -702,8 +702,8 @@ func NewErroringSelectionProofDomainProvider() eth2client.SelectionProofDomainPr
}
// SelectionProofDomain is a mock.
func (m *ErroringSelectionProofDomainProvider) SelectionProofDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{}, errors.New("error")
func (m *ErroringSelectionProofDomainProvider) SelectionProofDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{}, errors.New("error")
}
// AggregateAndProofDomainProvider is a mock for eth2client.AggregateAndProofDomainProvider.
@ -715,8 +715,8 @@ func NewAggregateAndProofDomainProvider() eth2client.AggregateAndProofDomainProv
}
// AggregateAndProofDomain is a mock.
func (m *AggregateAndProofDomainProvider) AggregateAndProofDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{0x06, 0x00, 0x00, 0x00}, nil
func (m *AggregateAndProofDomainProvider) AggregateAndProofDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{0x06, 0x00, 0x00, 0x00}, nil
}
// ErroringAggregateAndProofDomainProvider is a mock for eth2client.AggregateAndProofDomainProvider.
@ -728,8 +728,8 @@ func NewErroringAggregateAndProofDomainProvider() eth2client.AggregateAndProofDo
}
// AggregateAndProofDomain is a mock.
func (m *ErroringAggregateAndProofDomainProvider) AggregateAndProofDomain(ctx context.Context) (spec.DomainType, error) {
return spec.DomainType{}, errors.New("error")
func (m *ErroringAggregateAndProofDomainProvider) AggregateAndProofDomain(ctx context.Context) (phase0.DomainType, error) {
return phase0.DomainType{}, errors.New("error")
}
// DomainProvider is a mock for eth2client.DomainProvider.
@ -741,8 +741,8 @@ func NewDomainProvider() eth2client.DomainProvider {
}
// Domain is a mock.
func (m *DomainProvider) Domain(ctx context.Context, domainType spec.DomainType, epoch spec.Epoch) (spec.Domain, error) {
var domain spec.Domain
func (m *DomainProvider) Domain(ctx context.Context, domainType phase0.DomainType, epoch phase0.Epoch) (phase0.Domain, error) {
var domain phase0.Domain
// Put the domain type in the first four bytes, to differentiate signatures.
copy(domain[:], domainType[:])
@ -758,8 +758,8 @@ func NewErroringDomainProvider() eth2client.DomainProvider {
}
// Domain is a mock.
func (m *ErroringDomainProvider) Domain(ctx context.Context, domainType spec.DomainType, epoch spec.Epoch) (spec.Domain, error) {
return spec.Domain{}, errors.New("error")
func (m *ErroringDomainProvider) Domain(ctx context.Context, domainType phase0.DomainType, epoch phase0.Epoch) (phase0.Domain, error) {
return phase0.Domain{}, errors.New("error")
}
func _byte(input string) []byte {
@ -767,19 +767,19 @@ func _byte(input string) []byte {
return res
}
func _blsPubKey(input string) spec.BLSPubKey {
func _blsPubKey(input string) phase0.BLSPubKey {
tmp, _ := hex.DecodeString(strings.TrimPrefix(input, "0x"))
var res spec.BLSPubKey
var res phase0.BLSPubKey
copy(res[:], tmp)
return res
}
func _epochValidator(index spec.ValidatorIndex, pubKey string, withdrwalCredentials string) *api.Validator {
func _epochValidator(index phase0.ValidatorIndex, pubKey string, withdrwalCredentials string) *api.Validator {
return &api.Validator{
Index: index,
Balance: 32000000000,
Status: api.ValidatorStateActiveOngoing,
Validator: &spec.Validator{
Validator: &phase0.Validator{
PublicKey: _blsPubKey(pubKey),
WithdrawalCredentials: _byte(withdrwalCredentials),
EffectiveBalance: 32000000,
@ -801,8 +801,8 @@ func NewValidatorsProvider() eth2client.ValidatorsProvider {
}
// Validators is a mock.
func (m *ValidatorsProvider) Validators(ctx context.Context, stateID string, validators []spec.ValidatorIndex) (map[spec.ValidatorIndex]*api.Validator, error) {
base := map[spec.ValidatorIndex]*api.Validator{
func (m *ValidatorsProvider) Validators(ctx context.Context, stateID string, validators []phase0.ValidatorIndex) (map[phase0.ValidatorIndex]*api.Validator, error) {
base := map[phase0.ValidatorIndex]*api.Validator{
0: _epochValidator(0,
"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c",
"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b"),
@ -905,7 +905,7 @@ func (m *ValidatorsProvider) Validators(ctx context.Context, stateID string, val
return base, nil
}
res := make(map[spec.ValidatorIndex]*api.Validator)
res := make(map[phase0.ValidatorIndex]*api.Validator)
for k, v := range base {
for _, index := range validators {
if k == index {
@ -918,8 +918,8 @@ func (m *ValidatorsProvider) Validators(ctx context.Context, stateID string, val
}
// ValidatorsByPubKey is a mock.
func (m *ValidatorsProvider) ValidatorsByPubKey(ctx context.Context, stateID string, validators []spec.BLSPubKey) (map[spec.ValidatorIndex]*api.Validator, error) {
base := map[spec.ValidatorIndex]*api.Validator{
func (m *ValidatorsProvider) ValidatorsByPubKey(ctx context.Context, stateID string, validators []phase0.BLSPubKey) (map[phase0.ValidatorIndex]*api.Validator, error) {
base := map[phase0.ValidatorIndex]*api.Validator{
0: _epochValidator(0,
"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c",
"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b"),
@ -1022,7 +1022,7 @@ func (m *ValidatorsProvider) ValidatorsByPubKey(ctx context.Context, stateID str
return base, nil
}
res := make(map[spec.ValidatorIndex]*api.Validator)
res := make(map[phase0.ValidatorIndex]*api.Validator)
for k, v := range base {
for _, pubKey := range validators {
if v.Validator.PublicKey == pubKey {
@ -1043,8 +1043,8 @@ func NewValidatorsWithoutBalanceProvider() eth2client.ValidatorsProvider {
}
// Validators is a mock.
func (m *ValidatorsWithoutBalanceProvider) Validators(ctx context.Context, stateID string, validators []spec.ValidatorIndex) (map[spec.ValidatorIndex]*api.Validator, error) {
base := map[spec.ValidatorIndex]*api.Validator{
func (m *ValidatorsWithoutBalanceProvider) Validators(ctx context.Context, stateID string, validators []phase0.ValidatorIndex) (map[phase0.ValidatorIndex]*api.Validator, error) {
base := map[phase0.ValidatorIndex]*api.Validator{
0: _epochValidator(0,
"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c",
"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b"),
@ -1147,7 +1147,7 @@ func (m *ValidatorsWithoutBalanceProvider) Validators(ctx context.Context, state
return base, nil
}
res := make(map[spec.ValidatorIndex]*api.Validator)
res := make(map[phase0.ValidatorIndex]*api.Validator)
for k, v := range base {
for _, index := range validators {
if k == index {
@ -1160,8 +1160,8 @@ func (m *ValidatorsWithoutBalanceProvider) Validators(ctx context.Context, state
}
// ValidatorsByPubKey is a mock.
func (m *ValidatorsWithoutBalanceProvider) ValidatorsByPubKey(ctx context.Context, stateID string, validators []spec.BLSPubKey) (map[spec.ValidatorIndex]*api.Validator, error) {
base := map[spec.ValidatorIndex]*api.Validator{
func (m *ValidatorsWithoutBalanceProvider) ValidatorsByPubKey(ctx context.Context, stateID string, validators []phase0.BLSPubKey) (map[phase0.ValidatorIndex]*api.Validator, error) {
base := map[phase0.ValidatorIndex]*api.Validator{
0: _epochValidator(0,
"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c",
"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b"),
@ -1264,7 +1264,7 @@ func (m *ValidatorsWithoutBalanceProvider) ValidatorsByPubKey(ctx context.Contex
return base, nil
}
res := make(map[spec.ValidatorIndex]*api.Validator)
res := make(map[phase0.ValidatorIndex]*api.Validator)
for k, v := range base {
for _, pubKey := range validators {
if v.Validator.PublicKey == pubKey {
@ -1277,8 +1277,8 @@ func (m *ValidatorsWithoutBalanceProvider) ValidatorsByPubKey(ctx context.Contex
}
// ValidatorsWithoutBalance is a mock.
func (m *ValidatorsWithoutBalanceProvider) ValidatorsWithoutBalance(ctx context.Context, stateID string, validators []spec.ValidatorIndex) (map[spec.ValidatorIndex]*api.Validator, error) {
base := map[spec.ValidatorIndex]*api.Validator{
func (m *ValidatorsWithoutBalanceProvider) ValidatorsWithoutBalance(ctx context.Context, stateID string, validators []phase0.ValidatorIndex) (map[phase0.ValidatorIndex]*api.Validator, error) {
base := map[phase0.ValidatorIndex]*api.Validator{
0: _epochValidator(0,
"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c",
"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b"),
@ -1385,7 +1385,7 @@ func (m *ValidatorsWithoutBalanceProvider) ValidatorsWithoutBalance(ctx context.
return base, nil
}
res := make(map[spec.ValidatorIndex]*api.Validator)
res := make(map[phase0.ValidatorIndex]*api.Validator)
for k, v := range base {
for _, index := range validators {
if k == index {

View File

@ -17,7 +17,7 @@ import (
"context"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/validatorsmanager"
)
@ -29,21 +29,21 @@ func NewValidatorsManager() validatorsmanager.Service {
}
// RefreshValidatorsFromBeaconNode is a mock.
func (v *validatorsManager) RefreshValidatorsFromBeaconNode(ctx context.Context, pubKeys []spec.BLSPubKey) error {
func (v *validatorsManager) RefreshValidatorsFromBeaconNode(ctx context.Context, pubKeys []phase0.BLSPubKey) error {
return nil
}
// ValidatorsByIndex is a mock.
func (v *validatorsManager) ValidatorsByIndex(ctx context.Context, indices []spec.ValidatorIndex) map[spec.ValidatorIndex]*spec.Validator {
return make(map[spec.ValidatorIndex]*spec.Validator)
func (v *validatorsManager) ValidatorsByIndex(ctx context.Context, indices []phase0.ValidatorIndex) map[phase0.ValidatorIndex]*phase0.Validator {
return make(map[phase0.ValidatorIndex]*phase0.Validator)
}
// ValidatorsByIndex is a mock.
func (v *validatorsManager) ValidatorsByPubKey(ctx context.Context, pubKeys []spec.BLSPubKey) map[spec.ValidatorIndex]*spec.Validator {
return make(map[spec.ValidatorIndex]*spec.Validator)
func (v *validatorsManager) ValidatorsByPubKey(ctx context.Context, pubKeys []phase0.BLSPubKey) map[phase0.ValidatorIndex]*phase0.Validator {
return make(map[phase0.ValidatorIndex]*phase0.Validator)
}
// ValidatorStateAtEpoch is a mock.
func (v *validatorsManager) ValidatorStateAtEpoch(ctx context.Context, index spec.ValidatorIndex, epoch spec.Epoch) (api.ValidatorState, error) {
func (v *validatorsManager) ValidatorStateAtEpoch(ctx context.Context, index phase0.ValidatorIndex, epoch phase0.Epoch) (api.ValidatorState, error) {
return api.ValidatorStateUnknown, nil
}

View File

@ -25,7 +25,7 @@ import (
eth2client "github.com/attestantio/go-eth2-client"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/chaintime"
"github.com/attestantio/vouch/services/metrics"
"github.com/attestantio/vouch/services/validatorsmanager"
@ -47,10 +47,10 @@ type Service struct {
endpoints []*dirk.Endpoint
accountPaths []string
credentials credentials.TransportCredentials
accounts map[spec.BLSPubKey]e2wtypes.Account
accounts map[phase0.BLSPubKey]e2wtypes.Account
validatorsManager validatorsmanager.Service
domainProvider eth2client.DomainProvider
farFutureEpoch spec.Epoch
farFutureEpoch phase0.Epoch
currentEpochProvider chaintime.Service
wallets map[string]e2wtypes.Wallet
walletsMutex sync.RWMutex
@ -163,7 +163,7 @@ func (s *Service) refreshAccounts(ctx context.Context) error {
verificationRegexes := accountPathsToVerificationRegexes(s.accountPaths)
// Fetch accounts for each wallet.
accounts := make(map[spec.BLSPubKey]e2wtypes.Account)
accounts := make(map[phase0.BLSPubKey]e2wtypes.Account)
_, err := util.Scatter(len(wallets), func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) {
for i := offset; i < offset+entries; i++ {
walletAccounts := s.fetchAccountsForWallet(ctx, wallets[i], verificationRegexes)
@ -213,7 +213,7 @@ func (s *Service) openWallet(ctx context.Context, name string) (e2wtypes.Wallet,
// refreshValidators refreshes the validator information for our known accounts.
func (s *Service) refreshValidators(ctx context.Context) error {
accountPubKeys := make([]spec.BLSPubKey, 0, len(s.accounts))
accountPubKeys := make([]phase0.BLSPubKey, 0, len(s.accounts))
for pubKey := range s.accounts {
accountPubKeys = append(accountPubKeys, pubKey)
}
@ -246,7 +246,7 @@ func credentialsFromCerts(ctx context.Context, clientCert []byte, clientKey []by
}
// ValidatingAccountsForEpoch obtains the validating accounts for a given epoch.
func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epoch) (map[spec.ValidatorIndex]e2wtypes.Account, error) {
func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch phase0.Epoch) (map[phase0.ValidatorIndex]e2wtypes.Account, error) {
// stateCount is used to update metrics.
stateCount := map[api.ValidatorState]uint64{
api.ValidatorStateUnknown: 0,
@ -261,8 +261,8 @@ func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epo
api.ValidatorStateWithdrawalDone: 0,
}
validatingAccounts := make(map[spec.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]spec.BLSPubKey, 0, len(s.accounts))
validatingAccounts := make(map[phase0.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]phase0.BLSPubKey, 0, len(s.accounts))
for pubKey := range s.accounts {
pubKeys = append(pubKeys, pubKey)
}
@ -295,14 +295,14 @@ func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epo
}
// ValidatingAccountsForEpochByIndex obtains the specified validating accounts for a given epoch.
func (s *Service) ValidatingAccountsForEpochByIndex(ctx context.Context, epoch spec.Epoch, indices []spec.ValidatorIndex) (map[spec.ValidatorIndex]e2wtypes.Account, error) {
validatingAccounts := make(map[spec.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]spec.BLSPubKey, 0, len(s.accounts))
func (s *Service) ValidatingAccountsForEpochByIndex(ctx context.Context, epoch phase0.Epoch, indices []phase0.ValidatorIndex) (map[phase0.ValidatorIndex]e2wtypes.Account, error) {
validatingAccounts := make(map[phase0.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]phase0.BLSPubKey, 0, len(s.accounts))
for pubKey := range s.accounts {
pubKeys = append(pubKeys, pubKey)
}
indexPresenceMap := make(map[spec.ValidatorIndex]bool)
indexPresenceMap := make(map[phase0.ValidatorIndex]bool)
for _, index := range indices {
indexPresenceMap[index] = true
}
@ -351,8 +351,8 @@ func accountPathsToVerificationRegexes(paths []string) []*regexp.Regexp {
return regexes
}
func (s *Service) fetchAccountsForWallet(ctx context.Context, wallet e2wtypes.Wallet, verificationRegexes []*regexp.Regexp) map[spec.BLSPubKey]e2wtypes.Account {
res := make(map[spec.BLSPubKey]e2wtypes.Account)
func (s *Service) fetchAccountsForWallet(ctx context.Context, wallet e2wtypes.Wallet, verificationRegexes []*regexp.Regexp) map[phase0.BLSPubKey]e2wtypes.Account {
res := make(map[phase0.BLSPubKey]e2wtypes.Account)
for account := range wallet.Accounts(ctx) {
// Ensure the name matches one of our account paths.
name := fmt.Sprintf("%s/%s", wallet.Name(), account.Name())

View File

@ -19,7 +19,7 @@ import (
"testing"
"time"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
standardchaintime "github.com/attestantio/vouch/services/chaintime/standard"
nullmetrics "github.com/attestantio/vouch/services/metrics/null"
@ -154,7 +154,7 @@ func TestAccountPathsToVerificationRegexes(t *testing.T) {
func TestAccounts(t *testing.T) {
tests := []struct {
name string
accounts map[spec.BLSPubKey]e2wtypes.Account
accounts map[phase0.BLSPubKey]e2wtypes.Account
expected int
}{
{

View File

@ -16,7 +16,7 @@ package mock
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/accountmanager"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -29,19 +29,19 @@ func NewValidatingAccountsProvider() accountmanager.ValidatingAccountsProvider {
}
// ValidatingAccountsForEpoch is a mock.
func (v *validatingAccountsProvider) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epoch) (map[spec.ValidatorIndex]e2wtypes.Account, error) {
return make(map[spec.ValidatorIndex]e2wtypes.Account), nil
func (v *validatingAccountsProvider) ValidatingAccountsForEpoch(ctx context.Context, epoch phase0.Epoch) (map[phase0.ValidatorIndex]e2wtypes.Account, error) {
return make(map[phase0.ValidatorIndex]e2wtypes.Account), nil
}
// ValidatingAccountsForEpochByIndex obtains the specified validating accounts for a given epoch.
func (v *validatingAccountsProvider) ValidatingAccountsForEpochByIndex(ctx context.Context,
epoch spec.Epoch,
indices []spec.ValidatorIndex,
epoch phase0.Epoch,
indices []phase0.ValidatorIndex,
) (
map[spec.ValidatorIndex]e2wtypes.Account,
map[phase0.ValidatorIndex]e2wtypes.Account,
error,
) {
return make(map[spec.ValidatorIndex]e2wtypes.Account), nil
return make(map[phase0.ValidatorIndex]e2wtypes.Account), nil
}
type refresher struct{}

View File

@ -17,7 +17,7 @@ package accountmanager
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -27,14 +27,14 @@ type Service interface{}
// ValidatingAccountsProvider provides methods for validating accounts.
type ValidatingAccountsProvider interface {
// ValidatingAccountsForEpoch obtains the validating accounts for a given epoch.
ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epoch) (map[spec.ValidatorIndex]e2wtypes.Account, error)
ValidatingAccountsForEpoch(ctx context.Context, epoch phase0.Epoch) (map[phase0.ValidatorIndex]e2wtypes.Account, error)
// ValidatingAccountsForEpochByIndex obtains the specified validating accounts for a given epoch.
ValidatingAccountsForEpochByIndex(ctx context.Context,
epoch spec.Epoch,
indices []spec.ValidatorIndex,
epoch phase0.Epoch,
indices []phase0.ValidatorIndex,
) (
map[spec.ValidatorIndex]e2wtypes.Account,
map[phase0.ValidatorIndex]e2wtypes.Account,
error,
)
}

View File

@ -22,7 +22,7 @@ import (
eth2client "github.com/attestantio/go-eth2-client"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/chaintime"
"github.com/attestantio/vouch/services/metrics"
"github.com/attestantio/vouch/services/validatorsmanager"
@ -42,11 +42,11 @@ type Service struct {
stores []e2wtypes.Store
accountPaths []string
passphrases [][]byte
accounts map[spec.BLSPubKey]e2wtypes.Account
accounts map[phase0.BLSPubKey]e2wtypes.Account
validatorsManager validatorsmanager.Service
slotsPerEpoch spec.Slot
slotsPerEpoch phase0.Slot
domainProvider eth2client.DomainProvider
farFutureEpoch spec.Epoch
farFutureEpoch phase0.Epoch
currentEpochProvider chaintime.Service
}
@ -94,7 +94,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
accountPaths: parameters.accountPaths,
passphrases: parameters.passphrases,
validatorsManager: parameters.validatorsManager,
slotsPerEpoch: spec.Slot(slotsPerEpoch),
slotsPerEpoch: phase0.Slot(slotsPerEpoch),
domainProvider: parameters.domainProvider,
farFutureEpoch: farFutureEpoch,
currentEpochProvider: parameters.currentEpochProvider,
@ -153,7 +153,7 @@ func (s *Service) refreshAccounts(ctx context.Context) error {
verificationRegexes := accountPathsToVerificationRegexes(s.accountPaths)
// Fetch accounts for each wallet.
accounts := make(map[spec.BLSPubKey]e2wtypes.Account)
accounts := make(map[phase0.BLSPubKey]e2wtypes.Account)
for _, wallet := range wallets {
// if _, isProvider := wallet.(e2wtypes.WalletAccountsByPathProvider); isProvider {
// fmt.Printf("TODO: fetch accounts by path")
@ -172,7 +172,7 @@ func (s *Service) refreshAccounts(ctx context.Context) error {
// refreshValidators refreshes the validator information for our known accounts.
func (s *Service) refreshValidators(ctx context.Context) error {
accountPubKeys := make([]spec.BLSPubKey, 0, len(s.accounts))
accountPubKeys := make([]phase0.BLSPubKey, 0, len(s.accounts))
for pubKey := range s.accounts {
accountPubKeys = append(accountPubKeys, pubKey)
}
@ -183,7 +183,7 @@ func (s *Service) refreshValidators(ctx context.Context) error {
}
// ValidatingAccountsForEpoch obtains the validating accounts for a given epoch.
func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epoch) (map[spec.ValidatorIndex]e2wtypes.Account, error) {
func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch phase0.Epoch) (map[phase0.ValidatorIndex]e2wtypes.Account, error) {
// stateCount is used to update metrics.
stateCount := map[api.ValidatorState]uint64{
api.ValidatorStateUnknown: 0,
@ -198,8 +198,8 @@ func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epo
api.ValidatorStateWithdrawalDone: 0,
}
validatingAccounts := make(map[spec.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]spec.BLSPubKey, 0, len(s.accounts))
validatingAccounts := make(map[phase0.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]phase0.BLSPubKey, 0, len(s.accounts))
for pubKey := range s.accounts {
pubKeys = append(pubKeys, pubKey)
}
@ -232,14 +232,14 @@ func (s *Service) ValidatingAccountsForEpoch(ctx context.Context, epoch spec.Epo
}
// ValidatingAccountsForEpochByIndex obtains the specified validating accounts for a given epoch.
func (s *Service) ValidatingAccountsForEpochByIndex(ctx context.Context, epoch spec.Epoch, indices []spec.ValidatorIndex) (map[spec.ValidatorIndex]e2wtypes.Account, error) {
validatingAccounts := make(map[spec.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]spec.BLSPubKey, 0, len(s.accounts))
func (s *Service) ValidatingAccountsForEpochByIndex(ctx context.Context, epoch phase0.Epoch, indices []phase0.ValidatorIndex) (map[phase0.ValidatorIndex]e2wtypes.Account, error) {
validatingAccounts := make(map[phase0.ValidatorIndex]e2wtypes.Account)
pubKeys := make([]phase0.BLSPubKey, 0, len(s.accounts))
for pubKey := range s.accounts {
pubKeys = append(pubKeys, pubKey)
}
indexPresenceMap := make(map[spec.ValidatorIndex]bool)
indexPresenceMap := make(map[phase0.ValidatorIndex]bool)
for _, index := range indices {
indexPresenceMap[index] = true
}
@ -287,7 +287,7 @@ func accountPathsToVerificationRegexes(paths []string) []*regexp.Regexp {
return regexes
}
func (s *Service) fetchAccountsForWallet(ctx context.Context, wallet e2wtypes.Wallet, accounts map[spec.BLSPubKey]e2wtypes.Account, verificationRegexes []*regexp.Regexp) {
func (s *Service) fetchAccountsForWallet(ctx context.Context, wallet e2wtypes.Wallet, accounts map[phase0.BLSPubKey]e2wtypes.Account, verificationRegexes []*regexp.Regexp) {
for account := range wallet.Accounts(ctx) {
// Ensure the name matches one of our account paths.
name := fmt.Sprintf("%s/%s", wallet.Name(), account.Name())

View File

@ -16,23 +16,23 @@ package attestationaggregator
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
// Duty contains information about an attestation aggregation duty.
type Duty struct {
// Slot is the slot of the attestation aggregation; required for obtaining the aggregate.
Slot spec.Slot
Slot phase0.Slot
// Attestation data root is the root of the attestation to be aggregated; required for obtaining the aggregate.
AttestationDataRoot spec.Root
AttestationDataRoot phase0.Root
// ValidatorIndex is the index of the validator carrying out the aggregation; reuqired for submitting the aggregate.
ValidatorIndex spec.ValidatorIndex
ValidatorIndex phase0.ValidatorIndex
// SlotSignature is the signature of the slot by the validator carrying out the aggregation; reuqired for submitting the aggregate.
SlotSignature spec.BLSSignature
SlotSignature phase0.BLSSignature
// Attestation is the attestation from the validator that is part of the related to the aggregate.
// Required for Prysm non-spec GRPC method.
Attestation *spec.Attestation
Attestation *phase0.Attestation
// Account is the account carrying out the aggregation.
// Required for Prysm non-spec GRPC method.
Account e2wtypes.Account
@ -41,7 +41,7 @@ type Duty struct {
// IsAggregatorProvider provides information about if a validator is an aggregator.
type IsAggregatorProvider interface {
// IsAggregator returns true if the given validator is an aggregator for the given committee at the given slot.
IsAggregator(ctx context.Context, validatorIndex spec.ValidatorIndex, committeeIndex spec.CommitteeIndex, slot spec.Slot, committeeSize uint64) (bool, spec.BLSSignature, error)
IsAggregator(ctx context.Context, validatorIndex phase0.ValidatorIndex, committeeIndex phase0.CommitteeIndex, slot phase0.Slot, committeeSize uint64) (bool, phase0.BLSSignature, error)
}
// Service is the attestation aggregation service.

View File

@ -21,7 +21,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/accountmanager"
"github.com/attestantio/vouch/services/attestationaggregator"
"github.com/attestantio/vouch/services/metrics"
@ -100,12 +100,12 @@ func (s *Service) Aggregate(ctx context.Context, data interface{}) {
log.Trace().Msg("Aggregating")
// Obtain the aggregate attestation.
var aggregateAttestation *spec.Attestation
var aggregateAttestation *phase0.Attestation
var err error
if s.aggregateAttestationProvider != nil {
aggregateAttestation, err = s.aggregateAttestationProvider.AggregateAttestation(ctx, duty.Slot, duty.AttestationDataRoot)
} else {
var validatorPubKey spec.BLSPubKey
var validatorPubKey phase0.BLSPubKey
if provider, isProvider := duty.Account.(e2wtypes.AccountCompositePublicKeyProvider); isProvider {
copy(validatorPubKey[:], provider.CompositePublicKey().Marshal())
} else {
@ -125,8 +125,8 @@ func (s *Service) Aggregate(ctx context.Context, data interface{}) {
}
// Fetch the validating account.
epoch := spec.Epoch(uint64(aggregateAttestation.Data.Slot) / s.slotsPerEpoch)
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, epoch, []spec.ValidatorIndex{duty.ValidatorIndex})
epoch := phase0.Epoch(uint64(aggregateAttestation.Data.Slot) / s.slotsPerEpoch)
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, epoch, []phase0.ValidatorIndex{duty.ValidatorIndex})
if err != nil {
log.Error().Err(err).Msg("Failed to obtain proposing validator account")
s.monitor.AttestationAggregationCompleted(started, "failed")
@ -141,7 +141,7 @@ func (s *Service) Aggregate(ctx context.Context, data interface{}) {
log.Trace().Dur("elapsed", time.Since(started)).Msg("Obtained aggregating account")
// Sign the aggregate attestation.
aggregateAndProof := &spec.AggregateAndProof{
aggregateAndProof := &phase0.AggregateAndProof{
AggregatorIndex: duty.ValidatorIndex,
Aggregate: aggregateAttestation,
SelectionProof: duty.SlotSignature,
@ -150,7 +150,7 @@ func (s *Service) Aggregate(ctx context.Context, data interface{}) {
if err != nil {
log.Error().Err(err).Msg("Failed to generate hash tree root of aggregate and proof")
}
sig, err := s.aggregateAndProofSigner.SignAggregateAndProof(ctx, account, duty.Slot, spec.Root(aggregateAndProofRoot))
sig, err := s.aggregateAndProofSigner.SignAggregateAndProof(ctx, account, duty.Slot, phase0.Root(aggregateAndProofRoot))
if err != nil {
log.Error().Err(err).Msg("Failed to sign aggregate and proof")
s.monitor.AttestationAggregationCompleted(started, "failed")
@ -159,7 +159,7 @@ func (s *Service) Aggregate(ctx context.Context, data interface{}) {
log.Trace().Dur("elapsed", time.Since(started)).Msg("Signed aggregate attestation")
// Submit the signed aggregate and proof.
signedAggregateAndProofs := []*spec.SignedAggregateAndProof{
signedAggregateAndProofs := []*phase0.SignedAggregateAndProof{
{
Message: aggregateAndProof,
Signature: sig,
@ -180,11 +180,11 @@ func (s *Service) Aggregate(ctx context.Context, data interface{}) {
// IsAggregator reports if we are an attestation aggregator for a given validator/committee/slot combination.
func (s *Service) IsAggregator(ctx context.Context,
validatorIndex spec.ValidatorIndex,
committeeIndex spec.CommitteeIndex,
slot spec.Slot,
validatorIndex phase0.ValidatorIndex,
committeeIndex phase0.CommitteeIndex,
slot phase0.Slot,
committeeSize uint64,
) (bool, spec.BLSSignature, error) {
) (bool, phase0.BLSSignature, error) {
modulo := committeeSize / s.targetAggregatorsPerCommittee
if modulo == 0 {
// Modulo must be at least 1.
@ -192,30 +192,30 @@ func (s *Service) IsAggregator(ctx context.Context,
}
// Fetch the validator from the account manager.
epoch := spec.Epoch(uint64(slot) / s.slotsPerEpoch)
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, epoch, []spec.ValidatorIndex{validatorIndex})
epoch := phase0.Epoch(uint64(slot) / s.slotsPerEpoch)
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, epoch, []phase0.ValidatorIndex{validatorIndex})
if err != nil {
return false, spec.BLSSignature{}, errors.Wrap(err, "failed to obtain validator")
return false, phase0.BLSSignature{}, errors.Wrap(err, "failed to obtain validator")
}
if len(accounts) == 0 {
return false, spec.BLSSignature{}, errors.New("validator unknown")
return false, phase0.BLSSignature{}, errors.New("validator unknown")
}
account := accounts[validatorIndex]
// Sign the slot.
signature, err := s.slotSelectionSigner.SignSlotSelection(ctx, account, slot)
if err != nil {
return false, spec.BLSSignature{}, errors.Wrap(err, "failed to sign the slot")
return false, phase0.BLSSignature{}, errors.Wrap(err, "failed to sign the slot")
}
// Hash the signature.
sigHash := sha256.New()
n, err := sigHash.Write(signature[:])
if err != nil {
return false, spec.BLSSignature{}, errors.Wrap(err, "failed to hash the slot signature")
return false, phase0.BLSSignature{}, errors.Wrap(err, "failed to hash the slot signature")
}
if n != len(signature) {
return false, spec.BLSSignature{}, errors.New("failed to write all bytes of the slot signature to the hash")
return false, phase0.BLSSignature{}, errors.New("failed to write all bytes of the slot signature to the hash")
}
hash := sigHash.Sum(nil)

View File

@ -18,7 +18,7 @@ import (
"sort"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// MergeDuties merges attester duties given by an Ethereum 2 client into vouch's per-slot structure.
@ -28,11 +28,11 @@ func MergeDuties(ctx context.Context, attesterDuties []*api.AttesterDuty) ([]*Du
return duties, nil
}
validatorIndices := make(map[spec.Slot][]spec.ValidatorIndex)
committeeIndices := make(map[spec.Slot][]spec.CommitteeIndex)
validatorCommitteeIndices := make(map[spec.Slot][]uint64)
committeeLengths := make(map[spec.Slot]map[spec.CommitteeIndex]uint64)
committeesAtSlots := make(map[spec.Slot]uint64)
validatorIndices := make(map[phase0.Slot][]phase0.ValidatorIndex)
committeeIndices := make(map[phase0.Slot][]phase0.CommitteeIndex)
validatorCommitteeIndices := make(map[phase0.Slot][]uint64)
committeeLengths := make(map[phase0.Slot]map[phase0.CommitteeIndex]uint64)
committeesAtSlots := make(map[phase0.Slot]uint64)
// Set the base capacity for our arrays based on the number of attester duties.
// This is much higher than we need, but is overall minimal and avoids reallocations.
@ -63,9 +63,9 @@ func MergeDuties(ctx context.Context, attesterDuties []*api.AttesterDuty) ([]*Du
_, exists := validatorIndices[duty.Slot]
if !exists {
validatorIndices[duty.Slot] = make([]spec.ValidatorIndex, 0, arrayCap)
committeeIndices[duty.Slot] = make([]spec.CommitteeIndex, 0, arrayCap)
committeeLengths[duty.Slot] = make(map[spec.CommitteeIndex]uint64)
validatorIndices[duty.Slot] = make([]phase0.ValidatorIndex, 0, arrayCap)
committeeIndices[duty.Slot] = make([]phase0.CommitteeIndex, 0, arrayCap)
committeeLengths[duty.Slot] = make(map[phase0.CommitteeIndex]uint64)
committeesAtSlots[duty.Slot] = duty.CommitteesAtSlot
}
committeesAtSlots[duty.Slot] = duty.CommitteesAtSlot

View File

@ -16,7 +16,7 @@ package mock
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// Service is a mock attester.
@ -28,6 +28,6 @@ func New() *Service {
}
// Attest carries out attestations for a slot.
func (s *Service) Attest(ctx context.Context, data interface{}) ([]*spec.Attestation, error) {
return make([]*spec.Attestation, 0), nil
func (s *Service) Attest(ctx context.Context, data interface{}) ([]*phase0.Attestation, error) {
return make([]*phase0.Attestation, 0), nil
}

View File

@ -17,27 +17,27 @@ import (
"context"
"fmt"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// Duty contains information about beacon block attester duties for a given slot.
type Duty struct {
slot spec.Slot
slot phase0.Slot
committeesAtSlot uint64
validatorIndices []spec.ValidatorIndex
committeeIndices []spec.CommitteeIndex
validatorIndices []phase0.ValidatorIndex
committeeIndices []phase0.CommitteeIndex
validatorCommitteeIndices []uint64
committeeLengths map[spec.CommitteeIndex]uint64
committeeLengths map[phase0.CommitteeIndex]uint64
}
// NewDuty creates a new beacon block attester duty.
func NewDuty(ctx context.Context,
slot spec.Slot,
slot phase0.Slot,
committeesAtSlot uint64,
validatorIndices []spec.ValidatorIndex,
committeeIndices []spec.CommitteeIndex,
validatorIndices []phase0.ValidatorIndex,
committeeIndices []phase0.CommitteeIndex,
validatorCommitteeIndices []uint64,
committeeLengths map[spec.CommitteeIndex]uint64,
committeeLengths map[phase0.CommitteeIndex]uint64,
) (*Duty, error) {
// Ensure there is a matching committee size for each committee index.
for i := range committeeIndices {
@ -57,7 +57,7 @@ func NewDuty(ctx context.Context,
}
// Slot provides the slot for the beacon block attester.
func (d *Duty) Slot() spec.Slot {
func (d *Duty) Slot() phase0.Slot {
return d.slot
}
@ -67,12 +67,12 @@ func (d *Duty) CommitteesAtSlot() uint64 {
}
// ValidatorIndices provides the validator indices for the beacon block attester.
func (d *Duty) ValidatorIndices() []spec.ValidatorIndex {
func (d *Duty) ValidatorIndices() []phase0.ValidatorIndex {
return d.validatorIndices
}
// CommitteeIndices provides the committee indices for the beacon block attester.
func (d *Duty) CommitteeIndices() []spec.CommitteeIndex {
func (d *Duty) CommitteeIndices() []phase0.CommitteeIndex {
return d.committeeIndices
}
@ -82,7 +82,7 @@ func (d *Duty) ValidatorCommitteeIndices() []uint64 {
}
// CommitteeSize provides the committee size for a given index.
func (d *Duty) CommitteeSize(committeeIndex spec.CommitteeIndex) uint64 {
func (d *Duty) CommitteeSize(committeeIndex phase0.CommitteeIndex) uint64 {
return d.committeeLengths[committeeIndex]
}
@ -109,5 +109,5 @@ func (d *Duty) Tuples() []string {
type Service interface {
// Attest carries out attestations for a slot.
// It returns a list of attestations made.
Attest(ctx context.Context, details interface{}) ([]*spec.Attestation, error)
Attest(ctx context.Context, details interface{}) ([]*phase0.Attestation, error)
}

View File

@ -20,7 +20,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/accountmanager"
"github.com/attestantio/vouch/services/attester"
"github.com/attestantio/vouch/services/metrics"
@ -80,7 +80,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
// Attest carries out attestations for a slot.
// It returns a map of attestations made, keyed on the validator index.
func (s *Service) Attest(ctx context.Context, data interface{}) ([]*spec.Attestation, error) {
func (s *Service) Attest(ctx context.Context, data interface{}) ([]*phase0.Attestation, error) {
started := time.Now()
duty, ok := data.(*attester.Duty)
@ -110,13 +110,13 @@ func (s *Service) Attest(ctx context.Context, data interface{}) ([]*spec.Attesta
s.monitor.AttestationsCompleted(started, len(duty.ValidatorIndices()), "failed")
return nil, fmt.Errorf("attestation request for slot %d returned source epoch %d greater than target epoch %d", duty.Slot(), attestationData.Source.Epoch, attestationData.Target.Epoch)
}
if attestationData.Target.Epoch > spec.Epoch(uint64(duty.Slot())/s.slotsPerEpoch) {
if attestationData.Target.Epoch > phase0.Epoch(uint64(duty.Slot())/s.slotsPerEpoch) {
s.monitor.AttestationsCompleted(started, len(duty.ValidatorIndices()), "failed")
return nil, fmt.Errorf("attestation request for slot %d returned target epoch %d greater than current epoch %d", duty.Slot(), attestationData.Target.Epoch, spec.Epoch(uint64(duty.Slot())/s.slotsPerEpoch))
return nil, fmt.Errorf("attestation request for slot %d returned target epoch %d greater than current epoch %d", duty.Slot(), attestationData.Target.Epoch, phase0.Epoch(uint64(duty.Slot())/s.slotsPerEpoch))
}
// Fetch the validating accounts.
validatingAccounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, spec.Epoch(uint64(duty.Slot())/s.slotsPerEpoch), duty.ValidatorIndices())
validatingAccounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, phase0.Epoch(uint64(duty.Slot())/s.slotsPerEpoch), duty.ValidatorIndices())
if err != nil {
s.monitor.AttestationsCompleted(started, len(duty.ValidatorIndices()), "failed")
return nil, errors.New("failed to obtain attesting validator accounts")
@ -124,7 +124,7 @@ func (s *Service) Attest(ctx context.Context, data interface{}) ([]*spec.Attesta
log.Trace().Dur("elapsed", time.Since(started)).Int("validating_accounts", len(validatingAccounts)).Msg("Obtained validating accounts")
// Break the map in to two arrays.
accountValidatorIndices := make([]spec.ValidatorIndex, 0, len(validatingAccounts))
accountValidatorIndices := make([]phase0.ValidatorIndex, 0, len(validatingAccounts))
accountsArray := make([]e2wtypes.Account, 0, len(validatingAccounts))
for index, account := range validatingAccounts {
accountValidatorIndices = append(accountValidatorIndices, index)
@ -132,16 +132,16 @@ func (s *Service) Attest(ctx context.Context, data interface{}) ([]*spec.Attesta
}
// Set the per-validator information.
validatorIndexToArrayIndexMap := make(map[spec.ValidatorIndex]int)
validatorIndexToArrayIndexMap := make(map[phase0.ValidatorIndex]int)
for i := range duty.ValidatorIndices() {
validatorIndexToArrayIndexMap[duty.ValidatorIndices()[i]] = i
}
committeeIndices := make([]spec.CommitteeIndex, len(validatingAccounts))
validatorCommitteeIndices := make([]spec.ValidatorIndex, len(validatingAccounts))
committeeIndices := make([]phase0.CommitteeIndex, len(validatingAccounts))
validatorCommitteeIndices := make([]phase0.ValidatorIndex, len(validatingAccounts))
committeeSizes := make([]uint64, len(validatingAccounts))
for i := range accountsArray {
committeeIndices[i] = duty.CommitteeIndices()[validatorIndexToArrayIndexMap[accountValidatorIndices[i]]]
validatorCommitteeIndices[i] = spec.ValidatorIndex(duty.ValidatorCommitteeIndices()[validatorIndexToArrayIndexMap[accountValidatorIndices[i]]])
validatorCommitteeIndices[i] = phase0.ValidatorIndex(duty.ValidatorCommitteeIndices()[validatorIndexToArrayIndexMap[accountValidatorIndices[i]]])
committeeSizes[i] = duty.CommitteeSize(committeeIndices[i])
}
@ -166,16 +166,16 @@ func (s *Service) Attest(ctx context.Context, data interface{}) ([]*spec.Attesta
func (s *Service) attest(
ctx context.Context,
slot spec.Slot,
slot phase0.Slot,
duty *attester.Duty,
accounts []e2wtypes.Account,
validatorIndices []spec.ValidatorIndex,
committeeIndices []spec.CommitteeIndex,
validatorCommitteeIndices []spec.ValidatorIndex,
validatorIndices []phase0.ValidatorIndex,
committeeIndices []phase0.CommitteeIndex,
validatorCommitteeIndices []phase0.ValidatorIndex,
committeeSizes []uint64,
data *spec.AttestationData,
data *phase0.AttestationData,
started time.Time,
) ([]*spec.Attestation, error) {
) ([]*phase0.Attestation, error) {
// Sign the attestation for all validating accounts.
uintCommitteeIndices := make([]uint64, len(committeeIndices))
@ -202,8 +202,8 @@ func (s *Service) attest(
log.Trace().Dur("elapsed", time.Since(started)).Msg("Signed")
// Create the attestations.
zeroSig := spec.BLSSignature{}
attestations := make([]*spec.Attestation, 0, len(sigs))
zeroSig := phase0.BLSSignature{}
attestations := make([]*phase0.Attestation, 0, len(sigs))
for i := range sigs {
if bytes.Equal(sigs[i][:], zeroSig[:]) {
log.Warn().Msg("No signature for validator; not creating attestation")
@ -211,17 +211,17 @@ func (s *Service) attest(
}
aggregationBits := bitfield.NewBitlist(committeeSizes[i])
aggregationBits.SetBitAt(uint64(validatorCommitteeIndices[i]), true)
attestation := &spec.Attestation{
attestation := &phase0.Attestation{
AggregationBits: aggregationBits,
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: duty.Slot(),
Index: committeeIndices[i],
BeaconBlockRoot: data.BeaconBlockRoot,
Source: &spec.Checkpoint{
Source: &phase0.Checkpoint{
Epoch: data.Source.Epoch,
Root: data.Source.Root,
},
Target: &spec.Checkpoint{
Target: &phase0.Checkpoint{
Epoch: data.Target.Epoch,
Root: data.Target.Root,
},

View File

@ -17,25 +17,25 @@ import (
"context"
"fmt"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
// Duty contains information about a beacon block proposal duty.
type Duty struct {
// Details for the duty.
slot spec.Slot
validatorIndex spec.ValidatorIndex
slot phase0.Slot
validatorIndex phase0.ValidatorIndex
// randaoReveal is required to be passed to the beacon node when proposing the block; can be pre-calculated.
randaoReveal spec.BLSSignature
randaoReveal phase0.BLSSignature
// account is used to sign the proposal; can be pre-fetched.
account e2wtypes.Account
}
// NewDuty creates a new beacon block proposer duty.
func NewDuty(slot spec.Slot, validatorIndex spec.ValidatorIndex) *Duty {
func NewDuty(slot phase0.Slot, validatorIndex phase0.ValidatorIndex) *Duty {
return &Duty{
slot: slot,
validatorIndex: validatorIndex,
@ -43,12 +43,12 @@ func NewDuty(slot spec.Slot, validatorIndex spec.ValidatorIndex) *Duty {
}
// Slot provides the slot for the beacon block proposer.
func (d *Duty) Slot() spec.Slot {
func (d *Duty) Slot() phase0.Slot {
return d.slot
}
// ValidatorIndex provides the validator index for the beacon block proposer.
func (d *Duty) ValidatorIndex() spec.ValidatorIndex {
func (d *Duty) ValidatorIndex() phase0.ValidatorIndex {
return d.validatorIndex
}
@ -58,12 +58,12 @@ func (d *Duty) String() string {
}
// SetRandaoReveal sets the RANDAO reveal.
func (d *Duty) SetRandaoReveal(randaoReveal spec.BLSSignature) {
func (d *Duty) SetRandaoReveal(randaoReveal phase0.BLSSignature) {
d.randaoReveal = randaoReveal
}
// RANDAOReveal provides the RANDAO reveal.
func (d *Duty) RANDAOReveal() spec.BLSSignature {
func (d *Duty) RANDAOReveal() phase0.BLSSignature {
return d.randaoReveal
}

View File

@ -19,7 +19,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/accountmanager"
"github.com/attestantio/vouch/services/beaconblockproposer"
"github.com/attestantio/vouch/services/chaintime"
@ -90,7 +90,7 @@ func (s *Service) Prepare(ctx context.Context, data interface{}) error {
// Fetch the validating account.
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx,
dutyEpoch,
[]spec.ValidatorIndex{duty.ValidatorIndex()},
[]phase0.ValidatorIndex{duty.ValidatorIndex()},
)
if err != nil {
return errors.Wrap(err, "failed to obtain proposing validator account")
@ -125,7 +125,7 @@ func (s *Service) Propose(ctx context.Context, data interface{}) {
log := log.With().Uint64("proposing_slot", uint64(duty.Slot())).Uint64("validator_index", uint64(duty.ValidatorIndex())).Logger()
log.Trace().Msg("Proposing")
var zeroSig spec.BLSSignature
var zeroSig phase0.BLSSignature
if duty.RANDAOReveal() == zeroSig {
log.Error().Msg("Missing RANDAO reveal")
s.monitor.BeaconBlockProposalCompleted(started, "failed")
@ -183,7 +183,7 @@ func (s *Service) Propose(ctx context.Context, data interface{}) {
}
log.Trace().Dur("elapsed", time.Since(started)).Msg("Signed proposal")
signedBlock := &spec.SignedBeaconBlock{
signedBlock := &phase0.SignedBeaconBlock{
Message: proposal,
Signature: sig,
}

View File

@ -16,7 +16,7 @@ package mock
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/beaconcommitteesubscriber"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -30,8 +30,8 @@ func New() beaconcommitteesubscriber.Service {
// Subscribe is a mock.
func (s *service) Subscribe(ctx context.Context,
epoch spec.Epoch,
accounts map[spec.ValidatorIndex]e2wtypes.Account,
) (map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
return make(map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription), nil
epoch phase0.Epoch,
accounts map[phase0.ValidatorIndex]e2wtypes.Account,
) (map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
return make(map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription), nil
}

View File

@ -18,7 +18,7 @@ import (
"context"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -26,14 +26,14 @@ import (
type Subscription struct {
Duty *api.AttesterDuty
IsAggregator bool
Signature spec.BLSSignature
Signature phase0.BLSSignature
}
// Service is the beacon committee subscriber service.
type Service interface {
// Subscribe subscribes to beacon committees for a given epoch.
Subscribe(ctx context.Context,
epoch spec.Epoch,
accounts map[spec.ValidatorIndex]e2wtypes.Account,
) (map[spec.Slot]map[spec.CommitteeIndex]*Subscription, error)
epoch phase0.Epoch,
accounts map[phase0.ValidatorIndex]e2wtypes.Account,
) (map[phase0.Slot]map[phase0.CommitteeIndex]*Subscription, error)
}

View File

@ -20,7 +20,7 @@ import (
eth2client "github.com/attestantio/go-eth2-client"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/attestationaggregator"
"github.com/attestantio/vouch/services/attester"
"github.com/attestantio/vouch/services/beaconcommitteesubscriber"
@ -73,19 +73,19 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
// Subscribe subscribes to beacon committees for a given epoch.
// This returns data about the subnets to which we are subscribing.
func (s *Service) Subscribe(ctx context.Context,
epoch spec.Epoch,
accounts map[spec.ValidatorIndex]e2wtypes.Account,
) (map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
epoch phase0.Epoch,
accounts map[phase0.ValidatorIndex]e2wtypes.Account,
) (map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
if len(accounts) == 0 {
// Nothing to do.
return map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription{}, nil
return map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription{}, nil
}
started := time.Now()
log := log.With().Uint64("epoch", uint64(epoch)).Logger()
log.Trace().Msg("Subscribing")
validatorIndices := make([]spec.ValidatorIndex, 0, len(accounts))
validatorIndices := make([]phase0.ValidatorIndex, 0, len(accounts))
for index := range accounts {
validatorIndices = append(validatorIndices, index)
}
@ -154,17 +154,17 @@ func (s *Service) Subscribe(ctx context.Context,
// calculateSubscriptionInfo calculates our beacon block attesation subnet requirements given a set of duties.
// It returns a map of slot => committee => subscription information.
func (s *Service) calculateSubscriptionInfo(ctx context.Context,
epoch spec.Epoch,
accounts map[spec.ValidatorIndex]e2wtypes.Account,
epoch phase0.Epoch,
accounts map[phase0.ValidatorIndex]e2wtypes.Account,
duties []*attester.Duty,
) (map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
) (map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
// Map is slot => committee => info.
subscriptionInfo := make(map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription)
subscriptionInfo := make(map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription)
subscriptionInfoMutex := deadlock.RWMutex{}
// // Map is validator ID => account.
// accountMap := make(map[spec.ValidatorIndex]accountmanager.ValidatingAccount, len(accounts))
// accountMap := make(map[phase0.ValidatorIndex]accountmanager.ValidatingAccount, len(accounts))
// for _, account := range accounts {
// index, err := account.Index(ctx)
// if err != nil {
@ -215,7 +215,7 @@ func (s *Service) calculateSubscriptionInfo(ctx context.Context,
}
// Obtain composite public key if available, otherwise standard public key.
account := accounts[duty.ValidatorIndices()[i]]
var pubKey spec.BLSPubKey
var pubKey phase0.BLSPubKey
if provider, isProvider := account.(e2wtypes.AccountCompositePublicKeyProvider); isProvider {
copy(pubKey[:], provider.CompositePublicKey().Marshal())
} else {
@ -223,7 +223,7 @@ func (s *Service) calculateSubscriptionInfo(ctx context.Context,
}
subscriptionInfoMutex.Lock()
if _, exists := subscriptionInfo[duty.Slot()]; !exists {
subscriptionInfo[duty.Slot()] = make(map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription)
subscriptionInfo[duty.Slot()] = make(map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription)
}
subscriptionInfo[duty.Slot()][duty.CommitteeIndices()[i]] = &beaconcommitteesubscriber.Subscription{
Duty: &api.AttesterDuty{

View File

@ -16,7 +16,7 @@ package chaintime
import (
"time"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// Service provides a number of functions for calculating chain-related times.
@ -24,15 +24,15 @@ type Service interface {
// GenesisTime provides the time of the chain's genesis.
GenesisTime() time.Time
// StartOfSlot provides the time at which a given slot starts.
StartOfSlot(slot spec.Slot) time.Time
StartOfSlot(slot phase0.Slot) time.Time
// StartOfEpoch provides the time at which a given epoch starts.
StartOfEpoch(epoch spec.Epoch) time.Time
StartOfEpoch(epoch phase0.Epoch) time.Time
// CurrentSlot provides the current slot.
CurrentSlot() spec.Slot
CurrentSlot() phase0.Slot
// CurrentEpoch provides the current epoch.
CurrentEpoch() spec.Epoch
CurrentEpoch() phase0.Epoch
// SlotToEpoch provides the epoch of the given slot.
SlotToEpoch(slot spec.Slot) spec.Epoch
SlotToEpoch(slot phase0.Slot) phase0.Epoch
// FirstSlotOfEpoch provides the first slot of the given epoch.
FirstSlotOfEpoch(epoch spec.Epoch) spec.Slot
FirstSlotOfEpoch(epoch phase0.Epoch) phase0.Slot
}

View File

@ -17,7 +17,7 @@ import (
"context"
"time"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"github.com/rs/zerolog"
zerologger "github.com/rs/zerolog/log"
@ -79,37 +79,37 @@ func (s *Service) GenesisTime() time.Time {
}
// StartOfSlot provides the time at which a given slot starts.
func (s *Service) StartOfSlot(slot spec.Slot) time.Time {
func (s *Service) StartOfSlot(slot phase0.Slot) time.Time {
return s.genesisTime.Add(time.Duration(slot) * s.slotDuration)
}
// StartOfEpoch provides the time at which a given epoch starts.
func (s *Service) StartOfEpoch(epoch spec.Epoch) time.Time {
func (s *Service) StartOfEpoch(epoch phase0.Epoch) time.Time {
return s.genesisTime.Add(time.Duration(uint64(epoch)*s.slotsPerEpoch) * s.slotDuration)
}
// CurrentSlot provides the current slot.
func (s *Service) CurrentSlot() spec.Slot {
func (s *Service) CurrentSlot() phase0.Slot {
if s.genesisTime.After(time.Now()) {
return spec.Slot(0)
return phase0.Slot(0)
}
return spec.Slot(uint64(time.Since(s.genesisTime).Seconds()) / uint64(s.slotDuration.Seconds()))
return phase0.Slot(uint64(time.Since(s.genesisTime).Seconds()) / uint64(s.slotDuration.Seconds()))
}
// CurrentEpoch provides the current epoch.
func (s *Service) CurrentEpoch() spec.Epoch {
func (s *Service) CurrentEpoch() phase0.Epoch {
if s.genesisTime.After(time.Now()) {
return spec.Epoch(0)
return phase0.Epoch(0)
}
return spec.Epoch(uint64(time.Since(s.genesisTime).Seconds()) / (uint64(s.slotDuration.Seconds()) * s.slotsPerEpoch))
return phase0.Epoch(uint64(time.Since(s.genesisTime).Seconds()) / (uint64(s.slotDuration.Seconds()) * s.slotsPerEpoch))
}
// SlotToEpoch provides the epoch of a given slot.
func (s *Service) SlotToEpoch(slot spec.Slot) spec.Epoch {
return spec.Epoch(uint64(slot) / s.slotsPerEpoch)
func (s *Service) SlotToEpoch(slot phase0.Slot) phase0.Epoch {
return phase0.Epoch(uint64(slot) / s.slotsPerEpoch)
}
// FirstSlotOfEpoch provides the first slot of the given epoch.
func (s *Service) FirstSlotOfEpoch(epoch spec.Epoch) spec.Slot {
return spec.Slot(uint64(epoch) * s.slotsPerEpoch)
func (s *Service) FirstSlotOfEpoch(epoch phase0.Epoch) phase0.Slot {
return phase0.Slot(uint64(epoch) * s.slotsPerEpoch)
}

View File

@ -18,7 +18,7 @@ import (
"testing"
"time"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/attestantio/vouch/services/chaintime"
"github.com/attestantio/vouch/services/chaintime/standard"
@ -144,7 +144,7 @@ func TestCurrentSlot(t *testing.T) {
s, err := createMockService(slotDuration, slotsPerEpoch, genesisTime)
require.NoError(t, err)
require.Equal(t, spec.Slot(5), s.CurrentSlot())
require.Equal(t, phase0.Slot(5), s.CurrentSlot())
}
func TestCurrentSlotPreGenesis(t *testing.T) {
@ -155,7 +155,7 @@ func TestCurrentSlotPreGenesis(t *testing.T) {
s, err := createMockService(slotDuration, slotsPerEpoch, genesisTime)
require.NoError(t, err)
require.Equal(t, spec.Slot(0), s.CurrentSlot())
require.Equal(t, phase0.Slot(0), s.CurrentSlot())
}
func TestCurrentEpoch(t *testing.T) {
@ -166,7 +166,7 @@ func TestCurrentEpoch(t *testing.T) {
s, err := createMockService(slotDuration, slotsPerEpoch, genesisTime)
require.NoError(t, err)
require.Equal(t, spec.Epoch(2), s.CurrentEpoch())
require.Equal(t, phase0.Epoch(2), s.CurrentEpoch())
}
func TestCurrentEpochPreGenesis(t *testing.T) {
@ -177,14 +177,14 @@ func TestCurrentEpochPreGenesis(t *testing.T) {
s, err := createMockService(slotDuration, slotsPerEpoch, genesisTime)
require.NoError(t, err)
require.Equal(t, spec.Epoch(0), s.CurrentEpoch())
require.Equal(t, phase0.Epoch(0), s.CurrentEpoch())
}
func TestSlotToEpoch(t *testing.T) {
tests := []struct {
name string
slot spec.Slot
epoch spec.Epoch
slot phase0.Slot
epoch phase0.Epoch
}{
{
name: "ZeroFirstSlot",
@ -221,8 +221,8 @@ func TestSlotToEpoch(t *testing.T) {
func TestFirstSlotOfEpoch(t *testing.T) {
tests := []struct {
name string
epoch spec.Epoch
slot spec.Slot
epoch phase0.Epoch
slot phase0.Slot
}{
{
name: "Zero",

View File

@ -19,15 +19,15 @@ import (
"time"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/attestationaggregator"
"github.com/attestantio/vouch/services/attester"
)
// scheduleAttestations schedules attestations for the given epoch and validator indices.
func (s *Service) scheduleAttestations(ctx context.Context,
epoch spec.Epoch,
validatorIndices []spec.ValidatorIndex,
epoch phase0.Epoch,
validatorIndices []phase0.ValidatorIndex,
notCurrentSlot bool,
) {
if len(validatorIndices) == 0 {
@ -162,7 +162,7 @@ func (s *Service) AttestAndScheduleAggregate(ctx context.Context, data interface
continue
}
if info.IsAggregator {
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, epoch, []spec.ValidatorIndex{info.Duty.ValidatorIndex})
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpochByIndex(ctx, epoch, []phase0.ValidatorIndex{info.Duty.ValidatorIndex})
if err != nil {
// Don't return here; we want to try to set up as many aggregator jobs as possible.
log.Error().Err(err).Msg("Failed to obtain accounts")

View File

@ -20,7 +20,7 @@ import (
"time"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// HandleHeadEvent handles the "head" events from the beacon node.
@ -30,7 +30,7 @@ func (s *Service) HandleHeadEvent(event *api.Event) {
}
ctx := context.Background()
var zeroRoot spec.Root
var zeroRoot phase0.Root
data := event.Data.(*api.HeadEvent)
log := log.With().Uint64("slot", uint64(data.Slot)).Logger()
@ -126,7 +126,7 @@ func (s *Service) handleCurrentDependentRootChanged(ctx context.Context) {
s.refreshAttesterDutiesForEpoch(ctx, s.chainTimeService.CurrentEpoch()+1)
}
func (s *Service) refreshProposerDutiesForEpoch(ctx context.Context, epoch spec.Epoch) {
func (s *Service) refreshProposerDutiesForEpoch(ctx context.Context, epoch phase0.Epoch) {
// First thing we do is cancel all scheduled beacon bock proposal jobs.
s.scheduler.CancelJobs(ctx, "Beacon block proposal")
@ -145,8 +145,8 @@ func (s *Service) refreshProposerDutiesForEpoch(ctx context.Context, epoch spec.
s.scheduleProposals(ctx, epoch, validatorIndices, true /* notCurrentSlot */)
}
func (s *Service) refreshAttesterDutiesForEpoch(ctx context.Context, epoch spec.Epoch) {
cancelledJobs := make(map[spec.Slot]bool)
func (s *Service) refreshAttesterDutiesForEpoch(ctx context.Context, epoch phase0.Epoch) {
cancelledJobs := make(map[phase0.Slot]bool)
// First thing we do is cancel all scheduled attestations jobs.
for slot := s.chainTimeService.FirstSlotOfEpoch(epoch); slot < s.chainTimeService.FirstSlotOfEpoch(epoch+1); slot++ {
if err := s.scheduler.CancelJob(ctx, fmt.Sprintf("Attestations for slot %d", slot)); err == nil {

View File

@ -18,14 +18,14 @@ import (
"fmt"
"time"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/beaconblockproposer"
)
// scheduleProposals schedules proposals for the given epoch and validator indices.
func (s *Service) scheduleProposals(ctx context.Context,
epoch spec.Epoch,
validatorIndices []spec.ValidatorIndex,
epoch phase0.Epoch,
validatorIndices []phase0.ValidatorIndex,
notCurrentSlot bool,
) {
if len(validatorIndices) == 0 {

View File

@ -20,7 +20,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/accountmanager"
"github.com/attestantio/vouch/services/attestationaggregator"
"github.com/attestantio/vouch/services/attester"
@ -52,17 +52,17 @@ type Service struct {
attestationAggregator attestationaggregator.Service
beaconCommitteeSubscriber beaconcommitteesubscriber.Service
activeValidators int
subscriptionInfos map[spec.Epoch]map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription
subscriptionInfos map[phase0.Epoch]map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription
subscriptionInfosMutex sync.Mutex
accountsRefresher accountmanager.Refresher
maxAttestationDelay time.Duration
reorgs bool
// Tracking for reorgs.
lastBlockRoot spec.Root
lastBlockEpoch spec.Epoch
currentDutyDependentRoot spec.Root
previousDutyDependentRoot spec.Root
lastBlockRoot phase0.Root
lastBlockEpoch phase0.Epoch
currentDutyDependentRoot phase0.Root
previousDutyDependentRoot phase0.Root
}
// module-wide log.
@ -107,7 +107,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
accountsRefresher: parameters.accountsRefresher,
maxAttestationDelay: parameters.maxAttestationDelay,
reorgs: parameters.reorgs,
subscriptionInfos: make(map[spec.Epoch]map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription),
subscriptionInfos: make(map[phase0.Epoch]map[phase0.Slot]map[phase0.CommitteeIndex]*beaconcommitteesubscriber.Subscription),
}
// Subscribe to head events. This allows us to go early for attestations if a block arrives, as well as
@ -281,10 +281,10 @@ func (s *Service) epochTicker(ctx context.Context, data interface{}) {
// accountsAndIndicesForEpoch obtains the accounts and validator indices for the specified epoch.
func (s *Service) accountsAndIndicesForEpoch(ctx context.Context,
epoch spec.Epoch,
epoch phase0.Epoch,
) (
map[spec.ValidatorIndex]e2wtypes.Account,
[]spec.ValidatorIndex,
map[phase0.ValidatorIndex]e2wtypes.Account,
[]phase0.ValidatorIndex,
error,
) {
accounts, err := s.validatingAccountsProvider.ValidatingAccountsForEpoch(ctx, epoch)
@ -292,7 +292,7 @@ func (s *Service) accountsAndIndicesForEpoch(ctx context.Context,
return nil, nil, errors.Wrap(err, "failed to obtain accounts")
}
validatorIndices := make([]spec.ValidatorIndex, 0, len(accounts))
validatorIndices := make([]phase0.ValidatorIndex, 0, len(accounts))
for index := range accounts {
validatorIndices = append(validatorIndices, index)
}

View File

@ -20,7 +20,7 @@ import (
"strings"
"time"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"github.com/rs/zerolog"
zerologger "github.com/rs/zerolog/log"
@ -61,7 +61,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
}
// Graffiti provides graffiti.
func (s *Service) Graffiti(ctx context.Context, slot spec.Slot, validatorIndex spec.ValidatorIndex) ([]byte, error) {
func (s *Service) Graffiti(ctx context.Context, slot phase0.Slot, validatorIndex phase0.ValidatorIndex) ([]byte, error) {
// Replace location parameters with values.
location := strings.ReplaceAll(s.location, "{{SLOT}}", fmt.Sprintf("%d", slot))
location = strings.ReplaceAll(location, "{{VALIDATORINDEX}}", fmt.Sprintf("%d", validatorIndex))

View File

@ -21,7 +21,7 @@ import (
"path/filepath"
"testing"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/graffitiprovider/dynamic"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"
@ -183,7 +183,7 @@ func TestReplacement(t *testing.T) {
require.NoError(t, err)
for validatorIndex := uint64(0); validatorIndex < 16; validatorIndex++ {
for slot := uint64(0); slot < 16; slot++ {
graffiti, err := svc.Graffiti(ctx, spec.Slot(slot), spec.ValidatorIndex(validatorIndex))
graffiti, err := svc.Graffiti(ctx, phase0.Slot(slot), phase0.ValidatorIndex(validatorIndex))
require.NoError(t, err)
delete(expectedGraffitis, string(graffiti))
}
@ -299,7 +299,7 @@ func TestMultiline(t *testing.T) {
require.NoError(t, err)
for validatorIndex := uint64(0); validatorIndex < 16; validatorIndex++ {
for slot := uint64(0); slot < 16; slot++ {
graffiti, err := svc.Graffiti(ctx, spec.Slot(slot), spec.ValidatorIndex(validatorIndex))
graffiti, err := svc.Graffiti(ctx, phase0.Slot(slot), phase0.ValidatorIndex(validatorIndex))
require.NoError(t, err)
require.Contains(t, test.expectedGraffitis, string(graffiti))
delete(obtainedGraffitis, string(graffiti))

View File

@ -17,11 +17,11 @@ package graffitiprovider
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// Service is the graffiti provider service.
type Service interface {
// Graffiti returns the graffiti for a given slot and validator.
Graffiti(ctx context.Context, slot spec.Slot, validatorIndex spec.ValidatorIndex) ([]byte, error)
Graffiti(ctx context.Context, slot phase0.Slot, validatorIndex phase0.ValidatorIndex) ([]byte, error)
}

View File

@ -16,7 +16,7 @@ package static
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"github.com/rs/zerolog"
zerologger "github.com/rs/zerolog/log"
@ -51,6 +51,6 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
}
// Graffiti provides graffiti.
func (s *Service) Graffiti(ctx context.Context, slot spec.Slot, validatorIndex spec.ValidatorIndex) ([]byte, error) {
func (s *Service) Graffiti(ctx context.Context, slot phase0.Slot, validatorIndex phase0.ValidatorIndex) ([]byte, error) {
return s.graffiti, nil
}

View File

@ -16,7 +16,7 @@ package mock
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -31,84 +31,84 @@ func New() *Service {
// SignAggregateAndProof signs an aggregate attestation for given slot and root.
func (s *Service) SignAggregateAndProof(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
root spec.Root,
slot phase0.Slot,
root phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
return spec.BLSSignature{}, nil
return phase0.BLSSignature{}, nil
}
// SignBeaconAttestation signs a beacon attestation.
func (s *Service) SignBeaconAttestation(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
committeeIndex spec.CommitteeIndex,
blockRoot spec.Root,
sourceEpoch spec.Epoch,
sourceRoot spec.Root,
targetEpoch spec.Epoch,
targetRoot spec.Root,
slot phase0.Slot,
committeeIndex phase0.CommitteeIndex,
blockRoot phase0.Root,
sourceEpoch phase0.Epoch,
sourceRoot phase0.Root,
targetEpoch phase0.Epoch,
targetRoot phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
return spec.BLSSignature{}, nil
return phase0.BLSSignature{}, nil
}
// SignBeaconAttestations signs multiple beacon attestations.
func (s *Service) SignBeaconAttestations(ctx context.Context,
accounts []e2wtypes.Account,
slot spec.Slot,
committeeIndices []spec.CommitteeIndex,
blockRoot spec.Root,
sourceEpoch spec.Epoch,
sourceRoot spec.Root,
targetEpoch spec.Epoch,
targetRoot spec.Root,
slot phase0.Slot,
committeeIndices []phase0.CommitteeIndex,
blockRoot phase0.Root,
sourceEpoch phase0.Epoch,
sourceRoot phase0.Root,
targetEpoch phase0.Epoch,
targetRoot phase0.Root,
) (
[]spec.BLSSignature,
[]phase0.BLSSignature,
error,
) {
return []spec.BLSSignature{}, nil
return []phase0.BLSSignature{}, nil
}
// SignBeaconBlockProposal signs a beacon block proposal.
func (s *Service) SignBeaconBlockProposal(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
proposerIndex spec.ValidatorIndex,
parentRoot spec.Root,
stateRoot spec.Root,
bodyRoot spec.Root,
slot phase0.Slot,
proposerIndex phase0.ValidatorIndex,
parentRoot phase0.Root,
stateRoot phase0.Root,
bodyRoot phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
return spec.BLSSignature{}, nil
return phase0.BLSSignature{}, nil
}
// SignRANDAOReveal returns a RANDAO signature.
// This signs an epoch with the "RANDAO" domain.
func (s *Service) SignRANDAOReveal(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
slot phase0.Slot,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
return spec.BLSSignature{}, nil
return phase0.BLSSignature{}, nil
}
// SignSlotSelection returns a slot selection signature.
// This signs a slot with the "selection proof" domain.
func (s *Service) SignSlotSelection(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
slot phase0.Slot,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
return spec.BLSSignature{}, nil
return phase0.BLSSignature{}, nil
}

View File

@ -17,7 +17,7 @@ package signer
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -29,10 +29,10 @@ type AggregateAndProofSigner interface {
// SignAggregateAndProof signs an aggregate attestation for given slot and root.
SignAggregateAndProof(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
root spec.Root,
slot phase0.Slot,
root phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
)
}
@ -42,15 +42,15 @@ type BeaconAttestationSigner interface {
// SignBeaconAttestation signs a beacon attestation.
SignBeaconAttestation(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
committeeIndex spec.CommitteeIndex,
blockRoot spec.Root,
sourceEpoch spec.Epoch,
sourceRoot spec.Root,
targetEpoch spec.Epoch,
targetRoot spec.Root,
slot phase0.Slot,
committeeIndex phase0.CommitteeIndex,
blockRoot phase0.Root,
sourceEpoch phase0.Epoch,
sourceRoot phase0.Root,
targetEpoch phase0.Epoch,
targetRoot phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
)
}
@ -60,15 +60,15 @@ type BeaconAttestationsSigner interface {
// SignBeaconAttestation signs multiple beacon attestations.
SignBeaconAttestations(ctx context.Context,
accounts []e2wtypes.Account,
slot spec.Slot,
committeeIndices []spec.CommitteeIndex,
blockRoot spec.Root,
sourceEpoch spec.Epoch,
sourceRoot spec.Root,
targetEpoch spec.Epoch,
targetRoot spec.Root,
slot phase0.Slot,
committeeIndices []phase0.CommitteeIndex,
blockRoot phase0.Root,
sourceEpoch phase0.Epoch,
sourceRoot phase0.Root,
targetEpoch phase0.Epoch,
targetRoot phase0.Root,
) (
[]spec.BLSSignature,
[]phase0.BLSSignature,
error,
)
}
@ -78,13 +78,13 @@ type BeaconBlockSigner interface {
// SignBeaconBlockProposal signs a beacon block proposal.
SignBeaconBlockProposal(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
proposerIndex spec.ValidatorIndex,
parentRoot spec.Root,
stateRoot spec.Root,
bodyRoot spec.Root,
slot phase0.Slot,
proposerIndex phase0.ValidatorIndex,
parentRoot phase0.Root,
stateRoot phase0.Root,
bodyRoot phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
)
}
@ -95,9 +95,9 @@ type RANDAORevealSigner interface {
// This signs an epoch with the "RANDAO" domain.
SignRANDAOReveal(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
slot phase0.Slot,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
)
}
@ -108,9 +108,9 @@ type SlotSelectionSigner interface {
// This signs a slot with the "selection proof" domain.
SignSlotSelection(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
slot phase0.Slot,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
)
}

View File

@ -16,7 +16,7 @@ package standard
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
e2types "github.com/wealdtech/go-eth2-types/v2"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
@ -25,10 +25,10 @@ import (
// sign signs a root, using protected methods if possible.
func (s *Service) sign(ctx context.Context,
account e2wtypes.Account,
root spec.Root,
domain spec.Domain,
root phase0.Root,
domain phase0.Domain,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
var sig e2types.Signature
@ -36,24 +36,24 @@ func (s *Service) sign(ctx context.Context,
var err error
sig, err = protectingSigner.SignGeneric(ctx, root[:], domain[:])
if err != nil {
return spec.BLSSignature{}, err
return phase0.BLSSignature{}, err
}
} else {
container := spec.SigningData{
container := phase0.SigningData{
ObjectRoot: root,
Domain: domain,
}
root, err := container.HashTreeRoot()
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to generate hash tree root")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to generate hash tree root")
}
sig, err = account.(e2wtypes.AccountSigner).Sign(ctx, root[:])
if err != nil {
return spec.BLSSignature{}, err
return phase0.BLSSignature{}, err
}
}
var signature spec.BLSSignature
var signature phase0.BLSSignature
copy(signature[:], sig.Marshal())
return signature, nil
}

View File

@ -17,7 +17,7 @@ import (
"context"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/metrics"
"github.com/pkg/errors"
"github.com/rs/zerolog"
@ -28,12 +28,12 @@ import (
type Service struct {
monitor metrics.SignerMonitor
clientMonitor metrics.ClientMonitor
slotsPerEpoch spec.Slot
beaconProposerDomainType spec.DomainType
beaconAttesterDomainType spec.DomainType
randaoDomainType spec.DomainType
selectionProofDomainType spec.DomainType
aggregateAndProofDomainType spec.DomainType
slotsPerEpoch phase0.Slot
beaconProposerDomainType phase0.DomainType
beaconAttesterDomainType phase0.DomainType
randaoDomainType phase0.DomainType
selectionProofDomainType phase0.DomainType
aggregateAndProofDomainType phase0.DomainType
domainProvider eth2client.DomainProvider
}
@ -81,7 +81,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
s := &Service{
monitor: parameters.monitor,
clientMonitor: parameters.clientMonitor,
slotsPerEpoch: spec.Slot(slotsPerEpoch),
slotsPerEpoch: phase0.Slot(slotsPerEpoch),
beaconAttesterDomainType: beaconAttesterDomainType,
beaconProposerDomainType: beaconProposerDomainType,
randaoDomainType: randaoDomainType,

View File

@ -16,7 +16,7 @@ package standard
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -24,23 +24,23 @@ import (
// SignAggregateAndProof signs an aggregate and proof item.
func (s *Service) SignAggregateAndProof(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
aggregateAndProofRoot spec.Root,
slot phase0.Slot,
aggregateAndProofRoot phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
// Fetch the domain.
domain, err := s.domainProvider.Domain(ctx,
s.aggregateAndProofDomainType,
spec.Epoch(slot/s.slotsPerEpoch))
phase0.Epoch(slot/s.slotsPerEpoch))
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for beacon aggregate and proof")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for beacon aggregate and proof")
}
sig, err := s.sign(ctx, account, aggregateAndProofRoot, domain)
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to aggregate and proof")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to aggregate and proof")
}
return sig, nil

View File

@ -16,7 +16,7 @@ package standard
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -24,25 +24,25 @@ import (
// SignBeaconAttestation signs a beacon attestation item.
func (s *Service) SignBeaconAttestation(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
committeeIndex spec.CommitteeIndex,
blockRoot spec.Root,
sourceEpoch spec.Epoch,
sourceRoot spec.Root,
targetEpoch spec.Epoch,
targetRoot spec.Root,
slot phase0.Slot,
committeeIndex phase0.CommitteeIndex,
blockRoot phase0.Root,
sourceEpoch phase0.Epoch,
sourceRoot phase0.Root,
targetEpoch phase0.Epoch,
targetRoot phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
domain, err := s.domainProvider.Domain(ctx,
s.beaconAttesterDomainType,
spec.Epoch(slot/s.slotsPerEpoch))
phase0.Epoch(slot/s.slotsPerEpoch))
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for beacon attestation")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for beacon attestation")
}
var sig spec.BLSSignature
var sig phase0.BLSSignature
if protectingSigner, isProtectingSigner := account.(e2wtypes.AccountProtectingSigner); isProtectingSigner {
signature, err := protectingSigner.SignBeaconAttestation(ctx,
uint64(slot),
@ -54,30 +54,30 @@ func (s *Service) SignBeaconAttestation(ctx context.Context,
targetRoot[:],
domain[:])
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to sign beacon attestation")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to sign beacon attestation")
}
copy(sig[:], signature.Marshal())
} else {
attestation := &spec.AttestationData{
attestation := &phase0.AttestationData{
Slot: slot,
Index: committeeIndex,
BeaconBlockRoot: blockRoot,
Source: &spec.Checkpoint{
Source: &phase0.Checkpoint{
Epoch: sourceEpoch,
Root: sourceRoot,
},
Target: &spec.Checkpoint{
Target: &phase0.Checkpoint{
Epoch: targetEpoch,
Root: targetRoot,
},
}
root, err := attestation.HashTreeRoot()
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to generate hash tree root")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to generate hash tree root")
}
sig, err = s.sign(ctx, account, root, domain)
if err != nil {
return spec.BLSSignature{}, err
return phase0.BLSSignature{}, err
}
}

View File

@ -16,7 +16,7 @@ package standard
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
@ -25,15 +25,15 @@ import (
// SignBeaconAttestations signs multiple beacon attestations.
func (s *Service) SignBeaconAttestations(ctx context.Context,
accounts []e2wtypes.Account,
slot spec.Slot,
committeeIndices []spec.CommitteeIndex,
blockRoot spec.Root,
sourceEpoch spec.Epoch,
sourceRoot spec.Root,
targetEpoch spec.Epoch,
targetRoot spec.Root,
slot phase0.Slot,
committeeIndices []phase0.CommitteeIndex,
blockRoot phase0.Root,
sourceEpoch phase0.Epoch,
sourceRoot phase0.Root,
targetEpoch phase0.Epoch,
targetRoot phase0.Root,
) (
[]spec.BLSSignature,
[]phase0.BLSSignature,
error,
) {
span, ctx := opentracing.StartSpanFromContext(ctx, "signer.SignBeaconAttestations")
@ -45,7 +45,7 @@ func (s *Service) SignBeaconAttestations(ctx context.Context,
signatureDomain, err := s.domainProvider.Domain(ctx,
s.beaconAttesterDomainType,
spec.Epoch(slot/s.slotsPerEpoch))
phase0.Epoch(slot/s.slotsPerEpoch))
if err != nil {
return nil, errors.Wrap(err, "failed to obtain signature domain for beacon attestation")
}
@ -71,7 +71,7 @@ func (s *Service) SignBeaconAttestations(ctx context.Context,
}
}
sigs := make([]spec.BLSSignature, len(accounts))
sigs := make([]phase0.BLSSignature, len(accounts))
if len(signingAccounts) > 0 {
signatures, err := s.signBeaconAttestations(ctx, signingAccounts, slot, accountCommitteeIndices, blockRoot, sourceEpoch, sourceRoot, targetEpoch, targetRoot, signatureDomain)
if err != nil {
@ -96,17 +96,17 @@ func (s *Service) SignBeaconAttestations(ctx context.Context,
func (s *Service) signBeaconAttestations(ctx context.Context,
accounts []e2wtypes.Account,
slot spec.Slot,
slot phase0.Slot,
committeeIndices []uint64,
blockRoot spec.Root,
sourceEpoch spec.Epoch,
sourceRoot spec.Root,
targetEpoch spec.Epoch,
targetRoot spec.Root,
signatureDomain spec.Domain,
) ([]spec.BLSSignature, error) {
blockRoot phase0.Root,
sourceEpoch phase0.Epoch,
sourceRoot phase0.Root,
targetEpoch phase0.Epoch,
targetRoot phase0.Root,
signatureDomain phase0.Domain,
) ([]phase0.BLSSignature, error) {
var err error
sigs := make([]spec.BLSSignature, len(accounts))
sigs := make([]phase0.BLSSignature, len(accounts))
if len(accounts) == 0 {
return sigs, nil
@ -137,7 +137,7 @@ func (s *Service) signBeaconAttestations(ctx context.Context,
sigs[i], err = s.SignBeaconAttestation(ctx,
accounts[i],
slot,
spec.CommitteeIndex(committeeIndices[i]),
phase0.CommitteeIndex(committeeIndices[i]),
blockRoot,
sourceEpoch,
sourceRoot,

View File

@ -16,7 +16,7 @@ package standard
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -24,25 +24,25 @@ import (
// SignBeaconBlockProposal signs a beacon block proposal.
func (s *Service) SignBeaconBlockProposal(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
proposerIndex spec.ValidatorIndex,
parentRoot spec.Root,
stateRoot spec.Root,
bodyRoot spec.Root,
slot phase0.Slot,
proposerIndex phase0.ValidatorIndex,
parentRoot phase0.Root,
stateRoot phase0.Root,
bodyRoot phase0.Root,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
// Fetch the domain.
domain, err := s.domainProvider.Domain(ctx,
s.beaconProposerDomainType,
spec.Epoch(slot/s.slotsPerEpoch))
phase0.Epoch(slot/s.slotsPerEpoch))
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for beacon proposal")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for beacon proposal")
}
var sig spec.BLSSignature
var sig phase0.BLSSignature
if protectingSigner, isProtectingSigner := account.(e2wtypes.AccountProtectingSigner); isProtectingSigner {
signature, err := protectingSigner.SignBeaconProposal(ctx,
uint64(slot),
@ -52,11 +52,11 @@ func (s *Service) SignBeaconBlockProposal(ctx context.Context,
bodyRoot[:],
domain[:])
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to sign beacon block proposal")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to sign beacon block proposal")
}
copy(sig[:], signature.Marshal())
} else {
header := &spec.BeaconBlockHeader{
header := &phase0.BeaconBlockHeader{
Slot: slot,
ProposerIndex: proposerIndex,
ParentRoot: parentRoot,
@ -65,11 +65,11 @@ func (s *Service) SignBeaconBlockProposal(ctx context.Context,
}
root, err := header.HashTreeRoot()
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to generate hash tree root")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to generate hash tree root")
}
sig, err = s.sign(ctx, account, root, domain)
if err != nil {
return spec.BLSSignature{}, err
return phase0.BLSSignature{}, err
}
}

View File

@ -17,7 +17,7 @@ import (
"context"
"encoding/binary"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -26,13 +26,13 @@ import (
// This signs an epoch with the "RANDAO reveal" domain.
func (s *Service) SignRANDAOReveal(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
slot phase0.Slot,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
var messageRoot spec.Root
epoch := spec.Epoch(slot / s.slotsPerEpoch)
var messageRoot phase0.Root
epoch := phase0.Epoch(slot / s.slotsPerEpoch)
binary.LittleEndian.PutUint64(messageRoot[:], uint64(epoch))
// Obtain the RANDAO reveal signature domain.
@ -40,15 +40,15 @@ func (s *Service) SignRANDAOReveal(ctx context.Context,
s.randaoDomainType,
epoch)
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for RANDAO reveal")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for RANDAO reveal")
}
var epochBytes spec.Root
var epochBytes phase0.Root
binary.LittleEndian.PutUint64(epochBytes[:], uint64(epoch))
sig, err := s.sign(ctx, account, epochBytes, domain)
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to sign RANDO reveal")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to sign RANDO reveal")
}
return sig, nil

View File

@ -17,7 +17,7 @@ import (
"context"
"encoding/binary"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
)
@ -26,28 +26,28 @@ import (
// This signs a slot with the "selection proof" domain.
func (s *Service) SignSlotSelection(ctx context.Context,
account e2wtypes.Account,
slot spec.Slot,
slot phase0.Slot,
) (
spec.BLSSignature,
phase0.BLSSignature,
error,
) {
var messageRoot spec.Root
var messageRoot phase0.Root
binary.LittleEndian.PutUint64(messageRoot[:], uint64(slot))
// Calculate the domain.
domain, err := s.domainProvider.Domain(ctx,
s.selectionProofDomainType,
spec.Epoch(slot/s.slotsPerEpoch))
phase0.Epoch(slot/s.slotsPerEpoch))
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for selection proof")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to obtain signature domain for selection proof")
}
var slotBytes spec.Root
var slotBytes phase0.Root
binary.LittleEndian.PutUint64(slotBytes[:], uint64(slot))
sig, err := s.sign(ctx, account, slotBytes, domain)
if err != nil {
return spec.BLSSignature{}, errors.Wrap(err, "failed to sign RANDO reveal")
return phase0.BLSSignature{}, errors.Wrap(err, "failed to sign RANDO reveal")
}
return sig, nil

View File

@ -20,7 +20,7 @@ import (
eth2client "github.com/attestantio/go-eth2-client"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/metrics"
"github.com/pkg/errors"
"github.com/rs/zerolog"
@ -64,7 +64,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
}
// SubmitBeaconBlock submits a block.
func (s *Service) SubmitBeaconBlock(ctx context.Context, block *spec.SignedBeaconBlock) error {
func (s *Service) SubmitBeaconBlock(ctx context.Context, block *phase0.SignedBeaconBlock) error {
if block == nil {
return errors.New("no beacon block supplied")
}
@ -91,7 +91,7 @@ func (s *Service) SubmitBeaconBlock(ctx context.Context, block *spec.SignedBeaco
}
// SubmitAttestations submits multiple attestations.
func (s *Service) SubmitAttestations(ctx context.Context, attestations []*spec.Attestation) error {
func (s *Service) SubmitAttestations(ctx context.Context, attestations []*phase0.Attestation) error {
if len(attestations) == 0 {
return errors.New("no attestations supplied")
}
@ -162,7 +162,7 @@ func (s *Service) SubmitBeaconCommitteeSubscriptions(ctx context.Context, subscr
}
// SubmitAggregateAttestations submits aggregate attestations.
func (s *Service) SubmitAggregateAttestations(ctx context.Context, aggregates []*spec.SignedAggregateAndProof) error {
func (s *Service) SubmitAggregateAttestations(ctx context.Context, aggregates []*phase0.SignedAggregateAndProof) error {
if len(aggregates) == 0 {
return errors.New("no aggregate attestations supplied")
}

View File

@ -18,7 +18,7 @@ import (
"testing"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/attestantio/vouch/services/submitter"
"github.com/attestantio/vouch/services/submitter/immediate"
@ -119,7 +119,7 @@ func TestSubmitBeaconBlock(t *testing.T) {
tests := []struct {
name string
params []immediate.Parameter
block *spec.SignedBeaconBlock
block *phase0.SignedBeaconBlock
err string
}{
{
@ -142,7 +142,7 @@ func TestSubmitBeaconBlock(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
block: &spec.SignedBeaconBlock{},
block: &phase0.SignedBeaconBlock{},
},
{
name: "Erroring",
@ -153,7 +153,7 @@ func TestSubmitBeaconBlock(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
block: &spec.SignedBeaconBlock{},
block: &phase0.SignedBeaconBlock{},
err: "failed to submit beacon block: error",
},
{
@ -165,7 +165,7 @@ func TestSubmitBeaconBlock(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
block: &spec.SignedBeaconBlock{},
block: &phase0.SignedBeaconBlock{},
},
}
@ -188,7 +188,7 @@ func TestSubmitAttestations(t *testing.T) {
tests := []struct {
name string
params []immediate.Parameter
attestations []*spec.Attestation
attestations []*phase0.Attestation
err string
}{
{
@ -211,7 +211,7 @@ func TestSubmitAttestations(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
attestations: []*spec.Attestation{},
attestations: []*phase0.Attestation{},
err: "no attestations supplied",
},
{
@ -223,7 +223,7 @@ func TestSubmitAttestations(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
attestations: []*spec.Attestation{{}},
attestations: []*phase0.Attestation{{}},
err: "failed to submit attestations: error",
},
{
@ -235,7 +235,7 @@ func TestSubmitAttestations(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
attestations: []*spec.Attestation{{}},
attestations: []*phase0.Attestation{{}},
},
}
@ -258,7 +258,7 @@ func TestSubmitAggregateAttestations(t *testing.T) {
tests := []struct {
name string
params []immediate.Parameter
aggregates []*spec.SignedAggregateAndProof
aggregates []*phase0.SignedAggregateAndProof
err string
}{
{
@ -281,7 +281,7 @@ func TestSubmitAggregateAttestations(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
aggregates: []*spec.SignedAggregateAndProof{},
aggregates: []*phase0.SignedAggregateAndProof{},
err: "no aggregate attestations supplied",
},
{
@ -293,7 +293,7 @@ func TestSubmitAggregateAttestations(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewErroringAggregateAttestationsSubmitter()),
},
aggregates: []*spec.SignedAggregateAndProof{
aggregates: []*phase0.SignedAggregateAndProof{
{},
},
err: "failed to submit aggregate attestation: error",
@ -307,7 +307,7 @@ func TestSubmitAggregateAttestations(t *testing.T) {
immediate.WithBeaconCommitteeSubscriptionsSubmitter(mock.NewBeaconCommitteeSubscriptionsSubmitter()),
immediate.WithAggregateAttestationsSubmitter(mock.NewAggregateAttestationsSubmitter()),
},
aggregates: []*spec.SignedAggregateAndProof{
aggregates: []*phase0.SignedAggregateAndProof{
{},
},
},

View File

@ -20,13 +20,13 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"golang.org/x/sync/semaphore"
)
// SubmitAggregateAttestations submits aggregate attestations.
func (s *Service) SubmitAggregateAttestations(ctx context.Context, aggregates []*spec.SignedAggregateAndProof) error {
func (s *Service) SubmitAggregateAttestations(ctx context.Context, aggregates []*phase0.SignedAggregateAndProof) error {
if len(aggregates) == 0 {
return errors.New("no aggregate attestations supplied")
}

View File

@ -21,13 +21,13 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"golang.org/x/sync/semaphore"
)
// SubmitAttestations submits a batch of attestations.
func (s *Service) SubmitAttestations(ctx context.Context, attestations []*spec.Attestation) error {
func (s *Service) SubmitAttestations(ctx context.Context, attestations []*phase0.Attestation) error {
if len(attestations) == 0 {
return errors.New("no attestations supplied")
}

View File

@ -19,13 +19,13 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"golang.org/x/sync/semaphore"
)
// SubmitBeaconBlock submits a beacon block.
func (s *Service) SubmitBeaconBlock(ctx context.Context, block *spec.SignedBeaconBlock) error {
func (s *Service) SubmitBeaconBlock(ctx context.Context, block *phase0.SignedBeaconBlock) error {
if block == nil {
return errors.New("no beacon block supplied")
}

View File

@ -18,7 +18,7 @@ import (
"encoding/json"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"github.com/rs/zerolog"
zerologger "github.com/rs/zerolog/log"
@ -49,7 +49,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
}
// SubmitBeaconBlock submits a block.
func (s *Service) SubmitBeaconBlock(ctx context.Context, block *spec.SignedBeaconBlock) error {
func (s *Service) SubmitBeaconBlock(ctx context.Context, block *phase0.SignedBeaconBlock) error {
if block == nil {
return errors.New("no beacon block supplied")
}
@ -65,7 +65,7 @@ func (s *Service) SubmitBeaconBlock(ctx context.Context, block *spec.SignedBeaco
}
// SubmitAttestations submits multiple attestations.
func (s *Service) SubmitAttestations(ctx context.Context, attestations []*spec.Attestation) error {
func (s *Service) SubmitAttestations(ctx context.Context, attestations []*phase0.Attestation) error {
if len(attestations) == 0 {
return errors.New("no attestations supplied")
}
@ -105,7 +105,7 @@ func (s *Service) SubmitBeaconCommitteeSubscriptions(ctx context.Context, subscr
}
// SubmitAggregateAttestations submits aggregate attestations.
func (s *Service) SubmitAggregateAttestations(ctx context.Context, aggregates []*spec.SignedAggregateAndProof) error {
func (s *Service) SubmitAggregateAttestations(ctx context.Context, aggregates []*phase0.SignedAggregateAndProof) error {
if len(aggregates) == 0 {
return errors.New("no aggregate attestations supplied")
}

View File

@ -17,7 +17,7 @@ import (
"context"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// Service is the submitter service.
@ -26,13 +26,13 @@ type Service interface{}
// AttestationsSubmitter is the interface for a submitter of attestations.
type AttestationsSubmitter interface {
// SubmitAttestations submits multiple attestations.
SubmitAttestations(ctx context.Context, attestations []*spec.Attestation) error
SubmitAttestations(ctx context.Context, attestations []*phase0.Attestation) error
}
// BeaconBlockSubmitter is the interface for a submitter of beacon blocks.
type BeaconBlockSubmitter interface {
// SubmitBeaconBlock submits a block.
SubmitBeaconBlock(ctx context.Context, block *spec.SignedBeaconBlock) error
SubmitBeaconBlock(ctx context.Context, block *phase0.SignedBeaconBlock) error
}
// BeaconCommitteeSubscriptionsSubmitter is the interface for a submitter of beacon committee subscriptions.
@ -44,5 +44,5 @@ type BeaconCommitteeSubscriptionsSubmitter interface {
// AggregateAttestationsSubmitter is the interface for a submitter of aggregate attestations.
type AggregateAttestationsSubmitter interface {
// SubmitAggregateAttestations submits aggregate attestations.
SubmitAggregateAttestations(ctx context.Context, aggregateAttestations []*spec.SignedAggregateAndProof) error
SubmitAggregateAttestations(ctx context.Context, aggregateAttestations []*phase0.SignedAggregateAndProof) error
}

View File

@ -19,21 +19,21 @@ import (
"context"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// Service is the generic validators manager service.
type Service interface {
// RefreshValidatorsFromBeaconNode refreshes the local store from the beacon node.
// This is an expensive operation, and should not be called in the validating path.
RefreshValidatorsFromBeaconNode(ctx context.Context, pubKeys []spec.BLSPubKey) error
RefreshValidatorsFromBeaconNode(ctx context.Context, pubKeys []phase0.BLSPubKey) error
// ValidatorsByIndex fetches the requested validators from local store given their indices.
ValidatorsByIndex(ctx context.Context, indices []spec.ValidatorIndex) map[spec.ValidatorIndex]*spec.Validator
ValidatorsByIndex(ctx context.Context, indices []phase0.ValidatorIndex) map[phase0.ValidatorIndex]*phase0.Validator
// ValidatorsByPubKey fetches the requested validators from local store given their public keys.
ValidatorsByPubKey(ctx context.Context, pubKeys []spec.BLSPubKey) map[spec.ValidatorIndex]*spec.Validator
ValidatorsByPubKey(ctx context.Context, pubKeys []phase0.BLSPubKey) map[phase0.ValidatorIndex]*phase0.Validator
// ValidatorStateAtEpoch returns the given validator's state at the given epoch.
ValidatorStateAtEpoch(ctx context.Context, index spec.ValidatorIndex, epoch spec.Epoch) (api.ValidatorState, error)
ValidatorStateAtEpoch(ctx context.Context, index phase0.ValidatorIndex, epoch phase0.Epoch) (api.ValidatorState, error)
}

View File

@ -17,7 +17,7 @@ import (
"context"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/metrics"
nullmetrics "github.com/attestantio/vouch/services/metrics/null"
"github.com/pkg/errors"
@ -29,7 +29,7 @@ type parameters struct {
monitor metrics.ValidatorsManagerMonitor
clientMonitor metrics.ClientMonitor
validatorsProvider eth2client.ValidatorsProvider
farFutureEpoch spec.Epoch
farFutureEpoch phase0.Epoch
}
// Parameter is the interface for service parameters.
@ -72,7 +72,7 @@ func WithValidatorsProvider(provider eth2client.ValidatorsProvider) Parameter {
}
// WithFarFutureEpoch sets the far future epoch.
func WithFarFutureEpoch(farFutureEpoch spec.Epoch) Parameter {
func WithFarFutureEpoch(farFutureEpoch phase0.Epoch) Parameter {
return parameterFunc(func(p *parameters) {
p.farFutureEpoch = farFutureEpoch
})

View File

@ -19,14 +19,14 @@ import (
eth2client "github.com/attestantio/go-eth2-client"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
// RefreshValidatorsFromBeaconNode refreshes the local store from the beacon node.
// This is an expensive operation, and should not be called in the validating path.
func (s *Service) RefreshValidatorsFromBeaconNode(ctx context.Context, pubKeys []spec.BLSPubKey) error {
var validators map[spec.ValidatorIndex]*api.Validator
func (s *Service) RefreshValidatorsFromBeaconNode(ctx context.Context, pubKeys []phase0.BLSPubKey) error {
var validators map[phase0.ValidatorIndex]*api.Validator
var err error
started := time.Now()
// Use ValidatorsWithoutBalance by preference (check relative timings to see if this has improved.)
@ -61,9 +61,9 @@ func (s *Service) RefreshValidatorsFromBeaconNode(ctx context.Context, pubKeys [
return nil
}
validatorsByIndex := make(map[spec.ValidatorIndex]*spec.Validator)
validatorsByPubKey := make(map[spec.BLSPubKey]*spec.Validator)
validatorPubKeyToIndex := make(map[spec.BLSPubKey]spec.ValidatorIndex)
validatorsByIndex := make(map[phase0.ValidatorIndex]*phase0.Validator)
validatorsByPubKey := make(map[phase0.BLSPubKey]*phase0.Validator)
validatorPubKeyToIndex := make(map[phase0.BLSPubKey]phase0.ValidatorIndex)
for _, validator := range validators {
validatorsByIndex[validator.Index] = validator.Validator
validatorsByPubKey[validator.Validator.PublicKey] = validator.Validator

View File

@ -17,7 +17,7 @@ import (
"context"
"testing"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
nullmetrics "github.com/attestantio/vouch/services/metrics/null"
"github.com/attestantio/vouch/services/validatorsmanager/standard"
@ -32,38 +32,38 @@ func TestRefreshValidatorsFromBeaconNode(t *testing.T) {
standard.WithLogLevel(zerolog.Disabled),
standard.WithMonitor(nullmetrics.New(context.Background())),
standard.WithClientMonitor(nullmetrics.New(context.Background())),
standard.WithFarFutureEpoch(spec.Epoch(0xffffffffffffffff)),
standard.WithFarFutureEpoch(phase0.Epoch(0xffffffffffffffff)),
standard.WithValidatorsProvider(mock.NewValidatorsProvider()),
)
require.NoError(t, err)
// Keys we want to fetch.
fetchKeys := []spec.BLSPubKey{
fetchKeys := []phase0.BLSPubKey{
testutil.HexToPubKey("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"),
testutil.HexToPubKey("0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b"),
testutil.HexToPubKey("0xa3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b"),
}
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []spec.BLSPubKey{
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []phase0.BLSPubKey{
testutil.HexToPubKey("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"),
testutil.HexToPubKey("0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b"),
}))
require.Len(t, s.ValidatorsByPubKey(ctx, fetchKeys), 2)
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []spec.BLSPubKey{
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []phase0.BLSPubKey{
testutil.HexToPubKey("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"),
testutil.HexToPubKey("0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b"),
testutil.HexToPubKey("0xa3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b"),
}))
require.Len(t, s.ValidatorsByPubKey(ctx, fetchKeys), 3)
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []spec.BLSPubKey{
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []phase0.BLSPubKey{
testutil.HexToPubKey("0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b"),
testutil.HexToPubKey("0xa3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b"),
}))
require.Len(t, s.ValidatorsByPubKey(ctx, fetchKeys), 2)
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []spec.BLSPubKey{
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []phase0.BLSPubKey{
testutil.HexToPubKey("0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7"),
testutil.HexToPubKey("0x9893413c00283a3f9ed9fd9845dda1cea38228d22567f9541dccc357e54a2d6a6e204103c92564cbc05f4905ac7c493a"),
testutil.HexToPubKey("0x876dd4705157eb66dc71bc2e07fb151ea53e1a62a0bb980a7ce72d15f58944a8a3752d754f52f4a60dbfc7b18169f268"),

View File

@ -18,7 +18,7 @@ import (
"sync"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/metrics"
"github.com/pkg/errors"
"github.com/rs/zerolog"
@ -30,12 +30,12 @@ type Service struct {
monitor metrics.ValidatorsManagerMonitor
clientMonitor metrics.ClientMonitor
validatorsProvider eth2client.ValidatorsProvider
farFutureEpoch spec.Epoch
farFutureEpoch phase0.Epoch
validatorsMutex sync.RWMutex
validatorsByIndex map[spec.ValidatorIndex]*spec.Validator
validatorsByPubKey map[spec.BLSPubKey]*spec.Validator
validatorPubKeyToIndex map[spec.BLSPubKey]spec.ValidatorIndex
validatorsByIndex map[phase0.ValidatorIndex]*phase0.Validator
validatorsByPubKey map[phase0.BLSPubKey]*phase0.Validator
validatorPubKeyToIndex map[phase0.BLSPubKey]phase0.ValidatorIndex
}
// module-wide log.
@ -59,9 +59,9 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
clientMonitor: parameters.clientMonitor,
farFutureEpoch: parameters.farFutureEpoch,
validatorsProvider: parameters.validatorsProvider,
validatorsByIndex: make(map[spec.ValidatorIndex]*spec.Validator),
validatorsByPubKey: make(map[spec.BLSPubKey]*spec.Validator),
validatorPubKeyToIndex: make(map[spec.BLSPubKey]spec.ValidatorIndex),
validatorsByIndex: make(map[phase0.ValidatorIndex]*phase0.Validator),
validatorsByPubKey: make(map[phase0.BLSPubKey]*phase0.Validator),
validatorPubKeyToIndex: make(map[phase0.BLSPubKey]phase0.ValidatorIndex),
}
return s, nil

View File

@ -17,7 +17,7 @@ import (
"context"
"testing"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
nullmetrics "github.com/attestantio/vouch/services/metrics/null"
"github.com/attestantio/vouch/services/validatorsmanager/standard"
@ -27,7 +27,7 @@ import (
)
func TestService(t *testing.T) {
farFutureEpoch := spec.Epoch(0xffffffffffffffff)
farFutureEpoch := phase0.Epoch(0xffffffffffffffff)
validatorsProvider := mock.NewValidatorsProvider()
tests := []struct {

View File

@ -16,12 +16,12 @@ package standard
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// ValidatorsByIndex fetches the requested validators from local store given their indices.
func (s *Service) ValidatorsByIndex(ctx context.Context, indices []spec.ValidatorIndex) map[spec.ValidatorIndex]*spec.Validator {
res := make(map[spec.ValidatorIndex]*spec.Validator)
func (s *Service) ValidatorsByIndex(ctx context.Context, indices []phase0.ValidatorIndex) map[phase0.ValidatorIndex]*phase0.Validator {
res := make(map[phase0.ValidatorIndex]*phase0.Validator)
s.validatorsMutex.RLock()
for _, index := range indices {
if validator, exists := s.validatorsByIndex[index]; exists {

View File

@ -17,7 +17,7 @@ import (
"context"
"testing"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
nullmetrics "github.com/attestantio/vouch/services/metrics/null"
"github.com/attestantio/vouch/services/validatorsmanager/standard"
@ -32,11 +32,11 @@ func TestValidatorsByIndex(t *testing.T) {
standard.WithLogLevel(zerolog.Disabled),
standard.WithMonitor(nullmetrics.New(context.Background())),
standard.WithClientMonitor(nullmetrics.New(context.Background())),
standard.WithFarFutureEpoch(spec.Epoch(0xffffffffffffffff)),
standard.WithFarFutureEpoch(phase0.Epoch(0xffffffffffffffff)),
standard.WithValidatorsProvider(mock.NewValidatorsProvider()),
)
require.NoError(t, err)
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []spec.BLSPubKey{
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []phase0.BLSPubKey{
testutil.HexToPubKey("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"),
testutil.HexToPubKey("0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b"),
testutil.HexToPubKey("0xa3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b"),
@ -73,7 +73,7 @@ func TestValidatorsByIndex(t *testing.T) {
tests := []struct {
name string
validatorIndices []spec.ValidatorIndex
validatorIndices []phase0.ValidatorIndex
expected int
}{
{
@ -82,17 +82,17 @@ func TestValidatorsByIndex(t *testing.T) {
},
{
name: "Empty",
validatorIndices: []spec.ValidatorIndex{},
validatorIndices: []phase0.ValidatorIndex{},
expected: 0,
},
{
name: "Good",
validatorIndices: []spec.ValidatorIndex{1, 2, 3},
validatorIndices: []phase0.ValidatorIndex{1, 2, 3},
expected: 3,
},
{
name: "Missing",
validatorIndices: []spec.ValidatorIndex{1, 2, 12341234123412341234},
validatorIndices: []phase0.ValidatorIndex{1, 2, 12341234123412341234},
expected: 2,
},
}

View File

@ -16,12 +16,12 @@ package standard
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// ValidatorsByPubKey fetches the requested validators from local store given their public keys.
func (s *Service) ValidatorsByPubKey(ctx context.Context, pubKeys []spec.BLSPubKey) map[spec.ValidatorIndex]*spec.Validator {
res := make(map[spec.ValidatorIndex]*spec.Validator)
func (s *Service) ValidatorsByPubKey(ctx context.Context, pubKeys []phase0.BLSPubKey) map[phase0.ValidatorIndex]*phase0.Validator {
res := make(map[phase0.ValidatorIndex]*phase0.Validator)
s.validatorsMutex.RLock()
for _, pubKey := range pubKeys {
if validator, exists := s.validatorsByPubKey[pubKey]; exists {

View File

@ -17,7 +17,7 @@ import (
"context"
"testing"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
nullmetrics "github.com/attestantio/vouch/services/metrics/null"
"github.com/attestantio/vouch/services/validatorsmanager/standard"
@ -32,11 +32,11 @@ func TestValidatorsByPubKey(t *testing.T) {
standard.WithLogLevel(zerolog.Disabled),
standard.WithMonitor(nullmetrics.New(context.Background())),
standard.WithClientMonitor(nullmetrics.New(context.Background())),
standard.WithFarFutureEpoch(spec.Epoch(0xffffffffffffffff)),
standard.WithFarFutureEpoch(phase0.Epoch(0xffffffffffffffff)),
standard.WithValidatorsProvider(mock.NewValidatorsProvider()),
)
require.NoError(t, err)
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []spec.BLSPubKey{
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []phase0.BLSPubKey{
testutil.HexToPubKey("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"),
testutil.HexToPubKey("0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b"),
testutil.HexToPubKey("0xa3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b"),
@ -73,7 +73,7 @@ func TestValidatorsByPubKey(t *testing.T) {
tests := []struct {
name string
validatorPubKeys []spec.BLSPubKey
validatorPubKeys []phase0.BLSPubKey
expected int
}{
{
@ -82,12 +82,12 @@ func TestValidatorsByPubKey(t *testing.T) {
},
{
name: "Empty",
validatorPubKeys: []spec.BLSPubKey{},
validatorPubKeys: []phase0.BLSPubKey{},
expected: 0,
},
{
name: "Good",
validatorPubKeys: []spec.BLSPubKey{
validatorPubKeys: []phase0.BLSPubKey{
testutil.HexToPubKey("0xa1c76af1545d7901214bb6be06be5d9e458f8e989c19373a920f0018327c83982f6a2ac138260b8def732cb366411ddc"),
testutil.HexToPubKey("0x8dd74e1bb5228fc1fca274fda02b971c1003a4f409bbdfbcfec6426bf2f52addcbbebccdbf45eee6ae11eb5b5ee7244d"),
testutil.HexToPubKey("0x954eb88ed1207f891dc3c28fa6cfdf8f53bf0ed3d838f3476c0900a61314d22d4f0a300da3cd010444dd5183e35a593c"),
@ -96,7 +96,7 @@ func TestValidatorsByPubKey(t *testing.T) {
},
{
name: "Missing",
validatorPubKeys: []spec.BLSPubKey{
validatorPubKeys: []phase0.BLSPubKey{
testutil.HexToPubKey("0xa1c76af1545d7901214bb6be06be5d9e458f8e989c19373a920f0018327c83982f6a2ac138260b8def732cb366411ddc"),
testutil.HexToPubKey("0x8dd74e1bb5228fc1fca274fda02b971c1003a4f409bbdfbcfec6426bf2f52addcbbebccdbf45eee6ae11eb5b5ee7244d"),
testutil.HexToPubKey("0x97d1108d128ead4d11e9fd2325547ad1cf57de92bcbcc79b7a15ba22057df0bf9026eb93569f2e57edee7a7bc4bf2a23"),

View File

@ -17,12 +17,12 @@ import (
"context"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
// ValidatorStateAtEpoch returns the validator's state at the given epoch.
func (s *Service) ValidatorStateAtEpoch(ctx context.Context, index spec.ValidatorIndex, epoch spec.Epoch) (api.ValidatorState, error) {
func (s *Service) ValidatorStateAtEpoch(ctx context.Context, index phase0.ValidatorIndex, epoch phase0.Epoch) (api.ValidatorState, error) {
s.validatorsMutex.RLock()
validator, exists := s.validatorsByIndex[index]
s.validatorsMutex.RUnlock()

View File

@ -18,7 +18,7 @@ import (
"testing"
api "github.com/attestantio/go-eth2-client/api/v1"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
nullmetrics "github.com/attestantio/vouch/services/metrics/null"
"github.com/attestantio/vouch/services/validatorsmanager/standard"
@ -33,11 +33,11 @@ func TestValidatorStateAtEpoch(t *testing.T) {
standard.WithLogLevel(zerolog.Disabled),
standard.WithMonitor(nullmetrics.New(context.Background())),
standard.WithClientMonitor(nullmetrics.New(context.Background())),
standard.WithFarFutureEpoch(spec.Epoch(0xffffffffffffffff)),
standard.WithFarFutureEpoch(phase0.Epoch(0xffffffffffffffff)),
standard.WithValidatorsProvider(mock.NewValidatorsProvider()),
)
require.NoError(t, err)
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []spec.BLSPubKey{
require.NoError(t, s.RefreshValidatorsFromBeaconNode(ctx, []phase0.BLSPubKey{
testutil.HexToPubKey("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"),
testutil.HexToPubKey("0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b"),
testutil.HexToPubKey("0xa3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b"),
@ -74,8 +74,8 @@ func TestValidatorStateAtEpoch(t *testing.T) {
tests := []struct {
name string
validatorIndex spec.ValidatorIndex
epoch spec.Epoch
validatorIndex phase0.ValidatorIndex
epoch phase0.Epoch
state api.ValidatorState
err string
}{

View File

@ -18,18 +18,18 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
type aggregateAttestationResponse struct {
provider string
aggregate *spec.Attestation
aggregate *phase0.Attestation
score float64
}
// AggregateAttestation provides the aggregate attestation from a number of beacon nodes.
func (s *Service) AggregateAttestation(ctx context.Context, slot spec.Slot, attestationDataRoot spec.Root) (*spec.Attestation, error) {
func (s *Service) AggregateAttestation(ctx context.Context, slot phase0.Slot, attestationDataRoot phase0.Root) (*phase0.Attestation, error) {
started := time.Now()
// We create a cancelable context with a timeout. If the context times out we take the best to date.
@ -69,7 +69,7 @@ func (s *Service) AggregateAttestation(ctx context.Context, slot spec.Slot, atte
responded := 0
errored := 0
bestScore := float64(0)
var bestAggregateAttestation *spec.Attestation
var bestAggregateAttestation *phase0.Attestation
bestProvider := ""
for responded+errored != len(s.aggregateAttestationProviders) {

View File

@ -18,7 +18,7 @@ import (
"testing"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/prysmaticlabs/go-bitfield"
"github.com/rs/zerolog"
@ -48,7 +48,7 @@ func TestScore(t *testing.T) {
tests := []struct {
name string
aggregate *spec.Attestation
aggregate *phase0.Attestation
score float64
}{
{
@ -57,9 +57,9 @@ func TestScore(t *testing.T) {
},
{
name: "Empty",
aggregate: &spec.Attestation{
aggregate: &phase0.Attestation{
AggregationBits: populatedBitlist(100, 0),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 5,
},
},
@ -67,9 +67,9 @@ func TestScore(t *testing.T) {
},
{
name: "Full",
aggregate: &spec.Attestation{
aggregate: &phase0.Attestation{
AggregationBits: populatedBitlist(100, 100),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 5,
},
},

View File

@ -19,7 +19,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/attestantio/vouch/strategies/aggregateattestation/best"
"github.com/rs/zerolog"
@ -30,8 +30,8 @@ func TestAggregateAttestation(t *testing.T) {
tests := []struct {
name string
params []best.Parameter
slot spec.Slot
attestationDataRoot spec.Root
slot phase0.Slot
attestationDataRoot phase0.Root
err string
}{
{
@ -43,7 +43,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},
@ -58,7 +58,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},
@ -74,7 +74,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},
@ -91,7 +91,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},

View File

@ -16,14 +16,14 @@ package best
import (
"context"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// scoreAggregateAttestation generates a score for an aggregate attestation.
// The score is relative to the completeness of the aggregate.
func (s *Service) scoreAggregateAttestation(ctx context.Context,
name string,
aggregate *spec.Attestation,
aggregate *phase0.Attestation,
) float64 {
if aggregate == nil {
return 0

View File

@ -18,23 +18,23 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
// AggregateAttestation provides the aggregate attestation from a number of beacon nodes.
func (s *Service) AggregateAttestation(ctx context.Context, slot spec.Slot, attestationDataRoot spec.Root) (*spec.Attestation, error) {
func (s *Service) AggregateAttestation(ctx context.Context, slot phase0.Slot, attestationDataRoot phase0.Root) (*phase0.Attestation, error) {
started := time.Now()
// We create a cancelable context with a timeout. When a provider responds we cancel the context to cancel the other requests.
ctx, cancel := context.WithTimeout(ctx, s.timeout)
respCh := make(chan *spec.Attestation, 1)
respCh := make(chan *phase0.Attestation, 1)
for name, provider := range s.aggregateAttestationProviders {
go func(ctx context.Context,
name string,
provider eth2client.AggregateAttestationProvider,
ch chan *spec.Attestation) {
ch chan *phase0.Attestation) {
log := log.With().Str("provider", name).Uint64("slot", uint64(slot)).Logger()
aggregate, err := provider.AggregateAttestation(ctx, slot, attestationDataRoot)

View File

@ -19,7 +19,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/attestantio/vouch/strategies/aggregateattestation/first"
"github.com/rs/zerolog"
@ -30,8 +30,8 @@ func TestAggregateAttestation(t *testing.T) {
tests := []struct {
name string
params []first.Parameter
slot spec.Slot
attestationDataRoot spec.Root
slot phase0.Slot
attestationDataRoot phase0.Root
err string
}{
{
@ -43,7 +43,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},
@ -58,7 +58,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},
@ -74,7 +74,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},
@ -92,7 +92,7 @@ func TestAggregateAttestation(t *testing.T) {
}),
},
slot: 12345,
attestationDataRoot: spec.Root{
attestationDataRoot: phase0.Root{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},

View File

@ -18,18 +18,18 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
type attestationDataResponse struct {
provider string
attestationData *spec.AttestationData
attestationData *phase0.AttestationData
score float64
}
// AttestationData provides the best attestation data from a number of beacon nodes.
func (s *Service) AttestationData(ctx context.Context, slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error) {
func (s *Service) AttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) {
started := time.Now()
log := log.With().Uint64("slot", uint64(slot)).Logger()
@ -65,7 +65,7 @@ func (s *Service) AttestationData(ctx context.Context, slot spec.Slot, committee
responded := 0
errored := 0
bestScore := float64(0)
var bestAttestationData *spec.AttestationData
var bestAttestationData *phase0.AttestationData
bestProvider := ""
for responded+errored != len(s.attestationDataProviders) {

View File

@ -19,7 +19,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/attestantio/vouch/strategies/attestationdata/best"
"github.com/rs/zerolog"
@ -30,8 +30,8 @@ func TestAttestationData(t *testing.T) {
tests := []struct {
name string
params []best.Parameter
slot spec.Slot
committeeIndex spec.CommitteeIndex
slot phase0.Slot
committeeIndex phase0.CommitteeIndex
err string
}{
{

View File

@ -18,7 +18,7 @@ import (
"fmt"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// scoreAttestationData generates a score for attestation data.
@ -26,13 +26,13 @@ import (
func (s *Service) scoreAttestationData(ctx context.Context,
provider eth2client.AttestationDataProvider,
name string,
attestationData *spec.AttestationData,
attestationData *phase0.AttestationData,
) float64 {
if attestationData == nil {
return 0
}
var slot spec.Slot
var slot phase0.Slot
if headerProvider, isProvider := provider.(eth2client.BeaconBlockHeadersProvider); isProvider {
block, err := headerProvider.BeaconBlockHeader(ctx, fmt.Sprintf("%#x", attestationData.BeaconBlockRoot))
if err != nil {

View File

@ -18,20 +18,20 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)
// AttestationData provides the first attestation data from a number of beacon nodes.
func (s *Service) AttestationData(ctx context.Context, slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error) {
func (s *Service) AttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) {
started := time.Now()
// We create a cancelable context with a timeout. When a provider responds we cancel the context to cancel the other requests.
ctx, cancel := context.WithTimeout(ctx, s.timeout)
respCh := make(chan *spec.AttestationData, 1)
respCh := make(chan *phase0.AttestationData, 1)
for name, provider := range s.attestationDataProviders {
go func(ctx context.Context, name string, provider eth2client.AttestationDataProvider, ch chan *spec.AttestationData) {
go func(ctx context.Context, name string, provider eth2client.AttestationDataProvider, ch chan *phase0.AttestationData) {
log := log.With().Str("provider", name).Uint64("slot", uint64(slot)).Logger()
attestationData, err := provider.AttestationData(ctx, slot, committeeIndex)

View File

@ -19,7 +19,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/attestantio/vouch/strategies/attestationdata/first"
"github.com/rs/zerolog"
@ -30,8 +30,8 @@ func TestAttestationData(t *testing.T) {
tests := []struct {
name string
params []first.Parameter
slot spec.Slot
committeeIndex spec.CommitteeIndex
slot phase0.Slot
committeeIndex phase0.CommitteeIndex
err string
}{
{

View File

@ -20,15 +20,15 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"golang.org/x/sync/semaphore"
)
// BeaconBlockProposal provides the best beacon block proposal from a number of beacon nodes.
func (s *Service) BeaconBlockProposal(ctx context.Context, slot spec.Slot, randaoReveal spec.BLSSignature, graffiti []byte) (*spec.BeaconBlock, error) {
func (s *Service) BeaconBlockProposal(ctx context.Context, slot phase0.Slot, randaoReveal phase0.BLSSignature, graffiti []byte) (*phase0.BeaconBlock, error) {
var mu sync.Mutex
bestScore := float64(0)
var bestProposal *spec.BeaconBlock
var bestProposal *phase0.BeaconBlock
bestProvider := ""
started := time.Now()
@ -63,7 +63,7 @@ func (s *Service) BeaconBlockProposal(ctx context.Context, slot spec.Slot, randa
// Obtain the slot of the block to which the proposal refers.
// We use this to allow the scorer to score blocks with earlier parents lower.
var parentSlot spec.Slot
var parentSlot phase0.Slot
parentBlock, err := s.signedBeaconBlockProvider.SignedBeaconBlock(ctx, fmt.Sprintf("%#x", proposal.ParentRoot[:]))
switch {
case err != nil:

View File

@ -18,7 +18,7 @@ import (
"testing"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/mock"
"github.com/attestantio/vouch/services/metrics/null"
"github.com/attestantio/vouch/strategies/beaconblockproposal/best"
@ -44,7 +44,7 @@ func TestBeaconBlockProposal(t *testing.T) {
block, err := service.BeaconBlockProposal(ctx,
12345,
spec.BLSSignature([96]byte{
phase0.BLSSignature([96]byte{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,

View File

@ -17,12 +17,12 @@ import (
"context"
"sort"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// scoreBeaconBlockPropsal generates a score for a beacon block.
// The score is relative to the reward expected by proposing the block.
func scoreBeaconBlockProposal(ctx context.Context, name string, parentSlot spec.Slot, blockProposal *spec.BeaconBlock) float64 {
func scoreBeaconBlockProposal(ctx context.Context, name string, parentSlot phase0.Slot, blockProposal *phase0.BeaconBlock) float64 {
if blockProposal == nil {
return 0
}
@ -35,11 +35,11 @@ func scoreBeaconBlockProposal(ctx context.Context, name string, parentSlot spec.
// We need to avoid duplicates in attestations.
// Map is slot -> committee index -> validator committee index -> attested.
attested := make(map[spec.Slot]map[spec.CommitteeIndex]map[uint64]bool)
attested := make(map[phase0.Slot]map[phase0.CommitteeIndex]map[uint64]bool)
for _, attestation := range blockProposal.Body.Attestations {
slotAttested, exists := attested[attestation.Data.Slot]
if !exists {
slotAttested = make(map[spec.CommitteeIndex]map[uint64]bool)
slotAttested = make(map[phase0.CommitteeIndex]map[uint64]bool)
attested[attestation.Data.Slot] = slotAttested
}
committeeAttested, exists := slotAttested[attestation.Data.Index]

View File

@ -17,7 +17,7 @@ import (
"context"
"testing"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/testutil"
"github.com/prysmaticlabs/go-bitfield"
"github.com/stretchr/testify/assert"
@ -42,8 +42,8 @@ func specificAggregationBits(set []uint64, total uint64) bitfield.Bitlist {
func TestScore(t *testing.T) {
tests := []struct {
name string
block *spec.BeaconBlock
parentSlot spec.Slot
block *phase0.BeaconBlock
parentSlot phase0.Slot
score float64
err string
}{
@ -54,19 +54,19 @@ func TestScore(t *testing.T) {
},
{
name: "Empty",
block: &spec.BeaconBlock{},
block: &phase0.BeaconBlock{},
parentSlot: 1,
score: 0,
},
{
name: "SingleAttestation",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(1, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
@ -78,13 +78,13 @@ func TestScore(t *testing.T) {
},
{
name: "SingleAttestationParentRootDistance2",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(1, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
@ -96,13 +96,13 @@ func TestScore(t *testing.T) {
},
{
name: "SingleAttestationDistance2",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(1, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12343,
},
},
@ -114,19 +114,19 @@ func TestScore(t *testing.T) {
},
{
name: "TwoAttestations",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(2, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
{
AggregationBits: aggregationBits(1, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12341,
},
},
@ -138,23 +138,23 @@ func TestScore(t *testing.T) {
},
{
name: "AttesterSlashing",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(50, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
},
AttesterSlashings: []*spec.AttesterSlashing{
AttesterSlashings: []*phase0.AttesterSlashing{
{
Attestation1: &spec.IndexedAttestation{
Attestation1: &phase0.IndexedAttestation{
AttestingIndices: []uint64{1, 2, 3},
},
Attestation2: &spec.IndexedAttestation{
Attestation2: &phase0.IndexedAttestation{
AttestingIndices: []uint64{2, 3, 4},
},
},
@ -166,19 +166,19 @@ func TestScore(t *testing.T) {
},
{
name: "DuplicateAttestations",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: specificAggregationBits([]uint64{1, 2, 3}, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
{
AggregationBits: specificAggregationBits([]uint64{2, 3, 4}, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
@ -190,31 +190,31 @@ func TestScore(t *testing.T) {
},
{
name: "Full",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(50, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
},
AttesterSlashings: []*spec.AttesterSlashing{
AttesterSlashings: []*phase0.AttesterSlashing{
{
Attestation1: &spec.IndexedAttestation{
Attestation1: &phase0.IndexedAttestation{
AttestingIndices: []uint64{1, 2, 3},
},
Attestation2: &spec.IndexedAttestation{
Attestation2: &phase0.IndexedAttestation{
AttestingIndices: []uint64{2, 3, 4},
},
},
},
ProposerSlashings: []*spec.ProposerSlashing{
ProposerSlashings: []*phase0.ProposerSlashing{
{
SignedHeader1: &spec.SignedBeaconBlockHeader{
Message: &spec.BeaconBlockHeader{
SignedHeader1: &phase0.SignedBeaconBlockHeader{
Message: &phase0.BeaconBlockHeader{
Slot: 10,
ProposerIndex: 1,
ParentRoot: testutil.HexToRoot("0x0101010101010101010101010101010101010101010101010101010101010101"),
@ -223,8 +223,8 @@ func TestScore(t *testing.T) {
},
Signature: testutil.HexToSignature("0x040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404"),
},
SignedHeader2: &spec.SignedBeaconBlockHeader{
Message: &spec.BeaconBlockHeader{
SignedHeader2: &phase0.SignedBeaconBlockHeader{
Message: &phase0.BeaconBlockHeader{
Slot: 10,
ProposerIndex: 1,
ParentRoot: testutil.HexToRoot("0x0404040404040404040404040404040404040404040404040404040404040404"),
@ -242,31 +242,31 @@ func TestScore(t *testing.T) {
},
{
name: "FullParentRootDistance2",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(50, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
},
AttesterSlashings: []*spec.AttesterSlashing{
AttesterSlashings: []*phase0.AttesterSlashing{
{
Attestation1: &spec.IndexedAttestation{
Attestation1: &phase0.IndexedAttestation{
AttestingIndices: []uint64{1, 2, 3},
},
Attestation2: &spec.IndexedAttestation{
Attestation2: &phase0.IndexedAttestation{
AttestingIndices: []uint64{2, 3, 4},
},
},
},
ProposerSlashings: []*spec.ProposerSlashing{
ProposerSlashings: []*phase0.ProposerSlashing{
{
SignedHeader1: &spec.SignedBeaconBlockHeader{
Message: &spec.BeaconBlockHeader{
SignedHeader1: &phase0.SignedBeaconBlockHeader{
Message: &phase0.BeaconBlockHeader{
Slot: 10,
ProposerIndex: 1,
ParentRoot: testutil.HexToRoot("0x0101010101010101010101010101010101010101010101010101010101010101"),
@ -275,8 +275,8 @@ func TestScore(t *testing.T) {
},
Signature: testutil.HexToSignature("0x040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404"),
},
SignedHeader2: &spec.SignedBeaconBlockHeader{
Message: &spec.BeaconBlockHeader{
SignedHeader2: &phase0.SignedBeaconBlockHeader{
Message: &phase0.BeaconBlockHeader{
Slot: 10,
ProposerIndex: 1,
ParentRoot: testutil.HexToRoot("0x0404040404040404040404040404040404040404040404040404040404040404"),
@ -294,31 +294,31 @@ func TestScore(t *testing.T) {
},
{
name: "FullParentRootDistance4",
block: &spec.BeaconBlock{
block: &phase0.BeaconBlock{
Slot: 12345,
Body: &spec.BeaconBlockBody{
Attestations: []*spec.Attestation{
Body: &phase0.BeaconBlockBody{
Attestations: []*phase0.Attestation{
{
AggregationBits: aggregationBits(50, 128),
Data: &spec.AttestationData{
Data: &phase0.AttestationData{
Slot: 12344,
},
},
},
AttesterSlashings: []*spec.AttesterSlashing{
AttesterSlashings: []*phase0.AttesterSlashing{
{
Attestation1: &spec.IndexedAttestation{
Attestation1: &phase0.IndexedAttestation{
AttestingIndices: []uint64{1, 2, 3},
},
Attestation2: &spec.IndexedAttestation{
Attestation2: &phase0.IndexedAttestation{
AttestingIndices: []uint64{2, 3, 4},
},
},
},
ProposerSlashings: []*spec.ProposerSlashing{
ProposerSlashings: []*phase0.ProposerSlashing{
{
SignedHeader1: &spec.SignedBeaconBlockHeader{
Message: &spec.BeaconBlockHeader{
SignedHeader1: &phase0.SignedBeaconBlockHeader{
Message: &phase0.BeaconBlockHeader{
Slot: 10,
ProposerIndex: 1,
ParentRoot: testutil.HexToRoot("0x0101010101010101010101010101010101010101010101010101010101010101"),
@ -327,8 +327,8 @@ func TestScore(t *testing.T) {
},
Signature: testutil.HexToSignature("0x040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404"),
},
SignedHeader2: &spec.SignedBeaconBlockHeader{
Message: &spec.BeaconBlockHeader{
SignedHeader2: &phase0.SignedBeaconBlockHeader{
Message: &phase0.BeaconBlockHeader{
Slot: 10,
ProposerIndex: 1,
ParentRoot: testutil.HexToRoot("0x0404040404040404040404040404040404040404040404040404040404040404"),

View File

@ -18,7 +18,7 @@ import (
"time"
eth2client "github.com/attestantio/go-eth2-client"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/vouch/services/metrics"
"github.com/pkg/errors"
"github.com/rs/zerolog"
@ -58,14 +58,14 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
}
// BeaconBlockProposal provides the first beacon block proposal from a number of beacon nodes.
func (s *Service) BeaconBlockProposal(ctx context.Context, slot spec.Slot, randaoReveal spec.BLSSignature, graffiti []byte) (*spec.BeaconBlock, error) {
func (s *Service) BeaconBlockProposal(ctx context.Context, slot phase0.Slot, randaoReveal phase0.BLSSignature, graffiti []byte) (*phase0.BeaconBlock, error) {
// We create a cancelable context with a timeout. As soon as the first provider has responded we
// cancel the context to cancel the other requests.
ctx, cancel := context.WithTimeout(ctx, s.timeout)
proposalCh := make(chan *spec.BeaconBlock, 1)
proposalCh := make(chan *phase0.BeaconBlock, 1)
for name, provider := range s.beaconBlockProposalProviders {
go func(ctx context.Context, name string, provider eth2client.BeaconBlockProposalProvider, ch chan *spec.BeaconBlock) {
go func(ctx context.Context, name string, provider eth2client.BeaconBlockProposalProvider, ch chan *phase0.BeaconBlock) {
log := log.With().Str("provider", name).Uint64("slot", uint64(slot)).Logger()
started := time.Now()

View File

@ -17,7 +17,7 @@ import (
"encoding/hex"
"strings"
spec "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// HexToBytes converts a hex string to a byte array.
@ -32,54 +32,54 @@ func HexToBytes(input string) []byte {
// HexToPubKey converts a hex string to a spec public key.
// This should only be used for pre-defined test strings; it will panic if the input is invalid.
func HexToPubKey(input string) spec.BLSPubKey {
func HexToPubKey(input string) phase0.BLSPubKey {
data := HexToBytes(input)
var res spec.BLSPubKey
var res phase0.BLSPubKey
copy(res[:], data)
return res
}
// HexToSignature converts a hex string to a spec signature.
// This should only be used for pre-defined test strings; it will panic if the input is invalid.
func HexToSignature(input string) spec.BLSSignature {
func HexToSignature(input string) phase0.BLSSignature {
data := HexToBytes(input)
var res spec.BLSSignature
var res phase0.BLSSignature
copy(res[:], data)
return res
}
// HexToDomainType converts a hex string to a spec domain type.
// This should only be used for pre-defined test strings; it will panic if the input is invalid.
func HexToDomainType(input string) spec.DomainType {
func HexToDomainType(input string) phase0.DomainType {
data := HexToBytes(input)
var res spec.DomainType
var res phase0.DomainType
copy(res[:], data)
return res
}
// HexToDomain converts a hex string to a spec domain.
// This should only be used for pre-defined test strings; it will panic if the input is invalid.
func HexToDomain(input string) spec.Domain {
func HexToDomain(input string) phase0.Domain {
data := HexToBytes(input)
var res spec.Domain
var res phase0.Domain
copy(res[:], data)
return res
}
// HexToVersion converts a hex string to a spec version.
// This should only be used for pre-defined test strings; it will panic if the input is invalid.
func HexToVersion(input string) spec.Version {
func HexToVersion(input string) phase0.Version {
data := HexToBytes(input)
var res spec.Version
var res phase0.Version
copy(res[:], data)
return res
}
// HexToRoot converts a hex string to a spec root.
// This should only be used for pre-defined test strings; it will panic if the input is invalid.
func HexToRoot(input string) spec.Root {
func HexToRoot(input string) phase0.Root {
data := HexToBytes(input)
var res spec.Root
var res phase0.Root
copy(res[:], data)
return res
}