2WP: Allow other elements chains as parent chains for pegs#362
2WP: Allow other elements chains as parent chains for pegs#362jtimon merged 3 commits intoElementsProject:elements-0.14.1from
Conversation
30ec4dd to
2126521
Compare
773ab52 to
e756199
Compare
|
Rebased after #363 was merged, which was a requirement for this (or some other way to do the same). |
e756199 to
cbf9912
Compare
cbf9912 to
19ecf0c
Compare
|
Removed the 'WIP' because now it seems to pass most of the tests. |
|
Will review |
src/init.cpp
Outdated
| strUsage += HelpMessageOpt("-parentpubkeyprefix", strprintf(_("The byte prefix, in decimal, of the parent chain's base58 pubkey address. (default: %d)"), 111)); | ||
| strUsage += HelpMessageOpt("-parentscriptprefix", strprintf(_("The byte prefix, in decimal, of the parent chain's base58 script address. (default: %d)"), 196)); | ||
|
|
||
| strUsage += HelpMessageOpt("-con_parent_chain_has_pow", "Whether parent chain uses pow or signed blocks default: 1"); |
There was a problem hiding this comment.
put default in parenthesis
src/validation.cpp
Outdated
| } | ||
|
|
||
| template<typename T> | ||
| static bool CheckPegoutTx(const std::vector<unsigned char>& tx_data, T& pegtx, const COutPoint& prevout, const CAmount claim_amount, const CScript& claim_script) |
src/validation.cpp
Outdated
| return false; | ||
| } | ||
| if (merkle_block.txn.ExtractMatches(txHashes, txIndices) != merkle_block.header.hashMerkleRoot || txHashes.size() != 1) { | ||
| // TODO do this inside to prever DoS ? |
|
concept ACK. Going to have to carefully comb over these changes. |
|
Could we split up these changes into basic refactors, then consensus changes? |
2e077cc to
2f0f2fc
Compare
50338cc to
6de5683
Compare
|
Uncommented more tests. |
6de5683 to
4118621
Compare
5cae62a to
3f10c98
Compare
qa/rpc-tests/feature_fedpeg.py
Outdated
| proof = parent.gettxoutproof([txid1]) | ||
|
|
||
| raw = parent.getrawtransaction(txid1) | ||
| import json |
There was a problem hiding this comment.
That's a strange place to import json..
| print(e.error["message"]) | ||
| assert("Given or recovered script is not a witness program." in e.error["message"]) | ||
|
|
||
| # # Should fail due to non-matching wallet address |
There was a problem hiding this comment.
Is this here because it should fail due to this if it would not fail due to non-witness (clause above)?
This is very good for clarity, but it doesn't really test if it would fail in that case..
There was a problem hiding this comment.
That's simply the same test as in https://github.com/ElementsProject/elements/blob/elements-0.14.1/qa/rpc-tests/pegging.py#L233 but commented because I didn't manage to make it work, note here there's a similar one above "Should fail due to non-witness", perhaps that's enough.
Perhaps I should just remove that commented code, but then I will forget about it.
@instagibbs thoughts?
There was a problem hiding this comment.
was this functionality supposed to be working?
|
How much extra work is it to do this properly and check for the correct asset id? Shouldn't it just be a single check? |
dbcc884 to
502357a
Compare
|
Fixed import nit, rebased (was clean). @instagibbs Added a wip commit doing the check, but the tests fail, unless I'm misunderstanding something, because the asset id in the pegin tx from the parent chain is not explicit but confidential. |
|
The output shouldn't be confidential though? The mainchain_address is unconfidential, yes? |
58b09f9 to
abc8305
Compare
|
Right, sorry, it was just a bug that confused me. It seems to work now. Let me know if you prefer me to squash, rename the commit or something else. I would squash, I think. |
qa/rpc-tests/feature_fedpeg.py
Outdated
| self.parentgenesisblockhash = self.nodes[0].getblockhash(0) | ||
| print('parentgenesisblockhash', self.parentgenesisblockhash) | ||
| parent_pegged_asset = self.nodes[0].getsidechaininfo()['pegged_asset'] | ||
| print('parent_pegged_asset', parent_pegged_asset) |
This allows other elements chains as parent chains for pegs, for testing purposes for now it also assumes that the parent chain has CT/CA tx format, which is orthogonal to the parent chain having pow or signed blocks It would be nice to also test bitcoin-like chains with signed blocks instead of pow by adding another parameter -con_parent_chain_has_CT or similar and decouple the logic Introduce -con_parent_pegged_asset option to check the asset in the peg-in txs from the parent chains. CT: Introduce GetAmountFromParentChainPegin for CT txs RPC: Adapt rpcwallet to initial -con_parent_chain_has_pow Introduce CheckProofGeneric Introduce pow::CheckProofParent
abc8305 to
3f62b32
Compare
| throw JSONRPCError(RPC_TYPE_ERROR, "The included txoutproof is malformed. Are you sure that is the whole string?"); | ||
| } | ||
|
|
||
| if (!ssTxOutProof.empty() || !CheckBitcoinProof(merkleBlock.header.GetHash(), merkleBlock.header.nBits)) |
There was a problem hiding this comment.
why are we dropping this check?
There was a problem hiding this comment.
|
utACK 3f62b32 other than single question |
7c33e3a qt: Add missing mnemonics in menu bar options (Shashwat) Pull request description: Since ElementsProject#362 we have defaulted to add mnemonic shortcuts for the context menus. The Window -> Minimize option and File -> Load PSBT from clipboard were hitherto missing a mnemonic shortcut. This PR adds mnemonic shortcuts for them Changes introduced in this PR: | Master | PR | | ----------| ---- | |  | | ||| ACKs for top commit: jarolrod: tACK 7c33e3a hebasto: ACK 7c33e3a, tested on Linux Mint 20.2 (Qt 5.12.8). Tree-SHA512: 32f201ae7716b19ca123856292f8bfa0d805f6c7271ac1b5e08eff6b95017443754c8a76e8396ccca1869a57384e11016cbd99d63ccdd2fae6da4eaf3ae32298
Fix #360 (doesn't really fix it as noted in #362 (comment) , but it is still useful for testing)
Dependencies: