From 7ae3d82ea5a7dbd937392519438d0904976b78a4 Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Mon, 26 Aug 2019 01:26:12 -0700 Subject: [PATCH] add log for CXReceipts --- core/blockchain.go | 5 ++++- node/node_cross_shard.go | 1 + node/node_handler.go | 2 +- node/node_newblock.go | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index fce730eac..ba39b1c8e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1072,7 +1072,10 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. continue } shardReceipts := GetToShardReceipts(cxReceipts, uint32(i)) - rawdb.WriteCXReceipts(batch, uint32(i), block.NumberU64(), block.Hash(), shardReceipts, false) + err := rawdb.WriteCXReceipts(batch, uint32(i), block.NumberU64(), block.Hash(), shardReceipts, false) + if err != nil { + utils.Logger().Debug().Err(err).Interface("shardReceipts", shardReceipts).Int("toShardID", i).Msg("WriteCXReceipts cannot write into database") + } } // Mark incomingReceipts in the block as spent diff --git a/node/node_cross_shard.go b/node/node_cross_shard.go index 08aa4f79f..acaa6b4ae 100644 --- a/node/node_cross_shard.go +++ b/node/node_cross_shard.go @@ -278,5 +278,6 @@ func (node *Node) ProcessReceiptMessage(msgPayload []byte) { // TODO: remove in future if not useful node.Blockchain().WriteCXReceipts(cxp.MerkleProof.ShardID, cxp.MerkleProof.BlockNum.Uint64(), cxp.MerkleProof.BlockHash, cxp.Receipts, true) + utils.Logger().Debug().Msg("[ProcessReceiptMessage] Add CXReceiptsProof to pending Receipts") node.AddPendingReceipts(&cxp) } diff --git a/node/node_handler.go b/node/node_handler.go index 288521ace..5176f3a04 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -318,7 +318,7 @@ func (node *Node) BroadcastCXReceipts(newBlock *types.Block) { } cxReceipts, err := node.Blockchain().ReadCXReceipts(uint32(i), newBlock.NumberU64(), newBlock.Hash(), false) if err != nil || len(cxReceipts) == 0 { - //utils.Logger().Warn().Err(err).Uint32("ToShardID", uint32(i)).Int("numCXReceipts", len(cxReceipts)).Msg("[BroadcastCXReceipts] No ReadCXReceipts found") + utils.Logger().Warn().Err(err).Uint32("ToShardID", uint32(i)).Int("numCXReceipts", len(cxReceipts)).Msg("[BroadcastCXReceipts] No ReadCXReceipts found") continue } merkleProof, err := node.Blockchain().CXMerkleProof(uint32(i), newBlock) diff --git a/node/node_newblock.go b/node/node_newblock.go index 2efeae52b..0b302b790 100644 --- a/node/node_newblock.go +++ b/node/node_newblock.go @@ -242,5 +242,6 @@ func (node *Node) proposeReceiptsProof() []*types.CXReceiptsProof { } node.pendingCXReceipts = pendingReceiptsList node.pendingCXMutex.Unlock() + utils.Logger().Debug().Msgf("[proposeReceiptsProof] number of validReceipts %d", len(validReceiptsList)) return validReceiptsList }