Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

10 changes: 10 additions & 0 deletions cumulus/pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,13 @@ try-runtime = [
"polkadot-runtime-parachains/try-runtime",
"sp-runtime/try-runtime",
]

# Enables `TransactionIndex` host functions for parachain validation
# without requiring maintenance of a transaction index.
# However, the host environment (polkadot-prepare/execute-worker) still expects these functions to exist,
# so we provide a replacement no-op implementation gated by this feature.
#
# Used by: `validate_block::implementation::validate_block`.
#
# Note: The parachain collator software is expected to use/include `transaction_index::HostFunctions`.
transaction-index = []
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ where
sp_io::offchain_index::host_clear.replace_implementation(host_offchain_index_clear),
cumulus_primitives_proof_size_hostfunction::storage_proof_size::host_storage_proof_size
.replace_implementation(host_storage_proof_size),
#[cfg(feature = "transaction-index")]
sp_io::transaction_index::host_index.replace_implementation(host_transaction_index_index),
#[cfg(feature = "transaction-index")]
sp_io::transaction_index::host_renew.replace_implementation(host_transaction_index_renew),
);

let block_data = codec::decode_from_bytes::<ParachainBlockData<B::LazyBlock>>(block_data)
Expand Down Expand Up @@ -221,7 +225,6 @@ where
if overlay.storage(well_known_keys::CODE).is_some() && num_blocks > 1 {
panic!("When applying a runtime upgrade, only one block per PoV is allowed. Received {num_blocks}.")
}

run_with_externalities_and_recorder::<B, _, _>(
&backend,
&mut Default::default(),
Expand Down Expand Up @@ -539,3 +542,21 @@ fn host_default_child_storage_next_key(storage_key: &[u8], key: &[u8]) -> Option
fn host_offchain_index_set(_key: &[u8], _value: &[u8]) {}

fn host_offchain_index_clear(_key: &[u8]) {}

/// Parachain validation does not require maintaining a transaction index,
/// and indexing transactions does **not** contribute to the parachain state.
/// However, the host environment still expects this function to exist,
/// so we provide a no-op implementation.
#[cfg(feature = "transaction-index")]
fn host_transaction_index_index(_extrinsic: u32, _size: u32, _context_hash: [u8; 32]) {
// No-op host function used during parachain validation.
}

/// Parachain validation does not require maintaining a transaction index,
/// and indexing transactions does **not** contribute to the parachain state.
/// However, the host environment still expects this function to exist,
/// so we provide a no-op implementation.
#[cfg(feature = "transaction-index")]
fn host_transaction_index_renew(_extrinsic: u32, _context_hash: [u8; 32]) {
// No-op host function used during parachain validation.
}
12 changes: 12 additions & 0 deletions prdoc/pr_11467.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: "[stable2512] Backport #10662 - Bulletin as parachain missing features (partial)"
doc:
- audience: Runtime Dev
description: |-
Partial backport of #10662 to stable2512. This PR includes:
1. Add `transaction_index::HostFunctions` with NO-OP impl to the cumulus `ParachainSystem` `validate_block` for polkadot-prepare/execute-worker, gated behind the `transaction-index` feature.
2. Introduce the `TransactionStorageApi::retention_period` runtime API in `sp-transaction-storage-proof`.
crates:
- name: cumulus-pallet-parachain-system
bump: patch
- name: sp-transaction-storage-proof
bump: patch
Comment thread
bkontur marked this conversation as resolved.
2 changes: 2 additions & 0 deletions substrate/primitives/transaction-storage-proof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
async-trait = { optional = true, workspace = true }
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
sp-api = { workspace = true }
sp-core = { optional = true, workspace = true }
sp-inherents.workspace = true
sp-runtime.workspace = true
Expand All @@ -30,6 +31,7 @@ std = [
"async-trait",
"codec/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"sp-inherents/std",
"sp-runtime/std",
Expand Down
2 changes: 2 additions & 0 deletions substrate/primitives/transaction-storage-proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#![cfg_attr(not(feature = "std"), no_std)]

pub mod runtime_api;

extern crate alloc;

use core::result::Result;
Expand Down
28 changes: 28 additions & 0 deletions substrate/primitives/transaction-storage-proof/src/runtime_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Runtime API definition for the transaction storage proof processing.

use sp_runtime::traits::NumberFor;

sp_api::decl_runtime_apis! {
/// Runtime API trait for transaction storage support.
pub trait TransactionStorageApi {
/// Get the actual value of a retention period in blocks.
fn retention_period() -> NumberFor<Block>;
}
}
Loading