Skip to content

Commit 0d99eae

Browse files
committed
update
1 parent fecfd87 commit 0d99eae

4 files changed

Lines changed: 138 additions & 19 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Runtime Build
2+
3+
on:
4+
push:
5+
branches:
6+
- update
7+
workflow_dispatch:
8+
inputs:
9+
try_runtime_uri:
10+
description: "WebSocket endpoint used by try-runtime create-snapshot"
11+
required: false
12+
type: string
13+
14+
jobs:
15+
build_runtime:
16+
name: Build Runtime Wasm
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Cache cargo registry
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.cargo/registry
26+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
27+
28+
- name: Cache cargo git index
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.cargo/git
32+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.toml') }}
33+
34+
- name: Cache target directory
35+
uses: actions/cache@v4
36+
with:
37+
path: target
38+
key: ${{ runner.os }}-runtime-target-${{ hashFiles('**/Cargo.toml', 'Cargo.lock') }}
39+
40+
- name: Install build dependencies
41+
run: |
42+
sudo apt update
43+
sudo apt install -y cmake pkg-config libssl-dev git gcc build-essential clang
44+
45+
- name: Setup Rust toolchain
46+
uses: actions-rs/toolchain@v1
47+
with:
48+
toolchain: nightly-2021-01-19-x86_64-unknown-linux-gnu
49+
target: wasm32-unknown-unknown
50+
override: true
51+
- name: Check try-runtime upgrade
52+
run: |
53+
set -euo pipefail
54+
echo "=== Checking Runtime Migration Via try-runtime ==="
55+
56+
TRY_RUNTIME_URI="wss://rpc.crustnetwork.xyz"
57+
58+
echo "Using try-runtime endpoint: $TRY_RUNTIME_URI"
59+
60+
cargo install --locked --git https://github.com/paritytech/try-runtime-cli --rev a93c9b5abe5d31a4cf1936204f7e5c489184b521
61+
try-runtime --version
62+
63+
CARGO_TARGET_DIR=target/try-runtime cargo build --release -p crust-runtime --features try-runtime
64+
65+
TRY_RUNTIME_WASM="target/try-runtime/release/wbuild/crust-runtime/target/wasm32-unknown-unknown/release/crust_runtime.wasm"
66+
if [ ! -f "$TRY_RUNTIME_WASM" ]; then
67+
TRY_RUNTIME_WASM="target/try-runtime/release/wbuild/crust-runtime/crust_runtime.wasm"
68+
fi
69+
70+
if [ ! -f "$TRY_RUNTIME_WASM" ]; then
71+
echo "❌ ERROR: try-runtime wasm not found"
72+
exit 1
73+
fi
74+
75+
try-runtime create-snapshot --uri "$TRY_RUNTIME_URI" snapshot.raw
76+
77+
try-runtime \
78+
--runtime "$TRY_RUNTIME_WASM" \
79+
on-runtime-upgrade --disable-spec-version-check --checks=pre-and-post snap -p snapshot.raw
80+
81+
echo "=== try-runtime Check Passed ==="
82+
- name: Build runtime
83+
run: cargo build --release -p crust-runtime
84+
85+
- name: Collect runtime artifacts
86+
run: |
87+
mkdir -p artifacts/runtime
88+
if [ ! -d target/release/wbuild/crust-runtime ]; then
89+
echo "Runtime output directory target/release/wbuild/crust-runtime not found"
90+
exit 1
91+
fi
92+
find target/release/wbuild/crust-runtime -maxdepth 1 -type f -name "*.wasm" -exec cp {} artifacts/runtime/ \;
93+
ls -lah artifacts/runtime
94+
95+
- name: Upload runtime artifacts
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: crust-runtime-${{ github.sha }}
99+
path: artifacts/runtime/*
100+
if-no-files-found: error
101+
retention-days: 14

.github/workflows/rust.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
name: Crust CI
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
- mainnet*
8-
- feature/*
9-
paths-ignore:
10-
- '**.md'
11-
pull_request:
12-
branches:
13-
- master
14-
- mainnet*
15-
- feature/*
16-
paths-ignore:
17-
- '**.md'
4+
workflow_dispatch:
185
jobs:
196
build_and_test:
207
name: Build & Test

runtime/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pallet-sudo = { default-features = false, git = "https://github.com/crustio/subs
5858
frame-support = { default-features = false, git = "https://github.com/crustio/substrate", rev = "3971a18dd746ff5190d2d274cfcdaf7dae5f8ce4" }
5959
pallet-staking-reward-curve = { default-features = false, git = "https://github.com/crustio/substrate", rev = "3971a18dd746ff5190d2d274cfcdaf7dae5f8ce4" }
6060
frame-system = { default-features = false, git = "https://github.com/crustio/substrate", rev = "3971a18dd746ff5190d2d274cfcdaf7dae5f8ce4" }
61+
frame-try-runtime = { default-features = false, optional = true, git = "https://github.com/crustio/substrate", rev = "3971a18dd746ff5190d2d274cfcdaf7dae5f8ce4" }
6162
pallet-timestamp = { default-features = false, git = "https://github.com/crustio/substrate", rev = "3971a18dd746ff5190d2d274cfcdaf7dae5f8ce4" }
6263
pallet-tips = { default-features = false, git = "https://github.com/crustio/substrate", rev = "3971a18dd746ff5190d2d274cfcdaf7dae5f8ce4" }
6364
pallet-transaction-payment = { default-features = false, git = "https://github.com/crustio/substrate", rev = "3971a18dd746ff5190d2d274cfcdaf7dae5f8ce4" }
@@ -139,6 +140,7 @@ std = [
139140
"locks/std",
140141
"csm-locking/std",
141142
"frame-system/std",
143+
"frame-try-runtime?/std",
142144
"frame-system-rpc-runtime-api/std",
143145
"pallet-timestamp/std",
144146
"pallet-tips/std",
@@ -163,4 +165,12 @@ runtime-benchmarks = [
163165
"csm-locking/runtime-benchmarks",
164166
"locks/runtime-benchmarks",
165167
"bridge/runtime-benchmarks",
168+
]
169+
170+
try-runtime = [
171+
"frame-executive/try-runtime",
172+
"frame-support/try-runtime",
173+
"frame-system/try-runtime",
174+
"frame-try-runtime/try-runtime",
175+
"sp-runtime/try-runtime",
166176
]

runtime/src/lib.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
103103
spec_name: create_runtime_str!("crust"),
104104
impl_name: create_runtime_str!("crustio-crust"),
105105
authoring_version: 1,
106-
spec_version: 27,
106+
spec_version: 28,
107107
impl_version: 1,
108108
apis: RUNTIME_API_VERSIONS,
109109
transaction_version: 1
@@ -732,10 +732,10 @@ impl pallet_transaction_payment::Config for Runtime {
732732
TargetedFeeAdjustment<Self, TargetBlockFullness, AdjustmentVariable, MinimumMultiplier>;
733733
}
734734

735-
// impl pallet_sudo::Config for Runtime {
736-
// type Event = Event;
737-
// type Call = Call;
738-
// }
735+
impl pallet_sudo::Config for Runtime {
736+
type Event = Event;
737+
type Call = Call;
738+
}
739739

740740
parameter_types! {
741741
pub const PunishmentSlots: u32 = 8; // 8 report slot == 8 hours
@@ -914,6 +914,9 @@ construct_runtime! {
914914
// ChainBridge
915915
ChainBridge: bridge::{Module, Call, Storage, Event<T>},
916916
BridgeTransfer: bridge_transfer::{Module, Call, Event<T>, Storage},
917+
918+
// reopen Sudo
919+
Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>},
917920
}
918921
}
919922

@@ -941,6 +944,7 @@ pub type SignedExtra = (
941944
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
942945
/// Extrinsic type that has already been checked.
943946
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Index, SignedExtra>;
947+
944948
/// Executive: handles dispatch to the various modules.
945949
pub type Executive = frame_executive::Executive<
946950
Runtime,
@@ -1113,6 +1117,23 @@ impl_runtime_apis! {
11131117
}
11141118
}
11151119

1120+
#[cfg(feature = "try-runtime")]
1121+
impl frame_try_runtime::TryRuntime<Block> for Runtime {
1122+
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
1123+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
1124+
(weight, RuntimeBlockWeights::get().max_block)
1125+
}
1126+
1127+
fn execute_block(
1128+
block: Block,
1129+
state_root_check: bool,
1130+
signature_check: bool,
1131+
select: frame_try_runtime::TryStateSelect,
1132+
) -> Weight {
1133+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
1134+
}
1135+
}
1136+
11161137
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
11171138
fn account_nonce(account: AccountId) -> Index {
11181139
System::account_nonce(account)

0 commit comments

Comments
 (0)