Skip to content

Denial-of-service prevention: low-difficulty blocks#534

Merged
gavinandresen merged 2 commits intobitcoin:masterfrom
gavinandresen:DoSorphans
Dec 1, 2011
Merged

Denial-of-service prevention: low-difficulty blocks#534
gavinandresen merged 2 commits intobitcoin:masterfrom
gavinandresen:DoSorphans

Conversation

@gavinandresen
Copy link
Copy Markdown
Contributor

The attack this prevents: Generate valid low-difficulty blocks (maybe built on top of an early part of the block chain) and send them to a bitcoin node. Before this patch the bitcoin client could store an arbitrary number of them in memory or on disk, in case they later became part of the main chain.

Two checks are added:

  1. Blocks before the last blockchain lock-in are rejected, and the peer sending these obviously-not-part-of-the-main-chain blocks it will be disconnected and banned.

  2. Blocks must have a plausible proof-of-work. It is impossible for a difficulty 1.0 block to follow a difficulty 1-million block (it would take at least 19 months for difficulty to drop from 1-million to 1). Blocks with too-low proof-of-work are ignored, and peers relaying them are disconnected/banned.

Requiring plausible proof-of-work for orphan blocks or alternate chains foils this attack (you would have to be able to generate valid blocks near current difficulty).

@gavinandresen
Copy link
Copy Markdown
Contributor Author

Testing: Unless somebody has already written a tool to generate low-difficulty valid-but-orphan blocks, I think we may have to rely on code review and unit tests (unit tests are part of this pull).

(I am working on a tool to generate blocks and transactions for testing, but have more work to do on it)

@alexwaters
Copy link
Copy Markdown
Contributor

Would test-net-in-a-box allow me to create orphaned blocks to test this?

@gavinandresen
Copy link
Copy Markdown
Contributor Author

You can't use testnet to test this, because testnet doesn't have block-chain lock-in points and there's no way to generate orphan blocks on purpose with too-low difficulty.

@ByteCoin
Copy link
Copy Markdown

ByteCoin commented Oct 4, 2011

What's the justification for having more checkpoints than just the latest?

@gavinandresen
Copy link
Copy Markdown
Contributor Author

Justification for more than the last checkpoint is it makes it harder for an attacker to waste a newbie's time downloading a long-but-invalid chain.

Pruning some of the checkpoints in the middle is probably a good idea.

gavinandresen added a commit that referenced this pull request Dec 1, 2011
Denial-of-service prevention: low-difficulty blocks
@gavinandresen gavinandresen merged commit 43f20bb into bitcoin:master Dec 1, 2011
coblee referenced this pull request in litecoin-project/litecoin Jul 17, 2012
Denial-of-service prevention: low-difficulty blocks
@rebroad
Copy link
Copy Markdown
Contributor

rebroad commented Jun 2, 2013

I would be curious to know if this network rule change is in line with the Satoshi White Paper on bitcoin.

@gmaxwell
Copy link
Copy Markdown
Contributor

gmaxwell commented Jun 2, 2013

Why are you replying to two year old pulls? This doesn't make the node reject any blocks that it wouldn't already (ultimately) reject.

@sipa
Copy link
Copy Markdown
Member

sipa commented Jun 2, 2013

Indeed, it's not a rule change. It just detects invalid blocks earlier.

@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants