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
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14979,6 +14979,7 @@
  "cumulus-relay-chain-inprocess-interface",
  "cumulus-relay-chain-interface",
  "cumulus-relay-chain-minimal-node",
+ "cumulus-test-relay-sproof-builder",
  "fc-api",
  "fc-consensus",
  "fc-db",
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
before · node/cli/Cargo.toml
1################################################################################2# Package34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Unique Node'8edition = '2021'9homepage = 'https://unique.network'10license = 'GPLv3'11name = 'unique-node'12repository = 'https://github.com/UniqueNetwork/unique-chain'13version.workspace = true1415[[bin]]16name = 'unique-collator'17path = "src/main.rs"1819[package.metadata.docs.rs]20targets = ['x86_64-unknown-linux-gnu']2122[dependencies]23clap = "4.4"24futures = '0.3.28'25serde_json = "1.0"26tokio = { version = "1.32", features = ["time"] }2728log = { workspace = true }2930parity-scale-codec = { workspace = true }3132cumulus-client-cli = { workspace = true }33cumulus-client-collator = { workspace = true }34cumulus-client-consensus-aura = { workspace = true }35cumulus-client-consensus-common = { workspace = true }36cumulus-client-consensus-proposer = { workspace = true }37cumulus-client-network = { workspace = true }38cumulus-client-service = { workspace = true }39cumulus-primitives-aura = { workspace = true }40cumulus-primitives-core = { workspace = true }41cumulus-primitives-parachain-inherent = { features = ["std"], workspace = true }42cumulus-relay-chain-inprocess-interface = { workspace = true }43cumulus-relay-chain-interface = { workspace = true }44cumulus-relay-chain-minimal-node = { workspace = true }45cumulus-client-parachain-inherent = { workspace = true }46frame-benchmarking = { workspace = true }47frame-benchmarking-cli = { workspace = true }48opal-runtime = { workspace = true, optional = true }49pallet-transaction-payment-rpc-runtime-api = { workspace = true }50polkadot-cli = { workspace = true }51polkadot-primitives = { workspace = true }52polkadot-service = { workspace = true }53quartz-runtime = { workspace = true, optional = true }54sc-basic-authorship = { workspace = true }55sc-chain-spec = { workspace = true }56sc-cli = { workspace = true }57sc-client-api = { workspace = true }58sc-consensus = { workspace = true }59sc-consensus-manual-seal = { workspace = true }60sc-executor = { workspace = true }61sc-network = { workspace = true }62sc-network-sync = { workspace = true }63sc-service = { workspace = true }64sc-sysinfo = { workspace = true }65sc-telemetry = { workspace = true }66sc-tracing = { workspace = true }67sc-transaction-pool = { workspace = true }68serde = { workspace = true }69sp-api = { workspace = true }70sp-state-machine = { workspace = true }71sp-block-builder = { workspace = true }72sp-blockchain = { workspace = true }73sp-consensus-aura = { workspace = true }74sp-core = { workspace = true }75sp-io = { workspace = true }76sp-keystore = { workspace = true }77sp-offchain = { workspace = true }78sp-runtime = { workspace = true }79sp-session = { workspace = true }80sp-timestamp = { workspace = true }81sp-transaction-pool = { workspace = true }82substrate-frame-rpc-system = { workspace = true }83substrate-prometheus-endpoint = { workspace = true }84try-runtime-cli = { workspace = true }85unique-runtime = { workspace = true, optional = true }86up-common = { workspace = true }87up-data-structs = { workspace = true }8889fc-consensus = { workspace = true }90fc-db = { workspace = true }91fc-mapping-sync = { workspace = true }92fc-rpc-core = { workspace = true }93fc-rpc.workspace = true94fp-rpc = { workspace = true }9596app-promotion-rpc = { workspace = true }97fc-api.workspace = true98fp-storage.workspace = true99jsonrpsee.workspace = true100pallet-transaction-payment-rpc.workspace = true101sc-rpc-api.workspace = true102sc-rpc.workspace = true103sp-inherents.workspace = true104uc-rpc = { workspace = true }105up-pov-estimate-rpc = { workspace = true }106up-rpc = { workspace = true }107108[build-dependencies]109substrate-build-script-utils = { workspace = true }110111[features]112all-runtimes = ['opal-runtime', 'quartz-runtime', 'unique-runtime']113default = ["opal-runtime"]114gov-test-timings = [115	'opal-runtime/gov-test-timings',116	'quartz-runtime?/gov-test-timings',117	'unique-runtime?/gov-test-timings',118]119lookahead = ['opal-runtime/lookahead']120pov-estimate = [121	'opal-runtime/pov-estimate',122	'quartz-runtime?/pov-estimate',123	'uc-rpc/pov-estimate',124	'unique-runtime?/pov-estimate',125]126runtime-benchmarks = [127	'opal-runtime/runtime-benchmarks',128	'polkadot-cli/runtime-benchmarks',129	'polkadot-service/runtime-benchmarks',130	'quartz-runtime?/runtime-benchmarks',131	'sc-service/runtime-benchmarks',132	'unique-runtime?/runtime-benchmarks',133]134sapphire-runtime = ['quartz-runtime', 'quartz-runtime/become-sapphire']135session-test-timings = [136	'opal-runtime/session-test-timings',137	'quartz-runtime?/session-test-timings',138	'unique-runtime?/session-test-timings',139]140try-runtime = [141	'opal-runtime?/try-runtime',142	'quartz-runtime?/try-runtime',143	'try-runtime-cli/try-runtime',144	'unique-runtime?/try-runtime',145]
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::<