Some refactoring and add the "generateblock" RPC method#39
Merged
galpHub merged 6 commits intoDiviProject:Developmentfrom Oct 5, 2020
Merged
Some refactoring and add the "generateblock" RPC method#39galpHub merged 6 commits intoDiviProject:Developmentfrom
galpHub merged 6 commits intoDiviProject:Developmentfrom
Conversation
Mark the new StakingVaultFunding.py regtest as executable, so that it can be run directly from a command-line (without having to type "python" in front, like the other tests). It already has a shebang line anyway.
Remove some of the members in BlockFactory, which are actually only needed in the constructor and passed on to the constructors of other members (but not directly in BlockFactory). This makes the code more explicit about what is actually needed / used where.
When trying to sign a transaction with a keystore and the input is a vault script, try signing it both as owner and as staker (if signing as owner fails). This will allow signing the stake transaction correctly, and also will be useful for testing the OP_REQUIRE_COINSTAKE fork.
CScript's operator<< for pushing data is not necessarily doing it in the minimal way (namely when a single-byte op-code like OP_5 or OP_1NEGATE can be used). This means that CombineSignature (e.g. from using signrawtransaction) may produce signatures that fail verification with SCRIPT_VERIFY_MINIMALDATA. For "normal" signature types like P2PKH this does not happen; but the OP_0 and OP_1 in the signature of vault scripts trigger the bug. This fixes CombineSignatures to push data in a minimal way. It also adds a unit test that SignSignatures + CombineSignatures works for signing vault scripts both as vault and owner.
The new generateblock RPC method can be used to mine a block on demand (on regtest), while also providing extra control for testing. In particular, custom transactions can be included into the block without verifying them through normal means. In the future, more such things might be added as needed for testing, e.g. a custom coinstake tx.
Allow passing a custom coinstake transaction to generateblock, which will then be used instead of a created one. It is the caller's responsibility to make sure this yields a valid block; but on regtest with minimal dificulty, that is not hard if enough coinage is spent.
4eb15e6 to
93eb76e
Compare
galpHub
approved these changes
Oct 5, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This contains some of the harmless (not changing behaviour / introducing a fork) commits from #38, split out for easier review and merging. In particular, some small cleanups / refactorings / fixes as well as the new
generateblockRPC method. That method can be used to generate a single block on regtest (likesetgenerate True 1), and allows extra control that can be useful for testing. (In particular, a list of custom transactions can be added apart from the normal mempool logic, and a custom coinstake transaction can be used instead of generating one.)