diff --git a/app/abci_utils.go b/app/abci_utils.go index c1a3a661..9f75dae0 100644 --- a/app/abci_utils.go +++ b/app/abci_utils.go @@ -2,6 +2,7 @@ package app import ( "fmt" + "sort" "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" @@ -97,6 +98,8 @@ func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHan return abci.ResponsePrepareProposal{Txs: h.txSelector.SelectedTxs()} } + counter := make(map[string]int, h.mempool.CountTx()) + iterator := h.mempool.Select(ctx, req.Txs) selectedTxsSignersSeqs := make(map[string]uint64) var selectedTxsNums int @@ -134,6 +137,12 @@ func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHan txSignersSeqs[signer] = nonce } } + + if _, exists := counter[signer]; !exists { + counter[ethSender.Hex()] = 1 + } else { + counter[ethSender.Hex()] += 1 + } } } } @@ -146,6 +155,12 @@ func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHan continue } + if _, exists := counter[signer]; !exists { + counter[signer] = 1 + } else { + counter[signer] += 1 + } + // If we have seen this signer before in this block, we must make // sure that the current sequence is seq+1; otherwise is invalid // and we skip it. @@ -198,6 +213,29 @@ func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHan iterator = iterator.Next() } + + if len(counter) > 0 { + type kv struct { + k string + v int + } + + kvSlice := make([]kv, 0, len(counter)) + + for k, v := range counter { + kvSlice = append(kvSlice, kv{k, v}) + } + + sort.Slice(kvSlice, func(i, j int) bool { + return kvSlice[i].v > kvSlice[j].v + }) + + ctx.Logger().Info("uncommitted txs", "count", h.mempool.CountTx()) + + for i := 0; i < 10 && i < len(kvSlice); i++ { + ctx.Logger().Info("uncommitted txs", "top", i+1, "address", kvSlice[i].k, "count", kvSlice[i].v) + } + } return abci.ResponsePrepareProposal{Txs: h.txSelector.SelectedTxs()} } }