From e2f80a85e0fae5b85b8d0ede372cad328e8593ce Mon Sep 17 00:00:00 2001 From: Jerry Date: Thu, 19 Jan 2023 18:15:32 -0800 Subject: [PATCH 01/11] Increase grpc message size limit in pprof --- internal/cli/debug_pprof.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cli/debug_pprof.go b/internal/cli/debug_pprof.go index 01698719e5..4cbe989408 100644 --- a/internal/cli/debug_pprof.go +++ b/internal/cli/debug_pprof.go @@ -7,6 +7,7 @@ import ( "fmt" "strings" + "google.golang.org/grpc" empty "google.golang.org/protobuf/types/known/emptypb" "github.com/ethereum/go-ethereum/internal/cli/flagset" @@ -103,7 +104,7 @@ func (d *DebugPprofCommand) Run(args []string) int { req.Profile = profile } - stream, err := clt.DebugPprof(ctx, req) + stream, err := clt.DebugPprof(ctx, req, grpc.MaxCallRecvMsgSize(1024*1024*1024)) if err != nil { return err From c450f29678e663c516b82a9ac20522cc4f0815f1 Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Wed, 25 Jan 2023 17:39:28 +0530 Subject: [PATCH 02/11] ReadBorReceipts improvements --- core/blockchain.go | 2 +- core/bor_blockchain.go | 2 +- core/rawdb/bor_receipt.go | 24 ++++++++++++------------ eth/filters/test_backend.go | 2 +- eth/tracers/api.go | 2 +- internal/ethapi/api.go | 16 ++++++++-------- params/config.go | 4 ++++ 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 74fd4bfeda..cbcf02fef4 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2059,7 +2059,7 @@ func (bc *BlockChain) collectLogs(hash common.Hash, removed bool) []*types.Log { receipts := rawdb.ReadReceipts(bc.db, hash, *number, bc.chainConfig) // Append bor receipt - borReceipt := rawdb.ReadBorReceipt(bc.db, hash, *number) + borReceipt := rawdb.ReadBorReceipt(bc.db, hash, *number, bc.chainConfig) if borReceipt != nil { receipts = append(receipts, borReceipt) } diff --git a/core/bor_blockchain.go b/core/bor_blockchain.go index ae2cdf3c6f..49973421bd 100644 --- a/core/bor_blockchain.go +++ b/core/bor_blockchain.go @@ -19,7 +19,7 @@ func (bc *BlockChain) GetBorReceiptByHash(hash common.Hash) *types.Receipt { } // read bor reciept by hash and number - receipt := rawdb.ReadBorReceipt(bc.db, hash, *number) + receipt := rawdb.ReadBorReceipt(bc.db, hash, *number, bc.chainConfig) if receipt == nil { return nil } diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index e225083741..535b48ee48 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" ) @@ -52,15 +53,9 @@ func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.Raw // First try to look up the data in ancient database. Extra hash // comparison is necessary since ancient database only maintains // the canonical data. - data, _ := db.Ancient(freezerBorReceiptTable, number) - if len(data) > 0 { - h, _ := db.Ancient(freezerHashTable, number) - if common.BytesToHash(h) == hash { - return data - } - } - // Then try to look up the data in leveldb. - data, _ = db.Get(borReceiptKey(number, hash)) + + // Look up the data in leveldb. + data, _ := db.Get(borReceiptKey(number, hash)) if len(data) > 0 { return data } @@ -101,7 +96,12 @@ func ReadRawBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types. // ReadBorReceipt retrieves all the bor block receipts belonging to a block, including // its correspoinding metadata fields. If it is unable to populate these metadata // fields then nil is returned. -func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types.Receipt { +func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64, config *params.ChainConfig) *types.Receipt { + + if config != nil && !config.Bor.IsSprintStart(number, config.Bor.CalculateSprint(number)) { + return nil + } + // We're deriving many fields from the block body, retrieve beside the receipt borReceipt := ReadRawBorReceipt(db, hash, number) if borReceipt == nil { @@ -114,8 +114,8 @@ func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types.Rec return nil } - body := ReadBody(db, hash, number) - if body == nil { + body := HasBody(db, hash, number) + if !body { log.Error("Missing body but have bor receipt", "hash", hash, "number", number) return nil } diff --git a/eth/filters/test_backend.go b/eth/filters/test_backend.go index 979ed3efb6..8b2ef4a7f2 100644 --- a/eth/filters/test_backend.go +++ b/eth/filters/test_backend.go @@ -38,7 +38,7 @@ func (b *TestBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) return &types.Receipt{}, nil } - receipt := rawdb.ReadBorReceipt(b.DB, hash, *number) + receipt := rawdb.ReadBorReceipt(b.DB, hash, *number, nil) if receipt == nil { return &types.Receipt{}, nil } diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 3fce91ac9c..13f5c627cd 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -177,7 +177,7 @@ func (api *API) getAllBlockTransactions(ctx context.Context, block *types.Block) stateSyncPresent := false - borReceipt := rawdb.ReadBorReceipt(api.backend.ChainDb(), block.Hash(), block.NumberU64()) + borReceipt := rawdb.ReadBorReceipt(api.backend.ChainDb(), block.Hash(), block.NumberU64(), api.backend.ChainConfig()) if borReceipt != nil { txHash := types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash())) if txHash != (common.Hash{}) { diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 372d630c07..fa07dcf419 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -636,7 +636,7 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, var txHash common.Hash - borReceipt := rawdb.ReadBorReceipt(s.b.ChainDb(), block.Hash(), block.NumberU64()) + borReceipt := rawdb.ReadBorReceipt(s.b.ChainDb(), block.Hash(), block.NumberU64(), s.b.ChainConfig()) if borReceipt != nil { receipts = append(receipts, borReceipt) txHash = types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash())) @@ -1453,7 +1453,11 @@ func newRPCPendingTransaction(tx *types.Transaction, current *types.Header, conf func newRPCTransactionFromBlockIndex(b *types.Block, index uint64, config *params.ChainConfig, db ethdb.Database) *RPCTransaction { txs := b.Transactions() - borReceipt := rawdb.ReadBorReceipt(db, b.Hash(), b.NumberU64()) + if index >= uint64(len(txs)+1) { + return nil + } + + borReceipt := rawdb.ReadBorReceipt(db, b.Hash(), b.NumberU64(), config) if borReceipt != nil { tx, _, _, _ := rawdb.ReadBorTransaction(db, borReceipt.TxHash) @@ -1461,10 +1465,6 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64, config *param txs = append(txs, tx) } } - - if index >= uint64(len(txs)) { - return nil - } return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index, b.BaseFee(), config) } @@ -1602,7 +1602,7 @@ func (api *PublicTransactionPoolAPI) getAllBlockTransactions(ctx context.Context stateSyncPresent := false - borReceipt := rawdb.ReadBorReceipt(api.b.ChainDb(), block.Hash(), block.NumberU64()) + borReceipt := rawdb.ReadBorReceipt(api.b.ChainDb(), block.Hash(), block.NumberU64(), api.b.ChainConfig()) if borReceipt != nil { txHash := types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash())) if txHash != (common.Hash{}) { @@ -1772,7 +1772,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha if borTx { // Fetch bor block receipt - receipt = rawdb.ReadBorReceipt(s.b.ChainDb(), blockHash, blockNumber) + receipt = rawdb.ReadBorReceipt(s.b.ChainDb(), blockHash, blockNumber, s.b.ChainConfig()) } else { receipts, err := s.b.GetReceipts(ctx, blockHash) if err != nil { diff --git a/params/config.go b/params/config.go index 94729224bb..f410f772fd 100644 --- a/params/config.go +++ b/params/config.go @@ -617,6 +617,10 @@ func (c *BorConfig) IsDelhi(number *big.Int) bool { return isForked(c.DelhiBlock, number) } +func (c *BorConfig) IsSprintStart(number, sprint uint64) bool { + return number%sprint == 0 +} + func (c *BorConfig) calculateBorConfigHelper(field map[string]uint64, number uint64) uint64 { keys := make([]string, 0, len(field)) for k := range field { From a4fbd71a01e3a59e1d17da146092f0291fdcf180 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Wed, 25 Jan 2023 17:48:13 +0530 Subject: [PATCH 03/11] use internal function --- core/rawdb/bor_receipt.go | 3 +-- params/config.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index 535b48ee48..f599eeee96 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -97,8 +97,7 @@ func ReadRawBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types. // its correspoinding metadata fields. If it is unable to populate these metadata // fields then nil is returned. func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64, config *params.ChainConfig) *types.Receipt { - - if config != nil && !config.Bor.IsSprintStart(number, config.Bor.CalculateSprint(number)) { + if config != nil && !config.Bor.IsSprintStart(number) { return nil } diff --git a/params/config.go b/params/config.go index f410f772fd..9833c9eac5 100644 --- a/params/config.go +++ b/params/config.go @@ -617,8 +617,8 @@ func (c *BorConfig) IsDelhi(number *big.Int) bool { return isForked(c.DelhiBlock, number) } -func (c *BorConfig) IsSprintStart(number, sprint uint64) bool { - return number%sprint == 0 +func (c *BorConfig) IsSprintStart(number uint64) bool { + return number%c.CalculateSprint(number) == 0 } func (c *BorConfig) calculateBorConfigHelper(field map[string]uint64, number uint64) uint64 { From 5806219c59a2ff44e8b6c5c0a36deb9e0d7eb14d Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Wed, 25 Jan 2023 18:59:51 +0530 Subject: [PATCH 04/11] fix tests --- core/rawdb/bor_receipt.go | 2 +- internal/ethapi/api.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index 535b48ee48..39eb0087db 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -98,7 +98,7 @@ func ReadRawBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types. // fields then nil is returned. func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64, config *params.ChainConfig) *types.Receipt { - if config != nil && !config.Bor.IsSprintStart(number, config.Bor.CalculateSprint(number)) { + if config != nil && config.Bor != nil && config.Bor.Sprint != nil && !config.Bor.IsSprintStart(number, config.Bor.CalculateSprint(number)) { return nil } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index fa07dcf419..6337628d41 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1465,6 +1465,10 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64, config *param txs = append(txs, tx) } } + + if index >= uint64(len(txs)) { + return nil + } return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index, b.BaseFee(), config) } From 2e838a6b1313d26674f3a8df4b044e35dcbf35a0 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Wed, 25 Jan 2023 21:21:20 +0400 Subject: [PATCH 05/11] fetch geth upstread for ReadBorReceiptRLP --- core/rawdb/bor_receipt.go | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index f599eeee96..1a7fc76e12 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -48,29 +48,19 @@ func HasBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) bool { return true } -// ReadBorReceiptRLP retrieves the block receipt belonging to a block in RLP encoding. func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { - // First try to look up the data in ancient database. Extra hash - // comparison is necessary since ancient database only maintains - // the canonical data. - - // Look up the data in leveldb. - data, _ := db.Get(borReceiptKey(number, hash)) - if len(data) > 0 { - return data - } - // In the background freezer is moving data from leveldb to flatten files. - // So during the first check for ancient db, the data is not yet in there, - // but when we reach into leveldb, the data was already moved. That would - // result in a not found error. - data, _ = db.Ancient(freezerBorReceiptTable, number) - if len(data) > 0 { - h, _ := db.Ancient(freezerHashTable, number) - if common.BytesToHash(h) == hash { - return data + var data []byte + db.ReadAncients(func(reader ethdb.AncientReader) error { + // Check if the data is in ancients + if isCanon(reader, number, hash) { + data, _ = reader.Ancient(freezerBorReceiptTable, number) + return nil } - } - return nil // Can't find the data anywhere. + // If not, try reading from leveldb + data, _ = db.Get(blockReceiptsKey(number, hash)) + return nil + }) + return data } // ReadRawBorReceipt retrieves the block receipt belonging to a block. From 645c8419acbc923a71c84835006d121125e98e65 Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 25 Jan 2023 11:40:41 -0800 Subject: [PATCH 06/11] Only query bor receipt when the query index is equal to # tx in block body This change reduces the frequency of calling ReadBorReceipt and ReadBorTransaction, which are CPU and db intensive. --- internal/ethapi/api.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 6337628d41..6bb7c225be 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1457,15 +1457,19 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64, config *param return nil } - borReceipt := rawdb.ReadBorReceipt(db, b.Hash(), b.NumberU64(), config) - if borReceipt != nil { - tx, _, _, _ := rawdb.ReadBorTransaction(db, borReceipt.TxHash) - - if tx != nil { - txs = append(txs, tx) + // If the index out of the range of transactions defined in block body, it means that the transaction is a bor state sync transaction, and we need to fetch it from the database + if index == uint64(len(txs)) { + borReceipt := rawdb.ReadBorReceipt(db, b.Hash(), b.NumberU64(), config) + if borReceipt != nil { + tx, _, _, _ := rawdb.ReadBorTransaction(db, borReceipt.TxHash) + + if tx != nil { + txs = append(txs, tx) + } } } + // If the index is still out of the range after checking bor state sync transaction, it means that the transaction index is invalid if index >= uint64(len(txs)) { return nil } From b09ff0587da551686cd5ea8b7a332b695c07976d Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 25 Jan 2023 15:19:05 -0800 Subject: [PATCH 07/11] Revert "fetch geth upstread for ReadBorReceiptRLP" This reverts commit 2e838a6b1313d26674f3a8df4b044e35dcbf35a0. --- core/rawdb/bor_receipt.go | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index 63e26c92c4..a80f99e3c2 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -48,19 +48,29 @@ func HasBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) bool { return true } +// ReadBorReceiptRLP retrieves the block receipt belonging to a block in RLP encoding. func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { - var data []byte - db.ReadAncients(func(reader ethdb.AncientReader) error { - // Check if the data is in ancients - if isCanon(reader, number, hash) { - data, _ = reader.Ancient(freezerBorReceiptTable, number) - return nil + // First try to look up the data in ancient database. Extra hash + // comparison is necessary since ancient database only maintains + // the canonical data. + + // Look up the data in leveldb. + data, _ := db.Get(borReceiptKey(number, hash)) + if len(data) > 0 { + return data + } + // In the background freezer is moving data from leveldb to flatten files. + // So during the first check for ancient db, the data is not yet in there, + // but when we reach into leveldb, the data was already moved. That would + // result in a not found error. + data, _ = db.Ancient(freezerBorReceiptTable, number) + if len(data) > 0 { + h, _ := db.Ancient(freezerHashTable, number) + if common.BytesToHash(h) == hash { + return data } - // If not, try reading from leveldb - data, _ = db.Get(blockReceiptsKey(number, hash)) - return nil - }) - return data + } + return nil // Can't find the data anywhere. } // ReadRawBorReceipt retrieves the block receipt belonging to a block. From b5f8d7ad89348fd255a1cf1e4358a63070b3f6fe Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 25 Jan 2023 15:21:28 -0800 Subject: [PATCH 08/11] Restore ReadBorReceiptRLP --- core/rawdb/bor_receipt.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index a80f99e3c2..0550787776 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -53,9 +53,16 @@ func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.Raw // First try to look up the data in ancient database. Extra hash // comparison is necessary since ancient database only maintains // the canonical data. + data, _ := db.Ancient(freezerBorReceiptTable, number) + if len(data) > 0 { + h, _ := db.Ancient(freezerHashTable, number) + if common.BytesToHash(h) == hash { + return data + } + } - // Look up the data in leveldb. - data, _ := db.Get(borReceiptKey(number, hash)) + // Then try to look up the data in leveldb. + data, _ = db.Get(borReceiptKey(number, hash)) if len(data) > 0 { return data } From 80ca80ddb8299fa361741d05769facbfe7cd549a Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 26 Jan 2023 13:03:57 +0400 Subject: [PATCH 09/11] fix bor receipts --- core/rawdb/bor_receipt.go | 43 ++++++++++++--------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index 0550787776..663ea915c5 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -48,36 +48,19 @@ func HasBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) bool { return true } -// ReadBorReceiptRLP retrieves the block receipt belonging to a block in RLP encoding. func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { - // First try to look up the data in ancient database. Extra hash - // comparison is necessary since ancient database only maintains - // the canonical data. - data, _ := db.Ancient(freezerBorReceiptTable, number) - if len(data) > 0 { - h, _ := db.Ancient(freezerHashTable, number) - if common.BytesToHash(h) == hash { - return data + var data []byte + db.ReadAncients(func(reader ethdb.AncientReader) error { + // Check if the data is in ancients + if isCanon(reader, number, hash) { + data, _ = reader.Ancient(freezerBorReceiptTable, number) + return nil } - } - - // Then try to look up the data in leveldb. - data, _ = db.Get(borReceiptKey(number, hash)) - if len(data) > 0 { - return data - } - // In the background freezer is moving data from leveldb to flatten files. - // So during the first check for ancient db, the data is not yet in there, - // but when we reach into leveldb, the data was already moved. That would - // result in a not found error. - data, _ = db.Ancient(freezerBorReceiptTable, number) - if len(data) > 0 { - h, _ := db.Ancient(freezerHashTable, number) - if common.BytesToHash(h) == hash { - return data - } - } - return nil // Can't find the data anywhere. + // If not, try reading from leveldb + data, _ = db.Get(borReceiptKey(number, hash)) + return nil + }) + return data } // ReadRawBorReceipt retrieves the block receipt belonging to a block. @@ -120,8 +103,8 @@ func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64, config *pa return nil } - body := HasBody(db, hash, number) - if !body { + body := ReadBody(db, hash, number) + if body == nil { log.Error("Missing body but have bor receipt", "hash", hash, "number", number) return nil } From fddb9df403b42bc4c83c760e21cfd65f990d6279 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 26 Jan 2023 13:05:24 +0400 Subject: [PATCH 10/11] remove unused --- core/rawdb/bor_receipt.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index 663ea915c5..cf383cc1ca 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -34,20 +34,6 @@ func borTxLookupKey(hash common.Hash) []byte { return append(borTxLookupPrefix, hash.Bytes()...) } -// HasBorReceipt verifies the existence of all block receipt belonging -// to a block. -func HasBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) bool { - if has, err := db.Ancient(freezerHashTable, number); err == nil && common.BytesToHash(has) == hash { - return true - } - - if has, err := db.Has(borReceiptKey(number, hash)); !has || err != nil { - return false - } - - return true -} - func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { var data []byte db.ReadAncients(func(reader ethdb.AncientReader) error { From 6ce8e32220b673ff4b8bdbc051d867ea6e725122 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 26 Jan 2023 15:48:48 +0400 Subject: [PATCH 11/11] fix lints --- core/rawdb/bor_receipt.go | 11 ++++++++++- rpc/server.go | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go index cf383cc1ca..0739c67a9f 100644 --- a/core/rawdb/bor_receipt.go +++ b/core/rawdb/bor_receipt.go @@ -36,16 +36,25 @@ func borTxLookupKey(hash common.Hash) []byte { func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { var data []byte - db.ReadAncients(func(reader ethdb.AncientReader) error { + + err := db.ReadAncients(func(reader ethdb.AncientReader) error { // Check if the data is in ancients if isCanon(reader, number, hash) { data, _ = reader.Ancient(freezerBorReceiptTable, number) + return nil } + // If not, try reading from leveldb data, _ = db.Get(borReceiptKey(number, hash)) + return nil }) + + if err != nil { + log.Warn("during ReadBorReceiptRLP", "number", number, "hash", hash, "err", err) + } + return data } diff --git a/rpc/server.go b/rpc/server.go index 96c3861d66..dc8afa0b6e 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -23,6 +23,7 @@ import ( "sync/atomic" mapset "github.com/deckarep/golang-set" + "github.com/ethereum/go-ethereum/log" ) @@ -127,9 +128,11 @@ func (s *Server) serveSingleRequest(ctx context.Context, codec ServerCodec) { log.Debug("batch limit %d exceeded: %d requests given", s.BatchLimit, len(reqs)) } } else { + //nolint:contextcheck h.handleBatch(reqs) } } else { + //nolint:contextcheck h.handleMsg(reqs[0]) } }