Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
80 changes: 79 additions & 1 deletion .github/workflows/check-runtime-migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
check-runtime: ${{ steps.runtime.outputs.check-runtime }}
name: Extract tasks from matrix
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
Expand All @@ -55,6 +56,12 @@ jobs:
TASKS=$(echo $TASKS | jq -c .)
echo "runtime=$TASKS" >> $GITHUB_OUTPUT

# Filter runtimes with check_runtime enabled (metadata hash matches the live chain)
CHECK_RUNTIME_TASKS=$(jq -c '[.[] | select(.check_runtime == true)]' scripts/runtimes-matrix.json)
echo --- check-runtime tasks ---
echo $CHECK_RUNTIME_TASKS
echo "check-runtime=$CHECK_RUNTIME_TASKS" >> $GITHUB_OUTPUT

prepare-snapshots:
needs: [runtime-matrix]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -134,6 +141,77 @@ jobs:
key: try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.get-date.outputs.today }}


# Runs @polkadot-api/check-runtime against live RPCs to detect common runtime
# upgrade issues: missing or outdated metadata versions, absent runtime APIs,
# incorrect CheckMetadataHash configuration, and dev APIs in production builds.
check-runtimes:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antkve please, add here some specific/short desc what @polkadot-api/check-runtime@latest is really checking

needs: [runtime-matrix]
runs-on: ubuntu-latest
if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' && needs.runtime-matrix.outputs.runtime.check-runtime
strategy:
fail-fast: false
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.check-runtime) }}
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Load common environment variables via env file
run: cat .github/env >> $GITHUB_ENV

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # master
with:
targets: "wasm32v1-none"
components: "rust-src"
toolchain: "${{ env.RUST_STABLE_VERSION }}"

- name: Build ${{ matrix.runtime.name }} runtime
env:
PACKAGE_NAME: ${{ matrix.runtime.package }}
run: |
cargo build --release -p "$PACKAGE_NAME" --features on-chain-release-build -q --locked

- name: Check runtime
timeout-minutes: 10
env:
RUNTIME_NAME: ${{ matrix.runtime.name }}
PACKAGE_NAME: ${{ matrix.runtime.package }}
URIS_JSON: ${{ toJSON(matrix.runtime.uris) }}
run: |
RUNTIME_BLOB_NAME=$(echo "$PACKAGE_NAME" | sed 's/-/_/g').compact.compressed.wasm
WASM="./target/release/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME"
echo "WASM: $WASM"

# Try each RPC with a timeout to handle unreachable endpoints
# (check-runtime hangs indefinitely on unreachable RPCs).
readarray -t URIS < <(echo "$URIS_JSON" | jq -r '.[]')
for URI in "${URIS[@]}"; do
echo "Trying $URI..."
set +e
timeout 120 npx @polkadot-api/check-runtime@latest problems "$URI" --wasm "$WASM"
EXIT_CODE=$?
set -e
if [ $EXIT_CODE -eq 0 ]; then
exit 0
# When the time limit is reached, timeout returns exit code 124
elif [ $EXIT_CODE -eq 124 ]; then
echo "Timed out on $URI, trying next..."
continue
else
# Otherwise, it returns the exit status of the managed command
exit $EXIT_CODE
fi
done

echo "::error::No reachable RPC for $RUNTIME_NAME"
exit 1

check-migrations:
needs: [runtime-matrix, prepare-snapshots]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -210,7 +288,7 @@ jobs:
runs-on: ubuntu-latest
name: All migrations passed
if: always() && github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'
needs: [changes, check-migrations]
needs: [changes, check-runtimes, check-migrations]
steps:
- name: Decide outcome
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
Expand Down
100 changes: 65 additions & 35 deletions runtimes/bulletin-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]

extern crate alloc;
Expand Down Expand Up @@ -40,8 +39,12 @@ use sp_runtime::{
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use frame_support::{
dispatch::GetDispatchInfo,
genesis_builder_helper::{build_state, get_preset},
};
pub use frame_support::{
construct_runtime, parameter_types,
parameter_types,
traits::{
ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Get, KeyOwnerProofSystem, OriginTrait,
Randomness, StorageInfo,
Expand All @@ -54,10 +57,6 @@ pub use frame_support::{
},
StorageValue,
};
use frame_support::{
dispatch::GetDispatchInfo,
genesis_builder_helper::{build_state, get_preset},
};
pub use frame_system::Call as SystemCall;
pub use pallet_timestamp::Call as TimestampCall;

Expand Down Expand Up @@ -558,35 +557,66 @@ where
}
}

construct_runtime!(
pub struct Runtime {
System: frame_system = 0,
// Babe must be called before Session
Babe: pallet_babe = 1,
Timestamp: pallet_timestamp = 2,
Utility: pallet_utility = 3,
// Authorship must be before session in order to note author in the correct session.
Authorship: pallet_authorship = 10,
Offences: pallet_offences = 11,
Historical: pallet_session::historical = 12,
ValidatorSet: pallet_validator_set = 13,
Session: pallet_session = 14,
Grandpa: pallet_grandpa = 15,

// Storage
TransactionStorage: pallet_transaction_storage = 40,

// Bridge
RelayerSet: pallet_relayer_set = 50,
BridgePolkadotGrandpa: pallet_bridge_grandpa = 51,
BridgePolkadotParachains: pallet_bridge_parachains = 52,
BridgePolkadotMessages: pallet_bridge_messages = 53,

// Local Root
Sudo: pallet_sudo = 61,
Proxy: pallet_proxy = 62,
}
);
#[frame_support::runtime(legacy_ordering)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antkve we don't need to modify bulletin-polkadot solochain runtime, it will be remove soon

mod runtime {
#[runtime::runtime]
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeTask,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId,
RuntimeViewFunction
)]
pub struct Runtime;

#[runtime::pallet_index(0)]
pub type System = frame_system;
// Babe must be called before Session
#[runtime::pallet_index(1)]
pub type Babe = pallet_babe;
#[runtime::pallet_index(2)]
pub type Timestamp = pallet_timestamp;
#[runtime::pallet_index(3)]
pub type Utility = pallet_utility;
// Authorship must be before session in order to note author in the correct session.
#[runtime::pallet_index(10)]
pub type Authorship = pallet_authorship;
#[runtime::pallet_index(11)]
pub type Offences = pallet_offences;
#[runtime::pallet_index(12)]
pub type Historical = pallet_session::historical;
#[runtime::pallet_index(13)]
pub type ValidatorSet = pallet_validator_set;
#[runtime::pallet_index(14)]
pub type Session = pallet_session;
#[runtime::pallet_index(15)]
pub type Grandpa = pallet_grandpa;

// Storage
#[runtime::pallet_index(40)]
pub type TransactionStorage = pallet_transaction_storage;

// Bridge
#[runtime::pallet_index(50)]
pub type RelayerSet = pallet_relayer_set;
#[runtime::pallet_index(51)]
pub type BridgePolkadotGrandpa = pallet_bridge_grandpa;
#[runtime::pallet_index(52)]
pub type BridgePolkadotParachains = pallet_bridge_parachains;
#[runtime::pallet_index(53)]
pub type BridgePolkadotMessages = pallet_bridge_messages;

// Local Root
#[runtime::pallet_index(61)]
pub type Sudo = pallet_sudo;
#[runtime::pallet_index(62)]
pub type Proxy = pallet_proxy;
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
Expand Down
109 changes: 70 additions & 39 deletions runtimes/bulletin-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// limitations under the License.

#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]

// Make the WASM binary available.
#[cfg(feature = "std")]
Expand All @@ -40,7 +38,7 @@ use alloc::{vec, vec::Vec};
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::{
construct_runtime, derive_impl,
derive_impl,
dispatch::DispatchClass,
genesis_builder_helper::{build_state, get_preset},
parameter_types,
Expand Down Expand Up @@ -504,42 +502,75 @@ impl pallet_utility::Config for Runtime {
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
{
// System support stuff.
System: frame_system = 0,
ParachainSystem: cumulus_pallet_parachain_system = 1,
Timestamp: pallet_timestamp = 3,
ParachainInfo: parachain_info = 4,
WeightReclaim: cumulus_pallet_weight_reclaim = 5,
Utility: pallet_utility = 6,

// Monetary stuff.
Balances: pallet_balances = 10,
TransactionPayment: pallet_transaction_payment = 11,
SkipFeelessPayment: pallet_skip_feeless_payment = 12,

// Storage
TransactionStorage: pallet_transaction_storage = 40,

// Collator support. The order of these 5 are important and shall not change.
Authorship: pallet_authorship = 20,
CollatorSelection: pallet_collator_selection = 21,
Session: pallet_session = 22,
Aura: pallet_aura = 23,
AuraExt: cumulus_pallet_aura_ext = 24,

// XCM & related
XcmpQueue: cumulus_pallet_xcmp_queue = 30,
PolkadotXcm: pallet_xcm = 31,
CumulusXcm: cumulus_pallet_xcm = 32,
MessageQueue: pallet_message_queue = 34,

// Sudo
Sudo: pallet_sudo = 100,
}
);
#[frame_support::runtime(legacy_ordering)]
mod runtime {
#[runtime::runtime]
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeTask,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId,
RuntimeViewFunction
)]
pub struct Runtime;

// System support stuff.
#[runtime::pallet_index(0)]
pub type System = frame_system;
#[runtime::pallet_index(1)]
pub type ParachainSystem = cumulus_pallet_parachain_system;
#[runtime::pallet_index(3)]
pub type Timestamp = pallet_timestamp;
#[runtime::pallet_index(4)]
pub type ParachainInfo = parachain_info;
#[runtime::pallet_index(5)]
pub type WeightReclaim = cumulus_pallet_weight_reclaim;
#[runtime::pallet_index(6)]
pub type Utility = pallet_utility;

// Monetary stuff.
#[runtime::pallet_index(10)]
pub type Balances = pallet_balances;
#[runtime::pallet_index(11)]
pub type TransactionPayment = pallet_transaction_payment;
#[runtime::pallet_index(12)]
pub type SkipFeelessPayment = pallet_skip_feeless_payment;

// Storage
#[runtime::pallet_index(40)]
pub type TransactionStorage = pallet_transaction_storage;

// Collator support. The order of these 5 are important and shall not change.
#[runtime::pallet_index(20)]
pub type Authorship = pallet_authorship;
#[runtime::pallet_index(21)]
pub type CollatorSelection = pallet_collator_selection;
#[runtime::pallet_index(22)]
pub type Session = pallet_session;
#[runtime::pallet_index(23)]
pub type Aura = pallet_aura;
#[runtime::pallet_index(24)]
pub type AuraExt = cumulus_pallet_aura_ext;

// XCM & related
#[runtime::pallet_index(30)]
pub type XcmpQueue = cumulus_pallet_xcmp_queue;
#[runtime::pallet_index(31)]
pub type PolkadotXcm = pallet_xcm;
#[runtime::pallet_index(32)]
pub type CumulusXcm = cumulus_pallet_xcm;
#[runtime::pallet_index(34)]
pub type MessageQueue = pallet_message_queue;

// Sudo
#[runtime::pallet_index(100)]
pub type Sudo = pallet_sudo;
}

#[cfg(feature = "runtime-benchmarks")]
mod benches {
Expand Down
1 change: 1 addition & 0 deletions scripts/runtimes-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"uris": [
"wss://westend-bulletin-rpc.polkadot.io"
],
"check_runtime": true,
"integration_tests": true,
"try_runtime": {
"extra_flags": "--blocktime 6000 --disable-spec-version-check"
Expand Down
Loading