Skip to content

Commit 344a6d4

Browse files
authored
feat(trace)!: persist the correct size of the txs (#1461)
Currently, we use the length of the tx hash as the size. This means that all txs have the size 32. It would be more helpful that the tracing data captures the actual size of the transactions passing back and forth
1 parent 6025441 commit 344a6d4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

mempool/cat/reactor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
241241
for _, tx := range protoTxs {
242242
ntx := types.Tx(tx)
243243
key := ntx.Key()
244-
schema.WriteMempoolTx(memR.traceClient, string(e.Src.ID()), key[:], schema.Download)
244+
schema.WriteMempoolTx(memR.traceClient, string(e.Src.ID()), key[:], len(tx), schema.Download)
245245
// If we requested the transaction we mark it as received.
246246
if memR.requests.Has(peerID, key) {
247247
memR.requests.MarkReceived(peerID, key)
@@ -331,6 +331,7 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
331331
memR.traceClient,
332332
string(e.Src.ID()),
333333
txKey[:],
334+
len(tx),
334335
schema.Upload,
335336
)
336337
}

mempool/v1/reactor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
197197
memR.traceClient,
198198
string(e.Src.ID()),
199199
ntx.Hash(),
200+
len(tx),
200201
schema.Download,
201202
)
202203
err = memR.mempool.CheckTx(ntx, nil, txInfo)
@@ -303,6 +304,7 @@ func (memR *Reactor) broadcastTxRoutine(peer p2p.Peer) {
303304
memR.traceClient,
304305
string(peer.ID()),
305306
memTx.tx.Hash(),
307+
len(memTx.tx),
306308
schema.Upload,
307309
)
308310
}

pkg/trace/schema/mempool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (m MempoolTx) Table() string {
3535

3636
// WriteMempoolTx writes a tracing point for a tx using the predetermined
3737
// schema for mempool tracing.
38-
func WriteMempoolTx(client trace.Tracer, peer string, txHash []byte, transferType TransferType) {
38+
func WriteMempoolTx(client trace.Tracer, peer string, txHash []byte, size int, transferType TransferType) {
3939
// this check is redundant to what is checked during client.Write, although it
4040
// is an optimization to avoid allocations from the map of fields.
4141
if !client.IsCollecting(MempoolTxTable) {
@@ -44,7 +44,7 @@ func WriteMempoolTx(client trace.Tracer, peer string, txHash []byte, transferTyp
4444
client.Write(MempoolTx{
4545
TxHash: bytes.HexBytes(txHash).String(),
4646
Peer: peer,
47-
Size: len(txHash),
47+
Size: size,
4848
TransferType: transferType,
4949
})
5050
}

0 commit comments

Comments
 (0)