-
Notifications
You must be signed in to change notification settings - Fork 5
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: 🐛 update spam handling to avoid inconsistencies after runtime upgrades #338
Conversation
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.
All good! Some minor comments, good to merge!
* | ||
* This is used to check if the network is presumably under a spam attack. | ||
* Each element in the vector represents a block, and is `true` if the block was full, and `false` if it was not. |
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.
* Each element in the vector represents a block, and is `true` if the block was full, and `false` if it was not. | |
* Each element in the vector represents a block, and is `true` if the block was full, and `false` otherwise. |
// Setting the `PastBlocksStatus` bounded vector to contain as the first element a block considered full, then | ||
// exactly the minimum non full blocks, and then all full blocks, so that when adding the new non full block | ||
// the chain goes from being considered spammed to not spammed. |
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.
// Setting the `PastBlocksStatus` bounded vector to contain as the first element a block considered full, then | |
// exactly the minimum non full blocks, and then all full blocks, so that when adding the new non full block | |
// the chain goes from being considered spammed to not spammed. | |
// Setting the `PastBlocksStatus` bounded vector to contain, as the first element, a block considered full, followed by | |
// exactly the minimum required non-full blocks, and then all full blocks, so that when adding the new non-full block, | |
// the chain transitions from being considered spammed to not spammed. |
* | ||
* This is used to check if the network is presumably under a spam attack. | ||
* Each element in the vector represents a block, and is `true` if the block was full, and `false` if it was not. |
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.
* Each element in the vector represents a block, and is `true` if the block was full, and `false` if it was not. | |
* Each element in the vector represents a block, and is `true` if the block was full, and `false` otherwise. |
pallets/proofs-dealer/src/lib.rs
Outdated
/// | ||
/// This is used to check if the network is presumably under a spam attack. | ||
/// Each element in the vector represents a block, and is `true` if the block was full, and `false` if it was not. |
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.
/// Each element in the vector represents a block, and is `true` if the block was full, and `false` if it was not. | |
/// Each element in the vector represents a block, and is `true` if the block was full, and `false` otherwise. |
This PR changes the way we detect if the chain is currently being spammed or not to solve issue #26:
BlockFullnessPeriod
blocks. We add one to it if the previous block (current_block - 1
) was not full, and substract one from it if the blockcurrent_block - BlockFullnessPeriod - 1
was not full.PastBlocksStatus
that contains a bounded vector of boolean elements and sizeBlockFullnessPeriod
. Each index of the vector represents a block (the first element represents the oldest block of the setcurrent_block - BlockFullnessPeriod - 1
, the last element the newest block of the setcurrent_block - 1
) and each value represents whether that block was considered full or not.on_poll
hook gets executed):true
value to the bounded vector, otherwise pushes afalse
value.ChallengesTickerPaused
storage gets set or cleared accordingly.PastBlocksStatus
storage with the new vector.Note: ideally, we would use a
BitVec
to be more efficient storage-wise, but there's no current implementation of a boundedBitVec
, and since we are modifying the vector in every block, it gets included in the PoV so it cannot be unbounded