Skip to content

Commit

Permalink
feat(trace)!: persist the correct size of the txs (#1461)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cmwaters committed Aug 28, 2024
1 parent 6025441 commit 344a6d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mempool/cat/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
for _, tx := range protoTxs {
ntx := types.Tx(tx)
key := ntx.Key()
schema.WriteMempoolTx(memR.traceClient, string(e.Src.ID()), key[:], schema.Download)
schema.WriteMempoolTx(memR.traceClient, string(e.Src.ID()), key[:], len(tx), schema.Download)
// If we requested the transaction we mark it as received.
if memR.requests.Has(peerID, key) {
memR.requests.MarkReceived(peerID, key)
Expand Down Expand Up @@ -331,6 +331,7 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
memR.traceClient,
string(e.Src.ID()),
txKey[:],
len(tx),
schema.Upload,
)
}
Expand Down
2 changes: 2 additions & 0 deletions mempool/v1/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
memR.traceClient,
string(e.Src.ID()),
ntx.Hash(),
len(tx),
schema.Download,
)
err = memR.mempool.CheckTx(ntx, nil, txInfo)
Expand Down Expand Up @@ -303,6 +304,7 @@ func (memR *Reactor) broadcastTxRoutine(peer p2p.Peer) {
memR.traceClient,
string(peer.ID()),
memTx.tx.Hash(),
len(memTx.tx),
schema.Upload,
)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/trace/schema/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (m MempoolTx) Table() string {

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

0 comments on commit 344a6d4

Please sign in to comment.