Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: celestiaorg/celestia-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.49.1-tm-v0.34.35
Choose a base ref
...
head repository: celestiaorg/celestia-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.51.0-tm-v0.34.35
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Mar 17, 2025

  1. feat: purpose -1 to return all unconfirmed transactions in Unconfirme…

    …dTxs RPC (#1675)
    
    ## Description
    
    Instead of creating a new RPC method that returns all the unconfirmed
    mempool transactions, I used -1 as a special flag to do that. I think
    it's fine to do so. If it's not, can always define a new endpoint.
    
    #### PR checklist
    
    - [ ] Tests written/updated
    - [ ] Changelog entry added in `.changelog` (we use
    [unclog](https://github.com/informalsystems/unclog) to manage our
    changelog)
    - [ ] Updated relevant documentation (`docs/` or `spec/`) and code
    comments
    rach-id authored Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    89270d0 View commit details
Showing with 39 additions and 3 deletions.
  1. +32 −0 rpc/client/rpc_test.go
  2. +6 −2 rpc/core/mempool.go
  3. +1 −1 rpc/openapi/openapi.yaml
32 changes: 32 additions & 0 deletions rpc/client/rpc_test.go
Original file line number Diff line number Diff line change
@@ -404,6 +404,38 @@ func TestUnconfirmedTxs(t *testing.T) {
mempool.Flush()
}

func TestUncappedUnconfirmedTxs(t *testing.T) {
mempool := node.Mempool()
numberOfTransactions := 120 // needs to be greater than maxPerPage const
for i := 0; i < numberOfTransactions; i++ {
_, _, tx := MakeTxKV()

ch := make(chan *abci.Response, 1)
err := mempool.CheckTx(tx, func(resp *abci.Response) { ch <- resp }, mempl.TxInfo{})
require.NoError(t, err)

// wait for tx to arrive in mempoool.
select {
case <-ch:
case <-time.After(5 * time.Second):
t.Error("Timed out waiting for CheckTx callback")
}
}

for _, c := range GetClients() {
mc := c.(client.MempoolClient)
limit := -1 // set the limit to -1 to return everything
res, err := mc.UnconfirmedTxs(context.Background(), &limit)
require.NoError(t, err)

assert.Equal(t, numberOfTransactions, res.Count)
assert.Equal(t, numberOfTransactions, res.Total)
assert.Equal(t, mempool.SizeBytes(), res.TotalBytes)
}

mempool.Flush()
}

func TestNumUnconfirmedTxs(t *testing.T) {
_, _, tx := MakeTxKV()

8 changes: 6 additions & 2 deletions rpc/core/mempool.go
Original file line number Diff line number Diff line change
@@ -154,9 +154,13 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc
// UnconfirmedTxs gets unconfirmed transactions (maximum ?limit entries)
// including their number.
// More: https://docs.cometbft.com/v0.34/rpc/#/Info/unconfirmed_txs
// If limitPtr == -1, it will return all the unconfirmed transactions in the mempool.
func UnconfirmedTxs(ctx *rpctypes.Context, limitPtr *int) (*ctypes.ResultUnconfirmedTxs, error) {
// reuse per_page validator
limit := validatePerPage(limitPtr)
limit := *limitPtr
if limit != -1 {
// reuse per_page validator
limit = validatePerPage(limitPtr)
}
env := GetEnvironment()

txs := env.Mempool.ReapMaxTxs(limit)
2 changes: 1 addition & 1 deletion rpc/openapi/openapi.yaml
Original file line number Diff line number Diff line change
@@ -824,7 +824,7 @@ paths:
parameters:
- in: query
name: limit
description: Maximum number of unconfirmed transactions to return (max 100)
description: Maximum number of unconfirmed transactions to return (max 100). If set to -1, it will return all the unconfirmed mempool transactions.
required: false
schema:
type: integer