From 1a8e4df38325dcafef04f33980f13a7ba11e33c9 Mon Sep 17 00:00:00 2001 From: rekyyang <22545420+rekyyang@users.noreply.github.com> Date: Mon, 15 Jun 2026 12:26:44 +0800 Subject: [PATCH] add arrive record logs --- server.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/server.go b/server.go index 7a17b79..add1d31 100644 --- a/server.go +++ b/server.go @@ -17,6 +17,7 @@ import ( "sync" "time" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/txpool" "github.com/ethereum/go-ethereum/core/types" @@ -545,6 +546,8 @@ func (s *Server) handleBatchRPC(ctx context.Context, reqs []json.RawMessage, isL } } + logTxBundleArrival(parsedReq, origin) + id := string(parsedReq.ID) // If this is a duplicate Request ID, move the Request to a new batchGroup ids[id]++ @@ -1028,3 +1031,39 @@ func firstNonEmpty(vals ...string) string { } return "" } + +// logTxBundleArrival logs the arrival timestamp of eth_sendRawTransaction and +// eth_sendBundle requests. For bundles it also lists the tx hashes decoded from +// the raw RLP-encoded transactions in the bundle params. +func logTxBundleArrival(req *RPCReq, domain string) { + now := time.Now().UnixMilli() + switch req.Method { + case "eth_sendRawTransaction": + var params []hexutil.Bytes + if err := json.Unmarshal(req.Params, ¶ms); err != nil || len(params) == 0 { + return + } + tx := new(types.Transaction) + if err := tx.UnmarshalBinary(params[0]); err != nil { + return + } + log.Info("Tx arrival", "ts_ms", now, "domain", domain, "hash", tx.Hash()) + + case "eth_sendBundle": + var params []struct { + Txs []hexutil.Bytes `json:"txs"` + } + if err := json.Unmarshal(req.Params, ¶ms); err != nil || len(params) == 0 { + return + } + hashes := make([]common.Hash, 0, len(params[0].Txs)) + for _, raw := range params[0].Txs { + tx := new(types.Transaction) + if err := tx.UnmarshalBinary(raw); err != nil { + continue + } + hashes = append(hashes, tx.Hash()) + } + log.Info("Bundle arrival", "ts_ms", now, "domain", domain, "tx_count", len(hashes), "txs", hashes) + } +}