diff --git a/eth/handler.go b/eth/handler.go index c416894f89..ddcf5d1e3b 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -606,6 +606,17 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) { log.Error("Propagating dangling block", "number", block.Number(), "hash", hash) return } + + // These are the static and trusted peers which are not + // in `transfer := peers[:int(math.Sqrt(float64(len(peers))))]` + staticAndTrustedPeers := []*ethPeer{} + + for _, peer := range peers[int(math.Sqrt(float64(len(peers)))):] { + if peer.IsTrusted() || peer.IsStatic() { + staticAndTrustedPeers = append(staticAndTrustedPeers, peer) + } + } + // Send the block to a subset of our peers transfer := peers[:int(math.Sqrt(float64(len(peers))))] for _, peer := range transfer { @@ -614,6 +625,14 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) { log.Trace("Propagated block", "hash", hash, "recipients", len(transfer), "duration", common.PrettyDuration(time.Since(block.ReceivedAt))) + // Send the block to the trusted and static peers + for _, peer := range staticAndTrustedPeers { + log.Trace("Propagating block to static and trusted peer", "hash", hash, "peerID", peer.ID()) + peer.AsyncSendNewBlock(block, td) + } + + log.Trace("Propagated same block to additional static and trusted peers", "hash", hash, "recipients", len(staticAndTrustedPeers), "duration", common.PrettyDuration(time.Since(block.ReceivedAt))) + return } // Otherwise if the block is indeed in out own chain, announce it diff --git a/eth/protocols/eth/peer.go b/eth/protocols/eth/peer.go index 98ad22a8cf..21fd966d58 100644 --- a/eth/protocols/eth/peer.go +++ b/eth/protocols/eth/peer.go @@ -470,6 +470,16 @@ func (p *Peer) RequestTxs(hashes []common.Hash) error { }) } +// IsTrusted returns whether the peer is a trusted peer or not. +func (p *Peer) IsTrusted() bool { + return p.Info().Network.Trusted +} + +// IsStatic returns whether the peer is a static peer or not. +func (p *Peer) IsStatic() bool { + return p.Info().Network.Static +} + // knownCache is a cache for known hashes. type knownCache struct { hashes mapset.Set[common.Hash] diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 3dc8f46ceb..e6da894845 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -2238,7 +2238,8 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common. func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex int, borTx bool) map[string]interface{} { from, _ := types.Sender(signer, tx) - txHash := common.Hash{} + var txHash common.Hash + if borTx { txHash = types.GetDerivedBorTxHash(types.BorReceiptKey(blockNumber, blockHash)) } else {