-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat: double spend spam protection #1945
feat: double spend spam protection #1945
Conversation
/// The maximum number of double spend attempts to store that we got from PUTs | ||
const MAX_DOUBLE_SPEND_ATTEMPTS_TO_KEEP_FROM_PUTS: usize = 15; | ||
|
||
/// The maximum number of double spend attempts to store inside a record | ||
const MAX_DOUBLE_SPEND_ATTEMPTS_TO_KEEP_PER_RECORD: usize = 30; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MAX is now 2 as this measure protected us until the attackers reached the MAX double spent attempt to keep!
bd81c37
to
4cec77c
Compare
4cec77c
to
551b542
Compare
sn_node/src/put_validation.rs
Outdated
let array: Vec<_> = live_spends.clone().into_iter().collect(); | ||
if let [one, two] = array.as_slice() { | ||
warn!("Got two live spends {one:?} and {two:?}, things are messed up!"); | ||
return Ok((one.to_owned().clone(), two.to_owned().clone())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we return early here, will we have an inconsistent state among our nodes if there are more than 2 live branches?
Having >1 live branch is very unlikely, but should we collect all live branches and then return the first 2, just to be deterministic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right!
551b542
to
1bc3e4a
Compare
331bdf8
to
8071507
Compare
0e489e1
to
b3a73f7
Compare
Description
The attack
An attack to hide a good spend. Say we have:
A->B->C->D
The attacker wants to get rid of B to poison C and D. They can spam the network with lots of double spends for B until none of the nodes have the original one. The attack is quite intricate and we discussed different alternatives with 2 spends as max for a spend record or unlimited (record size) as max. In both cases the attack was successful.
The solution was to add a descendency check in the case where we have more than 2 spends to choose which to keep: