Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]++
Expand Down Expand Up @@ -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, &params); 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, &params); 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)
}
}
Loading