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

Fix and improve txn_doublespend.py test #5881

Merged
merged 3 commits into from Jul 2, 2015

Conversation

Projects
None yet
4 participants
@dgenr8
Contributor

dgenr8 commented Mar 12, 2015

The first commit illustrates a problem with the current txn_doublespend.py test. The test relies on unsupportable behavior in the wallet's SyncMetaData method. The test is made to produce inconsistent results by making a small change to specific test "amount" parameters.

The second commit introduces a primitive method CTransaction::IsEquivalentTo and uses it in the wallet to ensure that SyncMetaData is only called for malleability clones, not general conflict (doublespend) transactions. This makes the output of the illustrative version of txn_doublespend.py consistent and predictable.

The third commit is a revised txn_doublespend.py test that does not rely on broken SyncMetaData. Instead, it expects the fixed version of SyncMetaData. It also removes a dependency on the soon-to-be-deprecated accounting "move" method.

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Mar 12, 2015

Member

utACK.
Travis fails test_bitcoin: chainparams.cpp:286: const CChainParams& Params(): Assertion 'pCurrentParams' failed..
You probably need to rebase because there was a travis error after a certain commit on master.

Member

jonasschnelli commented Mar 12, 2015

utACK.
Travis fails test_bitcoin: chainparams.cpp:286: const CChainParams& Params(): Assertion 'pCurrentParams' failed..
You probably need to rebase because there was a travis error after a certain commit on master.

@gavinandresen

This comment has been minimized.

Show comment
Hide comment
@gavinandresen

gavinandresen Mar 18, 2015

Contributor

I don't like the new unit test-- you are testing the new "" account gets debited on a non-malleated doublespend.

But our wallet code will never produce a non-malleated double-spend (at least not without the user jumping through some hoops to copy the wallet to two machines, etc etc etc).

I'd be happier if the new unit test tested the new code, and created a malleated version of the spend-to-foo and made sure The Right Thing happened.

I'm also uncertain about changing the SyncMetaData behavior to only work for malleated transactions, but I think I can live with that (mostly because what you get depends on the order your node sees transactions, accounts are being deprecated, and non-malleated double-spends of a "spendfrom" should never happen unless you jump through hoops).

Contributor

gavinandresen commented Mar 18, 2015

I don't like the new unit test-- you are testing the new "" account gets debited on a non-malleated doublespend.

But our wallet code will never produce a non-malleated double-spend (at least not without the user jumping through some hoops to copy the wallet to two machines, etc etc etc).

I'd be happier if the new unit test tested the new code, and created a malleated version of the spend-to-foo and made sure The Right Thing happened.

I'm also uncertain about changing the SyncMetaData behavior to only work for malleated transactions, but I think I can live with that (mostly because what you get depends on the order your node sees transactions, accounts are being deprecated, and non-malleated double-spends of a "spendfrom" should never happen unless you jump through hoops).

@dgenr8

This comment has been minimized.

Show comment
Hide comment
@dgenr8

dgenr8 Mar 24, 2015

Contributor

Per @gavinandresen review:

  • Improved implementation of IsEquivalentTo
  • Added txn_clone.py, which tests malleability clone accounting
  • Updated rpc-tests.sh to call the new test with and without the --mineblock option

The new test relies on setting nlocktime via createrawtransaction. There is also a stand-alone #5936 for this change.

Contributor

dgenr8 commented Mar 24, 2015

Per @gavinandresen review:

  • Improved implementation of IsEquivalentTo
  • Added txn_clone.py, which tests malleability clone accounting
  • Updated rpc-tests.sh to call the new test with and without the --mineblock option

The new test relies on setting nlocktime via createrawtransaction. There is also a stand-alone #5936 for this change.

dgenr8 added some commits Mar 11, 2015

Implement CTransaction::IsEquivalentTo(...)
Define CTransaction::IsEquivalentTo(const CTransaction& tx)

True if only scriptSigs are different.  In other words, true if
the two transactions are malleability clones.  In other words,
true if the two transactions have the same effect on the
outside universe.

In the wallet, only SyncMetaData for equivalent transactions.
Better txn_doublespend.py test
Remove reliance on accounting "move" ledger entries.  Instead,
create funding transactions (and deal with fee complexities).

Do not rely on broken SyncMetaData.  Instead expect double-spend
amount to be debited from the default "" account.
@dgenr8

This comment has been minimized.

Show comment
Hide comment
@dgenr8

dgenr8 Apr 12, 2015

Contributor
  • Problem illustration squashed, archived here.
  • txn_clone.py updated to use rpc generate(...)
Contributor

dgenr8 commented Apr 12, 2015

  • Problem illustration squashed, archived here.
  • txn_clone.py updated to use rpc generate(...)
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Apr 15, 2015

Member

ACK on new test, for discussion with regard to adding a field to createrawtransaction RPC see #5936

Member

laanwj commented Apr 15, 2015

ACK on new test, for discussion with regard to adding a field to createrawtransaction RPC see #5936

@laanwj laanwj added the Tests label Apr 15, 2015

@dgenr8

This comment has been minimized.

Show comment
Hide comment
@dgenr8

dgenr8 May 12, 2015

Contributor

Removed the change to createrawtransaction.

Contributor

dgenr8 commented May 12, 2015

Removed the change to createrawtransaction.

Add txn_clone.py test
Does what the old txnmall.sh test did.

Creates an equivalent malleated clone and tests that SyncMetaData
syncs the accounting effects from the original transaction to the
confirmed clone.

@dgenr8 dgenr8 referenced this pull request Jun 15, 2015

Closed

Fix conflict tests #16

@laanwj laanwj merged commit 5d34e16 into bitcoin:master Jul 2, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Jul 2, 2015

Merge pull request #5881
5d34e16 Add txn_clone.py test (Tom Harding)
defd2d5 Better txn_doublespend.py test (Tom Harding)
b2b3619 Implement CTransaction::IsEquivalentTo(...) (Tom Harding)

laanwj added a commit that referenced this pull request Jul 2, 2015

tests: fix txn_clone.py
Solve merge conflict of test added in #5881 with #6097.

laanwj added a commit to laanwj/bitcoin that referenced this pull request Jul 2, 2015

Move recently introduced CTransAction::IsEquivalentTo to CWalletTx
CTransAction::IsEquivalentTo was introduced in #5881.
This functionality is only useful to the wallet, and should never have
been added to the primitive transaction type.

jonasschnelli added a commit to jonasschnelli/bitcoin that referenced this pull request Jul 8, 2015

Move recently introduced CTransAction::IsEquivalentTo to CWalletTx
CTransAction::IsEquivalentTo was introduced in #5881.
This functionality is only useful to the wallet, and should never have
been added to the primitive transaction type.

@str4d str4d referenced this pull request Feb 14, 2017

Merged

Bitcoin 0.12 test PRs 1 #2101

zkbot added a commit to zcash/zcash that referenced this pull request Feb 15, 2017

zkbot added a commit to zcash/zcash that referenced this pull request Feb 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment