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

Bugfix: remove conflicting transactions from memory pool #2033

Merged
merged 1 commit into from
Dec 1, 2012

Conversation

sipa
Copy link
Member

@sipa sipa commented Nov 24, 2012

When a transaction A is in the memory pool, while a transaction B (which shares an input with A) gets accepted into a block, A was kept forever in the memory pool.

This problem exists in probably all versions of Bitcoin ever. On v0.7.1, it can be demonstrating by mining with 7e15b68 applied. Every few hours, it seems such a transactions that conflicts with the memory pool gets mined (successful double spends?).

Fixing this results in less transactions in the memory pool, and faster construction of new blocks.

This should apply cleanly on v0.7.0, v0.7.1 and HEAD.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/c52f3b86ceb4b2d933f919e06275c670f31dbdb6 for binaries and test log.

@sipa
Copy link
Member Author

sipa commented Nov 25, 2012

I just observed mempool transactions depending on spent inputs on v0.7.1 with this patch - maybe it doesn't work.

When a transaction A is in the memory pool, while a transaction B
(which shares an input with A) gets accepted into a block, A was
kept forever in the memory pool.

This commit adds a CTxMemPool::removeConflicts method, which
removes transactions that conflict with a given transaction, and
all their children.

This results in less transactions in the memory pool, and faster
construction of new blocks.
@sipa
Copy link
Member Author

sipa commented Nov 25, 2012

Ok, seems the implementation didn't actually remove recursively. Should be fixed now.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/231b399952fd620ee0f72b1947024dba9651630d for binaries and test log.

@gmaxwell
Copy link
Contributor

ACK. I note we do not yet have any mempool unit tests. But I did test it with a bunch of real mainnet reorgs.

@gavinandresen
Copy link
Contributor

ACK

sipa added a commit that referenced this pull request Dec 1, 2012
Bugfix: remove conflicting transactions from memory pool
@sipa sipa merged commit cd7fb7d into bitcoin:master Dec 1, 2012
@rebroad
Copy link
Contributor

rebroad commented Dec 20, 2012

did this fix a bug that had been present since version 1?

@sipa
Copy link
Member Author

sipa commented Dec 20, 2012

@rebroad Yes, indeed. Not a bad one, though.

@rebroad
Copy link
Contributor

rebroad commented Dec 20, 2012

@sipa it looks like it was a bug that could have successfully created a DOS attack that may even have broken the network - i.e. create loads of conflicting transactions so that the mempool fills up to its limit and then the nodes would have stopped passing on new transactions... yes/no?

@gmaxwell
Copy link
Contributor

No, not really— because it requires mining blocks that have later spends than everyone else had accepted. So it's naturally limited by the attacker's ability to mine blocks.

@sipa sipa deleted the kickconflicts branch December 20, 2012 20:09
@rebroad
Copy link
Contributor

rebroad commented Dec 20, 2012

Unless the attacker managed to attack a mining node so that they saw the later spends instead of the earlier ones.

Or any pool mining owner who wanted to do this presumeably could.

@gmaxwell
Copy link
Contributor

Anyone who controls a large amount of hash power has much more potent attacks available to them than this. (E.g. orphan flooding)

@rebroad
Copy link
Contributor

rebroad commented Dec 21, 2012

Why would orphan flooding be a more potent attack than filling the mempool? I'd have thought the orphan pool filling up would be far less of a problem than the mempool filling up. Sorry, probably a discussion for #bitcoin...

@gmaxwell
Copy link
Contributor

Not orphan transactions. Orphan blocks.

laudney pushed a commit to reddcoin-project/reddcoin-3.10 that referenced this pull request Mar 19, 2014
Bugfix: remove conflicting transactions from memory pool
HashUnlimited pushed a commit to chaincoin/chaincoin that referenced this pull request Apr 19, 2018
* drop CMasternodeSync::ClearFulfilledRequests()

* Cleanup netfulfilledman periodically

* Do not expose RemoveFulfilledRequest()

Conflicts:
	src/masternode-sync.cpp
	src/masternode-sync.h
	src/netfulfilledman.h
	src/privatesend.cpp
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants