-
Notifications
You must be signed in to change notification settings - Fork 36.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC: Return transaction fee from testmempoolaccept #19093
Conversation
ISTM there is no need to close #19063 and open another PR. Better to have rebased on the original PR. |
I am not sure how to do that. The branch for that pr in my repo is gone. That PR somehow got a ton of commit the last time i tried to push. I tried to fix it by rebasing but wasn't working, and then it went much more messy and my local branch got deleted. So i opened a new one. It feels its better to close the previous one as i have no way to update it. Sorry for the mess. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
f70abce
to
520ae88
Compare
Thanks for the review. Updated and rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, code change looks good.
Could add release note and also add/update a test without fee
in the result.
Thanks @promag for the review and comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK, with some nits
520ae88
to
c7c3f45
Compare
Thanks @luke-jr for the review. Updated and rebased. @promag I have added a release note. Let me know if any modification needed there. Regarding the extra functional test, |
This commit returns 'fee' in the testmempoolaccept rpc results. 'fee' is only returned if the transaction is accepted in mempool. Existing functional tests are modified to reflect changed behaviour. Github-Pull: bitcoin#19093 Rebased-From: 520ae88
This commit returns 'fee' in the testmempoolaccept rpc results. 'fee' is only returned if the transaction is accepted in mempool. Existing functional tests are modified to reflect changed behaviour. Github-Pull: bitcoin#19093 Rebased-From: c7c3f45
c7c3f45
to
3218bba
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK!
I'm wondering why you decided to return fee instead of feerate? I think we typically use feerate to decide whether a fee is reasonable, although a user might prefer to just see a fee amount. It's a quick conversion between the two and I don't have a strong opinion, but was wondering what your rationale was?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3218bba
I'm building on top of this in #19339, just fyi @rajarshimaitra
That's a good proposal. I didn't thought about it, but it makes sense to report the fee rate instead of the total fee. I think its a better thing to do. Will change if others agree.
It looks ready from my side. Maybe needs few more ACKs. |
I am starting to think that it could even return the same info that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. A few style comments inline.
Additionally, a couple of comments on the commit log:
- the summary line should be in the imperative mood (i.e. "Return transaction fee from testmempoolaccept" instead of "testmempoolaccept returns transaction fee")
- change "if the transaction is accepted in mempool." to "if the transaction would be accepted to the mempool."
This commit returns 'fee' in the testmempoolaccept rpc results. 'fee' is only returned if the transaction would be accepted to the mempool. Existing functional tests are modified to reflect changed behaviour.
3218bba
to
c9781e9
Compare
Thanks @jnewbery for the review. Updated as per your suggestions and rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK c9781e9
Code review ACK c9781e9 s390 failure in travis is unrelated to this PR. I've restarted the job. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
@@ -878,6 +878,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request) | |||
{ | |||
{RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"}, | |||
{RPCResult::Type::BOOL, "allowed", "If the mempool allows this tx to be inserted"}, | |||
{RPCResult::Type::NUM, "fee", "Fee provided in this transaction (only present when 'allowed' is true)"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This will put the fee in raw satoshis? I don't think we do this anywhere else.
- Have you seen RPC: Return transaction fee from testmempoolaccept #19093 (comment)? Specifically, it would be better for the caller to have the feerate instead of the absolute fee. Otherwise, the caller is forced to implement a witness-aware tx-deserializer to determine the virtual size.
getmempoolentry
returns vsize, weight, as well as afees
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Now that I am thinking it makes sense to return feerate
. Do you want the fees
to be changed into feerate
?
I am starting to think that it could even return the same info that
getmempoolinfo
returns
Little confused on this one as getmepoolinfo
returns the following
Result:
{
"loaded": true|false (boolean) True if the mempool is fully loaded
"size": xxxxx, (numeric) Current tx count
"bytes": xxxxx, (numeric) Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted
"usage": xxxxx, (numeric) Total memory usage for the mempool
"maxmempool": xxxxx, (numeric) Maximum memory usage for the mempool
"mempoolminfee": xxxxx (numeric) Minimum fee rate in BTC/kB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee
"minrelaytxfee": xxxxx (numeric) Current minimum relay fee for transactions
}
Which of these do you think should be included here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, typo. Should have been getmempoolentry in the other comment as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like scope creep. I think returning the fee is fine to start with, and unblocks #19339. Could we defer adding more details to a later PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Changing the type to
STR_AMOUNT
like in all other places should be done for consistency and to protect against mistakes. I consider this a bug that should be fixed before merge. - Removing the field
fee
and replacing it with something else later is a breaking rpc change. For the sanity of our users we should keep breaking rpc changes at a minimum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does #19339 need the rpc changes? If not, then this can trivially be unblocked by cherry-picking this pull and undoing the RPC changes. I think an internal (non-rpc) change can go in earlier, as it doesn't have the breaking rpc change concerns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point about cherry picking the non-rpc changes.
Separately, I think fee
is a useful value to return to the user, since it's exact (unlike feerate which might be rounded).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, since getmempoolentry
also returns the absolute fee (and the vsize)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good point, I only need the fee from ATMP for #19339 so I'll just use that. @rajarshimaitra is listed as coauthor on there, and can continue iterating on the RPC stuff here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK c9781e9
Ignore my nit unless you have to retouch.
@@ -475,6 +475,7 @@ class MemPoolAccept | |||
*/ | |||
std::vector<COutPoint>& m_coins_to_uncache; | |||
const bool m_test_accept; | |||
CAmount* m_fee; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: to match your naming elsewhere you could have called this m_fee_out
Concept ACK |
I still consider my comment a bug that should be fixed before merge. Also my proposed change would be a breaking RPC change, and I wouldn't want to expose users to that. So better get it right the first time and avoid another "lets do it later" like e.g. #19543. |
(Ok, just adding new fields to an object is not a breaking change. Only if the new fields were wrapped into another object, but that probably doesn't make sense here) |
I've chatted to Marco offline and agree that this PR should be changed to add |
I agree with @MarcoFalke. Illustrated more clearly (just the relevant bits):
Summary of the small edits if you're interested: update release-notes.md instead of separate doc, doxygen comment for the optional @rajarshimaitra please feel free to use this branch :) |
Hi, Sorry I got busy with other works and couldn't check the updates here lately. Honestly, I am a little overwhelmed with all the discussions regarding this, couldn't really follow up on what's happening where. |
Hi @rajarshimaitra . Thanks for your work on this. It sounds like @gzhao408 has a bit more time than you to make the final changes here, so I'd suggest that she open a PR that takes your branch and makes those last minor changes to get this merged. What do you think? |
Yep I can do that! @rajarshimaitra you'll be co-author of the commit (the branch adding the suggested changes is a cherry-pick from yours). Does this sound alright to you? |
New version is at #19940 . Thanks for your hard work on this @rajarshimaitra ! @jonatack @MarcoFalke @fjahr @promag @luke-jr - mind re-reviewing the new version at #19940? It's this branch with some minor updates. |
23c35bf [test] add get_vsize util for more programmatic testing (gzhao408) 2233a93 [rpc] Return fee and vsize from testmempoolaccept (codeShark149) Pull request description: From #19093 and resolves #19057. Difference from #19093: return `vsize` and `fees` object (similar to `getmempoolentry`) when the test accept is successful. Updates release-notes.md. ACKs for top commit: jnewbery: utACK 23c35bf fjahr: utACK 23c35bf instagibbs: reACK 23c35bf Tree-SHA512: dcb81b7b817a4684e9076bc5d427a6f2d549d2edc66544e718260c4b5f8f1d5ae1d47b754175e9f0c8a3bd8371ce116c2dca0583588d513a7d733d5d614f2b04
23c35bf [test] add get_vsize util for more programmatic testing (gzhao408) 2233a93 [rpc] Return fee and vsize from testmempoolaccept (codeShark149) Pull request description: From bitcoin#19093 and resolves bitcoin#19057. Difference from bitcoin#19093: return `vsize` and `fees` object (similar to `getmempoolentry`) when the test accept is successful. Updates release-notes.md. ACKs for top commit: jnewbery: utACK 23c35bf fjahr: utACK 23c35bf instagibbs: reACK bitcoin@23c35bf Tree-SHA512: dcb81b7b817a4684e9076bc5d427a6f2d549d2edc66544e718260c4b5f8f1d5ae1d47b754175e9f0c8a3bd8371ce116c2dca0583588d513a7d733d5d614f2b04
This solves the issue #19057.
A previous PR made the initial work but is removed due to commit history corruption from my end. Sadly the github discussion is also lost with the previous PR, though it was not extensive.
This PR makes the changes incorporating marcofalk's last comment of implementing
CAmount*
insideATMPArgs
and is ready for review.Note:
testmempoolaccept
only returnsfee
if transaction is accepted in mempool.