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

Create invalid extrinsics fraud proof storage, and move block randomness into it #3314

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Dec 16, 2024

This PR:

  • creates a common InvalidInherentExtrinsicData fraud proof storage, and
  • moves the extrinsics_shuffling_seed derived from block_randomness into it

It also fixes some typos, and simplifies some of the code.

Part of #3281.

Eventually, all of InvalidInherentExtrinsicProof and most of DomainInherentExtrinsicData (except the sudo call) will be moved into InvalidInherentExtrinsicData.

Code contributor checklist:

@teor2345 teor2345 added the execution Subspace execution label Dec 16, 2024
@teor2345 teor2345 self-assigned this Dec 16, 2024
@teor2345 teor2345 enabled auto-merge December 16, 2024 23:01
Copy link
Member

@NingLin-P NingLin-P left a comment

Choose a reason for hiding this comment

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

Rest LGTM

@teor2345 teor2345 force-pushed the fraud-proof-data-simple branch from 231e06c to ae33c81 Compare December 18, 2024 23:57
@teor2345 teor2345 requested a review from NingLin-P December 18, 2024 23:58
Copy link
Member

@NingLin-P NingLin-P left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Comment on lines 265 to 266
// Used by caller
block_randomness: _,
Copy link
Member

Choose a reason for hiding this comment

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

This field was introduced recently and is not exist in the consensus runtime in mainnet, so we should also remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Specifically in #3312, where it wasn’t caught in review. Is there an automated test we could add to catch accidental changes like this?

Copy link
Member

Choose a reason for hiding this comment

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

It is hard to test compatibility with an existing network in unit/integration test, usually we will test runtime upgrade before release (by simulating the existing network in a local network).

@NingLin-P NingLin-P added the host-function-change This PR introduce host function change, must test compatibility with existing network before release label Dec 19, 2024
@teor2345 teor2345 requested a review from NingLin-P December 19, 2024 21:18
Comment on lines 56 to +58
#[derive(Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo)]
pub enum FraudProofStorageKeyRequest<Number> {
BlockRandomness,
InvalidInherentExtrinsicData,
Copy link
Contributor Author

@teor2345 teor2345 Dec 19, 2024

Choose a reason for hiding this comment

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

Hang on, is this a breaking runtime API change?

This enum is passed to a runtime API here:

sp_api::decl_runtime_apis! {
/// API necessary for fraud proof.
pub trait FraudProofApi<DomainHeader: HeaderT> {
/// Submit the fraud proof via an unsigned extrinsic.
fn submit_fraud_proof_unsigned(fraud_proof: FraudProof<NumberFor<Block>, Block::Hash, DomainHeader, H256>);
/// Reture the storage key used in fraud proof
fn fraud_proof_storage_key(req: FraudProofStorageKeyRequest<NumberFor<Block>>) -> Vec<u8>;
}
}

If it is, I think we'll need to bump the runtime version in this PR as well.

Edit: Or since it already got bumped in #3303, maybe that's ok.

Copy link
Member

Choose a reason for hiding this comment

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

This should be fine as runtime API only fail when we actually call it and it has never been called yet as there is no domain initialized (while the host function change will crash the node upon runtime/client upgrade).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, in this case it would produce wrong results (because enum variants have changed indexes) or fail (because the expected data does not accompany the variant at that index). So that’s fine as long as most nodes are upgraded before then.

We might want to bump the runtime version for Taurus though.

@teor2345 teor2345 added the breaking-runtime This PR introduces breaking changes to the runtime label Dec 20, 2024
Comment on lines 56 to +58
#[derive(Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo)]
pub enum FraudProofStorageKeyRequest<Number> {
BlockRandomness,
InvalidInherentExtrinsicData,
Copy link
Member

Choose a reason for hiding this comment

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

This should be fine as runtime API only fail when we actually call it and it has never been called yet as there is no domain initialized (while the host function change will crash the node upon runtime/client upgrade).

Comment on lines 265 to 266
// Used by caller
block_randomness: _,
Copy link
Member

Choose a reason for hiding this comment

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

It is hard to test compatibility with an existing network in unit/integration test, usually we will test runtime upgrade before release (by simulating the existing network in a local network).

@teor2345 teor2345 added this pull request to the merge queue Dec 20, 2024
Merged via the queue into main with commit 1a77163 Dec 20, 2024
8 checks passed
@teor2345 teor2345 deleted the fraud-proof-data-simple branch December 20, 2024 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-runtime This PR introduces breaking changes to the runtime execution Subspace execution host-function-change This PR introduce host function change, must test compatibility with existing network before release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants