diff --git a/pkg/eth/api.go b/pkg/eth/api.go index 43d1811ba..f98d1afd9 100644 --- a/pkg/eth/api.go +++ b/pkg/eth/api.go @@ -37,7 +37,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/ethclient" - "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/statediff" @@ -157,6 +156,7 @@ func (pea *PublicEthAPI) BlockNumber() hexutil.Uint64 { // * When fullTx is true all transactions in the block are returned, otherwise // only the transaction hash is returned. func (pea *PublicEthAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { + logrus.Debug("Received getBlockByNumber request for number ", number.Int64()) block, err := pea.B.BlockByNumber(ctx, number) if block != nil && err == nil { return pea.rpcMarshalBlock(block, true, fullTx) @@ -1097,13 +1097,13 @@ func (pea *PublicEthAPI) writeStateDiffFor(blockHash common.Hash) { func (pea *PublicEthAPI) rpcMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) { fields, err := RPCMarshalBlock(b, inclTx, fullTx) if err != nil { - log.Error("error RPC marshalling block with hash", b.Hash().String(), err) + logrus.Error("error RPC marshalling block with hash", b.Hash().String(), err) return nil, err } if inclTx { td, err := pea.B.GetTd(b.Hash()) if err != nil { - log.Error("error getting td for block with hash", b.Hash().String(), err) + logrus.Error("error getting td for block with hash and number", b.Hash().String(), b.Number().String(), err) return nil, err } fields["totalDifficulty"] = (*hexutil.Big)(td) diff --git a/pkg/eth/cid_retriever.go b/pkg/eth/cid_retriever.go index 1c970d619..bab05da34 100644 --- a/pkg/eth/cid_retriever.go +++ b/pkg/eth/cid_retriever.go @@ -361,7 +361,7 @@ func receiptFilterConditions(id *int, pgStr string, args []interface{}, rctFilte // RetrieveFilteredGQLLogs retrieves and returns all the log CIDs provided blockHash that conform to the provided // filter parameters. func (ecr *CIDRetriever) RetrieveFilteredGQLLogs(tx *sqlx.Tx, rctFilter ReceiptFilter, blockHash *common.Hash) ([]LogResult, error) { - log.Debug("retrieving log cids for receipt ids") + log.Debug("retrieving log cids for receipt ids with block hash", blockHash.String()) args := make([]interface{}, 0, 4) id := 1 pgStr := `SELECT CAST(eth.log_cids.block_number as Text), eth.log_cids.leaf_cid, eth.log_cids.index, eth.log_cids.rct_id, @@ -722,6 +722,7 @@ func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockHash(blockHash common.Has err := ecr.gormDB.Preload("TransactionCIDs", func(tx *gorm.DB) *gorm.DB { return tx.Select("cid", "tx_hash", "index", "src", "dst", "header_id", "block_number") }).Joins("IPLD").Find(&headerCIDs, "block_hash = ?", blockHash.String()).Error + if err != nil { log.Error("header cid retrieval error") return HeaderCIDRecord{}, err diff --git a/pkg/graphql/graphql.go b/pkg/graphql/graphql.go index c414e9a93..9456fc825 100644 --- a/pkg/graphql/graphql.go +++ b/pkg/graphql/graphql.go @@ -23,6 +23,7 @@ import ( "database/sql" "errors" "fmt" + "strings" "time" "github.com/ethereum/go-ethereum/common" @@ -1268,10 +1269,12 @@ func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct { if args.Condition.BlockHash != nil { headerCID, err := r.backend.Retriever.RetrieveHeaderAndTxCIDsByBlockHash(common.HexToHash(*args.Condition.BlockHash)) if err != nil { - return nil, err + if !strings.Contains(err.Error(), "not found") { + return nil, err + } + } else { + headerCIDs = append(headerCIDs, headerCID) } - - headerCIDs = append(headerCIDs, headerCID) } else if args.Condition.BlockNumber != nil { headerCIDs, err = r.backend.Retriever.RetrieveHeaderAndTxCIDsByBlockNumber(args.Condition.BlockNumber.ToInt().Int64()) if err != nil {