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 the stateless fraud proof #2761

Merged
merged 6 commits into from
May 22, 2024
Merged

Introduce the stateless fraud proof #2761

merged 6 commits into from
May 22, 2024

Conversation

NingLin-P
Copy link
Member

This PR is the last PR of #2652

This PR introduces the definition, generation, and verification of the stateless fraud proof.

NOTE: this PR removed the register_only for the new host function so it should only land (via a runtime upgrade) into gemini-3h after most of the nodes in the network have upgraded to release that includes #2755

Code contributor checklist:

@NingLin-P NingLin-P force-pushed the remove-unneeded-fp branch 2 times, most recently from f1c90f6 to 3beb4d8 Compare May 14, 2024 21:32
@NingLin-P NingLin-P changed the base branch from remove-unneeded-fp to main May 16, 2024 17:49
@NingLin-P NingLin-P changed the base branch from main to remove-unneeded-fp May 16, 2024 17:54
NingLin-P added 5 commits May 17, 2024 02:01
This is for the upcoming stateless FP because previous MMR only prove that there is a
historical state root but stateless FP need to ensure this is the exact state root of
a specific block. Note that XDM doesn't has this concern since it also check the channel
nonce

Signed-off-by: linning <linningde25@gmail.com>
Notice some of the fraud proof unit tests in pallet-domains is removed in this commit
because we already have end-to-end fraud proof integration tests in domain-operator
while these unit tests are mannully constructing the fraud proof and only cover some
of the verification steps thus just remove them instead of updating them base on the
new defination

Signed-off-by: linning <linningde25@gmail.com>
Signed-off-by: linning <linningde25@gmail.com>
Signed-off-by: linning <linningde25@gmail.com>
Signed-off-by: linning <linningde25@gmail.com>
@NingLin-P NingLin-P force-pushed the stateless-fraud-proof branch from ac44719 to a2610d1 Compare May 16, 2024 18:24
Copy link
Member

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

LGTM. Left some questions/nits

@@ -34,7 +33,7 @@ use sp_domains::{
InvalidBundleType, Transfers,
};
use sp_domains_fraud_proof::fraud_proof::{
ApplyExtrinsicMismatch, ExecutionPhase, FinalizeBlockMismatch, FraudProof,
ApplyExtrinsicMismatch, ExecutionPhase, FinalizeBlockMismatch, FraudProofVariant,
Copy link
Member

Choose a reason for hiding this comment

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

Its already an enum with bunch of variants. Feels redundant to call it FraudProofVariant

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, naming is hard as always :) WDYT FraudProofType?

Copy link
Member

Choose a reason for hiding this comment

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

I would leave it as FraudProof like we have initially

Copy link
Member Author

@NingLin-P NingLin-P May 20, 2024

Choose a reason for hiding this comment

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

FraudProof is already used by

pub struct FraudProof<Number, Hash, DomainHeader: HeaderT, MmrHash> {
    ...
    pub proof: FraudProofVariant<Number, Hash, DomainHeader>,
}

If you mean enum FraudProof and letting each variant contain duplicated fields like domain_id, bad_receipt_hash that is not the direction I would like to go, and I rather stick with FraudProofVariant

@@ -423,10 +423,6 @@ mod pallet {
#[pallet::storage]
pub type SuccessfulBundles<T> = StorageMap<_, Identity, DomainId, Vec<H256>, ValueQuery>;

/// Fraud proofs submitted successfully in current block.
#[pallet::storage]
pub(super) type SuccessfulFraudProofs<T: Config> =
Copy link
Member

Choose a reason for hiding this comment

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

why do we not need this anymore on the client?
How is client going to fetch the what fraud proofs are included in the previous consensus block ?
What am I missing here ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is previously required by the client to maintain all the mismatched ER in the aux storage, e.g. the client uses FP as a signal of bad ER pruning, but it is not more needed since #2329

vedhavyas
vedhavyas previously approved these changes May 21, 2024
Base automatically changed from remove-unneeded-fp to main May 21, 2024 13:32
@NingLin-P NingLin-P dismissed vedhavyas’s stale review May 21, 2024 13:32

The base branch was changed.

@NingLin-P NingLin-P enabled auto-merge May 21, 2024 16:33
@NingLin-P NingLin-P added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit 76aa651 May 22, 2024
11 checks passed
@NingLin-P NingLin-P deleted the stateless-fraud-proof branch May 22, 2024 05:51
@dariolina dariolina added the need to audit This change needs to be audited label May 22, 2024
@vanhauser-thc vanhauser-thc added audited This change was audited and removed need to audit This change needs to be audited labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audited This change was audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants