From 1610a05cbdd47f5cf5f37ef261473d25e32f87fb Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Wed, 21 Nov 2018 00:33:41 -0600 Subject: [PATCH] Remove counter from every mempoolTx (#2891) Within every tx in the mempool, we store a 64 bit counter, as an index for when it was inserted into the mempool. This counter doesn't really serve any purpose. It was likely added for debugging at one point, Removing the counter reclaims memory, which enables greater mempool sizes / mitigates resources at the same size. Closes #2835 --- CHANGELOG_PENDING.md | 1 + mempool/mempool.go | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index de4930be4..aa42e3722 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -27,5 +27,6 @@ program](https://hackerone.com/tendermint). - [config] \#2877 add blocktime_iota to the config.toml (@ackratos) - [mempool] \#2855 add txs from Update to cache +- [mempool] \#2835 Remove local int64 counter from being stored in every tx ### BUG FIXES: diff --git a/mempool/mempool.go b/mempool/mempool.go index 6f8ee0211..8f70ec6c8 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -131,7 +131,6 @@ type Mempool struct { proxyMtx sync.Mutex proxyAppConn proxy.AppConnMempool txs *clist.CList // concurrent linked-list of good txs - counter int64 // simple incrementing counter height int64 // the last block Update()'d to rechecking int32 // for re-checking filtered txs on Update() recheckCursor *clist.CElement // next expected response @@ -167,7 +166,6 @@ func NewMempool( config: config, proxyAppConn: proxyAppConn, txs: clist.New(), - counter: 0, height: height, rechecking: 0, recheckCursor: nil, @@ -365,9 +363,7 @@ func (mem *Mempool) resCbNormal(req *abci.Request, res *abci.Response) { postCheckErr = mem.postCheck(tx, r.CheckTx) } if (r.CheckTx.Code == abci.CodeTypeOK) && postCheckErr == nil { - mem.counter++ memTx := &mempoolTx{ - counter: mem.counter, height: mem.height, gasWanted: r.CheckTx.GasWanted, tx: tx, @@ -378,7 +374,6 @@ func (mem *Mempool) resCbNormal(req *abci.Request, res *abci.Response) { "res", r, "height", memTx.height, "total", mem.Size(), - "counter", memTx.counter, ) mem.metrics.TxSizeBytes.Observe(float64(len(tx))) mem.notifyTxsAvailable() @@ -613,7 +608,6 @@ func (mem *Mempool) recheckTxs(txs []types.Tx) { // mempoolTx is a transaction that successfully ran type mempoolTx struct { - counter int64 // a simple incrementing counter height int64 // height that this tx had been validated in gasWanted int64 // amount of gas this tx states it will require tx types.Tx //