From fbc8d7b1b33f96c38409b1e0d0411ffef68d91d3 Mon Sep 17 00:00:00 2001 From: sudeepdino008 Date: Tue, 17 Dec 2024 19:17:09 +0530 Subject: [PATCH 1/3] save --- .golangci.yml | 2 ++ cl/antiquary/beacon_states_collector.go | 4 ---- cl/beacon/handler/block_production.go | 2 +- cl/beacon/router.go | 4 +--- cl/persistence/beacon_indicies/indicies.go | 2 +- cl/persistence/blob_storage/blob_db.go | 2 +- .../historical_states_reader.go | 9 --------- cl/persistence/state/state_accessors.go | 2 +- cl/phase1/core/state/cache.go | 3 --- cl/phase1/core/state/cache_accessors.go | 3 --- .../execution_client/execution_client_rpc.go | 12 +++++------- cl/phase1/forkchoice/on_attestation.go | 7 ------- cl/phase1/network/gossip_manager.go | 2 +- .../services/sync_committee_messages_service.go | 5 +---- .../services/sync_contribution_service.go | 3 --- .../attestation_producer/attestation_producer.go | 4 ---- cmd/caplin/caplin1/run.go | 2 +- cmd/integration/commands/state_domains.go | 2 +- cmd/snapshots/cmp/cmp.go | 2 +- cmd/snapshots/copy/copy.go | 14 +++++++------- cmd/snapshots/manifest/manifest.go | 8 +++----- cmd/snapshots/torrents/torrents.go | 16 +++++----------- cmd/snapshots/verify/verify.go | 8 +++----- consensus/clique/verifier.go | 2 +- eth/gasprice/gasprice.go | 2 +- ethdb/privateapi/logsfilter.go | 2 +- ethstats/ethstats.go | 2 +- turbo/app/snapshots_cmd.go | 2 +- turbo/execution/eth1/ethereum_execution.go | 7 ------- turbo/execution/eth1/getters.go | 6 ------ turbo/jsonrpc/bor_snapshot.go | 2 +- turbo/jsonrpc/eth_api.go | 2 +- turbo/jsonrpc/tracing.go | 2 +- turbo/stages/headerdownload/header_algos.go | 2 +- turbo/stages/stageloop.go | 14 ++++++-------- 35 files changed, 50 insertions(+), 113 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 168bc592861..774128c38c4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -98,6 +98,8 @@ linters-settings: - fieldalignment - shadow - unsafeptr + enable: + - nilness goconst: min-len: 2 min-occurrences: 2 diff --git a/cl/antiquary/beacon_states_collector.go b/cl/antiquary/beacon_states_collector.go index 9ad867c2ee9..d78f4047ceb 100644 --- a/cl/antiquary/beacon_states_collector.go +++ b/cl/antiquary/beacon_states_collector.go @@ -107,7 +107,6 @@ func (i *beaconStatesCollector) addGenesisState(ctx context.Context, state *stat i.buf.Reset() i.compressor.Reset(i.buf) - var err error slot := state.Slot() epoch := slot / i.beaconCfg.SlotsPerEpoch // Setup state events handlers @@ -121,9 +120,6 @@ func (i *beaconStatesCollector) addGenesisState(ctx context.Context, state *stat events.AddValidator(uint64(index), v) return true }) - if err != nil { - return err - } roundedSlotToDump := slot - (slot % clparams.SlotsPerDump) if err := antiquateField(ctx, roundedSlotToDump, state.RawBalances(), i.buf, i.compressor, i.balancesDumpsCollector); err != nil { diff --git a/cl/beacon/handler/block_production.go b/cl/beacon/handler/block_production.go index bfc24b096e7..710fd009c4c 100644 --- a/cl/beacon/handler/block_production.go +++ b/cl/beacon/handler/block_production.go @@ -546,7 +546,7 @@ func (a *ApiHandler) getBuilderPayload( ethHeader.SetVersion(baseState.Version()) } // check kzg commitments - if header != nil && baseState.Version() >= clparams.DenebVersion { + if baseState.Version() >= clparams.DenebVersion { if header.Data.Message.BlobKzgCommitments.Len() >= cltypes.MaxBlobsCommittmentsPerBlock { return nil, fmt.Errorf("too many blob kzg commitments: %d", header.Data.Message.BlobKzgCommitments.Len()) } diff --git a/cl/beacon/router.go b/cl/beacon/router.go index da43116c618..a6c0e72d723 100644 --- a/cl/beacon/router.go +++ b/cl/beacon/router.go @@ -37,6 +37,7 @@ type LayeredBeaconHandler struct { func ListenAndServe(beaconHandler *LayeredBeaconHandler, routerCfg beacon_router_configuration.RouterConfiguration) error { listener, err := net.Listen(routerCfg.Protocol, routerCfg.Address) if err != nil { + log.Warn("[Beacon API] Failed to start listening", "addr", routerCfg.Address, "err", err) return err } defer listener.Close() @@ -72,9 +73,6 @@ func ListenAndServe(beaconHandler *LayeredBeaconHandler, routerCfg beacon_router IdleTimeout: routerCfg.IdleTimeout, WriteTimeout: routerCfg.WriteTimeout, } - if err != nil { - log.Warn("[Beacon API] Failed to start listening", "addr", routerCfg.Address, "err", err) - } if err := server.Serve(listener); err != nil { log.Warn("[Beacon API] failed to start serving", "addr", routerCfg.Address, "err", err) diff --git a/cl/persistence/beacon_indicies/indicies.go b/cl/persistence/beacon_indicies/indicies.go index ac25f94e6b1..c83fa08b211 100644 --- a/cl/persistence/beacon_indicies/indicies.go +++ b/cl/persistence/beacon_indicies/indicies.go @@ -253,7 +253,7 @@ func PruneSignedHeaders(tx kv.RwTx, from uint64) error { return err } for k, _, err := cursor.Seek(base_encoding.Encode64ToBytes4(from)); err == nil && k != nil; k, _, err = cursor.Prev() { - if err != nil { + if err != nil { //nolint:govet return err } if err := cursor.DeleteCurrent(); err != nil { diff --git a/cl/persistence/blob_storage/blob_db.go b/cl/persistence/blob_storage/blob_db.go index 51c8244da45..173d32e385d 100644 --- a/cl/persistence/blob_storage/blob_db.go +++ b/cl/persistence/blob_storage/blob_db.go @@ -265,7 +265,7 @@ func VerifyAgainstIdentifiersAndInsertIntoTheBlobStore(ctx context.Context, stor } if verifySignatureFn != nil { // verify the signature of the sidecar head, we leave this step up to the caller to define - if verifySignatureFn(sidecar.SignedBlockHeader); err != nil { + if err = verifySignatureFn(sidecar.SignedBlockHeader); err != nil { return 0, 0, err } } diff --git a/cl/persistence/state/historical_states_reader/historical_states_reader.go b/cl/persistence/state/historical_states_reader/historical_states_reader.go index a2536572f2b..f193ed2cda9 100644 --- a/cl/persistence/state/historical_states_reader/historical_states_reader.go +++ b/cl/persistence/state/historical_states_reader/historical_states_reader.go @@ -749,9 +749,6 @@ func (r *HistoricalStatesReader) readPendingEpochs(tx kv.Tx, slot uint64) (*soli } return true }) - if err != nil { - return nil, nil, err - } } return currentEpochAttestations, previousEpochAttestations, nil } @@ -789,9 +786,6 @@ func (r *HistoricalStatesReader) ReadParticipations(tx kv.Tx, kvGetter state_acc currentIdxs := solid.NewParticipationBitList(int(validatorLength), int(r.cfg.ValidatorRegistryLimit)) previousIdxs := solid.NewParticipationBitList(int(validatorLength), int(r.cfg.ValidatorRegistryLimit)) - if err != nil { - return nil, nil, err - } // Read the previous idxs for i := beginSlot; i <= slot; i++ { @@ -864,9 +858,6 @@ func (r *HistoricalStatesReader) ReadParticipations(tx kv.Tx, kvGetter state_acc } return true }) - if err != nil { - return nil, nil, err - } } return currentIdxs, previousIdxs, nil } diff --git a/cl/persistence/state/state_accessors.go b/cl/persistence/state/state_accessors.go index 143cf1189b4..3340f9425c7 100644 --- a/cl/persistence/state/state_accessors.go +++ b/cl/persistence/state/state_accessors.go @@ -151,7 +151,7 @@ func ReadValidatorsTable(tx kv.Tx, out *StaticValidatorTable) error { } out.validatorTable = append(out.validatorTable, staticValidator) } - if err != nil { + if err != nil { //nolint:govet return err } slot, err := GetStateProcessingProgress(tx) diff --git a/cl/phase1/core/state/cache.go b/cl/phase1/core/state/cache.go index 169c7ec18f3..a04090888c7 100644 --- a/cl/phase1/core/state/cache.go +++ b/cl/phase1/core/state/cache.go @@ -178,9 +178,6 @@ func (b *CachingBeaconState) _initializeValidatorsPhase0() error { if err != nil { return err } - if err != nil { - return err - } attestation := &solid.Attestation{ AggregationBits: pa.AggregationBits, Data: attestationData, diff --git a/cl/phase1/core/state/cache_accessors.go b/cl/phase1/core/state/cache_accessors.go index aa7880a8784..b9cb03bb42b 100644 --- a/cl/phase1/core/state/cache_accessors.go +++ b/cl/phase1/core/state/cache_accessors.go @@ -188,9 +188,6 @@ func (b *CachingBeaconState) BaseReward(index uint64) (uint64, error) { // It grabs values from cache as needed func (b *CachingBeaconState) SyncRewards() (proposerReward, participantReward uint64, err error) { activeBalance := b.GetTotalActiveBalance() - if err != nil { - return 0, 0, err - } totalActiveIncrements := activeBalance / b.BeaconConfig().EffectiveBalanceIncrement baseRewardPerInc := b.BaseRewardPerIncrement() totalBaseRewards := baseRewardPerInc * totalActiveIncrements diff --git a/cl/phase1/execution_client/execution_client_rpc.go b/cl/phase1/execution_client/execution_client_rpc.go index 486eacf04d9..87574f52acb 100644 --- a/cl/phase1/execution_client/execution_client_rpc.go +++ b/cl/phase1/execution_client/execution_client_rpc.go @@ -169,15 +169,13 @@ func (cc *ExecutionClientRpc) ForkChoiceUpdate(ctx context.Context, finalized li err := cc.client.CallContext(ctx, forkChoiceResp, rpc_helper.ForkChoiceUpdatedV1, args...) if err != nil { + if err.Error() == errContextExceeded { + // ignore timeouts + return nil, nil + } return nil, fmt.Errorf("execution Client RPC failed to retrieve ForkChoiceUpdate response, err: %w", err) } - // Ignore timeouts - if err != nil && err.Error() == errContextExceeded { - return nil, nil - } - if err != nil { - return nil, err - } + if forkChoiceResp.PayloadId == nil { return []byte{}, checkPayloadStatus(forkChoiceResp.PayloadStatus) } diff --git a/cl/phase1/forkchoice/on_attestation.go b/cl/phase1/forkchoice/on_attestation.go index deeb757442a..65ede2792a5 100644 --- a/cl/phase1/forkchoice/on_attestation.go +++ b/cl/phase1/forkchoice/on_attestation.go @@ -116,10 +116,6 @@ func (f *ForkChoiceStore) verifyAttestationWithCheckpointState( } if !fromBlock { indexedAttestation := state.GetIndexedAttestation(attestation, attestationIndicies) - if err != nil { - return nil, err - } - valid, err := targetState.isValidIndexedAttestation(indexedAttestation) if err != nil { return nil, err @@ -142,9 +138,6 @@ func (f *ForkChoiceStore) verifyAttestationWithState( } if !fromBlock { indexedAttestation := state.GetIndexedAttestation(attestation, attestationIndicies) - if err != nil { - return nil, err - } valid, err := state.IsValidIndexedAttestation(s, indexedAttestation) if err != nil { return nil, err diff --git a/cl/phase1/network/gossip_manager.go b/cl/phase1/network/gossip_manager.go index b370de6ff78..1955f27e89c 100644 --- a/cl/phase1/network/gossip_manager.go +++ b/cl/phase1/network/gossip_manager.go @@ -131,7 +131,7 @@ func (g *GossipManager) onRecv(ctx context.Context, data *sentinel.GossipData, l if errors.Is(err, services.ErrIgnore) || errors.Is(err, synced_data.ErrNotSynced) { return nil } - if err != nil { + if err != nil { //nolint:govet g.sentinel.BanPeer(ctx, data.Peer) return err } diff --git a/cl/phase1/network/services/sync_committee_messages_service.go b/cl/phase1/network/services/sync_committee_messages_service.go index 9af0269cc93..83c7c224c57 100644 --- a/cl/phase1/network/services/sync_committee_messages_service.go +++ b/cl/phase1/network/services/sync_committee_messages_service.go @@ -160,9 +160,6 @@ func verifySyncCommitteeMessageSignature(s *state.CachingBeaconState, msg *cltyp if err != nil { return nil, nil, nil, err } - signingRoot, err := utils.Sha256(msg.BeaconBlockRoot[:], domain), nil - if err != nil { - return nil, nil, nil, err - } + signingRoot := utils.Sha256(msg.BeaconBlockRoot[:], domain) return msg.Signature[:], signingRoot[:], publicKey[:], nil } diff --git a/cl/phase1/network/services/sync_contribution_service.go b/cl/phase1/network/services/sync_contribution_service.go index a0799c4f568..27da98964e1 100644 --- a/cl/phase1/network/services/sync_contribution_service.go +++ b/cl/phase1/network/services/sync_contribution_service.go @@ -285,9 +285,6 @@ func verifySyncContributionProofAggregatedSignature(s *state.CachingBeaconState, } msg := utils.Sha256(contribution.BeaconBlockRoot[:], domain) - if err != nil { - return nil, nil, nil, err - } // only use the ones pertaining to the aggregation bits subCommitteePubsKeys := make([][]byte, 0, len(subCommitteeKeys)) for i, key := range subCommitteeKeys { diff --git a/cl/validator/attestation_producer/attestation_producer.go b/cl/validator/attestation_producer/attestation_producer.go index 4f16a6db3fa..0e277f06e72 100644 --- a/cl/validator/attestation_producer/attestation_producer.go +++ b/cl/validator/attestation_producer/attestation_producer.go @@ -183,10 +183,6 @@ func (ap *attestationProducer) ProduceAndCacheAttestationData(tx kv.Tx, baseStat log.Warn("Failed to process slots", "slot", slot, "err", err) return solid.AttestationData{}, err } - if err != nil { - return solid.AttestationData{}, err - } - } targetCheckpoint, err := ap.computeTargetCheckpoint(tx, baseState, baseStateBlockRoot, slot) diff --git a/cmd/caplin/caplin1/run.go b/cmd/caplin/caplin1/run.go index 99877a288a2..81d4cbd331a 100644 --- a/cmd/caplin/caplin1/run.go +++ b/cmd/caplin/caplin1/run.go @@ -165,7 +165,7 @@ func RunCaplinService(ctx context.Context, engine execution_client.ExecutionEngi } genesisState = state.New(beaconConfig) - if genesisState.DecodeSSZ(stateBytes, int(beaconConfig.GetCurrentStateVersion(beaconConfig.GenesisEpoch))); err != nil { + if err := genesisState.DecodeSSZ(stateBytes, int(beaconConfig.GetCurrentStateVersion(beaconConfig.GenesisEpoch))); err != nil { return fmt.Errorf("could not decode genesis state: %s", err) } } else { diff --git a/cmd/integration/commands/state_domains.go b/cmd/integration/commands/state_domains.go index 6ca2ecfbea1..e754165af75 100644 --- a/cmd/integration/commands/state_domains.go +++ b/cmd/integration/commands/state_domains.go @@ -139,7 +139,7 @@ func requestDomains(chainDb, stateDb kv.RwDB, ctx context.Context, readDomain st defer agg.Close() r := state.NewReaderV3(domains) - if err != nil && startTxNum != 0 { + if startTxNum != 0 { return fmt.Errorf("failed to seek commitment to txn %d: %w", startTxNum, err) } latestTx := domains.TxNum() diff --git a/cmd/snapshots/cmp/cmp.go b/cmd/snapshots/cmp/cmp.go index 4ccbc6057f1..31918ea56ef 100644 --- a/cmd/snapshots/cmp/cmp.go +++ b/cmd/snapshots/cmp/cmp.go @@ -225,7 +225,7 @@ func cmp(cliCtx *cli.Context) error { return errors.New("no first session established") } - if session1 == nil { + if session2 == nil { return errors.New("no second session established") } diff --git a/cmd/snapshots/copy/copy.go b/cmd/snapshots/copy/copy.go index 2ddedb6ec38..4c632ada244 100644 --- a/cmd/snapshots/copy/copy.go +++ b/cmd/snapshots/copy/copy.go @@ -124,12 +124,12 @@ func copy(cliCtx *cli.Context) error { pos++ } - switch dst.LType { + switch dst.LType { //nolint:govet case sync.TorrentFs: return errors.New("can't copy to torrent - need intermediate local fs") case sync.RemoteFs: - if rcCli == nil { + if rcCli == nil { //nolint:govet rcCli, err = downloader.NewRCloneClient(logger) if err != nil { @@ -144,7 +144,7 @@ func copy(cliCtx *cli.Context) error { switch src.LType { case sync.TorrentFs: - config := sync.NewTorrentClientConfigFromCobra(cliCtx, dst.Chain) + config := sync.NewTorrentClientConfigFromCobra(cliCtx, dst.Chain) //nolint:govet torrentCli, err = sync.NewTorrentClient(cliCtx.Context, config) if err != nil { return fmt.Errorf("can't create torrent: %w", err) @@ -186,7 +186,7 @@ func copy(cliCtx *cli.Context) error { version := cliCtx.Int(VersionFlag.Name) if version != 0 { - dst.Version = snaptype.Version(version) + dst.Version = snaptype.Version(version) //nolint:govet } if cliCtx.Args().Len() > pos { @@ -205,7 +205,7 @@ func copy(cliCtx *cli.Context) error { switch src.LType { case sync.LocalFs: - switch dst.LType { + switch dst.LType { //nolint:govet case sync.LocalFs: return localToLocal(src, dst, firstBlock, lastBlock, snapTypes, torrents, hashes, manifest) case sync.RemoteFs: @@ -215,7 +215,7 @@ func copy(cliCtx *cli.Context) error { } case sync.RemoteFs: - switch dst.LType { + switch dst.LType { //nolint:govet case sync.LocalFs: return remoteToLocal(cliCtx.Context, rcCli, src, dst, firstBlock, lastBlock, snapTypes, torrents, hashes, manifest) case sync.RemoteFs: @@ -225,7 +225,7 @@ func copy(cliCtx *cli.Context) error { } case sync.TorrentFs: - switch dst.LType { + switch dst.LType { //nolint:govet case sync.LocalFs: return torrentToLocal(torrentCli, src, dst, firstBlock, lastBlock, snapTypes, torrents, hashes, manifest) case sync.RemoteFs: diff --git a/cmd/snapshots/manifest/manifest.go b/cmd/snapshots/manifest/manifest.go index 617b442a19b..540c8c3a52d 100644 --- a/cmd/snapshots/manifest/manifest.go +++ b/cmd/snapshots/manifest/manifest.go @@ -111,12 +111,10 @@ func manifest(cliCtx *cli.Context, command string) error { switch src.LType { case sync.RemoteFs: - if rcCli == nil { - rcCli, err = downloader.NewRCloneClient(logger) + rcCli, err = downloader.NewRCloneClient(logger) - if err != nil { - return err - } + if err != nil { + return err } if err = sync.CheckRemote(rcCli, src.Src); err != nil { diff --git a/cmd/snapshots/torrents/torrents.go b/cmd/snapshots/torrents/torrents.go index 49e20614fa8..f1b93ace28b 100644 --- a/cmd/snapshots/torrents/torrents.go +++ b/cmd/snapshots/torrents/torrents.go @@ -111,10 +111,6 @@ func torrents(cliCtx *cli.Context, command string) error { if src, err = sync.ParseLocator(cliCtx.Args().Get(pos)); err != nil { return err } - - if err != nil { - return err - } } pos++ @@ -144,12 +140,10 @@ func torrents(cliCtx *cli.Context, command string) error { switch src.LType { case sync.RemoteFs: - if rcCli == nil { - rcCli, err = downloader.NewRCloneClient(logger) + rcCli, err = downloader.NewRCloneClient(logger) - if err != nil { - return err - } + if err != nil { + return err } if err = sync.CheckRemote(rcCli, src.Src); err != nil { @@ -178,7 +172,7 @@ func torrents(cliCtx *cli.Context, command string) error { } if rcCli != nil { - if src != nil && src.LType == sync.RemoteFs { + if src.LType == sync.RemoteFs { ctx := cliCtx.Context // avoiding sonar dup complaint srcSession, err = rcCli.NewSession(ctx, filepath.Join(tempDir, "src"), src.Src+":"+src.Root, nil) @@ -188,7 +182,7 @@ func torrents(cliCtx *cli.Context, command string) error { } } - if src != nil && srcSession == nil { + if srcSession == nil { return errors.New("no src session established") } diff --git a/cmd/snapshots/verify/verify.go b/cmd/snapshots/verify/verify.go index 15ef7ebc735..95ef16ce9d2 100644 --- a/cmd/snapshots/verify/verify.go +++ b/cmd/snapshots/verify/verify.go @@ -124,12 +124,10 @@ func verify(cliCtx *cli.Context) error { } case sync.RemoteFs: - if rcCli == nil { - rcCli, err = downloader.NewRCloneClient(logger) + rcCli, err = downloader.NewRCloneClient(logger) - if err != nil { - return err - } + if err != nil { + return err } if err = sync.CheckRemote(rcCli, src.Src); err != nil { diff --git a/consensus/clique/verifier.go b/consensus/clique/verifier.go index fd2c300c3f1..59bb88af6ef 100644 --- a/consensus/clique/verifier.go +++ b/consensus/clique/verifier.go @@ -176,7 +176,7 @@ func (c *Clique) Snapshot(chain consensus.ChainHeaderReader, number uint64, hash headers []*types.Header snap *Snapshot ) - for snap == nil { + for snap == nil { //nolint:govet // If an in-memory snapshot was found, use that if s, ok := c.recents.Get(hash); ok { snap = s diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index b091b2a9dc4..47133618cae 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -261,7 +261,7 @@ func (oracle *Oracle) getBlockPrices(ctx context.Context, blockNum uint64, limit continue } sender, _ := tx.GetSender() - if err == nil && sender != block.Coinbase() { + if sender != block.Coinbase() { heap.Push(s, tip) count = count + 1 } diff --git a/ethdb/privateapi/logsfilter.go b/ethdb/privateapi/logsfilter.go index a791ac60439..2cdac94385e 100644 --- a/ethdb/privateapi/logsfilter.go +++ b/ethdb/privateapi/logsfilter.go @@ -149,7 +149,7 @@ func (a *LogsFilterAggregator) subscribeLogs(server remote.ETHBACKEND_SubscribeL for filterReq, recvErr = server.Recv(); recvErr == nil; filterReq, recvErr = server.Recv() { a.updateLogsFilter(filter, filterReq) } - if recvErr != nil && recvErr != io.EOF { // termination + if recvErr != io.EOF { // termination return fmt.Errorf("receiving log filter request: %w", recvErr) } return nil diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 8f8cd85f049..eb5ebb51ab4 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -207,7 +207,7 @@ func (s *Service) loop() { break } } - if err != nil || conn == nil { + if conn == nil { log.Warn("Stats server unreachable") errTimer.Reset(10 * time.Second) continue diff --git a/turbo/app/snapshots_cmd.go b/turbo/app/snapshots_cmd.go index 68100116297..72269b57514 100644 --- a/turbo/app/snapshots_cmd.go +++ b/turbo/app/snapshots_cmd.go @@ -1254,7 +1254,7 @@ func doCompress(cliCtx *cli.Context) error { default: } } - if err != nil && !errors.Is(err, io.EOF) { + if !errors.Is(err, io.EOF) { return err } if err := c.Compress(); err != nil { diff --git a/turbo/execution/eth1/ethereum_execution.go b/turbo/execution/eth1/ethereum_execution.go index 6e6c56745ca..6b89e2981c5 100644 --- a/turbo/execution/eth1/ethereum_execution.go +++ b/turbo/execution/eth1/ethereum_execution.go @@ -19,7 +19,6 @@ package eth1 import ( "context" "errors" - "fmt" "math/big" "sync/atomic" @@ -167,12 +166,6 @@ func (e *EthereumExecutionModule) unwindToCommonCanonical(tx kv.RwTx, header *ty currentHeader := header for isCanonical, err := e.isCanonicalHash(e.bacgroundCtx, tx, currentHeader.Hash()); !isCanonical && err == nil; isCanonical, err = e.isCanonicalHash(e.bacgroundCtx, tx, currentHeader.Hash()) { - if err != nil { - return err - } - if currentHeader == nil { - return fmt.Errorf("header %v not found", currentHeader.Hash()) - } currentHeader, err = e.getHeader(e.bacgroundCtx, tx, currentHeader.ParentHash, currentHeader.Number.Uint64()-1) if err != nil { return err diff --git a/turbo/execution/eth1/getters.go b/turbo/execution/eth1/getters.go index ffd9b008a78..d5758009723 100644 --- a/turbo/execution/eth1/getters.go +++ b/turbo/execution/eth1/getters.go @@ -155,9 +155,6 @@ func (e *EthereumExecutionModule) GetBodiesByHashes(ctx context.Context, req *ex return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByHashes: MarshalTransactionsBinary error %w", err) } - if err != nil { - return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByHashes: MarshalRequestsBinary error %w", err) - } bodies = append(bodies, &execution.BlockBody{ Transactions: txs, Withdrawals: eth1_utils.ConvertWithdrawalsToRpc(body.Withdrawals), @@ -201,9 +198,6 @@ func (e *EthereumExecutionModule) GetBodiesByRange(ctx context.Context, req *exe return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByRange: MarshalTransactionsBinary error %w", err) } - if err != nil { - return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByHashes: MarshalRequestsBinary error %w", err) - } bodies = append(bodies, &execution.BlockBody{ Transactions: txs, Withdrawals: eth1_utils.ConvertWithdrawalsToRpc(body.Withdrawals), diff --git a/turbo/jsonrpc/bor_snapshot.go b/turbo/jsonrpc/bor_snapshot.go index 3c71a2344ab..7183356259d 100644 --- a/turbo/jsonrpc/bor_snapshot.go +++ b/turbo/jsonrpc/bor_snapshot.go @@ -656,7 +656,7 @@ func snapshot(ctx context.Context, api *BorImpl, db kv.Tx, borDb kv.Tx, header * number := header.Number.Uint64() hash := header.Hash() - for snap == nil { + for snap == nil { //nolint:govet // If an on-disk checkpoint snapshot can be found, use that if number%checkpointInterval == 0 { if s, err := loadSnapshot(api, db, borDb, hash); err == nil { diff --git a/turbo/jsonrpc/eth_api.go b/turbo/jsonrpc/eth_api.go index 8190588c2aa..5b27ad313c1 100644 --- a/turbo/jsonrpc/eth_api.go +++ b/turbo/jsonrpc/eth_api.go @@ -270,7 +270,7 @@ func (api *BaseAPI) chainConfigWithGenesis(ctx context.Context, tx kv.Tx) (*chai if err != nil { return nil, nil, err } - if cc != nil && genesisBlock != nil { + if cc != nil { api._genesis.Store(genesisBlock) api._chainConfig.Store(cc) } diff --git a/turbo/jsonrpc/tracing.go b/turbo/jsonrpc/tracing.go index b5735979e09..c368dbcecf3 100644 --- a/turbo/jsonrpc/tracing.go +++ b/turbo/jsonrpc/tracing.go @@ -412,7 +412,7 @@ func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallA } var baseFee *uint256.Int - if header != nil && header.BaseFee != nil { + if header.BaseFee != nil { var overflow bool baseFee, overflow = uint256.FromBig(header.BaseFee) if overflow { diff --git a/turbo/stages/headerdownload/header_algos.go b/turbo/stages/headerdownload/header_algos.go index 219f73de9d7..7bc99c39788 100644 --- a/turbo/stages/headerdownload/header_algos.go +++ b/turbo/stages/headerdownload/header_algos.go @@ -432,7 +432,7 @@ func (hd *HeaderDownload) RequestMoreHeaders(currentTime time.Time) (*HeaderRequ func (hd *HeaderDownload) requestMoreHeadersForPOS(currentTime time.Time) (timeout bool, request *HeaderRequest, penalties []PenaltyItem) { anchor := hd.posAnchor if anchor == nil { - dataflow.HeaderDownloadStates.AddChange(anchor.blockHeight-1, dataflow.HeaderEmpty) + //dataflow.HeaderDownloadStates.AddChange(anchor.blockHeight-1, dataflow.HeaderEmpty) hd.logger.Debug("[downloader] No PoS anchor") return } diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index 38bc7de55d6..acbb47371f3 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -75,15 +75,13 @@ func StageLoop( defer close(waitForDone) if err := ProcessFrozenBlocks(ctx, db, blockReader, sync, hook); err != nil { - if err != nil { - if errors.Is(err, libcommon.ErrStopped) || errors.Is(err, context.Canceled) { - return - } + if errors.Is(err, libcommon.ErrStopped) || errors.Is(err, context.Canceled) { + return + } - logger.Error("Staged Sync", "err", err) - if recoveryErr := hd.RecoverFromDb(db); recoveryErr != nil { - logger.Error("Failed to recover header sentriesClient", "err", recoveryErr) - } + logger.Error("Staged Sync", "err", err) + if recoveryErr := hd.RecoverFromDb(db); recoveryErr != nil { + logger.Error("Failed to recover header sentriesClient", "err", recoveryErr) } } From 852d3ada0c58f4f53f6b079a59e75294186d1421 Mon Sep 17 00:00:00 2001 From: sudeepdino008 Date: Tue, 17 Dec 2024 19:19:06 +0530 Subject: [PATCH 2/3] save --- cl/beacon/handler/states.go | 4 ---- cmd/caplin/main.go | 4 ---- 2 files changed, 8 deletions(-) diff --git a/cl/beacon/handler/states.go b/cl/beacon/handler/states.go index b63deedd626..ac1779a6ff9 100644 --- a/cl/beacon/handler/states.go +++ b/cl/beacon/handler/states.go @@ -256,10 +256,6 @@ func (a *ApiHandler) getFinalityCheckpoints(w http.ResponseWriter, r *http.Reque } finalizedCheckpoint, currentJustifiedCheckpoint, previousJustifiedCheckpoint, ok := a.forkchoiceStore.GetFinalityCheckpoints(blockRoot) - if err != nil { - return nil, beaconhttp.NewEndpointError(http.StatusBadRequest, err) - } - snRoTx := a.caplinStateSnapshots.View() defer snRoTx.Close() diff --git a/cmd/caplin/main.go b/cmd/caplin/main.go index 7c6fe7d2ce2..2f1a10c0c23 100644 --- a/cmd/caplin/main.go +++ b/cmd/caplin/main.go @@ -87,10 +87,6 @@ func runCaplinNode(cliCtx *cli.Context) error { ctx, cn := context.WithCancel(cliCtx.Context) defer cn() - if err != nil { - log.Error("[Checkpoint Sync] Failed", "reason", err) - return err - } var executionEngine execution_client2.ExecutionEngine if cfg.RunEngineAPI { cc, err := execution_client2.NewExecutionClientRPC(cfg.JwtSecret, cfg.EngineAPIAddr, cfg.EngineAPIPort) From 80a046a42b1cc8ebfbcc75abf9ff915e55f166f2 Mon Sep 17 00:00:00 2001 From: sudeepdino008 Date: Tue, 17 Dec 2024 20:00:46 +0530 Subject: [PATCH 3/3] save --- cl/persistence/blob_storage/blob_db.go | 2 +- turbo/execution/eth1/ethereum_execution.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cl/persistence/blob_storage/blob_db.go b/cl/persistence/blob_storage/blob_db.go index 173d32e385d..0377bde4d7a 100644 --- a/cl/persistence/blob_storage/blob_db.go +++ b/cl/persistence/blob_storage/blob_db.go @@ -265,7 +265,7 @@ func VerifyAgainstIdentifiersAndInsertIntoTheBlobStore(ctx context.Context, stor } if verifySignatureFn != nil { // verify the signature of the sidecar head, we leave this step up to the caller to define - if err = verifySignatureFn(sidecar.SignedBlockHeader); err != nil { + if err := verifySignatureFn(sidecar.SignedBlockHeader); err != nil { return 0, 0, err } } diff --git a/turbo/execution/eth1/ethereum_execution.go b/turbo/execution/eth1/ethereum_execution.go index 6b89e2981c5..f2019dfbefb 100644 --- a/turbo/execution/eth1/ethereum_execution.go +++ b/turbo/execution/eth1/ethereum_execution.go @@ -19,6 +19,7 @@ package eth1 import ( "context" "errors" + "fmt" "math/big" "sync/atomic" @@ -170,6 +171,9 @@ func (e *EthereumExecutionModule) unwindToCommonCanonical(tx kv.RwTx, header *ty if err != nil { return err } + if currentHeader == nil { + return fmt.Errorf("header %v not found", currentHeader.Hash()) + } } if err := e.hook.BeforeRun(tx, true); err != nil { return err