diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5d7472563..909350675 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -131,9 +131,9 @@ jobs: cargo test -p pallet-relayer-set --features=runtime-benchmarks cargo test -p pallet-validator-set cargo test -p pallet-validator-set --features=runtime-benchmarks - cargo test -p pallet-transaction-storage + cargo test -p pallet-bulletin-transaction-storage # Bench test is skipped intentionally (running too long and anyway, we are doing fresh weights) - cargo test -p pallet-transaction-storage --features=runtime-benchmarks -- --skip bench_check_proof + cargo test -p pallet-bulletin-transaction-storage --features=runtime-benchmarks -- --skip bench_check_proof - name: Run (Polkadot) runtime tests run: | diff --git a/Cargo.lock b/Cargo.lock index 6385637cb..9a928bccb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1029,25 +1029,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" -[[package]] -name = "asset-hub-westend-emulated-chain" -version = "0.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?rev=f9df32360c6c22747f60b3ff58243890eecafc8e#f9df32360c6c22747f60b3ff58243890eecafc8e" -dependencies = [ - "asset-hub-westend-runtime", - "bp-bridge-hub-westend", - "cumulus-primitives-core", - "emulated-integration-tests-common", - "frame-support", - "parachains-common", - "sp-core 28.0.0", - "sp-keyring", - "staging-xcm", - "staging-xcm-builder", - "testnet-parachains-constants", - "westend-emulated-chain", -] - [[package]] name = "asset-hub-westend-runtime" version = "0.15.0" @@ -2125,6 +2106,18 @@ dependencies = [ "semver 0.6.0", ] +[[package]] +name = "bulletin-pallets-common" +version = "0.1.0" +dependencies = [ + "pallet-proxy", + "pallet-sudo", + "pallet-utility", + "parity-scale-codec", + "polkadot-sdk-frame", + "scale-info", +] + [[package]] name = "bulletin-polkadot-runtime" version = "1.0.0" @@ -2139,6 +2132,8 @@ dependencies = [ "bp-runtime", "bp-test-utils", "bridge-runtime-common", + "bulletin-pallets-common", + "bulletin-transaction-storage-primitives", "frame-benchmarking", "frame-executive", "frame-support", @@ -2154,6 +2149,7 @@ dependencies = [ "pallet-bridge-messages", "pallet-bridge-parachains", "pallet-bridge-relayers", + "pallet-bulletin-transaction-storage", "pallet-grandpa", "pallet-offences", "pallet-proxy", @@ -2164,12 +2160,10 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-transaction-storage", "pallet-utility", "pallet-validator-set", "pallet-xcm", "pallet-xcm-bridge-hub", - "pallets-common", "parachains-common", "parity-scale-codec", "scale-info", @@ -2198,13 +2192,13 @@ dependencies = [ "staging-xcm-executor", "static_assertions", "substrate-wasm-builder", - "transaction-storage-primitives", ] [[package]] name = "bulletin-sdk-rust" version = "0.1.0" dependencies = [ + "bulletin-transaction-storage-primitives", "cid", "parity-scale-codec", "scale-info", @@ -2214,7 +2208,6 @@ dependencies = [ "subxt-signer 0.44.2", "thiserror 2.0.18", "tokio", - "transaction-storage-primitives", ] [[package]] @@ -2248,24 +2241,40 @@ dependencies = [ "zombienet-sdk", ] +[[package]] +name = "bulletin-transaction-storage-primitives" +version = "0.1.0" +dependencies = [ + "cid", + "parity-scale-codec", + "scale-info", + "sp-io", + "tracing", +] + [[package]] name = "bulletin-westend-integration-tests" version = "0.1.0" dependencies = [ - "asset-hub-westend-emulated-chain", "asset-hub-westend-runtime", "bulletin-westend-runtime", "cumulus-primitives-core", "emulated-integration-tests-common", "frame-support", "parachains-common", + "polkadot-primitives", + "sc-consensus-grandpa", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-consensus-beefy", "sp-core 28.0.0", "sp-keyring", "sp-runtime", "staging-xcm", "staging-xcm-executor", - "westend-emulated-chain", + "testnet-parachains-constants", "westend-runtime", + "westend-runtime-constants", "xcm-emulator", ] @@ -2273,6 +2282,8 @@ dependencies = [ name = "bulletin-westend-runtime" version = "0.1.0" dependencies = [ + "bulletin-pallets-common", + "bulletin-transaction-storage-primitives", "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", @@ -2293,6 +2304,7 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-bulletin-transaction-storage", "pallet-collator-selection", "pallet-message-queue", "pallet-session", @@ -2301,11 +2313,9 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-transaction-storage", "pallet-utility", "pallet-xcm", "pallet-xcm-benchmarks", - "pallets-common", "parachains-common", "parachains-runtimes-test-utils", "parity-scale-codec", @@ -2336,7 +2346,6 @@ dependencies = [ "substrate-wasm-builder", "testnet-parachains-constants", "tracing", - "transaction-storage-primitives", "westend-runtime-constants", "xcm-runtime-apis", ] @@ -8743,6 +8752,20 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-bulletin-transaction-storage" +version = "0.1.0" +dependencies = [ + "array-bytes 6.2.3", + "bulletin-pallets-common", + "bulletin-transaction-storage-primitives", + "parity-scale-codec", + "polkadot-sdk-frame", + "scale-info", + "sp-transaction-storage-proof", + "tracing", +] + [[package]] name = "pallet-collator-selection" version = "9.0.0" @@ -9628,20 +9651,6 @@ dependencies = [ "sp-weights", ] -[[package]] -name = "pallet-transaction-storage" -version = "4.0.0-dev" -dependencies = [ - "array-bytes 6.2.3", - "pallets-common", - "parity-scale-codec", - "polkadot-sdk-frame", - "scale-info", - "sp-transaction-storage-proof", - "tracing", - "transaction-storage-primitives", -] - [[package]] name = "pallet-treasury" version = "27.0.0" @@ -9694,9 +9703,9 @@ dependencies = [ name = "pallet-validator-set" version = "1.0.0" dependencies = [ + "bulletin-pallets-common", "log", "pallet-session", - "pallets-common", "parity-scale-codec", "polkadot-sdk-frame", "scale-info", @@ -9840,18 +9849,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "pallets-common" -version = "0.1.0" -dependencies = [ - "pallet-proxy", - "pallet-sudo", - "pallet-utility", - "parity-scale-codec", - "polkadot-sdk-frame", - "scale-info", -] - [[package]] name = "parachains-common" version = "7.0.0" @@ -10308,9 +10305,9 @@ dependencies = [ "frame-try-runtime", "futures", "jsonrpsee", + "pallet-bulletin-transaction-storage", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-transaction-storage", "polkadot-primitives", "sc-basic-authorship", "sc-chain-spec", @@ -16981,17 +16978,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "transaction-storage-primitives" -version = "0.1.0" -dependencies = [ - "cid", - "parity-scale-codec", - "scale-info", - "sp-io", - "tracing", -] - [[package]] name = "trie-db" version = "0.31.0" @@ -17921,25 +17907,6 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" -[[package]] -name = "westend-emulated-chain" -version = "0.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?rev=f9df32360c6c22747f60b3ff58243890eecafc8e#f9df32360c6c22747f60b3ff58243890eecafc8e" -dependencies = [ - "emulated-integration-tests-common", - "pallet-staking", - "parachains-common", - "polkadot-primitives", - "sc-consensus-grandpa", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core 28.0.0", - "sp-runtime", - "westend-runtime", - "westend-runtime-constants", -] - [[package]] name = "westend-runtime" version = "7.0.0" diff --git a/Cargo.toml b/Cargo.toml index 8ae71c906..49222ccc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace.package] authors = ["Parity Technologies "] edition = "2021" +homepage = "https://github.com/paritytech/polkadot-bulletin-chain" repository = "https://github.com/paritytech/polkadot-bulletin-chain.git" [workspace.dependencies] @@ -34,14 +35,14 @@ tracing = { version = "0.1.41", default-features = false } westend-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk.git", package = "westend-runtime-constants", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } # Local workspace members +bulletin-pallets-common = { path = "pallets/common", default-features = false } bulletin-polkadot-runtime = { path = "runtimes/bulletin-polkadot" } bulletin-sdk-rust = { path = "sdk/rust", default-features = false } +bulletin-transaction-storage-primitives = { path = "pallets/transaction-storage/primitives", default-features = false } bulletin-westend-runtime = { path = "runtimes/bulletin-westend" } +pallet-bulletin-transaction-storage = { path = "pallets/transaction-storage", default-features = false } pallet-relayer-set = { path = "pallets/relayer-set", default-features = false } -pallet-transaction-storage = { path = "pallets/transaction-storage", default-features = false } pallet-validator-set = { path = "pallets/validator-set", default-features = false } -pallets-common = { path = "pallets/common", default-features = false } -transaction-storage-primitives = { path = "pallets/transaction-storage/primitives", default-features = false } # Polkadot SDK crates (shared git revision) frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } @@ -74,10 +75,12 @@ sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e" } sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } +sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } +sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } @@ -139,10 +142,8 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = " parachains-common = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = false } # XCM emulator framework for integration tests -asset-hub-westend-emulated-chain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = true } asset-hub-westend-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = true } emulated-integration-tests-common = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = true } -westend-emulated-chain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = true } westend-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = true } xcm-emulator = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "f9df32360c6c22747f60b3ff58243890eecafc8e", default-features = true } diff --git a/node/Cargo.toml b/node/Cargo.toml index 0b730808f..82791155f 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -77,7 +77,7 @@ frame-benchmarking = { optional = true, workspace = true, default-features = tru bulletin-polkadot-runtime = { workspace = true } # TODO: remove when bulletin-polkadot is upgraded live with TX storage runtime API -pallet-transaction-storage = { workspace = true } +pallet-bulletin-transaction-storage = { workspace = true } [build-dependencies] substrate-build-script-utils = { workspace = true } @@ -89,8 +89,8 @@ runtime-benchmarks = [ "frame-benchmarking-cli/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", + "pallet-bulletin-transaction-storage/runtime-benchmarks", "pallet-transaction-payment/runtime-benchmarks", - "pallet-transaction-storage/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", "sc-service/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -101,7 +101,7 @@ try-runtime = [ "bulletin-polkadot-runtime/try-runtime", "frame-support/try-runtime", "frame-try-runtime/try-runtime", + "pallet-bulletin-transaction-storage/try-runtime", "pallet-transaction-payment/try-runtime", - "pallet-transaction-storage/try-runtime", "sp-runtime/try-runtime", ] diff --git a/node/src/service.rs b/node/src/service.rs index a9332f229..49bef1722 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -322,8 +322,8 @@ pub fn new_full< // Fallback for solochain runtimes that do not yet have the transaction // storage API. TODO: remove once bulletin-polkadot is upgraded // with the TX storage runtime API. TODO: also remove the - // pallet_transaction_storage dependency. - pallet_transaction_storage::DEFAULT_RETENTION_PERIOD + // pallet_bulletin_transaction_storage dependency. + pallet_bulletin_transaction_storage::DEFAULT_RETENTION_PERIOD } }; let storage_proof = diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index 0121a3e4d..38cd79f00 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -1,11 +1,13 @@ [package] -name = "pallets-common" +name = "bulletin-pallets-common" version = "0.1.0" authors = ["Parity Technologies "] edition.workspace = true license = "Apache-2.0" description = "Common utilities for pallets and/or runtime" +homepage.workspace = true repository.workspace = true +readme = "README.md" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/common/README.md b/pallets/common/README.md new file mode 100644 index 000000000..4d246023f --- /dev/null +++ b/pallets/common/README.md @@ -0,0 +1,5 @@ +# bulletin-pallets-common + +Common utilities for Polkadot Bulletin Chain pallets and runtime, including shared proxy and governance configuration types. + +License: Apache-2.0 diff --git a/pallets/relayer-set/Cargo.toml b/pallets/relayer-set/Cargo.toml index 1b2bb6f1b..75638bd1f 100644 --- a/pallets/relayer-set/Cargo.toml +++ b/pallets/relayer-set/Cargo.toml @@ -6,6 +6,7 @@ edition.workspace = true repository.workspace = true license = "Apache-2.0" description = "Relayer set pallet" +publish = false [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/transaction-storage/Cargo.toml b/pallets/transaction-storage/Cargo.toml index 2c355d0db..4518f9aaf 100644 --- a/pallets/transaction-storage/Cargo.toml +++ b/pallets/transaction-storage/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "pallet-transaction-storage" -version = "4.0.0-dev" +name = "pallet-bulletin-transaction-storage" +version = "0.1.0" authors = ["Parity Technologies "] edition.workspace = true license = "Apache-2.0" -homepage = "https://substrate.io" +homepage.workspace = true repository.workspace = true description = "Storage chain pallet" readme = "README.md" @@ -17,7 +17,7 @@ array-bytes = { optional = true, workspace = true } codec = { workspace = true } scale-info = { features = ["derive"], workspace = true } tracing = { workspace = true } -transaction-storage-primitives = { workspace = true } +bulletin-transaction-storage-primitives = { workspace = true } polkadot-sdk-frame = { workspace = true, default-features = false, features = [ "runtime", @@ -25,25 +25,25 @@ polkadot-sdk-frame = { workspace = true, default-features = false, features = [ sp-transaction-storage-proof = { workspace = true, default-features = false } [dev-dependencies] -pallets-common = { workspace = true } +bulletin-pallets-common = { workspace = true } [features] default = ["std"] runtime-benchmarks = [ "array-bytes", - "pallets-common/runtime-benchmarks", + "bulletin-pallets-common/runtime-benchmarks", "polkadot-sdk-frame/runtime-benchmarks", ] std = [ + "bulletin-pallets-common/std", + "bulletin-transaction-storage-primitives/std", "codec/std", - "pallets-common/std", "polkadot-sdk-frame/std", "scale-info/std", "sp-transaction-storage-proof/std", "tracing/std", - "transaction-storage-primitives/std", ] try-runtime = [ - "pallets-common/try-runtime", + "bulletin-pallets-common/try-runtime", "polkadot-sdk-frame/try-runtime", ] diff --git a/pallets/transaction-storage/README.md b/pallets/transaction-storage/README.md index b2b22fe44..1232ec43f 100644 --- a/pallets/transaction-storage/README.md +++ b/pallets/transaction-storage/README.md @@ -1,82 +1,35 @@ -# Transaction Storage Pallet +# pallet-bulletin-transaction-storage -Indexes transactions and manages storage proofs. +Transaction storage pallet for the Polkadot Bulletin Chain. Indexes transactions and manages storage proofs. -Allows storing arbitrary data on the chain. Data is automatically removed after `RetentionPeriod` blocks, unless the storage is renewed. -Validators must submit proof of storing a random chunk of data for block `N - RetentionPeriod` when producing block `N`. +## Overview -# Running a chain +This pallet provides distributed data storage on-chain with proof-of-storage guarantees. It is designed for chains with no transaction fees and data is retrievable via the Bitswap protocol using content-addressed CIDs. -The following describes how to set up a new storage chain. +Key features: +- Store arbitrary data on-chain via the `store` extrinsic +- Automatic data removal after a configurable `RetentionPeriod` (default: 14 days at 6s block time) +- Data renewal to extend retention via `renew` +- Validators submit proofs of storing random data chunks when producing blocks +- CID generation for content-addressed data retrieval via Bitswap -Start with generating a chain spec. +## Usage -```bash -cargo run --release -- build-spec --chain=local > sc_init.json -``` +### Storing data -Edit the json chain spec file to customise the chain. The storage chain genesis params are configured in the `transactionStorage` section. -Note that `retentionPeriod` is specified in blocks and changing it also requires code changes at the moment. +Use the `transactionStorage.store` extrinsic to store data. A CID is generated from the content hash for retrieval via Bitswap. -Build a raw spec from the init spec. +### Renewing data -```bash -cargo run --release build-spec --chain=sc_init.json --raw > sc.json -``` +To prevent data from being removed after the retention period, use `transactionStorage.renew(block, index)` where `block` is the block number of the previous store or renew transaction, and `index` is the index of that transaction in the block. -Run a few validator nodes. +### Retrieving data -```bash -cargo run --release -- --chain=sc.json -d /tmp/alice --storage-chain --keep-blocks=100800 --ipfs-server --validator --alice -cargo run --release -- --chain=sc.json -d /tmp/bob --storage-chain --keep-blocks=100800 --ipfs-server --validator --bob -``` +Stored data is retrievable via the Bitswap protocol using the CID generated at storage time. -`--storage-chain` enables transaction indexing. -`--keep-blocks=100800` enables block pruning. The value here should be greater or equal than the retention period. -`--ipfs-server` enables serving stored content over IPFS. - -Once the network is started, any other joining nodes need to sync with `--sync=fast`. Regular sync will fail because block pruning removes old blocks. The chain does not keep full block history. - -```bash -cargo run --release -- --chain=sc.json -d /tmp/charlie --storage-chain --keep-blocks=100800 --ipfs-server --validator --charlie --sync=fast -``` - -# Making transactions - -To store data use the `transactionStorage.store` extrinsic. And IPFS CID can be generated from the Blake2-256 hash of the data. - -```js -const util_crypto = require('@polkadot/util-crypto'); -const keyring_api = require('@polkadot/keyring'); -const polkadot_api = require('@polkadot/api'); -const fs = require('fs'); -const multihash = require('multihashes'); -const CID = require('cids') - -const wsProvider = new polkadot_api.WsProvider(); -const api = await polkadot_api.ApiPromise.create({ provider: wsProvider }); - -const keyring = new keyring_api.Keyring({ type: "sr25519" }); -const alice = keyring.addFromUri("//Alice"); - -const file = fs.readFileSync('cute_kitten.jpeg'); -const hash = util_crypto.blake2AsU8a(file) -const encoded_hash = multihash.encode(hash, 'blake2b-256'); - -const cid = new CID(1, 'blake2b-256', encoded_hash) -console.log(cid.toString()); - -const txHash = await api.tx.transactionStorage.store('0x' + file.toString('hex')).signAndSend(alice); -``` -Data can be queried over IPFS - -```bash -ipfs swarm connect -ipfs block get /ipfs/ > kitten.jpeg -``` - -To renew data and prevent it from being disposed after the retention period, use `transactionStorage.renew(block, index)` -where `block` is the block number of the previous store or renew transction, and index is the index of that transaction in the block. +## Dependencies +- [`bulletin-transaction-storage-primitives`](primitives/) — CID utilities and shared types +- `sp-transaction-storage-proof` — Storage proof verification from Polkadot SDK License: Apache-2.0 diff --git a/pallets/transaction-storage/primitives/Cargo.toml b/pallets/transaction-storage/primitives/Cargo.toml index 187614591..765ae79a9 100644 --- a/pallets/transaction-storage/primitives/Cargo.toml +++ b/pallets/transaction-storage/primitives/Cargo.toml @@ -1,11 +1,13 @@ [package] -name = "transaction-storage-primitives" +name = "bulletin-transaction-storage-primitives" version = "0.1.0" authors.workspace = true edition.workspace = true license = "Apache-2.0" +homepage.workspace = true repository.workspace = true description = "Primitives for transaction storage pallet" +readme = "README.md" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/transaction-storage/primitives/README.md b/pallets/transaction-storage/primitives/README.md new file mode 100644 index 000000000..bfb15f816 --- /dev/null +++ b/pallets/transaction-storage/primitives/README.md @@ -0,0 +1,5 @@ +# bulletin-transaction-storage-primitives + +Primitive types and CID utilities for the Polkadot Bulletin Chain transaction storage pallet. + +License: Apache-2.0 diff --git a/pallets/transaction-storage/src/lib.rs b/pallets/transaction-storage/src/lib.rs index 99152a2c7..9a1f206a3 100644 --- a/pallets/transaction-storage/src/lib.rs +++ b/pallets/transaction-storage/src/lib.rs @@ -38,6 +38,10 @@ mod mock; mod tests; use alloc::vec::Vec; +use bulletin_transaction_storage_primitives::{ + cids::{calculate_cid, Cid, CidCodec, CidConfig, HashingAlgorithm, RAW_CODEC}, + ContentHash, +}; use codec::{Decode, Encode, MaxEncodedLen}; use core::fmt::Debug; use polkadot_sdk_frame::{ @@ -52,10 +56,6 @@ use sp_transaction_storage_proof::{ encode_index, num_chunks, random_chunk, ChunkIndex, InherentError, TransactionStorageProof, CHUNK_SIZE, INHERENT_IDENTIFIER, }; -use transaction_storage_primitives::{ - cids::{calculate_cid, Cid, CidCodec, CidConfig, HashingAlgorithm, RAW_CODEC}, - ContentHash, -}; /// A type alias for the balance type from this pallet's point of view. type BalanceOf = diff --git a/pallets/transaction-storage/src/migrations.rs b/pallets/transaction-storage/src/migrations.rs index 6127ca800..520ef64af 100644 --- a/pallets/transaction-storage/src/migrations.rs +++ b/pallets/transaction-storage/src/migrations.rs @@ -76,6 +76,10 @@ pub mod v1 { pallet::{Pallet, Transactions}, TransactionInfo, }; + use bulletin_transaction_storage_primitives::{ + cids::{CidCodec, HashingAlgorithm, RAW_CODEC}, + ContentHash, + }; use polkadot_sdk_frame::deps::{ frame_support::{ migrations::VersionedMigration, @@ -87,10 +91,6 @@ pub mod v1 { sp_runtime::traits::{BlakeTwo256, Hash}, }; use sp_transaction_storage_proof::ChunkIndex; - use transaction_storage_primitives::{ - cids::{CidCodec, HashingAlgorithm, RAW_CODEC}, - ContentHash, - }; /// `TransactionInfo` layout before v1 (no CID fields). #[derive(Encode, Decode, Clone, Debug, MaxEncodedLen)] diff --git a/pallets/transaction-storage/src/mock.rs b/pallets/transaction-storage/src/mock.rs index dc3b53ae6..ab3784edc 100644 --- a/pallets/transaction-storage/src/mock.rs +++ b/pallets/transaction-storage/src/mock.rs @@ -18,10 +18,10 @@ //! Test environment for transaction-storage pallet. use crate::{ - self as pallet_transaction_storage, TransactionStorageProof, DEFAULT_MAX_BLOCK_TRANSACTIONS, - DEFAULT_MAX_TRANSACTION_SIZE, + self as pallet_bulletin_transaction_storage, TransactionStorageProof, + DEFAULT_MAX_BLOCK_TRANSACTIONS, DEFAULT_MAX_TRANSACTION_SIZE, }; -use pallets_common::NoCurrency; +use bulletin_pallets_common::NoCurrency; use polkadot_sdk_frame::{prelude::*, runtime::prelude::*, testing_prelude::*}; type Block = MockBlock; @@ -31,7 +31,7 @@ construct_runtime!( pub enum Test { System: frame_system, - TransactionStorage: pallet_transaction_storage, + TransactionStorage: pallet_bulletin_transaction_storage, } ); @@ -50,7 +50,7 @@ parameter_types! { pub const RemoveExpiredAuthorizationLongevity: TransactionLongevity = 10; } -impl pallet_transaction_storage::Config for Test { +impl pallet_bulletin_transaction_storage::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type Currency = NoCurrency; @@ -72,7 +72,7 @@ impl pallet_transaction_storage::Config for Test { pub fn new_test_ext() -> TestExternalities { let t = RuntimeGenesisConfig { system: Default::default(), - transaction_storage: pallet_transaction_storage::GenesisConfig:: { + transaction_storage: pallet_bulletin_transaction_storage::GenesisConfig:: { retention_period: 10, byte_fee: 2, entry_fee: 200, diff --git a/pallets/transaction-storage/src/tests.rs b/pallets/transaction-storage/src/tests.rs index d210c9d28..cb70db1bb 100644 --- a/pallets/transaction-storage/src/tests.rs +++ b/pallets/transaction-storage/src/tests.rs @@ -29,6 +29,7 @@ use super::{ DEFAULT_MAX_TRANSACTION_SIZE, }; use crate::migrations::v1::OldTransactionInfo; +use bulletin_transaction_storage_primitives::cids::{CidConfig, HashingAlgorithm}; use codec::Encode; use polkadot_sdk_frame::{ deps::frame_support::{ @@ -42,7 +43,6 @@ use polkadot_sdk_frame::{ traits::StorageVersion, }; use sp_transaction_storage_proof::{random_chunk, registration::build_proof, CHUNK_SIZE}; -use transaction_storage_primitives::cids::{CidConfig, HashingAlgorithm}; type Call = super::Call; type Error = super::Error; diff --git a/pallets/transaction-storage/src/weights.rs b/pallets/transaction-storage/src/weights.rs index a488e040a..bc143de84 100644 --- a/pallets/transaction-storage/src/weights.rs +++ b/pallets/transaction-storage/src/weights.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for pallet_transaction_storage +//! Autogenerated weights for pallet_bulletin_transaction_storage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-06-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -30,7 +30,7 @@ // --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_transaction_storage +// --pallet=pallet_bulletin_transaction_storage // --no-storage-info // --no-median-slopes // --no-min-squares @@ -50,7 +50,7 @@ use polkadot_sdk_frame::weights_prelude::*; use core::marker::PhantomData; -/// Weight functions needed for pallet_transaction_storage. +/// Weight functions needed for pallet_bulletin_transaction_storage. pub trait WeightInfo { fn store(l: u32, ) -> Weight; fn renew() -> Weight; @@ -65,7 +65,7 @@ pub trait WeightInfo { fn validate_renew() -> Weight; } -/// Weights for pallet_transaction_storage using the Substrate node and recommended hardware. +/// Weights for pallet_bulletin_transaction_storage using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// Storage: TransactionStorage ByteFee (r:1 w:0) diff --git a/pallets/validator-set/Cargo.toml b/pallets/validator-set/Cargo.toml index 3d6da76b5..9976a4057 100644 --- a/pallets/validator-set/Cargo.toml +++ b/pallets/validator-set/Cargo.toml @@ -5,6 +5,7 @@ authors = ['Gautam Dhameja ', 'Parity Technologies ; + type Currency = bulletin_pallets_common::NoCurrency; type KeyDeposit = (); type DisablingStrategy = (); } diff --git a/runtimes/bulletin-polkadot/Cargo.toml b/runtimes/bulletin-polkadot/Cargo.toml index cef84f208..6316d9956 100644 --- a/runtimes/bulletin-polkadot/Cargo.toml +++ b/runtimes/bulletin-polkadot/Cargo.toml @@ -56,9 +56,9 @@ frame-system-benchmarking = { workspace = true, optional = true } # Local dependencies pallet-relayer-set = { workspace = true } -pallet-transaction-storage = { workspace = true } +pallet-bulletin-transaction-storage = { workspace = true } pallet-validator-set = { workspace = true } -pallets-common = { workspace = true } +bulletin-pallets-common = { workspace = true } # Bridge dependencies bp-header-chain = { workspace = true } @@ -101,7 +101,7 @@ sp-io = { workspace = true } sp-trie = { workspace = true } static_assertions = { workspace = true } sp-tracing = { workspace = true } -transaction-storage-primitives = { workspace = true } +bulletin-transaction-storage-primitives = { workspace = true } [features] default = ["std"] @@ -145,12 +145,12 @@ std = [ "frame-benchmarking?/std", "frame-system-benchmarking?/std", + "bulletin-pallets-common/std", + "pallet-bulletin-transaction-storage/std", "pallet-relayer-set/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", - "pallet-transaction-storage/std", "pallet-validator-set/std", - "pallets-common/std", "bp-header-chain/std", "bp-messages/std", @@ -168,6 +168,7 @@ std = [ "xcm-executor/std", "xcm/std", + "bulletin-transaction-storage-primitives/std", "pallet-bridge-relayers/std", "pallet-staking?/std", "pallet-xcm?/std", @@ -178,7 +179,6 @@ std = [ "sp-storage?/std", "sp-trie/std", "substrate-wasm-builder", - "transaction-storage-primitives/std", ] runtime-benchmarks = [ "array-bytes", @@ -203,14 +203,14 @@ runtime-benchmarks = [ "pallet-bridge-parachains/runtime-benchmarks", "pallet-xcm-bridge-hub/runtime-benchmarks", + "pallet-bulletin-transaction-storage/runtime-benchmarks", "pallet-relayer-set/runtime-benchmarks", "pallet-session/runtime-benchmarks", "pallet-transaction-payment/runtime-benchmarks", - "pallet-transaction-storage/runtime-benchmarks", "pallet-validator-set/runtime-benchmarks", + "bulletin-pallets-common/runtime-benchmarks", "pallet-bridge-relayers/runtime-benchmarks", - "pallets-common/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm/runtime-benchmarks", @@ -240,14 +240,14 @@ try-runtime = [ "pallet-bridge-parachains/try-runtime", "pallet-xcm-bridge-hub/try-runtime", + "bulletin-pallets-common/try-runtime", "pallet-bridge-relayers/try-runtime", + "pallet-bulletin-transaction-storage/try-runtime", "pallet-relayer-set/try-runtime", "pallet-staking/try-runtime", "pallet-transaction-payment/try-runtime", - "pallet-transaction-storage/try-runtime", "pallet-validator-set/try-runtime", "pallet-xcm?/try-runtime", - "pallets-common/try-runtime", "parachains-common?/try-runtime", "sp-runtime/try-runtime", ] diff --git a/runtimes/bulletin-polkadot/src/lib.rs b/runtimes/bulletin-polkadot/src/lib.rs index 3943a4983..0e7800b8a 100644 --- a/runtimes/bulletin-polkadot/src/lib.rs +++ b/runtimes/bulletin-polkadot/src/lib.rs @@ -292,7 +292,7 @@ impl pallet_session::Config for Runtime { type SessionHandler = ::KeyTypeIdProviders; type Keys = opaque::SessionKeys; type WeightInfo = pallet_session::weights::SubstrateWeight; - type Currency = pallets_common::NoCurrency; + type Currency = bulletin_pallets_common::NoCurrency; type KeyDeposit = (); // TODO: nothing for now, maybe in the future. type DisablingStrategy = (); @@ -367,8 +367,9 @@ impl SortedMembers for TestAccounts { } } -/// Tells [`pallet_transaction_storage::extension::ValidateStorageCalls`] how to find storage -/// calls inside wrapper extrinsics so it can recursively validate and consume authorization. +/// Tells [`pallet_bulletin_transaction_storage::extension::ValidateStorageCalls`] how to find +/// storage calls inside wrapper extrinsics so it can recursively validate and consume +/// authorization. /// /// Also implements [`Contains`] returning `true` for storage-mutating calls /// (store, store_with_cid_config, renew). Used with `EverythingBut` as the XCM @@ -377,7 +378,7 @@ impl SortedMembers for TestAccounts { #[derive(Clone, PartialEq, Eq, Default)] pub struct StorageCallInspector; -impl pallet_transaction_storage::CallInspector for StorageCallInspector { +impl pallet_bulletin_transaction_storage::CallInspector for StorageCallInspector { fn inspect_wrapper(call: &RuntimeCall) -> Option> { match call { RuntimeCall::Utility(c) => inspect_utility_wrapper(c), @@ -397,15 +398,15 @@ impl frame_support::traits::Contains for StorageCallInspector { } } -impl pallet_transaction_storage::Config for Runtime { +impl pallet_bulletin_transaction_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type Currency = NoCurrency; type RuntimeHoldReason = RuntimeHoldReason; type FeeDestination = (); - type WeightInfo = weights::pallet_transaction_storage::WeightInfo; + type WeightInfo = weights::pallet_bulletin_transaction_storage::WeightInfo; type MaxBlockTransactions = - ConstU32<{ pallet_transaction_storage::DEFAULT_MAX_BLOCK_TRANSACTIONS }>; + ConstU32<{ pallet_bulletin_transaction_storage::DEFAULT_MAX_BLOCK_TRANSACTIONS }>; /// Max transaction size per block needs to be aligned with [`BlockLength`]. type MaxTransactionSize = ConstU32<{ 8 * 1024 * 1024 }>; type AuthorizationPeriod = AuthorizationPeriod; @@ -465,7 +466,9 @@ const CHECK_PROOF: &str = "\ "; #[cfg(feature = "runtime-benchmarks")] -impl pallet_transaction_storage::benchmarking::BenchmarkHelper for CheckProofHelper { +impl pallet_bulletin_transaction_storage::benchmarking::BenchmarkHelper + for CheckProofHelper +{ fn encoded_check_proof(random_hash: &[u8]) -> Vec { assert_eq!(random_hash, &[0u8; 32], "CheckProofHelper proof was built with [0u8; 32]"); array_bytes::hex2bytes_unchecked(CHECK_PROOF) @@ -521,7 +524,7 @@ impl InstanceFilter for ProxyType { impl pallet_proxy::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type Currency = pallets_common::NoCurrency; + type Currency = bulletin_pallets_common::NoCurrency; type ProxyType = ProxyType; type ProxyDepositBase = (); type ProxyDepositFactor = (); @@ -574,7 +577,7 @@ construct_runtime!( Grandpa: pallet_grandpa = 15, // Storage - TransactionStorage: pallet_transaction_storage = 40, + TransactionStorage: pallet_bulletin_transaction_storage = 40, // Bridge RelayerSet: pallet_relayer_set = 50, @@ -608,11 +611,11 @@ fn validate_purge_keys(who: &AccountId) -> TransactionValidity { } } -use pallet_transaction_storage::{CallInspector, MAX_WRAPPER_DEPTH}; -use pallets_common::{ +use bulletin_pallets_common::{ inspect_proxy_wrapper, inspect_sudo_wrapper, inspect_utility_wrapper, proxy_inner_calls, utility_inner_calls, }; +use pallet_bulletin_transaction_storage::{CallInspector, MAX_WRAPPER_DEPTH}; /// Extract the signer from an origin that may be either `Signed` or `Authorized`. /// @@ -624,7 +627,9 @@ fn extract_signer(origin: &RuntimeOrigin) -> Option { } match origin.caller() { OriginCaller::TransactionStorage( - pallet_transaction_storage::pallet::Origin::::Authorized { who, .. }, + pallet_bulletin_transaction_storage::pallet::Origin::::Authorized { + who, .. + }, ) => Some(who.clone()), _ => None, } @@ -900,7 +905,10 @@ pub type TxExtension = ( frame_system::CheckEra, frame_system::CheckNonce, frame_system::CheckWeight, - pallet_transaction_storage::extension::ValidateStorageCalls, + pallet_bulletin_transaction_storage::extension::ValidateStorageCalls< + Runtime, + StorageCallInspector, + >, AllowedSignedCalls, BridgeRejectObsoleteHeadersAndMessages, ); @@ -924,13 +932,13 @@ pub type Executive = frame_executive::Executive< pub mod migrations { /// Unreleased migrations. Add new ones here: pub type Unreleased = - (pallet_transaction_storage::migrations::v1::MigrateV0ToV1,); + (pallet_bulletin_transaction_storage::migrations::v1::MigrateV0ToV1,); /// Migrations/checks that do not need to be versioned and can run on every update. pub type Permanent = ( - pallet_transaction_storage::migrations::SetRetentionPeriodIfZero< + pallet_bulletin_transaction_storage::migrations::SetRetentionPeriodIfZero< crate::Runtime, - pallet_transaction_storage::DefaultRetentionPeriod, + pallet_bulletin_transaction_storage::DefaultRetentionPeriod, >, ); @@ -950,7 +958,7 @@ mod benches { [frame_system, SystemBench::] [frame_system_extensions, SystemExtensionsBench::] [pallet_timestamp, Timestamp] - [pallet_transaction_storage, TransactionStorage] + [pallet_bulletin_transaction_storage, TransactionStorage] [pallet_validator_set, ValidatorSet] [pallet_relayer_set, RelayerSet] @@ -1070,7 +1078,7 @@ mod benches { #[cfg(feature = "runtime-benchmarks")] use benches::*; -use pallets_common::NoCurrency; +use bulletin_pallets_common::NoCurrency; impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtimes/bulletin-polkadot/src/weights/mod.rs b/runtimes/bulletin-polkadot/src/weights/mod.rs index 356994099..d086258de 100644 --- a/runtimes/bulletin-polkadot/src/weights/mod.rs +++ b/runtimes/bulletin-polkadot/src/weights/mod.rs @@ -12,11 +12,11 @@ pub mod frame_system_extensions; pub mod pallet_bridge_grandpa; pub mod pallet_bridge_messages; pub mod pallet_bridge_parachains; +pub mod pallet_bulletin_transaction_storage; pub mod pallet_proxy; pub mod pallet_relayer_set; pub mod pallet_sudo; pub mod pallet_timestamp; -pub mod pallet_transaction_storage; pub mod pallet_utility; pub mod pallet_validator_set; diff --git a/runtimes/bulletin-polkadot/src/weights/pallet_transaction_storage.rs b/runtimes/bulletin-polkadot/src/weights/pallet_bulletin_transaction_storage.rs similarity index 97% rename from runtimes/bulletin-polkadot/src/weights/pallet_transaction_storage.rs rename to runtimes/bulletin-polkadot/src/weights/pallet_bulletin_transaction_storage.rs index 14812e2d5..d2c901772 100644 --- a/runtimes/bulletin-polkadot/src/weights/pallet_transaction_storage.rs +++ b/runtimes/bulletin-polkadot/src/weights/pallet_bulletin_transaction_storage.rs @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for `pallet_transaction_storage` +//! Autogenerated weights for `pallet_bulletin_transaction_storage` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 48.0.0 //! DATE: 2025-09-26, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -29,7 +29,7 @@ // pallet // --extrinsic=* // --runtime=target/production/wbuild/bulletin-polkadot-runtime/bulletin_polkadot_runtime.wasm -// --pallet=pallet_transaction_storage +// --pallet=pallet_bulletin_transaction_storage // --header=/home/ubuntu/bkontur/polkadot-bulletin-chain/scripts/cmd/file_header.txt // --output=./runtimes/bulletin-polkadot/src/weights // --wasm-execution=compiled @@ -45,9 +45,9 @@ use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions for `pallet_transaction_storage`. +/// Weight functions for `pallet_bulletin_transaction_storage`. pub struct WeightInfo(PhantomData); -impl pallet_transaction_storage::WeightInfo for WeightInfo { +impl pallet_bulletin_transaction_storage::WeightInfo for WeightInfo { /// Storage: `TransactionStorage::BlockTransactions` (r:1 w:1) /// Proof: `TransactionStorage::BlockTransactions` (`max_values`: Some(1), `max_size`: Some(36866), added: 37361, mode: `MaxEncodedLen`) /// The range of component `l` is `[1, 8388608]`. diff --git a/runtimes/bulletin-polkadot/src/xcm_config.rs b/runtimes/bulletin-polkadot/src/xcm_config.rs index edff18444..46566b895 100644 --- a/runtimes/bulletin-polkadot/src/xcm_config.rs +++ b/runtimes/bulletin-polkadot/src/xcm_config.rs @@ -407,7 +407,7 @@ pub(crate) mod tests { #[test] fn xcm_transact_store_is_blocked() { run_test(|| { - use pallet_transaction_storage::{AuthorizationExtent, Call as TxStorageCall}; + use pallet_bulletin_transaction_storage::{AuthorizationExtent, Call as TxStorageCall}; let data = vec![42u8; 100]; let content_hash = sp_io::hashing::blake2_256(&data); @@ -460,7 +460,7 @@ pub(crate) mod tests { #[test] fn xcm_transact_wrapped_store_is_blocked() { run_test(|| { - use pallet_transaction_storage::{AuthorizationExtent, Call as TxStorageCall}; + use pallet_bulletin_transaction_storage::{AuthorizationExtent, Call as TxStorageCall}; let data = vec![42u8; 100]; let content_hash = sp_io::hashing::blake2_256(&data); @@ -515,7 +515,7 @@ pub(crate) mod tests { #[test] fn xcm_transact_renew_is_blocked() { run_test(|| { - use pallet_transaction_storage::Call as TxStorageCall; + use pallet_bulletin_transaction_storage::Call as TxStorageCall; let renew_call = RuntimeCall::TransactionStorage(TxStorageCall::::renew { block: 1, @@ -546,7 +546,7 @@ pub(crate) mod tests { #[test] fn xcm_transact_authorize_account_works() { run_test(|| { - use pallet_transaction_storage::{AuthorizationExtent, Call as TxStorageCall}; + use pallet_bulletin_transaction_storage::{AuthorizationExtent, Call as TxStorageCall}; let who = AccountKeyring::Ferdie.to_account_id(); diff --git a/runtimes/bulletin-polkadot/tests/tests.rs b/runtimes/bulletin-polkadot/tests/tests.rs index 22510bfec..5d804a31d 100644 --- a/runtimes/bulletin-polkadot/tests/tests.rs +++ b/runtimes/bulletin-polkadot/tests/tests.rs @@ -15,13 +15,14 @@ use bulletin_polkadot_runtime::{ }, AccountId, BridgePolkadotGrandpa, BridgePolkadotMessages, }; +use bulletin_transaction_storage_primitives::cids::{calculate_cid, CidConfig, HashingAlgorithm}; use frame_support::{assert_ok, dispatch::GetDispatchInfo, pallet_prelude::Hooks, traits::Get}; use pallet_bridge_messages::{ messages_generation::{encode_all_messages, encode_lane_data, prepare_messages_storage_proof}, BridgedChainOf, LaneIdOf, ThisChainOf, }; use pallet_bridge_parachains::ParachainHeaders; -use pallet_transaction_storage::{ +use pallet_bulletin_transaction_storage::{ AuthorizationExtent, Call as TxStorageCall, Config as TxStorageConfig, BAD_DATA_SIZE, }; use runtime::{ @@ -39,7 +40,6 @@ use sp_runtime::{ }; use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, TrieMut}; use std::collections::HashMap; -use transaction_storage_primitives::cids::{calculate_cid, CidConfig, HashingAlgorithm}; fn advance_block() { let current_number = System::block_number(); @@ -280,7 +280,7 @@ fn construct_extrinsic( frame_system::Pallet::::account(&account_id).nonce, ), frame_system::CheckWeight::::new(), - pallet_transaction_storage::extension::ValidateStorageCalls::< + pallet_bulletin_transaction_storage::extension::ValidateStorageCalls::< Runtime, runtime::StorageCallInspector, >::default(), @@ -1061,10 +1061,10 @@ fn allowed_signed_calls_preserves_storage_priority() { }); } -/// See [`pallet_transaction_storage::ensure_weight_sanity`]. +/// See [`pallet_bulletin_transaction_storage::ensure_weight_sanity`]. #[test] fn transaction_storage_weight_sanity() { - pallet_transaction_storage::ensure_weight_sanity::(None); + pallet_bulletin_transaction_storage::ensure_weight_sanity::(None); } // ============================================================================ @@ -1287,7 +1287,7 @@ fn wrapped_renew_requires_authorization() { pallet_sudo::GenesisConfig:: { key: Some(sudo_relayer_signer().into()) } .assimilate_storage(&mut t) .unwrap(); - pallet_transaction_storage::GenesisConfig:: { + pallet_bulletin_transaction_storage::GenesisConfig:: { retention_period: 100, byte_fee: 0, entry_fee: 0, @@ -1661,7 +1661,7 @@ fn max_recursion_depth_is_enforced() { // Nest store inside MAX_WRAPPER_DEPTH+1 batch wrappers. let mut call: RuntimeCall = RuntimeCall::TransactionStorage(TxStorageCall::::store { data: data.clone() }); - for _ in 0..=pallet_transaction_storage::MAX_WRAPPER_DEPTH { + for _ in 0..=pallet_bulletin_transaction_storage::MAX_WRAPPER_DEPTH { call = RuntimeCall::Utility(pallet_utility::Call::batch { calls: vec![call] }); } diff --git a/runtimes/bulletin-westend/Cargo.toml b/runtimes/bulletin-westend/Cargo.toml index 3eeb9b27a..97cd56d9c 100644 --- a/runtimes/bulletin-westend/Cargo.toml +++ b/runtimes/bulletin-westend/Cargo.toml @@ -6,6 +6,7 @@ edition.workspace = true description = "Westend's Bulletin parachain runtime" license = "Apache-2.0" repository.workspace = true +publish = false [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -38,8 +39,8 @@ pallet-timestamp = { workspace = true } pallet-utility = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } -pallet-transaction-storage = { workspace = true } -pallets-common = { workspace = true } +pallet-bulletin-transaction-storage = { workspace = true } +bulletin-pallets-common = { workspace = true } sp-api = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } @@ -85,7 +86,7 @@ testnet-parachains-constants = { features = ["westend"], workspace = true } [dev-dependencies] parachains-runtimes-test-utils = { workspace = true, default-features = true } sp-io = { workspace = true } -transaction-storage-primitives = { workspace = true } +bulletin-transaction-storage-primitives = { workspace = true } [build-dependencies] substrate-wasm-builder = { optional = true, workspace = true, default-features = true } @@ -93,6 +94,8 @@ substrate-wasm-builder = { optional = true, workspace = true, default-features = [features] default = ["std"] std = [ + "bulletin-pallets-common/std", + "bulletin-transaction-storage-primitives/std", "codec/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", @@ -114,6 +117,7 @@ std = [ "pallet-aura/std", "pallet-authorship/std", "pallet-balances/std", + "pallet-bulletin-transaction-storage/std", "pallet-collator-selection/std", "pallet-message-queue/std", "pallet-session/std", @@ -122,11 +126,9 @@ std = [ "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", - "pallet-transaction-storage/std", "pallet-utility/std", "pallet-xcm-benchmarks?/std", "pallet-xcm/std", - "pallets-common/std", "parachain-info/std", "parachains-common/std", "polkadot-parachain-primitives/std", @@ -152,7 +154,6 @@ std = [ "substrate-wasm-builder", "testnet-parachains-constants/std", "tracing/std", - "transaction-storage-primitives/std", "westend-runtime-constants/std", "xcm-builder/std", "xcm-executor/std", @@ -160,6 +161,7 @@ std = [ "xcm/std", ] runtime-benchmarks = [ + "bulletin-pallets-common/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-weight-reclaim/runtime-benchmarks", @@ -171,6 +173,7 @@ runtime-benchmarks = [ "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", + "pallet-bulletin-transaction-storage/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", "pallet-session/runtime-benchmarks", @@ -178,11 +181,9 @@ runtime-benchmarks = [ "pallet-sudo/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-transaction-payment/runtime-benchmarks", - "pallet-transaction-storage/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", - "pallets-common/runtime-benchmarks", "parachains-common/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", "polkadot-runtime-common/runtime-benchmarks", @@ -194,6 +195,7 @@ runtime-benchmarks = [ "xcm/runtime-benchmarks", ] try-runtime = [ + "bulletin-pallets-common/try-runtime", "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-parachain-system/try-runtime", "cumulus-pallet-weight-reclaim/try-runtime", @@ -206,6 +208,7 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", + "pallet-bulletin-transaction-storage/try-runtime", "pallet-collator-selection/try-runtime", "pallet-message-queue/try-runtime", "pallet-session/try-runtime", @@ -213,10 +216,8 @@ try-runtime = [ "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", - "pallet-transaction-storage/try-runtime", "pallet-utility/try-runtime", "pallet-xcm/try-runtime", - "pallets-common/try-runtime", "parachain-info/try-runtime", "parachains-common/try-runtime", "polkadot-runtime-common/try-runtime", diff --git a/runtimes/bulletin-westend/integration-tests/Cargo.toml b/runtimes/bulletin-westend/integration-tests/Cargo.toml index 045c1e84d..2d60ef854 100644 --- a/runtimes/bulletin-westend/integration-tests/Cargo.toml +++ b/runtimes/bulletin-westend/integration-tests/Cargo.toml @@ -19,16 +19,23 @@ xcm-executor = { workspace = true, default-features = true } xcm-emulator = { workspace = true } emulated-integration-tests-common = { workspace = true } -# Emulated chains from Polkadot SDK -westend-emulated-chain = { workspace = true } +# Runtimes used in emulated chains (defined locally in src/chains/) westend-runtime = { workspace = true } -asset-hub-westend-emulated-chain = { workspace = true } asset-hub-westend-runtime = { workspace = true } +# Dependencies for local chain definitions +sc-consensus-grandpa = { workspace = true } +sp-consensus-babe = { workspace = true, default-features = true } +sp-consensus-beefy = { workspace = true, default-features = true } +sp-authority-discovery = { workspace = true, default-features = true } +polkadot-primitives = { workspace = true, default-features = true } +westend-runtime-constants = { workspace = true, default-features = true } +testnet-parachains-constants = { workspace = true, default-features = true } +parachains-common = { workspace = true, default-features = true } + # Local runtime bulletin-westend-runtime = { workspace = true, default-features = true } cumulus-primitives-core = { workspace = true, default-features = true } -parachains-common = { workspace = true, default-features = true } [features] runtime-benchmarks = [ @@ -37,7 +44,9 @@ runtime-benchmarks = [ "cumulus-primitives-core/runtime-benchmarks", "frame-support/runtime-benchmarks", "parachains-common/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "westend-runtime-constants/runtime-benchmarks", "westend-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "xcm/runtime-benchmarks", diff --git a/runtimes/bulletin-westend/integration-tests/src/chains/asset_hub_westend.rs b/runtimes/bulletin-westend/integration-tests/src/chains/asset_hub_westend.rs new file mode 100644 index 000000000..0d3dbe02c --- /dev/null +++ b/runtimes/bulletin-westend/integration-tests/src/chains/asset_hub_westend.rs @@ -0,0 +1,101 @@ +// 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. + +//! Emulated Asset Hub Westend parachain definition. +//! +//! Based on upstream `asset-hub-westend-emulated-chain` from polkadot-sdk, +//! simplified for Bulletin chain integration tests (no foreign assets, no +//! Snowbridge, no Penpal configs). + +use emulated_integration_tests_common::{ + accounts, build_genesis_storage, collators, impl_accounts_helpers_for_parachain, + impl_assert_events_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, + xcm_emulator::decl_test_parachains, SAFE_XCM_VERSION, +}; +use frame_support::traits::OnInitialize; +use parachains_common::Balance; +use sp_core::storage::Storage; + +pub const PARA_ID: u32 = 1000; +pub const ED: Balance = testnet_parachains_constants::westend::currency::EXISTENTIAL_DEPOSIT; + +fn genesis() -> Storage { + let genesis_config = asset_hub_westend_runtime::RuntimeGenesisConfig { + system: asset_hub_westend_runtime::SystemConfig::default(), + balances: asset_hub_westend_runtime::BalancesConfig { + balances: accounts::init_balances().iter().cloned().map(|k| (k, ED * 4096)).collect(), + ..Default::default() + }, + parachain_info: asset_hub_westend_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: asset_hub_westend_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_westend_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + (acc.clone(), acc, asset_hub_westend_runtime::SessionKeys { aura }) + }) + .collect(), + ..Default::default() + }, + polkadot_xcm: asset_hub_westend_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + build_genesis_storage( + &genesis_config, + asset_hub_westend_runtime::WASM_BINARY + .expect("WASM binary was not built, please build it!"), + ) +} + +// AssetHubWestend parachain declaration +decl_test_parachains! { + pub struct AssetHubWestend { + genesis = genesis(), + on_init = { + asset_hub_westend_runtime::AuraExt::on_initialize(1); + }, + runtime = asset_hub_westend_runtime, + core = { + XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue, + LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId, + ParachainInfo: asset_hub_westend_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, + AdditionalInherentCode: (), + }, + pallets = { + PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm, + Balances: asset_hub_westend_runtime::Balances, + Assets: asset_hub_westend_runtime::Assets, + ForeignAssets: asset_hub_westend_runtime::ForeignAssets, + PoolAssets: asset_hub_westend_runtime::PoolAssets, + AssetConversion: asset_hub_westend_runtime::AssetConversion, + } + }, +} + +impl_accounts_helpers_for_parachain!(AssetHubWestend); +impl_assert_events_helpers_for_parachain!(AssetHubWestend); +impl_xcm_helpers_for_parachain!(AssetHubWestend); diff --git a/runtimes/bulletin-westend/integration-tests/src/chains/mod.rs b/runtimes/bulletin-westend/integration-tests/src/chains/mod.rs new file mode 100644 index 000000000..566446852 --- /dev/null +++ b/runtimes/bulletin-westend/integration-tests/src/chains/mod.rs @@ -0,0 +1,28 @@ +// 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. + +//! Emulated chain definitions for XCM integration tests. +//! +//! These modules define the Westend relay chain and Asset Hub Westend parachain +//! for use with the xcm-emulator framework. They are inlined here (rather than +//! depending on the upstream `westend-emulated-chain` and +//! `asset-hub-westend-emulated-chain` crates) because those crates are not +//! published to crates.io. + +pub mod asset_hub_westend; +pub mod westend; + +pub use asset_hub_westend::AssetHubWestend; +pub use westend::Westend; diff --git a/runtimes/bulletin-westend/integration-tests/src/chains/westend.rs b/runtimes/bulletin-westend/integration-tests/src/chains/westend.rs new file mode 100644 index 000000000..78c87738c --- /dev/null +++ b/runtimes/bulletin-westend/integration-tests/src/chains/westend.rs @@ -0,0 +1,120 @@ +// 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. + +//! Emulated Westend relay chain definition. +//! +//! Based on upstream `westend-emulated-chain` from polkadot-sdk, simplified for +//! Bulletin chain integration tests. + +use emulated_integration_tests_common::{ + accounts, build_genesis_storage, get_host_config, impl_accounts_helpers_for_relay_chain, + impl_assert_events_helpers_for_relay_chain, impl_hrmp_channels_helpers_for_relay_chain, + impl_send_transact_helpers_for_relay_chain, validators, xcm_emulator::decl_test_relay_chains, +}; +use parachains_common::Balance; +use polkadot_primitives::{AssignmentId, ValidatorId}; +use sc_consensus_grandpa::AuthorityId as GrandpaId; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; +use sp_core::storage::Storage; +use westend_runtime_constants::currency::UNITS as WND; + +const ENDOWMENT: Balance = 1_000_000 * WND; + +fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, +) -> westend_runtime::SessionKeys { + westend_runtime::SessionKeys { + babe, + grandpa, + para_validator, + para_assignment, + authority_discovery, + beefy, + } +} + +fn genesis() -> Storage { + let genesis_config = westend_runtime::RuntimeGenesisConfig { + system: westend_runtime::SystemConfig::default(), + balances: westend_runtime::BalancesConfig { + balances: accounts::init_balances().iter().cloned().map(|k| (k, ENDOWMENT)).collect(), + ..Default::default() + }, + session: westend_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + ), + ) + }) + .collect::>(), + ..Default::default() + }, + babe: westend_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: westend_runtime::BABE_GENESIS_EPOCH_CONFIG, + ..Default::default() + }, + configuration: westend_runtime::ConfigurationConfig { config: get_host_config() }, + ..Default::default() + }; + + build_genesis_storage(&genesis_config, westend_runtime::WASM_BINARY.unwrap()) +} + +// Westend relay chain declaration +decl_test_relay_chains! { + #[api_version(15)] + pub struct Westend { + genesis = genesis(), + on_init = (), + runtime = westend_runtime, + core = { + SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, + }, + pallets = { + XcmPallet: westend_runtime::XcmPallet, + Sudo: westend_runtime::Sudo, + Balances: westend_runtime::Balances, + Treasury: westend_runtime::Treasury, + AssetRate: westend_runtime::AssetRate, + Hrmp: westend_runtime::Hrmp, + Identity: westend_runtime::Identity, + IdentityMigrator: westend_runtime::IdentityMigrator, + } + }, +} + +impl_accounts_helpers_for_relay_chain!(Westend); +impl_assert_events_helpers_for_relay_chain!(Westend); +impl_hrmp_channels_helpers_for_relay_chain!(Westend); +impl_send_transact_helpers_for_relay_chain!(Westend); diff --git a/runtimes/bulletin-westend/integration-tests/src/lib.rs b/runtimes/bulletin-westend/integration-tests/src/lib.rs index 358dd9da1..d2f30d70f 100644 --- a/runtimes/bulletin-westend/integration-tests/src/lib.rs +++ b/runtimes/bulletin-westend/integration-tests/src/lib.rs @@ -21,8 +21,10 @@ #[cfg(test)] mod tests; -use asset_hub_westend_emulated_chain::AssetHubWestend; +mod chains; + use bulletin_westend_runtime::SessionKeys; +use chains::{AssetHubWestend, Westend}; use cumulus_primitives_core::ParaId; use emulated_integration_tests_common::{ accounts::{self, ALICE, BOB}, @@ -34,7 +36,6 @@ use frame_support::traits::OnInitialize; use parachains_common::{AuraId, Balance}; use sp_core::sr25519; use sp_keyring::Sr25519Keyring; -use westend_emulated_chain::Westend; use xcm_emulator::{ decl_test_networks, decl_test_sender_receiver_accounts_parameter_types, Parachain, }; diff --git a/runtimes/bulletin-westend/integration-tests/src/tests/reserve_transfers.rs b/runtimes/bulletin-westend/integration-tests/src/tests/reserve_transfers.rs index ed0406349..d4799bdcc 100644 --- a/runtimes/bulletin-westend/integration-tests/src/tests/reserve_transfers.rs +++ b/runtimes/bulletin-westend/integration-tests/src/tests/reserve_transfers.rs @@ -20,10 +20,10 @@ //! 2. WND reserve transfers from Bulletin back to Asset Hub (DestinationReserve) use crate::{ - AssetHubWestendParaReceiver, AssetHubWestendParaSender, BulletinWestend, - BulletinWestendParaReceiver, BulletinWestendParaSender, WestendMockNet, BULLETIN_PARA_ID, + chains::AssetHubWestend, AssetHubWestendParaReceiver, AssetHubWestendParaSender, + BulletinWestend, BulletinWestendParaReceiver, BulletinWestendParaSender, WestendMockNet, + BULLETIN_PARA_ID, }; -use asset_hub_westend_emulated_chain::AssetHubWestend; use frame_support::{ assert_ok, traits::fungible::{Inspect, Mutate}, diff --git a/runtimes/bulletin-westend/src/lib.rs b/runtimes/bulletin-westend/src/lib.rs index 64e8eee22..9794088a1 100644 --- a/runtimes/bulletin-westend/src/lib.rs +++ b/runtimes/bulletin-westend/src/lib.rs @@ -114,7 +114,7 @@ pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim< Runtime, pallet_transaction_payment::ChargeTransactionPayment, >, - pallet_transaction_storage::extension::ValidateStorageCalls< + pallet_bulletin_transaction_storage::extension::ValidateStorageCalls< Runtime, storage::StorageCallInspector, >, @@ -141,15 +141,15 @@ pub mod migrations { pallet_session::migrations::v1::InitOffenceSeverity, >, cumulus_pallet_aura_ext::migration::MigrateV0ToV1, - pallet_transaction_storage::migrations::v1::MigrateV0ToV1, + pallet_bulletin_transaction_storage::migrations::v1::MigrateV0ToV1, ); /// Migrations/checks that do not need to be versioned and can run on every update. pub type Permanent = ( pallet_xcm::migration::MigrateToLatestXcmVersion, - pallet_transaction_storage::migrations::SetRetentionPeriodIfZero< + pallet_bulletin_transaction_storage::migrations::SetRetentionPeriodIfZero< Runtime, - pallet_transaction_storage::DefaultRetentionPeriod, + pallet_bulletin_transaction_storage::DefaultRetentionPeriod, >, ); @@ -521,7 +521,7 @@ construct_runtime!( SkipFeelessPayment: pallet_skip_feeless_payment = 12, // Storage - TransactionStorage: pallet_transaction_storage = 40, + TransactionStorage: pallet_bulletin_transaction_storage = 40, // Collator support. The order of these 5 are important and shall not change. Authorship: pallet_authorship = 20, @@ -551,7 +551,7 @@ mod benches { [pallet_balances, Balances] [pallet_collator_selection, CollatorSelection] [pallet_session, SessionBench::] - [pallet_transaction_storage, TransactionStorage] + [pallet_bulletin_transaction_storage, TransactionStorage] [cumulus_pallet_xcmp_queue, XcmpQueue] [pallet_xcm, PalletXcmExtrinsicsBenchmark::] [pallet_message_queue, MessageQueue] diff --git a/runtimes/bulletin-westend/src/storage.rs b/runtimes/bulletin-westend/src/storage.rs index 876116b17..627dc6137 100644 --- a/runtimes/bulletin-westend/src/storage.rs +++ b/runtimes/bulletin-westend/src/storage.rs @@ -21,16 +21,16 @@ use super::{ RuntimeHoldReason, }; use alloc::vec::Vec; +use bulletin_pallets_common::{inspect_utility_wrapper, NoCurrency}; use frame_support::{ parameter_types, traits::{Contains, EitherOfDiverse, SortedMembers}, }; use frame_system::EnsureSignedBy; -use pallet_transaction_storage::{ +use pallet_bulletin_transaction_storage::{ CallInspector, DEFAULT_MAX_BLOCK_TRANSACTIONS, DEFAULT_MAX_TRANSACTION_SIZE, }; use pallet_xcm::EnsureXcm; -use pallets_common::{inspect_utility_wrapper, NoCurrency}; use sp_keyring::Sr25519Keyring; use sp_runtime::transaction_validity::{TransactionLongevity, TransactionPriority}; /// Provides test accounts for use with `EnsureSignedBy`. @@ -62,8 +62,9 @@ parameter_types! { pub const StoreRenewLongevity: TransactionLongevity = crate::DAYS as TransactionLongevity; } -/// Tells [`pallet_transaction_storage::extension::ValidateStorageCalls`] how to find storage -/// calls inside wrapper extrinsics so it can recursively validate and consume authorization. +/// Tells [`pallet_bulletin_transaction_storage::extension::ValidateStorageCalls`] how to find +/// storage calls inside wrapper extrinsics so it can recursively validate and consume +/// authorization. /// /// Also implements [`Contains`] returning `true` for storage-mutating calls /// (store, store_with_cid_config, renew). Used with `EverythingBut` as the XCM @@ -72,7 +73,7 @@ parameter_types! { #[derive(Clone, PartialEq, Eq, Default)] pub struct StorageCallInspector; -impl pallet_transaction_storage::CallInspector for StorageCallInspector { +impl pallet_bulletin_transaction_storage::CallInspector for StorageCallInspector { fn inspect_wrapper(call: &RuntimeCall) -> Option> { match call { RuntimeCall::Utility(c) => inspect_utility_wrapper(c), @@ -94,13 +95,13 @@ impl Contains for StorageCallInspector { } /// The main business of the Bulletin chain. -impl pallet_transaction_storage::Config for Runtime { +impl pallet_bulletin_transaction_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type Currency = NoCurrency; type RuntimeHoldReason = RuntimeHoldReason; type FeeDestination = (); - type WeightInfo = crate::weights::pallet_transaction_storage::WeightInfo; + type WeightInfo = crate::weights::pallet_bulletin_transaction_storage::WeightInfo; type MaxBlockTransactions = crate::ConstU32<{ DEFAULT_MAX_BLOCK_TRANSACTIONS }>; /// Max transaction size per block needs to be aligned with `BlockLength`. type MaxTransactionSize = crate::ConstU32<{ DEFAULT_MAX_TRANSACTION_SIZE }>; @@ -120,5 +121,6 @@ impl pallet_transaction_storage::Config for Runtime { type RemoveExpiredAuthorizationPriority = RemoveExpiredAuthorizationPriority; type RemoveExpiredAuthorizationLongevity = RemoveExpiredAuthorizationLongevity; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = pallet_transaction_storage::benchmarking::DefaultCheckProofHelper; + type BenchmarkHelper = + pallet_bulletin_transaction_storage::benchmarking::DefaultCheckProofHelper; } diff --git a/runtimes/bulletin-westend/src/weights/mod.rs b/runtimes/bulletin-westend/src/weights/mod.rs index 708a694d8..ca9af0ace 100644 --- a/runtimes/bulletin-westend/src/weights/mod.rs +++ b/runtimes/bulletin-westend/src/weights/mod.rs @@ -25,12 +25,12 @@ pub mod extrinsic_weights; pub mod frame_system; pub mod frame_system_extensions; pub mod pallet_balances; +pub mod pallet_bulletin_transaction_storage; pub mod pallet_collator_selection; pub mod pallet_message_queue; pub mod pallet_session; pub mod pallet_timestamp; pub mod pallet_transaction_payment; -pub mod pallet_transaction_storage; pub mod pallet_utility; pub mod pallet_xcm; pub mod paritydb_weights; diff --git a/runtimes/bulletin-westend/src/weights/pallet_transaction_storage.rs b/runtimes/bulletin-westend/src/weights/pallet_bulletin_transaction_storage.rs similarity index 97% rename from runtimes/bulletin-westend/src/weights/pallet_transaction_storage.rs rename to runtimes/bulletin-westend/src/weights/pallet_bulletin_transaction_storage.rs index 8a8514952..4e858e2cf 100644 --- a/runtimes/bulletin-westend/src/weights/pallet_transaction_storage.rs +++ b/runtimes/bulletin-westend/src/weights/pallet_bulletin_transaction_storage.rs @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for `pallet_transaction_storage` +//! Autogenerated weights for `pallet_bulletin_transaction_storage` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0 //! DATE: 2026-03-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -29,7 +29,7 @@ // pallet // --extrinsic=* // --runtime=target/production/wbuild/bulletin-westend-runtime/bulletin_westend_runtime.wasm -// --pallet=pallet_transaction_storage +// --pallet=pallet_bulletin_transaction_storage // --header=./scripts/cmd/file_header.txt // --output=./runtimes/bulletin-westend/src/weights // --wasm-execution=compiled @@ -45,9 +45,9 @@ use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions for `pallet_transaction_storage`. +/// Weight functions for `pallet_bulletin_transaction_storage`. pub struct WeightInfo(PhantomData); -impl pallet_transaction_storage::WeightInfo for WeightInfo { +impl pallet_bulletin_transaction_storage::WeightInfo for WeightInfo { /// Storage: `TransactionStorage::BlockTransactions` (r:1 w:1) /// Proof: `TransactionStorage::BlockTransactions` (`max_values`: Some(1), `max_size`: Some(41474), added: 41969, mode: `MaxEncodedLen`) /// The range of component `l` is `[1, 2097152]`. diff --git a/runtimes/bulletin-westend/tests/tests.rs b/runtimes/bulletin-westend/tests/tests.rs index ea528d4b0..4bfd09d44 100644 --- a/runtimes/bulletin-westend/tests/tests.rs +++ b/runtimes/bulletin-westend/tests/tests.rs @@ -16,6 +16,7 @@ #![cfg(test)] +use bulletin_transaction_storage_primitives::cids::{calculate_cid, CidConfig, HashingAlgorithm}; use bulletin_westend_runtime as runtime; use bulletin_westend_runtime::{ xcm_config::{GovernanceLocation, LocationToAccountId}, @@ -26,7 +27,7 @@ use bulletin_westend_runtime::{ use frame_support::{ assert_err, assert_ok, dispatch::GetDispatchInfo, pallet_prelude::Hooks, traits::Get, }; -use pallet_transaction_storage::{ +use pallet_bulletin_transaction_storage::{ AuthorizationExtent, Call as TxStorageCall, Config as TxStorageConfig, }; use parachains_common::{AccountId, AuraId, Hash as PcHash, Signature as PcSignature}; @@ -40,7 +41,6 @@ use sp_runtime::{ }; use std::collections::HashMap; use testnet_parachains_constants::westend::{fee::WeightToFee, locations::PeopleLocation}; -use transaction_storage_primitives::cids::{calculate_cid, CidConfig, HashingAlgorithm}; use xcm::latest::prelude::*; use xcm_runtime_apis::conversions::LocationToAccountHelper; @@ -86,7 +86,7 @@ fn construct_extrinsic( pallet_skip_feeless_payment::SkipCheckIfFeeless::from( pallet_transaction_payment::ChargeTransactionPayment::::from(0u128), ), - pallet_transaction_storage::extension::ValidateStorageCalls::< + pallet_bulletin_transaction_storage::extension::ValidateStorageCalls::< Runtime, bulletin_westend_runtime::storage::StorageCallInspector, >::default(), @@ -210,7 +210,7 @@ fn transaction_storage_runtime_sizes() { // On the Westend, very large extrinsics may be rejected earlier for exhausting // resources (block length/weight) before reaching the pallet's BAD_DATA_SIZE check. assert!( - res == Err(pallet_transaction_storage::BAD_DATA_SIZE.into()) || + res == Err(pallet_bulletin_transaction_storage::BAD_DATA_SIZE.into()) || res == Err(InvalidTransaction::ExhaustsResources.into()), "unexpected error: {res:?}" ); @@ -616,13 +616,13 @@ fn non_authorizer_cannot_sign_authorize_account_extrinsic() { fn people_chain_can_authorize_storage_with_transact() { // Prepare call. let account = Sr25519Keyring::Ferdie; - let authorize_call = RuntimeCall::TransactionStorage(pallet_transaction_storage::Call::< - Runtime, - >::authorize_account { - who: account.to_account_id(), - transactions: 16, - bytes: 1024, - }); + let authorize_call = RuntimeCall::TransactionStorage( + pallet_bulletin_transaction_storage::Call::::authorize_account { + who: account.to_account_id(), + transactions: 16, + bytes: 1024, + }, + ); // Execute XCM as People chain origin would do with `Transact -> Origin::Xcm`. ExtBuilder::::default() @@ -644,7 +644,7 @@ fn people_chain_can_authorize_storage_with_transact() { // Check event. System::assert_has_event(RuntimeEvent::TransactionStorage( - pallet_transaction_storage::Event::AccountAuthorized { + pallet_bulletin_transaction_storage::Event::AccountAuthorized { who: account.to_account_id(), transactions: 16, bytes: 1024, @@ -660,13 +660,13 @@ fn people_next_chain_can_authorize_storage_with_transact() { let people_next_location = Location::new(1, [Parachain(5140)]); let account = Sr25519Keyring::Ferdie; - let authorize_call = RuntimeCall::TransactionStorage(pallet_transaction_storage::Call::< - Runtime, - >::authorize_account { - who: account.to_account_id(), - transactions: 16, - bytes: 1024, - }); + let authorize_call = RuntimeCall::TransactionStorage( + pallet_bulletin_transaction_storage::Call::::authorize_account { + who: account.to_account_id(), + transactions: 16, + bytes: 1024, + }, + ); ExtBuilder::::default() .with_collators(vec![AccountId::from(ALICE)]) @@ -687,7 +687,7 @@ fn people_next_chain_can_authorize_storage_with_transact() { // Check event. System::assert_has_event(RuntimeEvent::TransactionStorage( - pallet_transaction_storage::Event::AccountAuthorized { + pallet_bulletin_transaction_storage::Event::AccountAuthorized { who: account.to_account_id(), transactions: 16, bytes: 1024, @@ -696,10 +696,10 @@ fn people_next_chain_can_authorize_storage_with_transact() { }) } -/// See [`pallet_transaction_storage::ensure_weight_sanity`]. +/// See [`pallet_bulletin_transaction_storage::ensure_weight_sanity`]. #[test] fn transaction_storage_weight_sanity() { - pallet_transaction_storage::ensure_weight_sanity::( + pallet_bulletin_transaction_storage::ensure_weight_sanity::( // Collator-side PoV cap: default 85% of max_pov_size. // See cumulus/client/consensus/aura/src/collators/slot_based/block_builder_task.rs Some(85), @@ -1033,7 +1033,7 @@ fn signed_store_prefers_preimage_authorization_over_account() { #[test] fn wrapped_renew_requires_authorization() { let mut t = RuntimeGenesisConfig::default().build_storage().unwrap(); - pallet_transaction_storage::GenesisConfig:: { + pallet_bulletin_transaction_storage::GenesisConfig:: { retention_period: 100, byte_fee: 0, entry_fee: 0, @@ -1317,7 +1317,7 @@ fn max_recursion_depth_is_enforced() { RuntimeCall::TransactionStorage(TxStorageCall::::store { data: data.clone(), }); - for _ in 0..=pallet_transaction_storage::MAX_WRAPPER_DEPTH { + for _ in 0..=pallet_bulletin_transaction_storage::MAX_WRAPPER_DEPTH { call = RuntimeCall::Utility(pallet_utility::Call::batch { calls: vec![call] }); } diff --git a/sdk/rust/Cargo.toml b/sdk/rust/Cargo.toml index 99d6d3623..acfa9b4ae 100644 --- a/sdk/rust/Cargo.toml +++ b/sdk/rust/Cargo.toml @@ -6,6 +6,7 @@ edition.workspace = true repository.workspace = true license = "GPL-3.0-or-later" description = "Off-chain client SDK for Polkadot Bulletin Chain" +publish = false [dependencies] # Core dependencies @@ -18,7 +19,7 @@ scale-info = { workspace = true, features = [ cid = { version = "0.11", default-features = false, features = ["alloc"] } # CID primitives -transaction-storage-primitives = { workspace = true } +bulletin-transaction-storage-primitives = { workspace = true } # Substrate primitives sp-core = { workspace = true } @@ -40,6 +41,7 @@ subxt = "0.44" default = ["std"] std = [ + "bulletin-transaction-storage-primitives/std", "cid/std", "codec/std", "scale-info/std", @@ -49,7 +51,6 @@ std = [ "subxt-signer", "thiserror", "tokio", - "transaction-storage-primitives/std", ] # Runtime benchmarking (no-op for SDK, but required for workspace consistency) diff --git a/sdk/rust/src/cid.rs b/sdk/rust/src/cid.rs index 3160c51e8..521981ae4 100644 --- a/sdk/rust/src/cid.rs +++ b/sdk/rust/src/cid.rs @@ -12,7 +12,7 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; // Re-export CID types from transaction-storage-primitives -pub use transaction_storage_primitives::{ +pub use bulletin_transaction_storage_primitives::{ cids::{calculate_cid, Cid, CidConfig, CidData, HashingAlgorithm}, ContentHash, };