<p>A 51% attack involves just 51% of the hashrate, no nodes are involved.</p>
<p>With a majority of the hashrate, miners can construct a new branch in the chain that overtakes the chain that was previously accepted.</p>
<p>It has to be an otherwise valid chain, as otherwise nodes would reject it. The attack doesn't let the 51% attackers make the network accept any invalid transactions - it can just roll them back.</p>

CC BY-SA 4.0
2021-04-30T06:26:52.743Z
Thank you. But aren't 51% attacks for producing invalid transactions, otherwise what is the point of an attacker? And how is it an attack? I assume it has to do with the protocol. Also, don't invalid transactions cause forks all the time in the blockchain? If this is true, wouldn't that produce the longest chain temporarily. I know that nodes accept the valid blocks, and the legitimate blockchain is the longest one. How do you have two competing chains with all valid transactions, what is the point? How does node know which block to add it it's own copy if there are two valid blocks?
Matt Tainsh
CC BY-SA 4.0
2021-04-30T06:59:05.007Z
The point of a 51% attack is reverting transactions: taking money back after paying someone, and then spending it again. Or it can be used to censor a transaction from being confirmed. A 51% attacker also gets 100% of block rewards, which may be an incentive. But in no case can it be used to force the network to accept *invalid* transactions. The money must exist, and the sender has to have the key to spend it.
Pieter Wuille
CC BY-SA 4.0
2021-04-30T07:00:15.003Z
As for choosing between valid chains: the rule is that (a) among all fully-valid chains (b) the chain with the most work (typically: longest chain) is taken and (c) in case of ties, the chain with the first-seen tip is preferred.
Pieter Wuille
CC BY-SA 4.0
2021-04-30T07:02:30.003Z
Invalid transactions do not cause forks; they're just immediately ignored by the network and dropped on the floor. The same is true for blocks that contain invalid transaction, and any chain that contains such a block.
Pieter Wuille
CC BY-SA 4.0
2021-04-30T07:38:09.087Z
Thank you for the detailed response Pieter! Understood. However, as for nodes, since they can't prevent 51% attacks, do they contribute to security by participating in consensus of the validity of transactions? I understand the more nodes, the more secure the network. I know they help validate blocks, is there some consensus mechanism between nodes of what is valid? Though transactions are objectively valid or invalid, so I can't see how that works. And do nodes actually contribute to decentralisation?
Matt Tainsh
CC BY-SA 4.0
2021-04-30T09:15:24.380Z
Nodes matter through economic effects only. Miners aren't going to be inclined to try producing invalid blocks if there are economically relevant independent nodes verifying the blocks they produce. But the effect of that is hard to quantify (when is a party running a node sufficiently relevant?). It's easier to just see it as an everyone for themselves: if you don't want to be tricked into accepting invalid blocks, use a full node yourself. If you do, you don't need to worry at all anyone about what anyone else is using.
Pieter Wuille
CC BY-SA 4.0
2021-04-30T10:48:15.163Z
Thank you! About to set one up, keen to dive into it.
Matt Tainsh
CC BY-SA 4.0
2021-04-30T05:57:44.653Z
2021-04-30T05:57:44.653Z
Pieter Wuille
<p>If 51% of the hashrate was controlled by bad actors mining invalid blocks, this would become the longest chain. Where do nodes come into the 51% attack? The canonical chain is the longest chain. Is this true even if less than majority of the nodes accept it. I assume that the canonical chain is the one which majority of full nodes accept as the canonical chain, but how does this fut into block height. Would a 51% attack have to be 51% of hash power and nodes or just hash power? If so, why?</p>

<blockchain><full-node><proof-of-work><consensus><majority-attack>
51% attack, miners, nodes or both
Matt Tainsh
# 51% attack, miners, nodes or both

(Asked by: username_0 on 2021-04-30)

If 51% of the hashrate was controlled by bad actors mining invalid blocks, this would become the longest chain. Where do nodes come into the 51% attack? The canonical chain is the longest chain. Is this true even if less than majority of the nodes accept it. I assume that the canonical chain is the one which majority of full nodes accept as the canonical chain, but how does this fut into block height. Would a 51% attack have to be 51% of hash power and nodes or just hash power? If so, why?

**Tags:** blockchain, full-node, proof-of-work, consensus, majority-attack


---

## 1 answers

### Answer by username_1 on 2021-04-30. Score: 2

A 51% attack involves just 51% of the hashrate, no nodes are involved.

With a majority of the hashrate, miners can construct a new branch in the chain that overtakes the chain that was previously accepted.

It has to be an otherwise valid chain, as otherwise nodes would reject it. The attack doesn't let the 51% attackers make the network accept any invalid transactions - it can just roll them back.

> **Comments:**
> **username_0**: Thank you. But aren't 51% attacks for producing invalid transactions, otherwise what is the point of an attacker? And how is it an attack? I assume it has to do with the protocol. Also, don't invalid transactions cause forks all the time in the blockchain? If this is true, wouldn't that produce the longest chain temporarily. I know that nodes accept the valid blocks, and the legitimate blockchain is the longest one. How do you have two competing chains with all valid transactions, what is the point? How does node know which block to add it it's own copy if there are two valid blocks?  
> **username_1**: The point of a 51% attack is reverting transactions: taking money back after paying someone, and then spending it again. Or it can be used to censor a transaction from being confirmed. A 51% attacker also gets 100% of block rewards, which may be an incentive. But in no case can it be used to force the network to accept *invalid* transactions. The money must exist, and the sender has to have the key to spend it.  
> **username_1**: As for choosing between valid chains: the rule is that (a) among all fully-valid chains (b) the chain with the most work (typically: longest chain) is taken and (c) in case of ties, the chain with the first-seen tip is preferred.  
> **username_1**: Invalid transactions do not cause forks; they're just immediately ignored by the network and dropped on the floor. The same is true for blocks that contain invalid transaction, and any chain that contains such a block.  
> **username_0**: Thank you for the detailed response username_1! Understood. However, as for nodes, since they can't prevent 51% attacks, do they contribute to security by participating in consensus of the validity of transactions? I understand the more nodes, the more secure the network. I know they help validate blocks, is there some consensus mechanism between nodes of what is valid? Though transactions are objectively valid or invalid, so I can't see how that works. And do nodes actually contribute to decentralisation?  
> **username_1**: Nodes matter through economic effects only. Miners aren't going to be inclined to try producing invalid blocks if there are economically relevant independent nodes verifying the blocks they produce. But the effect of that is hard to quantify (when is a party running a node sufficiently relevant?). It's easier to just see it as an everyone for themselves: if you don't want to be tricked into accepting invalid blocks, use a full node yourself. If you do, you don't need to worry at all anyone about what anyone else is using.  
> **username_0**: Thank you! About to set one up, keen to dive into it.  

---

