Skip to content

Conversation

@sdaftuar
Copy link
Member

@sdaftuar sdaftuar commented Jan 4, 2016

This adds 3 new RPC calls (getancestors getmempoolancestors, getdescendants getmempooldescendants, getmempoolentry) to expose more mempool information over RPC.

Now that we have policy rules that are tied to transaction chains (including limits on the number of in-mempool ancestors and in-mempool descendants, and mempool eviction and RBF policies that depend on fees of descendants), it seems helpful to be able to expose more information about the chains a given tx is part of over RPC.

This is motivated by the discussion in #7222. @petertodd You mentioned wanting to see specific use-cases for this information; I think there are clear improvements to the fee-bumping tools in your replace-by-fee repo that could be made if we had these functions (the first two tools I looked at just now don't seem to consider transaction chains at all in fee calculations?). I'll try to post a link in this PR to specific proposed improvements when I have something to share that will demonstrate this more clearly.

@btcdrak
Copy link
Contributor

btcdrak commented Jan 5, 2016

Concept ACK

@jonasschnelli
Copy link
Contributor

Concept ACK.
Some concrete use-cases would be nice.
Nice to see the new RPC commands cs_main lock free.

@sdaftuar sdaftuar force-pushed the add-chain-info branch 2 times, most recently from 1ff8f47 to 7ed3383 Compare January 5, 2016 14:26
@sdaftuar
Copy link
Member Author

sdaftuar commented Jan 5, 2016

Updated to remove dead code I inadvertently left in rpcblockchain.cpp.

@sdaftuar
Copy link
Member Author

sdaftuar commented Jan 6, 2016

Here's an example of a tool that would benefit from the getdescendants function:
https://github.com/sdaftuar/replace-by-fee-tools/blob/d0121b03d02c1a7e5e16425b55da1302ddf081aa/combine-transactions.py

This is a script that takes two txid's (that are signaling opt-in RBF) and combines them down to one -- consolidating duplicate output addresses (if any) and removing pay-to-self outputs, assumed for demo purposes to be change outputs -- and paying for all fees including those of descendants. The main idea is that this avoids over-paying for descendants -- it calls getdescendants on each transaction and takes the union of the two sets so that each descendant is paid for once. I don't know any simple or straightforward way to do this without this new RPC call.

There are similar benefits to having getancestors, such as if you wanted to understand why a stuck transaction wasn't confirming, then getancestors would give you the set of unconfirmed parents to look at (and you could write a replace-by-fee-tool that was smart enough to drop an input coming from a stuck unconfirmed parent, when possible, to replace a transaction with one likely to confirm sooner; or better still, replace such a stuck parent instead if possible).

@sipa
Copy link
Member

sipa commented Jan 6, 2016 via email

@sdaftuar
Copy link
Member Author

sdaftuar commented Jan 7, 2016

@sipa True. Perhaps getmempoolancestors/getmempooldescendants? I'm open to suggestions.

@laanwj if this code is ok I think it would make sense to include this in 0.12

@sdaftuar
Copy link
Member Author

Updated with new RPC names (getmempoolancestors and getmempooldescendants).

@luke-jr
Copy link
Member

luke-jr commented Jan 15, 2016

Any reason not to just add the ancestors/descendants info to getrawmempool (and also the getmempoolentry)?

@sdaftuar
Copy link
Member Author

The goal was to avoid having to dump the entire mempool if you were only interested in a very small subset of it. But I suppose there's no reason we couldn't also show the txid's of ancestors and descendants when you call getrawmempool (with verbose=true). If that seems useful, I'm happy to add that.

(edited)
Oh, right, you are suggesting that, and then yes I agree it would also make sense to update getmempoolentry to match. Sure, I'll go ahead and do that.

@sdaftuar
Copy link
Member Author

@luke-jr On further thought, the downside to that is that doing the calculation could cause getrawmempool to get up to ~25x slower (default policy allows length 25 ancestor and descendant chains, and the calculation of ancestors and descendants requires walking those chains), which on a full mempool could be a meaningful -- and perhaps unacceptable? -- slowdown.

The other possibility would be to add a new option to getrawmempool to determine whether to do the calculation or not, but I think we try to avoid adding new arguments to existing RPC calls? So now I think it's probably better to leave as-is. Let me know if you disagree...

@laanwj
Copy link
Member

laanwj commented Jan 22, 2016

Concept ACK

@laanwj
Copy link
Member

laanwj commented Feb 3, 2016

Needs rebase.

@sdaftuar
Copy link
Member Author

Rebased. There weren't any actual conflicts though, so not sure why github thought it wouldn't merge cleanly?

@laanwj
Copy link
Member

laanwj commented Feb 12, 2016

Thanks!
I've noticed that before. Github is somewhat less good (or "more careful") at merging than git.

luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Feb 13, 2016
Github-Pull: bitcoin#7292
Rebased-From: bf4fbe814df537e69d5b1092565efb6f8bb618b9
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Feb 13, 2016
Github-Pull: bitcoin#7292
Rebased-From: 2409317c8ba1ea11b0bb519121f8c441439a71db
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Feb 13, 2016
Github-Pull: bitcoin#7292
Rebased-From: 9644106526eea536cf056b4058a40b0dbbdbe32f
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Feb 13, 2016
Github-Pull: bitcoin#7292
Rebased-From: 31ef9d5c649beea8812d2ba92f779d639e1c8b2c
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Feb 13, 2016
Github-Pull: bitcoin#7292
Rebased-From: bc9020c1ab30ea9527ef63d4df4df10513f8756f
@sipa
Copy link
Member

sipa commented May 17, 2016

Rebase needed.

@sdaftuar
Copy link
Member Author

Rebased. Also added a commit that extends the mempool entry output to include the ancestor state (added by #7594), as well as a brief update to the release notes.

@sdaftuar
Copy link
Member Author

Unit tests are now failing on linux. I'll see if I can reproduce locally.

@sdaftuar
Copy link
Member Author

Oh, I suppose it could be this: #8069 (comment)

@sdaftuar
Copy link
Member Author

Looks like the travis issue was fixed by #8070, so I think this is ready now.

@paveljanik
Copy link
Contributor

reACK 5379307

@maflcko
Copy link
Member

maflcko commented May 20, 2016

utACK 5379307

@arowser
Copy link
Contributor

arowser commented May 25, 2016

Can one of the admins verify this patch?

@sipa
Copy link
Member

sipa commented Jun 3, 2016

utACK 5379307a23177c33b5a869513d1d1d09790b0269

@sdaftuar
Copy link
Member Author

sdaftuar commented Jun 9, 2016

Is there anything holding this up?

@sipa
Copy link
Member

sipa commented Jun 9, 2016

Can you squash the typo?

@sdaftuar sdaftuar force-pushed the add-chain-info branch 2 times, most recently from 67adf93 to 176e19b Compare June 9, 2016 13:58
@sdaftuar
Copy link
Member Author

sdaftuar commented Jun 9, 2016

@sipa done

@sipa
Copy link
Member

sipa commented Jun 9, 2016

utACK 176e19b (same tree as before)

@sipa sipa merged commit 176e19b into bitcoin:master Jun 9, 2016
sipa added a commit that referenced this pull request Jun 9, 2016
176e19b Mention new RPC's in release notes (Suhas Daftuar)
7f6eda8 Add ancestor statistics to mempool entry RPC output (Suhas Daftuar)
a9b8390 Add test coverage for new RPC calls (Suhas Daftuar)
b09b813 Add getmempoolentry RPC call (Suhas Daftuar)
0dfd869 Add getmempooldescendants RPC call (Suhas Daftuar)
8f7b5dc Add getmempoolancestors RPC call (Suhas Daftuar)
5ec0cde Refactor logic for converting mempool entries to JSON (Suhas Daftuar)
luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Jun 28, 2016
codablock pushed a commit to codablock/dash that referenced this pull request Dec 22, 2017
… RPC

176e19b Mention new RPC's in release notes (Suhas Daftuar)
7f6eda8 Add ancestor statistics to mempool entry RPC output (Suhas Daftuar)
a9b8390 Add test coverage for new RPC calls (Suhas Daftuar)
b09b813 Add getmempoolentry RPC call (Suhas Daftuar)
0dfd869 Add getmempooldescendants RPC call (Suhas Daftuar)
8f7b5dc Add getmempoolancestors RPC call (Suhas Daftuar)
5ec0cde Refactor logic for converting mempool entries to JSON (Suhas Daftuar)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
… RPC

176e19b Mention new RPC's in release notes (Suhas Daftuar)
7f6eda8 Add ancestor statistics to mempool entry RPC output (Suhas Daftuar)
a9b8390 Add test coverage for new RPC calls (Suhas Daftuar)
b09b813 Add getmempoolentry RPC call (Suhas Daftuar)
0dfd869 Add getmempooldescendants RPC call (Suhas Daftuar)
8f7b5dc Add getmempoolancestors RPC call (Suhas Daftuar)
5ec0cde Refactor logic for converting mempool entries to JSON (Suhas Daftuar)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants