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

Introduce bundle longevity #2586

Merged
merged 6 commits into from
Mar 14, 2024
Merged

Introduce bundle longevity #2586

merged 6 commits into from
Mar 14, 2024

Conversation

NingLin-P
Copy link
Member

This PR introduces bundle longevity, for bundle produced from the last 5 consensus blocks won't be considered stale (in main bundle produced before the parent block will be considered as stale), this should ideally fix the issue mentioned at #2516 (comment) and slow domain block production in 3h.

This PR also introduces an additional storage item BlockSlots to pallet-subspace to keep track of the slot of the last 6 blocks, it can be used to replace the CurrentSlot and the current_slot and parent_slot fields in ParentVoteVerificationData, but more mitigation code will be required for keeping compatible with 3h, which will be done in a separate PR.

Code contributor checklist:

It is used to check keep of the block slot for the last few blocks and used
to validate bundle

Signed-off-by: linning <[email protected]>
Bundle produced more than the 5 consensus blocks ago will be considered invalid,
domain tests are adjusted accordingly

Signed-off-by: linning <[email protected]>
@NingLin-P
Copy link
Member Author

Sorry for the force push noise, it is used to fix a clippy warning under --features runtime-benchmarks that I forgot to run locally.

@dariolina
Copy link
Member

Does this also allow the ER in the bundle to be not the leaf ER, but an older one? Or was that supported already?

@fengchen06
Copy link

Summary: This looks like a good idea! I did several quick checks below.

Previously, a bundle was supposed to include the "latest" ER. In this new proposal, a bundle just needs to include one of the latest 5 ERs. Let us do some quick sanity checks.

Check 1: This will introduce more conflicting domain txs. Does it matter?
Answer: Not really. More conflicting txs reduce the efficiency, but still under the standard "lazy blockchain" model.

Check 2: Consensus nodes need to maintain a chain of ERs. How can we ensure this?
Answer: If the only condition is to "include one of the latest 5 ERs", then malicious operators can collude to "skip" a particular ER. So, we need another condition, something like "all previous ERs are available except for the latest 5 ERs."

@NingLin-P
Copy link
Member Author

NingLin-P commented Mar 6, 2024

Does this also allow the ER in the bundle to be not the leaf ER, but an older one? Or was that supported already?

This is not allowed because we are relying on this to ensure the operator is update-to-date and executed the bundles from the latest block, thus the bundle produced by such an operator contains tx that is verified against the latest domain state, if there is an illegal tx in the bundle we can safely slash the operator without worry about if operator just lagging and verified the tx against an older domain state, in this case the bundle will be rejected due to stale ER.

The bundle longevity introduced in this PR is about the proof-of-time check, not the ER.

@dariolina
Copy link
Member

Let's continue the discussion about ER on the # research channel. In the meantime, the changes in this PR make sense and can be merged and updated on gemini-3h.

Copy link
Contributor

@vedhavyas vedhavyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Left some questions

crates/pallet-domains/src/lib.rs Outdated Show resolved Hide resolved
crates/pallet-domains/src/lib.rs Show resolved Hide resolved
@@ -186,6 +186,7 @@ parameter_types! {
pub const DomainChainByteFee: Balance = 1;
pub const MaxInitialDomainAccounts: u32 = 5;
pub const MinInitialDomainAccountBalance: Balance = SSC;
pub const BundleLongevity: u32 = 5;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why cannot we use the BlockSlotCount instead of creating a new type in config ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BlockSlotCount needs to be greater than BundleLongevity, and BlockSlotCount is in pallet-subspace we need to add a config item in pallet-domains anyway.

vedhavyas
vedhavyas previously approved these changes Mar 14, 2024
@NingLin-P NingLin-P added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 14, 2024
@NingLin-P NingLin-P added this pull request to the merge queue Mar 14, 2024
Merged via the queue into main with commit 3b9c276 Mar 14, 2024
11 checks passed
@NingLin-P NingLin-P deleted the bundle-longevity branch March 14, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants