Skip to content

Commit

Permalink
Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Sep 24, 2023
1 parent d741855 commit 4951c26
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 154 deletions.
187 changes: 100 additions & 87 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1398,93 +1398,7 @@ func selectSubmitterStrategy(ctx context.Context, monitor metrics.Service, eth2C
switch viper.GetString("submitter.style") {
case "multinode", "all":
log.Info().Msg("Starting multinode submitter strategy")

aggregateAttestationSubmitters := make(map[string]eth2client.AggregateAttestationsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.aggregateattestation.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for aggregate attestation submitter strategy", address))
}
aggregateAttestationSubmitters[address] = client.(eth2client.AggregateAttestationsSubmitter)
}

attestationsSubmitters := make(map[string]eth2client.AttestationsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.attestation.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for attestation submitter strategy", address))
}
attestationsSubmitters[address] = client.(eth2client.AttestationsSubmitter)
}

beaconBlockSubmitters := make(map[string]eth2client.BeaconBlockSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.beaconblock.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for beacon block submitter strategy", address))
}
beaconBlockSubmitters[address] = client.(eth2client.BeaconBlockSubmitter)
}

beaconCommitteeSubscriptionsSubmitters := make(map[string]eth2client.BeaconCommitteeSubscriptionsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.beaconcommitteesubscription.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for beacon committee subscription submitter strategy", address))
}
beaconCommitteeSubscriptionsSubmitters[address] = client.(eth2client.BeaconCommitteeSubscriptionsSubmitter)
}

proposalPreparationSubmitters := make(map[string]eth2client.ProposalPreparationsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.proposalpreparation.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for proposal preparation submitter strategy", address))
}
proposalPreparationSubmitters[address] = client.(eth2client.ProposalPreparationsSubmitter)
}

syncCommitteeContributionsSubmitters := make(map[string]eth2client.SyncCommitteeContributionsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.synccommitteecontribution.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for sync committee contribution submitter strategy", address))
}
syncCommitteeContributionsSubmitters[address] = client.(eth2client.SyncCommitteeContributionsSubmitter)
}

syncCommitteeMessagesSubmitters := make(map[string]eth2client.SyncCommitteeMessagesSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.synccommitteemessage.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for sync committee message submitter strategy", address))
}
syncCommitteeMessagesSubmitters[address] = client.(eth2client.SyncCommitteeMessagesSubmitter)
}

syncCommitteeSubscriptionsSubmitters := make(map[string]eth2client.SyncCommitteeSubscriptionsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.synccommitteesubscription.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for sync committee subscription submitter strategy", address))
}
syncCommitteeSubscriptionsSubmitters[address] = client.(eth2client.SyncCommitteeSubscriptionsSubmitter)
}

submitter, err = multinodesubmitter.New(ctx,
multinodesubmitter.WithClientMonitor(monitor.(metrics.ClientMonitor)),
multinodesubmitter.WithProcessConcurrency(util.ProcessConcurrency("submitter.multinode")),
multinodesubmitter.WithLogLevel(util.LogLevel("submitter.multinode")),
multinodesubmitter.WithTimeout(util.Timeout("submitter.multinode")),
multinodesubmitter.WithBeaconBlockSubmitters(beaconBlockSubmitters),
multinodesubmitter.WithAttestationsSubmitters(attestationsSubmitters),
multinodesubmitter.WithSyncCommitteeMessagesSubmitters(syncCommitteeMessagesSubmitters),
multinodesubmitter.WithSyncCommitteeContributionsSubmitters(syncCommitteeContributionsSubmitters),
multinodesubmitter.WithSyncCommitteeSubscriptionsSubmitters(syncCommitteeSubscriptionsSubmitters),
multinodesubmitter.WithAggregateAttestationsSubmitters(aggregateAttestationSubmitters),
multinodesubmitter.WithBeaconCommitteeSubscriptionsSubmitters(beaconCommitteeSubscriptionsSubmitters),
multinodesubmitter.WithProposalPreparationsSubmitters(proposalPreparationSubmitters),
)
submitter, err = startMultinodeSubmitter(ctx, monitor)
default:
log.Info().Msg("Starting standard submitter strategy")
submitter, err = immediatesubmitter.New(ctx,
Expand All @@ -1506,6 +1420,105 @@ func selectSubmitterStrategy(ctx context.Context, monitor metrics.Service, eth2C
return submitter, nil
}

func startMultinodeSubmitter(ctx context.Context,
monitor metrics.Service,
) (
submitter.Service,
error,
) {
aggregateAttestationSubmitters := make(map[string]eth2client.AggregateAttestationsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.aggregateattestation.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for aggregate attestation submitter strategy", address))
}
aggregateAttestationSubmitters[address] = client.(eth2client.AggregateAttestationsSubmitter)
}

attestationsSubmitters := make(map[string]eth2client.AttestationsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.attestation.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for attestation submitter strategy", address))
}
attestationsSubmitters[address] = client.(eth2client.AttestationsSubmitter)
}

beaconBlockSubmitters := make(map[string]eth2client.BeaconBlockSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.beaconblock.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for beacon block submitter strategy", address))
}
beaconBlockSubmitters[address] = client.(eth2client.BeaconBlockSubmitter)
}

beaconCommitteeSubscriptionsSubmitters := make(map[string]eth2client.BeaconCommitteeSubscriptionsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.beaconcommitteesubscription.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for beacon committee subscription submitter strategy", address))
}
beaconCommitteeSubscriptionsSubmitters[address] = client.(eth2client.BeaconCommitteeSubscriptionsSubmitter)
}

proposalPreparationSubmitters := make(map[string]eth2client.ProposalPreparationsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.proposalpreparation.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for proposal preparation submitter strategy", address))
}
proposalPreparationSubmitters[address] = client.(eth2client.ProposalPreparationsSubmitter)
}

syncCommitteeContributionsSubmitters := make(map[string]eth2client.SyncCommitteeContributionsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.synccommitteecontribution.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for sync committee contribution submitter strategy", address))
}
syncCommitteeContributionsSubmitters[address] = client.(eth2client.SyncCommitteeContributionsSubmitter)
}

syncCommitteeMessagesSubmitters := make(map[string]eth2client.SyncCommitteeMessagesSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.synccommitteemessage.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for sync committee message submitter strategy", address))
}
syncCommitteeMessagesSubmitters[address] = client.(eth2client.SyncCommitteeMessagesSubmitter)
}

syncCommitteeSubscriptionsSubmitters := make(map[string]eth2client.SyncCommitteeSubscriptionsSubmitter)
for _, address := range util.BeaconNodeAddresses("submitter.synccommitteesubscription.multinode") {
client, err := fetchClient(ctx, address)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch client %s for sync committee subscription submitter strategy", address))
}
syncCommitteeSubscriptionsSubmitters[address] = client.(eth2client.SyncCommitteeSubscriptionsSubmitter)
}

submitter, err := multinodesubmitter.New(ctx,
multinodesubmitter.WithClientMonitor(monitor.(metrics.ClientMonitor)),
multinodesubmitter.WithProcessConcurrency(util.ProcessConcurrency("submitter.multinode")),
multinodesubmitter.WithLogLevel(util.LogLevel("submitter.multinode")),
multinodesubmitter.WithTimeout(util.Timeout("submitter.multinode")),
multinodesubmitter.WithBeaconBlockSubmitters(beaconBlockSubmitters),
multinodesubmitter.WithAttestationsSubmitters(attestationsSubmitters),
multinodesubmitter.WithSyncCommitteeMessagesSubmitters(syncCommitteeMessagesSubmitters),
multinodesubmitter.WithSyncCommitteeContributionsSubmitters(syncCommitteeContributionsSubmitters),
multinodesubmitter.WithSyncCommitteeSubscriptionsSubmitters(syncCommitteeSubscriptionsSubmitters),
multinodesubmitter.WithAggregateAttestationsSubmitters(aggregateAttestationSubmitters),
multinodesubmitter.WithBeaconCommitteeSubscriptionsSubmitters(beaconCommitteeSubscriptionsSubmitters),
multinodesubmitter.WithProposalPreparationsSubmitters(proposalPreparationSubmitters),
)
if err != nil {
return nil, err
}

return submitter, nil
}

// runCommands potentially runs commands.
// Returns true if Vouch should exit.
func runCommands(ctx context.Context,
Expand Down
2 changes: 1 addition & 1 deletion mock/builderbidprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
type BuilderBidProvider struct{}

// BuilderBid returns a builder bid.
func (b BuilderBidProvider) BuilderBid(_ context.Context,
func (BuilderBidProvider) BuilderBid(_ context.Context,
_ phase0.Slot,
_ phase0.Hash32,
_ phase0.BLSPubKey,
Expand Down
Loading

0 comments on commit 4951c26

Please sign in to comment.