Skip to content

Commit

Permalink
Merge branch 'develop' into Workflow_dependency_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Taranpreet26311 authored Aug 26, 2024
2 parents ecaa22b + 261921a commit 28a6281
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 77 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Beacon chain now asserts that the external builder block uses the expected gas limit.
- Electra: Add electra objects to beacon API.
- Electra: Updated block publishing beacon APIs to support Electra.
- "Submitted builder validator registration settings for custom builders" log message moved to debug level.

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func configureEth1Config(cliCtx *cli.Context) error {
}

func configureNetwork(cliCtx *cli.Context) {
if len(cliCtx.StringSlice(cmd.BootstrapNode.Name)) > 0 {
if cliCtx.IsSet(cmd.BootstrapNode.Name) {
c := params.BeaconNetworkConfig()
c.BootstrapNodes = cliCtx.StringSlice(cmd.BootstrapNode.Name)
params.OverrideBeaconNetworkConfig(c)
Expand Down
105 changes: 32 additions & 73 deletions beacon-chain/rpc/prysm/v1alpha1/validator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,10 @@ func (vs *Server) SubmitAggregateSelectionProof(ctx context.Context, req *ethpb.
defer span.End()
span.AddAttributes(trace.Int64Attribute("slot", int64(req.Slot)))

if vs.SyncChecker.Syncing() {
return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond")
}

// An optimistic validator MUST NOT participate in attestation
// (i.e., sign across the DOMAIN_BEACON_ATTESTER, DOMAIN_SELECTION_PROOF or DOMAIN_AGGREGATE_AND_PROOF domains).
if err := vs.optimisticStatus(ctx); err != nil {
return nil, err
}

st, err := vs.HeadFetcher.HeadStateReadOnly(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not determine head state: %v", err)
}

validatorIndex, exists := st.ValidatorIndexByPubkey(bytesutil.ToBytes48(req.PublicKey))
if !exists {
return nil, status.Error(codes.Internal, "Could not locate validator index in DB")
}

epoch := slots.ToEpoch(req.Slot)
activeValidatorIndices, err := helpers.ActiveValidatorIndices(ctx, st, epoch)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get validators: %v", err)
}
seed, err := helpers.Seed(st, epoch, params.BeaconConfig().DomainBeaconAttester)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get seed: %v", err)
}
committee, err := helpers.BeaconCommittee(ctx, activeValidatorIndices, seed, req.Slot, req.CommitteeIndex)
indexInCommittee, validatorIndex, err := vs.processAggregateSelection(ctx, req)
if err != nil {
return nil, err
}

// Check if the validator is an aggregator
isAggregator, err := helpers.IsAggregator(uint64(len(committee)), req.SlotSignature)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get aggregator status: %v", err)
}
if !isAggregator {
return nil, status.Errorf(codes.InvalidArgument, "Validator is not an aggregator")
}

atts := vs.AttPool.AggregatedAttestationsBySlotIndex(ctx, req.Slot, req.CommitteeIndex)
// Filter out the best aggregated attestation (ie. the one with the most aggregated bits).
if len(atts) == 0 {
Expand All @@ -74,14 +35,6 @@ func (vs *Server) SubmitAggregateSelectionProof(ctx context.Context, req *ethpb.
return nil, status.Errorf(codes.NotFound, "Could not find attestation for slot and committee in pool")
}
}

var indexInCommittee uint64
for i, idx := range committee {
if idx == validatorIndex {
indexInCommittee = uint64(i)
}
}

best := bestAggregate(atts, req.CommitteeIndex, indexInCommittee)
attAndProof := &ethpb.AggregateAttestationAndProof{
Aggregate: best,
Expand All @@ -102,55 +55,68 @@ func (vs *Server) SubmitAggregateSelectionProofElectra(
defer span.End()
span.AddAttributes(trace.Int64Attribute("slot", int64(req.Slot)))

indexInCommittee, validatorIndex, err := vs.processAggregateSelection(ctx, req)
if err != nil {
return nil, err
}
atts := vs.AttPool.AggregatedAttestationsBySlotIndexElectra(ctx, req.Slot, req.CommitteeIndex)
if len(atts) == 0 {
atts = vs.AttPool.UnaggregatedAttestationsBySlotIndexElectra(ctx, req.Slot, req.CommitteeIndex)
if len(atts) == 0 {
return nil, status.Errorf(codes.NotFound, "No attestations found in pool")
}
}
best := bestAggregate(atts, req.CommitteeIndex, indexInCommittee)
attAndProof := &ethpb.AggregateAttestationAndProofElectra{
Aggregate: best,
SelectionProof: req.SlotSignature,
AggregatorIndex: validatorIndex,
}
return &ethpb.AggregateSelectionElectraResponse{AggregateAndProof: attAndProof}, nil
}

func (vs *Server) processAggregateSelection(ctx context.Context, req *ethpb.AggregateSelectionRequest) (uint64, primitives.ValidatorIndex, error) {
if vs.SyncChecker.Syncing() {
return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond")
return 0, 0, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond")
}

// An optimistic validator MUST NOT participate in attestation
// (i.e., sign across the DOMAIN_BEACON_ATTESTER, DOMAIN_SELECTION_PROOF or DOMAIN_AGGREGATE_AND_PROOF domains).
if err := vs.optimisticStatus(ctx); err != nil {
return nil, err
return 0, 0, err
}

st, err := vs.HeadFetcher.HeadStateReadOnly(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not determine head state: %v", err)
return 0, 0, status.Errorf(codes.Internal, "Could not determine head state: %v", err)
}

validatorIndex, exists := st.ValidatorIndexByPubkey(bytesutil.ToBytes48(req.PublicKey))
if !exists {
return nil, status.Error(codes.Internal, "Could not locate validator index in DB")
return 0, 0, status.Error(codes.Internal, "Could not locate validator index in DB")
}

epoch := slots.ToEpoch(req.Slot)
activeValidatorIndices, err := helpers.ActiveValidatorIndices(ctx, st, epoch)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get validators: %v", err)
return 0, 0, status.Errorf(codes.Internal, "Could not get validators: %v", err)
}
seed, err := helpers.Seed(st, epoch, params.BeaconConfig().DomainBeaconAttester)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get seed: %v", err)
return 0, 0, status.Errorf(codes.Internal, "Could not get seed: %v", err)
}
committee, err := helpers.BeaconCommittee(ctx, activeValidatorIndices, seed, req.Slot, req.CommitteeIndex)
if err != nil {
return nil, err
return 0, 0, err
}

// Check if the validator is an aggregator
isAggregator, err := helpers.IsAggregator(uint64(len(committee)), req.SlotSignature)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get aggregator status: %v", err)
return 0, 0, status.Errorf(codes.Internal, "Could not get aggregator status: %v", err)
}
if !isAggregator {
return nil, status.Errorf(codes.InvalidArgument, "Validator is not an aggregator")
}

atts := vs.AttPool.AggregatedAttestationsBySlotIndexElectra(ctx, req.Slot, req.CommitteeIndex)
if len(atts) == 0 {
atts = vs.AttPool.UnaggregatedAttestationsBySlotIndexElectra(ctx, req.Slot, req.CommitteeIndex)
if len(atts) == 0 {
return nil, status.Errorf(codes.NotFound, "No attestations found in pool")
}
return 0, 0, status.Errorf(codes.InvalidArgument, "Validator is not an aggregator")
}

var indexInCommittee uint64
Expand All @@ -159,14 +125,7 @@ func (vs *Server) SubmitAggregateSelectionProofElectra(
indexInCommittee = uint64(i)
}
}

best := bestAggregate(atts, req.CommitteeIndex, indexInCommittee)
attAndProof := &ethpb.AggregateAttestationAndProofElectra{
Aggregate: best,
SelectionProof: req.SlotSignature,
AggregatorIndex: validatorIndex,
}
return &ethpb.AggregateSelectionElectraResponse{AggregateAndProof: attAndProof}, nil
return indexInCommittee, validatorIndex, nil
}

// SubmitSignedAggregateSelectionProof is called by a validator to broadcast a signed
Expand Down
2 changes: 1 addition & 1 deletion validator/client/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func SubmitValidatorRegistrations(
}

if lastErr == nil {
log.Infoln("Submitted builder validator registration settings for custom builders")
log.Debugln("Submitted builder validator registration settings for custom builders")
} else {
log.WithError(lastErr).Warn("Could not submit all signed registrations to beacon node")
}
Expand Down
4 changes: 2 additions & 2 deletions validator/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,8 @@ func Web3SignerConfig(cliCtx *cli.Context) (*remoteweb3signer.SetupConfig, error
if cliCtx.IsSet(flags.WalletPasswordFileFlag.Name) {
log.Warnf("%s was provided while using web3signer and will be ignored", flags.WalletPasswordFileFlag.Name)
}

if publicKeysSlice := cliCtx.StringSlice(flags.Web3SignerPublicValidatorKeysFlag.Name); len(publicKeysSlice) > 0 {
if cliCtx.IsSet(flags.Web3SignerPublicValidatorKeysFlag.Name) {
publicKeysSlice := cliCtx.StringSlice(flags.Web3SignerPublicValidatorKeysFlag.Name)
if len(publicKeysSlice) == 1 {
pURL, err := url.ParseRequestURI(publicKeysSlice[0])
if err == nil && pURL.Scheme != "" && pURL.Host != "" {
Expand Down

0 comments on commit 28a6281

Please sign in to comment.