Skip to content
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

Make claimpegin fail in the case of a double claim #615

Closed

Conversation

Projects
None yet
2 participants
@stevenroose
Copy link
Member

commented May 8, 2019

Fixes #613. Builds on #614.

stevenroose added some commits May 7, 2019

Prevent pegin double spends from entering the mempool
This bug got introduced with the 0.17 rebase. In 0.14.1 the double pegin
claim check was done in the beginning of the validation logic, where the
coins view was the actual UTXO set. In 0.17, Core moved several checks
into a new method called CheckTxInputs in tx_verify.cpp, where we also
put the pegin check.  In the mempool acceptance check, however (as
opposed to the ConnectBlock check), CheckTxInputs is called with only a
partial UTXO view for optimization reasons. This commit adds an extra
pegin check in the beginning of the mempool code where we have a full
UTXO view.

@stevenroose stevenroose requested a review from instagibbs May 8, 2019

@stevenroose stevenroose added the 0.17 label May 8, 2019

Make claimpegin fail in the case of a double claim
Currently it will commit to the transaction without it being able to
enter the mempool. This makes the block creation code include the tx
into the block and create an invalid block.

@stevenroose stevenroose force-pushed the stevenroose:fix-claimpegin branch from 2b15ad3 to af82ff4 May 8, 2019

Improve the fedpeg test with extra double claim tests
- changes the expected behavior of claimpegin to fail on double spend
- adds extra test to make sure a block with a double spend is also not
  accepted
@@ -226,8 +232,11 @@ def run_test(self):

pegtxid1 = sidechain.claimpegin(raw, proof)
# Make sure it can't get accepted twice.
pegtxid2 = sidechain.claimpegin(raw, proof)
assert(pegtxid2 not in sidechain.getrawmempool())
try:

This comment has been minimized.

Copy link
@instagibbs

instagibbs May 8, 2019

Collaborator

use assert_raises_rpc_error instead

This comment has been minimized.

Copy link
@instagibbs

instagibbs May 8, 2019

Collaborator

also make it clearer that this is a mempool-mempool conflict, versus:

block-mempool

block-block

sidechain.generate(7)
if sidechain.gettransaction(pegtxid2)["confirmations"] > 0:
raise Exception("Pegin should not be able to get confirmed")
try:

This comment has been minimized.

Copy link
@instagibbs

instagibbs May 8, 2019

Collaborator

use assert_raises_rpc_error instead

This comment has been minimized.

Copy link
@instagibbs

instagibbs May 8, 2019

Collaborator

note that this is block-mempool conflict

doublespendblock.hashMerkleRoot = doublespendblock.calc_merkle_root()
add_witness_commitment(doublespendblock)
doublespendblock.solve()
try:

This comment has been minimized.

Copy link
@instagibbs

instagibbs May 8, 2019

Collaborator

use assert_raises_rpc_error instead

@instagibbs

This comment has been minimized.

Copy link
Collaborator

commented May 8, 2019

247bcb08d1b87ab7d00d75d57948f1d97dfe55c4 : I don't think the commit message is right. Even if you commit to a transaction that is mempool-invalid, it won't get included into the block template. Only things in mempool are considered as far as I know.

@instagibbs

This comment has been minimized.

Copy link
Collaborator

commented May 8, 2019

We should try covering all the scenarios:

mempool-mempool
block-mempool
blockA-blockB
blockA-blockA(different txs)
blockA-blockA(same tx) (this was the Core inflation bug)

@stevenroose

This comment has been minimized.

Copy link
Member Author

commented May 8, 2019

Closing, merged into #614.

@stevenroose stevenroose closed this May 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.