mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Remove redundant err checking (#7488)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
e91165b0b4
commit
f92244d497
@ -310,10 +310,7 @@ func (s *Service) finalizedImpliesNewJustified(ctx context.Context, state *state
|
||||
if !attestationutil.CheckPointIsEqual(s.justifiedCheckpt, state.CurrentJustifiedCheckpoint()) {
|
||||
if state.CurrentJustifiedCheckpoint().Epoch > s.justifiedCheckpt.Epoch {
|
||||
s.justifiedCheckpt = state.CurrentJustifiedCheckpoint()
|
||||
if err := s.cacheJustifiedStateBalances(ctx, bytesutil.ToBytes32(s.justifiedCheckpt.Root)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return s.cacheJustifiedStateBalances(ctx, bytesutil.ToBytes32(s.justifiedCheckpt.Root))
|
||||
}
|
||||
|
||||
// Update justified if store justified is not in chain with finalized check point.
|
||||
|
@ -330,11 +330,7 @@ func (s *Service) Stop() error {
|
||||
}
|
||||
|
||||
// Save initial sync cached blocks to the DB before stop.
|
||||
if err := s.beaconDB.SaveBlocks(s.ctx, s.getInitSyncBlocks()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return s.beaconDB.SaveBlocks(s.ctx, s.getInitSyncBlocks())
|
||||
}
|
||||
|
||||
// Status always returns nil unless there is an error condition that causes
|
||||
|
@ -371,14 +371,10 @@ func UpdateProposerIndicesInCache(state *stateTrie.BeaconState, epoch uint64) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := proposerIndicesCache.AddProposerIndices(&cache.ProposerIndices{
|
||||
return proposerIndicesCache.AddProposerIndices(&cache.ProposerIndices{
|
||||
BlockRoot: bytesutil.ToBytes32(r),
|
||||
ProposerIndices: proposerIndices,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// ClearCache clears the committee cache
|
||||
|
@ -95,11 +95,7 @@ func (s *Service) aggregateAndSaveForkChoiceAtts(atts []*ethpb.Attestation) erro
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.pool.SaveForkchoiceAttestations(aggregatedAtts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return s.pool.SaveForkchoiceAttestations(aggregatedAtts)
|
||||
}
|
||||
|
||||
// This checks if the attestation has previously been aggregated for fork choice
|
||||
|
@ -37,11 +37,8 @@ func (s *State) ForceCheckpoint(ctx context.Context, root []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.beaconDB.SaveState(ctx, fs, root32); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return s.beaconDB.SaveState(ctx, fs, root32)
|
||||
}
|
||||
|
||||
// SaveStateSummary saves the relevant state summary for a block and its corresponding state slot in the
|
||||
|
@ -295,11 +295,7 @@ func TestBlocksQueue_Loop(t *testing.T) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mc.ReceiveBlock(ctx, block, root); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return mc.ReceiveBlock(ctx, block, root)
|
||||
}
|
||||
|
||||
var blocks []*eth.SignedBeaconBlock
|
||||
|
@ -59,10 +59,7 @@ func (s *Service) sendGoodByeAndDisconnect(ctx context.Context, code uint64, id
|
||||
"peer": id,
|
||||
}).Debug("Could not send goodbye message to peer")
|
||||
}
|
||||
if err := s.p2p.Disconnect(id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return s.p2p.Disconnect(id)
|
||||
}
|
||||
|
||||
func (s *Service) sendGoodByeMessage(ctx context.Context, code uint64, id peer.ID) error {
|
||||
|
@ -271,12 +271,9 @@ func validateSelection(ctx context.Context, bs *stateTrie.BeaconState, data *eth
|
||||
return fmt.Errorf("validator is not an aggregator for slot %d", data.Slot)
|
||||
}
|
||||
|
||||
if err := helpers.ComputeDomainVerifySigningRoot(bs, validatorIndex,
|
||||
helpers.SlotToEpoch(data.Slot), data.Slot, params.BeaconConfig().DomainSelectionProof, proof); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
domain := params.BeaconConfig().DomainSelectionProof
|
||||
epoch := helpers.SlotToEpoch(data.Slot)
|
||||
return helpers.ComputeDomainVerifySigningRoot(bs, validatorIndex, epoch, data.Slot, domain, proof)
|
||||
}
|
||||
|
||||
// This verifies aggregator signature over the signed aggregate and proof object.
|
||||
|
@ -160,10 +160,7 @@ func WritePprofFiles(testDir string, index int) error {
|
||||
}
|
||||
url = fmt.Sprintf("http://127.0.0.1:%d/debug/pprof/profile", e2e.TestParams.BeaconNodeRPCPort+50+index)
|
||||
filePath = filepath.Join(testDir, fmt.Sprintf(cpuProfileFileName, index))
|
||||
if err := writeURLRespAtPath(url, filePath); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return writeURLRespAtPath(url, filePath)
|
||||
}
|
||||
|
||||
func writeURLRespAtPath(url string, filePath string) error {
|
||||
|
@ -161,10 +161,7 @@ func storeNewRandomKey(ks keyStore, password string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ks.StoreKey(ks.JoinPath(keyFileName(key.PublicKey)), key, password); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return ks.StoreKey(ks.JoinPath(keyFileName(key.PublicKey)), key, password)
|
||||
}
|
||||
|
||||
func writeKeyFile(file string, content []byte) error {
|
||||
|
@ -162,10 +162,7 @@ func (s *SpanDetector) UpdateSpans(ctx context.Context, att *ethpb.IndexedAttest
|
||||
if err := s.updateMinSpan(ctx, att); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.updateMaxSpan(ctx, att); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return s.updateMaxSpan(ctx, att)
|
||||
}
|
||||
|
||||
// saveSigBytes saves the first 2 bytes of the signature for the att we're updating the spans to.
|
||||
|
@ -155,8 +155,5 @@ func (s *Service) Status() error {
|
||||
if bs := s.beaconclient.Status(); bs != nil {
|
||||
return bs
|
||||
}
|
||||
if ds := s.detector.Status(); ds != nil {
|
||||
return ds
|
||||
}
|
||||
return nil
|
||||
return s.detector.Status()
|
||||
}
|
||||
|
@ -77,10 +77,7 @@ func generateGenesisBeaconState() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(*outputDir, benchutil.GenesisFileName), beaconBytes, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return ioutil.WriteFile(path.Join(*outputDir, benchutil.GenesisFileName), beaconBytes, 0644)
|
||||
}
|
||||
|
||||
func generateMarshalledFullStateAndBlock() error {
|
||||
@ -167,10 +164,8 @@ func generateMarshalledFullStateAndBlock() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(*outputDir, benchutil.FullBlockFileName), blockBytes, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
return ioutil.WriteFile(path.Join(*outputDir, benchutil.FullBlockFileName), blockBytes, 0644)
|
||||
}
|
||||
|
||||
func generate2FullEpochState() error {
|
||||
@ -204,10 +199,8 @@ func generate2FullEpochState() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(*outputDir, benchutil.BState2EpochFileName), beaconBytes, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
return ioutil.WriteFile(path.Join(*outputDir, benchutil.BState2EpochFileName), beaconBytes, 0644)
|
||||
}
|
||||
|
||||
func genesisBeaconState() (*stateTrie.BeaconState, error) {
|
||||
|
@ -201,11 +201,7 @@ func createSplitTargetStores(
|
||||
|
||||
if err := newStore.update(func(tx *bolt.Tx) error {
|
||||
attestationsBucket := tx.Bucket(historicAttestationsBucket)
|
||||
if err := addAttestations(attestationsBucket, pubKeyAttestations); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return addAttestations(attestationsBucket, pubKeyAttestations)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -51,10 +51,7 @@ func (store *Store) SaveProposalHistoryForSlot(ctx context.Context, pubKey []byt
|
||||
if err := valBucket.Put(bytesutil.Uint64ToBytesBigEndian(slot), signingRoot); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := pruneProposalHistoryBySlot(valBucket, slot); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return pruneProposalHistoryBySlot(valBucket, slot)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
@ -53,10 +53,7 @@ func (store *Store) SaveProposalHistoryForEpoch(ctx context.Context, pubKey []by
|
||||
if err := valBucket.Put(bytesutil.Bytes8(epoch), slotBits); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := pruneProposalHistory(valBucket, epoch); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return pruneProposalHistory(valBucket, epoch)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user