Skip to content

Commit

Permalink
Introduce new host function for incoming stateless fraud proof
Browse files Browse the repository at this point in the history
NOTE all the host function are marked as register_only meaning they are only
introduced in the client side not the runtime, we can remove register_only after
most of the consensus node upgraded to a release contains these host function
then use these function in the runtime

Signed-off-by: linning <[email protected]>
  • Loading branch information
NingLin-P committed May 10, 2024
1 parent 00927c6 commit 0e03641
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 61 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 46 additions & 1 deletion crates/pallet-domains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ use sp_domains_fraud_proof::fraud_proof::{
InvalidExtrinsicsRootProof, ValidBundleDigest,
};
use sp_domains_fraud_proof::{
DomainChainAllowlistUpdateExtrinsic, FraudProofExtension, FraudProofHostFunctions,
DomainChainAllowlistUpdateExtrinsic, DomainInherentExtrinsic, DomainInherentExtrinsicData,
DomainStorageKeyRequest, FraudProofExtension, FraudProofHostFunctions,
FraudProofVerificationInfoRequest, FraudProofVerificationInfoResponse, SetCodeExtrinsic,
StatelessDomainRuntimeCall,
};
use sp_runtime::traits::{
AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash as HashT, IdentityLookup, One,
Expand Down Expand Up @@ -442,6 +444,14 @@ impl FraudProofHostFunctions for MockDomainFraudProofExtension {
Some(H256::random())
}

fn derive_bundle_digest_v2(
&self,
_domain_runtime_code: Vec<u8>,
_bundle_body: Vec<OpaqueExtrinsic>,
) -> Option<H256> {
Some(H256::random())
}

fn execution_proof_check(
&self,
_domain_id: (u32, H256),
Expand All @@ -453,6 +463,41 @@ impl FraudProofHostFunctions for MockDomainFraudProofExtension {
) -> Option<Vec<u8>> {
None
}

fn check_extrinsics_in_single_context(
&self,
_domain_runtime_code: Vec<u8>,
_domain_block_id: (u32, H256),
_domain_block_state_root: H256,
_bundle_extrinsics: Vec<OpaqueExtrinsic>,
_encoded_proof: Vec<u8>,
) -> Option<Option<u32>> {
None
}

fn construct_domain_inherent_extrinsic(
&self,
_domain_runtime_code: Vec<u8>,
_domain_inherent_extrinsic_data: DomainInherentExtrinsicData,
) -> Option<DomainInherentExtrinsic> {
None
}

fn domain_storage_key(
&self,
_domain_runtime_code: Vec<u8>,
_req: DomainStorageKeyRequest,
) -> Option<Vec<u8>> {
None
}

fn domain_runtime_call(
&self,
_domain_runtime_code: Vec<u8>,
_call: StatelessDomainRuntimeCall,
) -> Option<bool> {
None
}
}

pub(crate) fn new_test_ext_with_extensions() -> sp_io::TestExternalities {
Expand Down
Loading

0 comments on commit 0e03641

Please sign in to comment.