diff --git a/beacon-chain/rpc/eth/beacon/blocks.go b/beacon-chain/rpc/eth/beacon/blocks.go index 07e17808998f..b3a0109c7a17 100644 --- a/beacon-chain/rpc/eth/beacon/blocks.go +++ b/beacon-chain/rpc/eth/beacon/blocks.go @@ -62,7 +62,7 @@ func (bs *Server) GetWeakSubjectivity(ctx context.Context, _ *empty.Empty) (*eth return nil, err } - hs, err := bs.HeadFetcher.HeadState(ctx) + hs, err := bs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Error(codes.Internal, "could not get head state") } diff --git a/beacon-chain/rpc/eth/beacon/pool.go b/beacon-chain/rpc/eth/beacon/pool.go index c494b01c5cbe..17c21657674c 100644 --- a/beacon-chain/rpc/eth/beacon/pool.go +++ b/beacon-chain/rpc/eth/beacon/pool.go @@ -144,7 +144,7 @@ func (bs *Server) ListPoolAttesterSlashings(ctx context.Context, _ *emptypb.Empt ctx, span := trace.StartSpan(ctx, "beacon.ListPoolAttesterSlashings") defer span.End() - headState, err := bs.ChainInfoFetcher.HeadState(ctx) + headState, err := bs.ChainInfoFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err) } @@ -200,7 +200,7 @@ func (bs *Server) ListPoolProposerSlashings(ctx context.Context, _ *emptypb.Empt ctx, span := trace.StartSpan(ctx, "beacon.ListPoolProposerSlashings") defer span.End() - headState, err := bs.ChainInfoFetcher.HeadState(ctx) + headState, err := bs.ChainInfoFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err) } diff --git a/beacon-chain/rpc/eth/validator/validator.go b/beacon-chain/rpc/eth/validator/validator.go index 0ed47d93f577..9bc4a289aec5 100644 --- a/beacon-chain/rpc/eth/validator/validator.go +++ b/beacon-chain/rpc/eth/validator/validator.go @@ -834,7 +834,7 @@ func (vs *Server) SubmitBeaconCommitteeSubscription(ctx context.Context, req *et return nil, status.Error(codes.InvalidArgument, "No subscriptions provided") } - s, err := vs.HeadFetcher.HeadState(ctx) + s, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err) } @@ -910,7 +910,7 @@ func (vs *Server) SubmitSyncCommitteeSubscription(ctx context.Context, req *ethp if len(req.Data) == 0 { return nil, status.Error(codes.InvalidArgument, "No subscriptions provided") } - s, err := vs.HeadFetcher.HeadState(ctx) + s, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go index 83620d1b450e..184b0afcd5f2 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go @@ -310,7 +310,7 @@ func (bs *Server) StreamBlocks(req *ethpb.StreamBlocksRequest, stream ethpb.Beac // One nil block shouldn't stop the stream. continue } - headState, err := bs.HeadFetcher.HeadState(bs.Ctx) + headState, err := bs.HeadFetcher.HeadStateReadOnly(bs.Ctx) if err != nil { log.WithError(err).WithField("blockSlot", data.SignedBlock.Block().Slot()).Error("Could not get head state") continue diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/slashings.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/slashings.go index 573750723fb4..b9d1d3372a42 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/slashings.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/slashings.go @@ -18,7 +18,7 @@ func (bs *Server) SubmitProposerSlashing( ctx context.Context, req *ethpb.ProposerSlashing, ) (*ethpb.SubmitSlashingResponse, error) { - beaconState, err := bs.HeadFetcher.HeadState(ctx) + beaconState, err := bs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not retrieve head state: %v", err) } @@ -43,7 +43,7 @@ func (bs *Server) SubmitAttesterSlashing( ctx context.Context, req *ethpb.AttesterSlashing, ) (*ethpb.SubmitSlashingResponse, error) { - beaconState, err := bs.HeadFetcher.HeadState(ctx) + beaconState, err := bs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not retrieve head state: %v", err) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go index 32e99a2f2efc..eebc355c77a3 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go @@ -359,7 +359,7 @@ func (bs *Server) GetValidator( "Need to specify either validator index or public key in request", ) } - headState, err := bs.HeadFetcher.HeadState(ctx) + headState, err := bs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator.go b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator.go index ab0533a3c019..503ff705d9aa 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator.go @@ -33,7 +33,7 @@ func (vs *Server) SubmitAggregateSelectionProof(ctx context.Context, req *ethpb. return nil, err } - st, err := vs.HeadFetcher.HeadState(ctx) + st, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not determine head state: %v", err) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/blocks.go b/beacon-chain/rpc/prysm/v1alpha1/validator/blocks.go index 9722de9789ae..0ebc8d2f7032 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/blocks.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/blocks.go @@ -124,7 +124,7 @@ func (vs *Server) sendBlocks(stream ethpb.BeaconNodeValidator_StreamBlocksAltair return nil } log := log.WithField("blockSlot", data.SignedBlock.Block().Slot()) - headState, err := vs.HeadFetcher.HeadState(vs.Ctx) + headState, err := vs.HeadFetcher.HeadStateReadOnly(vs.Ctx) if err != nil { log.WithError(err).Error("Could not get head state") return nil diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/exit.go b/beacon-chain/rpc/prysm/v1alpha1/validator/exit.go index 7727307052ed..b6f584c8eb36 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/exit.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/exit.go @@ -17,7 +17,7 @@ func (vs *Server) ProposeExit(ctx context.Context, req *ethpb.SignedVoluntaryExi if req == nil { return nil, status.Error(codes.InvalidArgument, "nil request") } - s, err := vs.HeadFetcher.HeadState(ctx) + s, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_eth1data.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_eth1data.go index 2f78c0f40994..a4a2d2ab84ad 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_eth1data.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_eth1data.go @@ -141,7 +141,7 @@ func (vs *Server) mockETH1DataVote(ctx context.Context, slot primitives.Slot) (* // BlockHash = hash(hash(current_epoch + slot_in_voting_period)), // ) slotInVotingPeriod := slot.ModSlot(params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().EpochsPerEth1VotingPeriod))) - headState, err := vs.HeadFetcher.HeadState(ctx) + headState, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, err } @@ -161,7 +161,7 @@ func (vs *Server) randomETH1DataVote(ctx context.Context) (*ethpb.Eth1Data, erro log.Warn("Beacon Node is no longer connected to an ETH1 chain, so ETH1 data votes are now random.") eth1DataNotification = true } - headState, err := vs.HeadFetcher.HeadState(ctx) + headState, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, err } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go index 6c795920370c..1477bbf680c4 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go @@ -121,7 +121,7 @@ func (vs *Server) WaitForActivation(req *ethpb.ValidatorActivationRequest, strea // ValidatorIndex is called by a validator to get its index location in the beacon state. func (vs *Server) ValidatorIndex(ctx context.Context, req *ethpb.ValidatorIndexRequest) (*ethpb.ValidatorIndexResponse, error) { - st, err := vs.HeadFetcher.HeadState(ctx) + st, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "Could not determine head state: %v", err) } @@ -157,7 +157,7 @@ func (vs *Server) DomainData(_ context.Context, request *ethpb.DomainRequest) (* // subscribes to an event stream triggered by the powchain service whenever the ChainStart log does // occur in the Deposit Contract on ETH 1.0. func (vs *Server) WaitForChainStart(_ *emptypb.Empty, stream ethpb.BeaconNodeValidator_WaitForChainStartServer) error { - head, err := vs.HeadFetcher.HeadState(stream.Context()) + head, err := vs.HeadFetcher.HeadStateReadOnly(stream.Context()) if err != nil { return status.Errorf(codes.Internal, "Could not retrieve head state: %v", err) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/status.go b/beacon-chain/rpc/prysm/v1alpha1/validator/status.go index 23ed80613bb9..ae7a5e003929 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/status.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/status.go @@ -42,7 +42,7 @@ func (vs *Server) ValidatorStatus( ctx context.Context, req *ethpb.ValidatorStatusRequest, ) (*ethpb.ValidatorStatusResponse, error) { - headState, err := vs.HeadFetcher.HeadState(ctx) + headState, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Error(codes.Internal, "Could not get head state") } @@ -59,7 +59,7 @@ func (vs *Server) MultipleValidatorStatus( if vs.SyncChecker.Syncing() { return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond") } - headState, err := vs.HeadFetcher.HeadState(ctx) + headState, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Error(codes.Internal, "Could not get head state") } @@ -107,7 +107,7 @@ func (vs *Server) CheckDoppelGanger(ctx context.Context, req *ethpb.DoppelGanger Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}, }, nil } - headState, err := vs.HeadFetcher.HeadState(ctx) + headState, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, status.Error(codes.Internal, "Could not get head state") } @@ -217,7 +217,7 @@ func (vs *Server) activationStatus( ctx context.Context, pubKeys [][]byte, ) (bool, []*ethpb.ValidatorActivationResponse_Status, error) { - headState, err := vs.HeadFetcher.HeadState(ctx) + headState, err := vs.HeadFetcher.HeadStateReadOnly(ctx) if err != nil { return false, nil, err } diff --git a/beacon-chain/rpc/statefetcher/fetcher.go b/beacon-chain/rpc/statefetcher/fetcher.go index d25265167076..6d730d93b3a0 100644 --- a/beacon-chain/rpc/statefetcher/fetcher.go +++ b/beacon-chain/rpc/statefetcher/fetcher.go @@ -193,7 +193,7 @@ func (p *StateProvider) StateRoot(ctx context.Context, stateId []byte) (root []b } func (p *StateProvider) stateByRoot(ctx context.Context, stateRoot []byte) (state.BeaconState, error) { - headState, err := p.ChainInfoFetcher.HeadState(ctx) + headState, err := p.ChainInfoFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, errors.Wrap(err, "could not get head state") } @@ -288,7 +288,7 @@ func (p *StateProvider) justifiedStateRoot(ctx context.Context) ([]byte, error) func (p *StateProvider) stateRootByRoot(ctx context.Context, stateRoot []byte) ([]byte, error) { var r [32]byte copy(r[:], stateRoot) - headState, err := p.ChainInfoFetcher.HeadState(ctx) + headState, err := p.ChainInfoFetcher.HeadStateReadOnly(ctx) if err != nil { return nil, errors.Wrap(err, "could not get head state") }