Skip to content
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dcf0aff
Align `StoragePeriod` between Bulletin and SDK
raymondkfcheung Dec 9, 2025
ae27ed5
Sync mock
raymondkfcheung Dec 9, 2025
32dadb1
Remove StoragePeriod
raymondkfcheung Dec 9, 2025
91536d4
Use default
raymondkfcheung Dec 9, 2025
0a49461
Update integrity_test
raymondkfcheung Dec 9, 2025
bde5119
Revert "Update integrity_test"
raymondkfcheung Dec 9, 2025
5116be3
Revert "Use default"
raymondkfcheung Dec 9, 2025
9804c05
Update integrity_test
raymondkfcheung Dec 9, 2025
8651ae8
Fix clippy
raymondkfcheung Dec 9, 2025
d75aa8e
Sync with SDK
raymondkfcheung Dec 10, 2025
e9bdf85
Merge branch 'refs/heads/main' into ray-align-storage-period
raymondkfcheung Dec 10, 2025
f807e4e
Update TODO
raymondkfcheung Dec 10, 2025
dbc73ad
Sync with SDK
raymondkfcheung Dec 10, 2025
3dcd8cd
Revert "Sync with SDK"
raymondkfcheung Dec 10, 2025
bcf5f2a
Update errors
raymondkfcheung Dec 11, 2025
ffee2b7
Update errors
raymondkfcheung Dec 11, 2025
b1a9c40
Fix fmt
raymondkfcheung Dec 11, 2025
a78822f
Merge branch 'ray-align-storage-period' into ray-align-check_proof
raymondkfcheung Dec 11, 2025
a742aa2
Fix fmt
raymondkfcheung Dec 11, 2025
d425eb0
Sync with SDK
raymondkfcheung Dec 12, 2025
b355dd1
Remove EmptyTransaction
raymondkfcheung Dec 12, 2025
2c7ab85
Fix clippy
raymondkfcheung Dec 12, 2025
9961bcf
Merge branch 'main' into ray-align-common-fn
raymondkfcheung Dec 12, 2025
8fba749
Merge branch 'main' into ray-align-storage-period
raymondkfcheung Dec 12, 2025
0f5773f
Fix clippy
raymondkfcheung Dec 12, 2025
e619929
Merge branch 'main' into ray-align-storage-period
bkontur Dec 28, 2025
16a7ca5
Merge branch 'main' into ray-align-common-fn
bkontur Dec 28, 2025
4dca624
Reflect pallet changes from https://github.com/paritytech/polkadot-sd…
bkontur Dec 29, 2025
263de3c
Remove unused constants
bkontur Dec 29, 2025
7a1fd6e
Setup single vs mbm migrations
bkontur Dec 29, 2025
929dcee
Merge remote-tracking branch 'origin/main' into ray-align-storage-period
bkontur Dec 29, 2025
c65c3f5
Add migration `SetRetentionPeriodIfZero` to ensure RetentionPeriod is…
bkontur Dec 29, 2025
74ec72d
Add post-upgrade check
bkontur Dec 29, 2025
feabb75
Merge remote-tracking branch 'raymondkfcheung/ray-align-storage-perio…
bkontur Dec 29, 2025
ebcf54e
Merge branch 'main' into ray-align-common-fn
bkontur Dec 30, 2025
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
31 changes: 19 additions & 12 deletions pallets/transaction-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ pub mod pallet {
NotConfigured,
/// Renewed extrinsic is not found.
RenewedNotFound,
/// Attempting to store an empty transaction
EmptyTransaction,
/// Proof was not expected in this block.
UnexpectedProof,
/// Proof failed verification.
Expand All @@ -248,8 +246,6 @@ pub mod pallet {
DoubleCheck,
/// Storage proof was not checked in the block.
ProofNotChecked,
/// Transaction is too large.
TransactionTooLarge,
/// Authorization was not found.
AuthorizationNotFound,
/// Authorization has not expired.
Expand Down Expand Up @@ -301,7 +297,7 @@ pub mod pallet {

// Insert new transactions, iff they have chunks.
let transactions = <BlockTransactions<T>>::take();
let total_chunks = transactions.last().map_or(0, |t| t.block_chunks);
let total_chunks = TransactionInfo::total_chunks(&transactions);
if total_chunks != 0 {
<Transactions<T>>::insert(n, transactions);
}
Expand Down Expand Up @@ -351,12 +347,12 @@ pub mod pallet {
// In the case of a regular unsigned transaction, this should have been checked by
// pre_dispatch. In the case of a regular signed transaction, this should have been
// checked by pre_dispatch_signed.
ensure!(Self::data_size_ok(data.len()), Error::<T>::BadDataSize);
Self::ensure_data_size_ok(data.len())?;

// Chunk data and compute storage root
let chunks: Vec<_> = data.chunks(CHUNK_SIZE).map(|c| c.to_vec()).collect();
let chunk_count = chunks.len();
debug_assert_eq!(chunk_count, num_chunks(data.len() as u32) as usize);
let chunk_count = chunks.len() as u32;
debug_assert_eq!(chunk_count, num_chunks(data.len() as u32));
let root = sp_io::trie::blake2_256_ordered_root(chunks, sp_runtime::StateVersion::V1);

let content_hash = sp_io::hashing::blake2_256(&data);
Expand All @@ -366,8 +362,10 @@ pub mod pallet {

let mut index = 0;
<BlockTransactions<T>>::mutate(|transactions| {
let total_chunks =
transactions.last().map_or(0, |t| t.block_chunks) + (chunk_count as u32);
if transactions.len() + 1 > T::MaxBlockTransactions::get() as usize {
return Err(Error::<T>::TooManyTransactions);
}
let total_chunks = TransactionInfo::total_chunks(transactions) + chunk_count;
index = transactions.len() as u32;
transactions
.try_push(TransactionInfo {
Expand Down Expand Up @@ -406,7 +404,7 @@ pub mod pallet {
// In the case of a regular unsigned transaction, this should have been checked by
// pre_dispatch. In the case of a regular signed transaction, this should have been
// checked by pre_dispatch_signed.
ensure!(Self::data_size_ok(info.size as usize), Error::<T>::BadDataSize);
Self::ensure_data_size_ok(info.size as usize)?;

let extrinsic_index =
<frame_system::Pallet<T>>::extrinsic_index().ok_or(Error::<T>::BadContext)?;
Expand All @@ -415,8 +413,11 @@ pub mod pallet {

let mut index = 0;
<BlockTransactions<T>>::mutate(|transactions| {
if transactions.len() + 1 > T::MaxBlockTransactions::get() as usize {
return Err(Error::<T>::TooManyTransactions);
}
let chunks = num_chunks(info.size);
let total_chunks = transactions.last().map_or(0, |t| t.block_chunks) + chunks;
let total_chunks = TransactionInfo::total_chunks(transactions) + chunks;
index = transactions.len() as u32;
transactions
.try_push(TransactionInfo {
Expand Down Expand Up @@ -892,6 +893,12 @@ pub mod pallet {
(size > 0) && (size <= T::MaxTransactionSize::get() as usize)
}

/// Ensures that the given data size is valid for storage.
fn ensure_data_size_ok(size: usize) -> Result<(), Error<T>> {
ensure!(Self::data_size_ok(size), Error::<T>::BadDataSize);
Ok(())
}

/// Returns the [`TransactionInfo`] for the specified store/renew transaction.
fn transaction_info(
block_number: BlockNumberFor<T>,
Expand Down