git.delta.rocks / unique-network / refs/commits / 59a15efbde76

difftreelog

feat provide pending parachain inherent to ethereum

Yaroslav Bolyukin2024-05-10parent: #ff95602.patch.diff
in: master

4 files changed

modifiedCargo.lockdiffbeforeafterboth
after · Cargo.lock
1204 packageslockfile v3
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -109,6 +109,7 @@
 cumulus-relay-chain-inprocess-interface = "0.10.0"
 cumulus-relay-chain-interface = "0.10.0"
 cumulus-relay-chain-minimal-node = "0.10.0"
+cumulus-test-relay-sproof-builder = "0.10.0"
 parachains-common = { default-features = false, version = "10.0.0"}
 frame-executive = { default-features = false, version = "31.0.0" }
 frame-support = { default-features = false, version = "31.0.0" }
modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -43,6 +43,7 @@
 cumulus-relay-chain-interface = { workspace = true }
 cumulus-relay-chain-minimal-node = { workspace = true }
 cumulus-client-parachain-inherent = { workspace = true }
+cumulus-test-relay-sproof-builder = { workspace = true }
 frame-benchmarking = { workspace = true }
 frame-benchmarking-cli = { workspace = true }
 opal-runtime = { workspace = true, optional = true }
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -40,6 +40,7 @@
 	StartRelayChainTasksParams,
 };
 use cumulus_primitives_core::ParaId;
+use cumulus_primitives_parachain_inherent::ParachainInherentData;
 use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
 use fc_mapping_sync::{kv::MappingSyncWorker, EthereumBlockNotificationSinks, SyncStrategy};
 use fc_rpc::{
@@ -81,6 +82,9 @@
 	cumulus_client_service::storage_proof_size::HostFunctions,
 );
 
+use cumulus_primitives_core::PersistedValidationData;
+use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
+
 use crate::{
 	chain_spec::RuntimeIdentification,
 	rpc::{create_eth, create_full, EthDeps, FullDeps},
@@ -234,6 +238,25 @@
 	pub trait LookaheadApiDep: cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> {}
 );
 
+fn ethereum_parachain_inherent() -> ParachainInherentData {
+	let (relay_parent_storage_root, relay_chain_state) =
+		RelayStateSproofBuilder::default().into_state_root_and_proof();
+	let vfp = PersistedValidationData {
+		// This is a hack to make `cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases`
+		// happy. Relay parent number can't be bigger than u32::MAX.
+		relay_parent_number: u32::MAX,
+		relay_parent_storage_root,
+		..Default::default()
+	};
+
+	ParachainInherentData {
+		validation_data: vfp,
+		relay_chain_state,
+		downward_messages: Default::default(),
+		horizontal_messages: Default::default(),
+	}
+}
+
 /// Starts a `ServiceBuilder` for a full service.
 ///
 /// Use this macro if you don't actually need the full service, but just the builder in order to
@@ -533,7 +556,9 @@
 				eth_pubsub_notification_sinks,
 				overrides,
 				sync: sync_service.clone(),
-				pending_create_inherent_data_providers: |_, ()| async move { Ok(()) },
+				pending_create_inherent_data_providers: |_, ()| async move {
+					Ok((ethereum_parachain_inherent(),))
+				},
 			};
 
 			create_eth::<
@@ -1121,7 +1146,9 @@
 				overrides,
 				sync: sync_service.clone(),
 				// We don't have any inherents except parachain built-ins, which we can't even extract from inside `run_aura`.
-				pending_create_inherent_data_providers: |_, ()| async move { Ok(()) },
+				pending_create_inherent_data_providers: |_, ()| async move {
+					Ok((ethereum_parachain_inherent(),))
+				},
 			};
 
 			create_eth::<