-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[wallet] Deprecate generate RPC method #14468
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
f6a6ba5 to
88ab22b
Compare
88ab22b to
f8c217b
Compare
|
utACK f8c217b modulo failing test, just needs a check that the wallet is enabled before running it |
f8c217b to
10c1084
Compare
|
Thanks @meshcollider. The |
|
re-utACK, just note that the whole rpc_deprecated test will be skipped now if the wallet isn't enabled, which is ok for now since this is the only test in it I guess |
Yes. I did consider just silently skipping the individual test case, but I think "mark the whole test as skipped if part of it is skipped" makes most sense. The other option "mark the test as passed even if part of it is skipped" means that test cases can be silently skipped. |
|
Concept ACK |
1 similar comment
|
Concept ACK |
|
utACK 10c1084d9fc6d4c13ca06bb2ca44088ce9b916ba |
jimmysong
left a 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.
A couple of nits =)
test/functional/wallet_basic.py
Outdated
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.
Shouldn't the right argument be +63?
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.
The memory usage change between these two calls is actually 32.
I'm not entirely sure why getmemoryinfo is part of the wallet_basic test. How bitcoin core allocates locked memory pages seems purely an implementation detail and shouldn't cause functional wallet tests to fail.
To minimize the delta in this PR, I changed the equality check to a looser inequality check, but I think this test case should be moved out of wallet_basic.py entirely in a future 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.
sounds like a good one for someone to do =).
Curious how the test passed before if it was only 32 bytes?
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.
The difference was 64 bytes before the change to the way the test generates blocks.
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.
makes sense.
test/functional/wallet_labels.py
Outdated
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.
maybe put the coinbase_address as a variable?
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.
The intent here is to have two addresses with 50 bitcoin each (see comment immediately above).
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.
makes sense.
|
Thanks for the review @jimmysong . I've responded to your nits. Hope my explanations make sense. |
|
utACK 10c1084d9fc6d4c13ca06bb2ca44088ce9b916ba |
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.
I'm not sure I understand this assertion, do we want here to blanket-ignore exceptions matching these strings?
seems to me that continuing with generatetoaddress if this failed is not a good idea
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.
Only accept importprivkey failure if:
- wallet is disabled
- there are multiple wallets to import to
- wallet is locked
In either case the outcome is the impossibility of spending the coinbase output. And if that's relevant to the test then it would fail for not having enough coins to spend.
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.
@promag is right. This call to importprivkey can fail for the three reasons listed.
I think that this is a bit too much magic behind the scenes though. I've tidied up the deterministic priv key import behaviour in another branch here: https://github.com/jnewbery/bitcoin/tree/deprecate_generate2. Rather than complicate this PR and add review burden here, are you happy to leave this as is for now and take the final commit in https://github.com/jnewbery/bitcoin/tree/deprecate_generate2 as a follow-up 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.
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.
Comment added.
promag
left a 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 10c1084.
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.
Just noting that could use w5.generatetoaddress despite the fact this RPC doesn't require a wallet.
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.
Yes, that's possible, but I think it's better to call the generatetoaddress method on the node endpoint rather than the wallet endoint (since it's a node method).
However, I have updated these calls to use the node alias rather than self.nodes[0] to be mode compact.
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.
IMO drop these comments — because it is deprecated code.
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.
you're right - these should have been removed
src/wallet/rpcwallet.cpp
Outdated
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, could use same wording as
bitcoin/src/wallet/rpcwallet.cpp
Line 1071 in 2468471
| throw JSONRPCError(RPC_METHOD_DEPRECATED, "addwitnessaddress is deprecated and will be fully removed in v0.17. " |
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.
I wanted to be explicit that it was the wallet method that was being deprecated. Just saying generate is deprecated could be interpreted as the node not being able to generate blocks at all.
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.
Only accept importprivkey failure if:
- wallet is disabled
- there are multiple wallets to import to
- wallet is locked
In either case the outcome is the impossibility of spending the coinbase output. And if that's relevant to the test then it would fail for not having enough coins to spend.
In advance of deprecating the generate RPC method, make some small changes to a small number of inidividual test cases: - make memory checking less prescriptive in wallet_basic.py - replace calls to generate with generatetoaddress in wallet_keypool.py - replace calls to generate with generatetoaddress and fixup label issues in wallet_labels.py - replace calls to generate with generatetoaddress in wallet_multiwallet.py
10c1084 to
351faf7
Compare
|
Addressed @promag's comments |
|
Concept ACK Can you replace the RPC example |
That example only works if bitcoind is compiled with a wallet and is running with a single wallet. I don't think it makes sense to make the example so specific. |
@Sjors sorry, I can't find that, can you link it? |
|
@jnewbery there can be more than one example in the RPC help, but this is the default config and most likely thing someone is looking for if they try regtest for the first time. |
|
Lines 168 to 169 in 9c5f0d5
I also think this is fine. FWIW I would remove all examples. |
Adds a generate() method to the TestNode class in the test framework. This method intercepts calls to generate, imports a dewterministic private key to the node and then calls generatetoaddress to generate the block to that address. Note that repeated calls to importprivkey for the same private keys are no-ops, so it's fine to call the generate() method many times.
351faf7 to
c9f0295
Compare
|
I've added a comment to address #14468 (comment). |
|
Unrelated failure https://travis-ci.org/bitcoin/bitcoin/jobs/443416363. Restarted job. |
|
utACK c9f0295 👋 generate |
|
|
||
| def skip_test_if_missing_module(self): | ||
| # The generate RPC method requires the wallet to be compiled | ||
| self.skip_if_no_wallet() |
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.
I don't think the whole test should be skipped if there is not wallet compiled in, but rather only the wallet-specific assert_raises_rpc_error should be skipped. This way other tests in this file that are not wallet-specific would run when the wallet is not compiled.
|
utACK c9f0295, but I'd prefer to not use |
See earlier comment:
I'd prefer not to change this PR and invalidate ACKs, but if you feel strongly about this, I could add a |
|
I locally tested the changes. Everything works correctly. Also note that popular tutorials (bitcoin.org and maybe others) start with this RPC as the first example. Giving an additional RPC help output which directly gives new users a copy-paste line might be useful. Not a big deal because websites will update eventually. ACK c9f0295 |
|
@Sjors @sanket1729 I've added a hint to use I didn't include the |
|
Tested. ACK ab9aca2 . |
|
Fine with me to keep it as is in this pull request for now, but if you disagree with the concept of (silently) skipping subtests if the module required to run them is not available, we should revert #14324 and remove the |
I can see the merit in both arguments, and don't feel strongly one way or the other. I'd prefer to not churn this PR any more, but as I said earlier, happy to change if you feel strongly. |
ab9aca2 [rpc] add 'getnewaddress' hint to 'generatetoaddress' help text. (John Newbery) c9f0295 [wallet] Deprecate the generate RPC method (John Newbery) aab8172 [tests] Add generate method to TestNode (John Newbery) c269209 [tests] Small fixups before deprecating generate (John Newbery) Pull request description: Deprecates the `generate` RPC method. For concept discussion, see #14299. Fixes #14299. Tree-SHA512: 16a3b8b742932e4f0476c06b23de07a34d9d215b41d9272c1c9d1e39966b0c2406f17c5ab3cc568947620c08171ebe5eb74fd7ed4b62151363e305ee2937cc80
Reviewers, 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. |
|
@NicolasDorier you might want to know about this. |
3fd7e76 [tests] Move deterministic address import to setup_nodes (John Newbery) Pull request description: This requires a small changes to a few tests, but means that deterministic addresses will always be imported (unless setup_nodes behaviour is explicitly overridden). Tidies up the way we import deterministic addresses, requested in review comment here: #14468 (comment). Tree-SHA512: 2b32edf500e286c463398487ab1153116a1dc90f64a53614716373311abdc83d8a251fdd8f42d1146b56e308664deaf62952113f66e98bc37f23968096d1a961
Instead of using the wallet's `generate` RPC method ( which is deprecated, see bitcoin/bitcoin#14468 ), use the server's `generatetoaddress` RPC method. Signed-off-by: Andres Correa Casablanca <[email protected]>
Summary: In advance of deprecating the generate RPC method, make some small changes to a small number of inidividual test cases: - make memory checking less prescriptive in wallet_basic.py - replace calls to generate with generatetoaddress in wallet_keypool.py - replace calls to generate with generatetoaddress and fixup label issues in wallet_labels.py - replace calls to generate with generatetoaddress in wallet_multiwallet.py This is a partial backport of Core [[bitcoin/bitcoin#14468 | PR14468]] : bitcoin/bitcoin@c269209 I also added a similar fix for abc-parkedchain.py Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D5969
Summary: Adds a generate() method to the TestNode class in the test framework. This method intercepts calls to generate, imports a dewterministic private key to the node and then calls generatetoaddress to generate the block to that address. Note that repeated calls to importprivkey for the same private keys are no-ops, so it's fine to call the generate() method many times. This is a partial backport of Core [[bitcoin/bitcoin#14468 | PR14468]] : bitcoin/bitcoin@aab8172 The code was slightly tweaked because we have some tests for which `self.rpc` is `None` because they've been created after [[bitcoin/bitcoin#14631 | PR14631]] which remove the call to importprivkey Depends on D5969 Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: majcosta Differential Revision: https://reviews.bitcoinabc.org/D5970
Summary: This is a partial backport of Core [[bitcoin/bitcoin#14468 | PR14468]] : bitcoin/bitcoin@c9f0295 Depends on D5970 Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D5971
Summary: Final step of [[bitcoin/bitcoin#14468 | PR14468]] Depends on D5971 Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D5972
Summary: In advance of deprecating the generate RPC method, make some small changes to a small number of inidividual test cases: - make memory checking less prescriptive in wallet_basic.py - replace calls to generate with generatetoaddress in wallet_keypool.py - replace calls to generate with generatetoaddress and fixup label issues in wallet_labels.py - replace calls to generate with generatetoaddress in wallet_multiwallet.py This is a partial backport of Core [[bitcoin/bitcoin#14468 | PR14468]] : bitcoin/bitcoin@c269209 I also added a similar fix for abc-parkedchain.py Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D5969
Deprecates the
generateRPC method.For concept discussion, see #14299.
Fixes #14299.