Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant err checking #7488

Merged
merged 2 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions beacon-chain/blockchain/process_block_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions beacon-chain/blockchain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions beacon-chain/core/helpers/committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions beacon-chain/state/stategen/setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions beacon-chain/sync/initial-sync/blocks_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions beacon-chain/sync/rpc_goodbye.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions beacon-chain/sync/validate_aggregate_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions endtoend/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions shared/keystore/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions slasher/detection/attestations/spanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions slasher/rpc/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
17 changes: 5 additions & 12 deletions tools/benchmark-files-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 1 addition & 5 deletions validator/db/kv/manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 1 addition & 4 deletions validator/db/kv/new_proposal_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 1 addition & 4 deletions validator/db/kv/proposal_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down