Skip to content

Commit

Permalink
add debug log for new block announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 committed Jul 17, 2023
1 parent 16746a7 commit ae95a28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
bc.blockProcFeed.Send(true)
defer bc.blockProcFeed.Send(false)

log.Info("[DEBUG] Inserting chain", "first number", chain[0].Number(), "first hash", chain[0].Hash(), "last number", chain[len(chain)-1].Number(), "last hash", chain[len(chain)-1].Hash())

// Do a sanity check that the provided chain is actually ordered and linked.
for i := 1; i < len(chain); i++ {
block, prev := chain[i], chain[i-1]
Expand Down
2 changes: 2 additions & 0 deletions eth/handler_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/protocols/eth"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/enode"
)

Expand Down Expand Up @@ -103,6 +104,7 @@ func (h *ethHandler) handleBlockAnnounces(peer *eth.Peer, hashes []common.Hash,
unknownNumbers = append(unknownNumbers, numbers[i])
}
}
log.Info("[DEBUG] In handle block announcement", "len", len(unknownHashes))
for i := 0; i < len(unknownHashes); i++ {
h.blockFetcher.Notify(peer.ID(), unknownHashes[i], unknownNumbers[i], time.Now(), peer.RequestOneHeader, peer.RequestBodies)
}
Expand Down
2 changes: 2 additions & 0 deletions eth/protocols/eth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,10 @@ func handleNewBlockhashes(backend Backend, msg Decoder, peer *Peer) error {
if err := msg.Decode(ann); err != nil {
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
}
log.Info("[DEBUG] Received block hashes from peer")
// Mark the hashes as present at the remote node
for _, block := range *ann {
log.Info("[DEBUG] Block", "number", block.Number, "hash", block.Hash)
peer.markBlock(block.Hash)
}
// Deliver them all to the backend for queuing
Expand Down

0 comments on commit ae95a28

Please sign in to comment.