-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: Use the default maxfeerate value as BTC/kB #16521
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
Conversation
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.
Thanks for working on this. A few questions.
5665a1a
to
31ad961
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
A few tests need to be updated, since the default is no longer an absolute value of 0.01, but a fee rate of 0.01 BTC/kB. Generally txs are less than 1kB, so the absurd high-fee will kick in earlier. |
Concept ACK.
Should backport this? |
Also, I'd rather not change validation in a bugfix for an rpc. |
@MarcoFalke sorry for not being clear on my comment, I wasn't suggesting to do that change here, hence the backport question. Thanks for referencing #15810. |
This was introduced here: #16382 (comment), so no it does not need backport. |
0bb71b1
to
c540e25
Compare
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.
Looks good. Some style comments
8153e7f
to
7335bd3
Compare
ACK 7335bd3 |
One of the Travis jobs has failed by timeout. |
I restarted Travis for you. ACK 7335bd3, though I suggest having the RPC code catch The rename from We're still in a bit of weird situation, but it's fine for now: |
cc @kallewoof |
rawTx = self.nodes[2].createrawtransaction(inputs, outputs) | ||
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx) | ||
assert_equal(rawTxSigned['complete'], True) | ||
# 1000 sat fee, ~100 b transaction, fee rate should land around 10 sat/b = 0.00010000 BTC/kB | ||
# 2000000 sat fee, ~100 b transaction, fee rate should land around 20000 sat/b = 0.20000000 BTC/kB |
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 tests the default, but removes the test for when a user provides a max fee rate below the default. That is probably the more frequent use case, so it should be tested.
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.
Agreed. I'll refactor the test a little bit so that both cases are covered.
@Sjors I agree with the rationale behind your suggestion, but I can't think of a neat way of actually implementing it. |
7335bd3
to
49b1f48
Compare
ACK 49b1f48 Show signature and timestampSignature:
Timestamp of file with hash |
src/rpc/rawtransaction.cpp
Outdated
*/ | ||
constexpr static CAmount DEFAULT_MAX_RAW_TX_FEE{COIN / 10}; | ||
const static CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10}; |
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.
Style nit: The storage-class specifier is typically put at the start of the declaration in this project -- that is: static const …
is typically used instead of const static …
:-)
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.
Fixed.
This patch adds test for the following case - maxfeerate is omitted, and the actual fee rate is higher than the default value(0.1 BTC/kB)
49b1f48
to
2dfd683
Compare
re-run ci |
I couldn't reproduce the failing test on my machine. Is it CI's problem? |
ACK 2dfd683 (ACKs by Sjors and MarcoFalke above for trivially different code) |
2dfd683 test: Add test for default maxfeerate in sendrawtransaction (Joonmo Yang) 261843e wallet/rpc: Use the default maxfeerate value as BTC/kB (Joonmo Yang) Pull request description: Fixes #16382 This patch tries to treat `maxfeerate` in sendrawtransaction/testmempoolaccept RPC as a rate(BTC/kB) instead of an absolute value(BTC). The included test case checks if the new behavior works correctly, by using the transaction with an absolute fee of ~0.02BTC, where the fee rate is ~0.2BTC/kB. This test should be failing if the default `maxfeerate` is 0.1BTC, but pass if the default value is 0.1BTC/kB ACKs for top commit: laanwj: ACK 2dfd683 (ACKs by Sjors and MarcoFalke above for trivially different code) Tree-SHA512: a1795bffe8a182acef8844797955db1f60bb0c0ded97148f3572dc265234d5219271a3a7aa0b6418a43f73b2b2720ef7412ba169c99bb1cdcac52051f537d6af
post-merge re-ACK 2dfd683 (only change is style nit) Show signature and timestampSignature:
Timestamp of file with hash |
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0) | ||
rawTx = self.nodes[0].getrawtransaction(txId, True) | ||
vout = next(o for o in rawTx['vout'] if o['value'] == Decimal('1.00000000')) | ||
|
||
self.sync_all() | ||
inputs = [{ "txid" : txId, "vout" : vout['n'] }] | ||
outputs = { self.nodes[0].getnewaddress() : Decimal("0.99999000") } # 1000 sat fee | ||
outputs = { self.nodes[0].getnewaddress() : Decimal("0.999990000") } # 10000 sat 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.
eh, actually this is incorrect. Appending zeros after the number after the decimal point does not change the number.
>>> 0.9 == 0.90
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.
Yeah, should be 0.99990000
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.
OMG. I'll send a patch soon.
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, should be
0.99990000
Done in #16929.
2dfd683 test: Add test for default maxfeerate in sendrawtransaction (Joonmo Yang) 261843e wallet/rpc: Use the default maxfeerate value as BTC/kB (Joonmo Yang) Pull request description: Fixes bitcoin#16382 This patch tries to treat `maxfeerate` in sendrawtransaction/testmempoolaccept RPC as a rate(BTC/kB) instead of an absolute value(BTC). The included test case checks if the new behavior works correctly, by using the transaction with an absolute fee of ~0.02BTC, where the fee rate is ~0.2BTC/kB. This test should be failing if the default `maxfeerate` is 0.1BTC, but pass if the default value is 0.1BTC/kB ACKs for top commit: laanwj: ACK 2dfd683 (ACKs by Sjors and MarcoFalke above for trivially different code) Tree-SHA512: a1795bffe8a182acef8844797955db1f60bb0c0ded97148f3572dc265234d5219271a3a7aa0b6418a43f73b2b2720ef7412ba169c99bb1cdcac52051f537d6af
6659810 test: use named args for sendrawtransaction calls (Jon Atack) 5c1cd78 doc: improve rawtransaction code/test docs (Jon Atack) acc14c5 test: fix incorrect value in rpc_rawtransaction.py (Jon Atack) Pull request description: Follow-up to PR #16521. - Fix incorrect value in rpc_rawtransaction test as per https://github.com/bitcoin/bitcoin/pull/16521/files#r325842308 - Improve the code docs - Use named arguments as per https://github.com/bitcoin/bitcoin/pull/16521/files#r310715127 Happy to squash or keep only the first commit if the others are too fixup-y. ACKs for top commit: laanwj: ACK 6659810 Tree-SHA512: bf5258f23802ab3ba3defb8791097e08e63f3e2af21023f832cd270dc88d1fa04349e921d69f9f5fedac5dce5cd3c1cc46b48febbede4bc18dccb8be994565b2
… as BTC/kB 6659810 test: use named args for sendrawtransaction calls (Jon Atack) 5c1cd78 doc: improve rawtransaction code/test docs (Jon Atack) acc14c5 test: fix incorrect value in rpc_rawtransaction.py (Jon Atack) Pull request description: Follow-up to PR bitcoin#16521. - Fix incorrect value in rpc_rawtransaction test as per https://github.com/bitcoin/bitcoin/pull/16521/files#r325842308 - Improve the code docs - Use named arguments as per https://github.com/bitcoin/bitcoin/pull/16521/files#r310715127 Happy to squash or keep only the first commit if the others are too fixup-y. ACKs for top commit: laanwj: ACK 6659810 Tree-SHA512: bf5258f23802ab3ba3defb8791097e08e63f3e2af21023f832cd270dc88d1fa04349e921d69f9f5fedac5dce5cd3c1cc46b48febbede4bc18dccb8be994565b2
Summary: * wallet/rpc: Use the default maxfeerate value as BTC/kB * test: Add test for default maxfeerate in sendrawtransaction This patch adds test for the following case - maxfeerate is omitted, and the actual fee rate is higher than the default value(0.1 BTC/kB) This is a backport of Core [[bitcoin/bitcoin#16521 | PR16521]] Test Plan: ninja all check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D8027
Fixes #16382
This patch tries to treat
maxfeerate
in sendrawtransaction/testmempoolaccept RPC as a rate(BTC/kB) instead of an absolute value(BTC).The included test case checks if the new behavior works correctly, by using the transaction with an absolute fee of ~0.02BTC, where the fee rate is ~0.2BTC/kB.
This test should be failing if the default
maxfeerate
is 0.1BTC, but pass if the default value is 0.1BTC/kB