Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CheckMetadataHash signed extension #75

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Changes from 1 commit
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
Next Next commit
add CheckMetadataHash signed extensions
  • Loading branch information
clangenb committed Jul 10, 2024
commit daf8a1f01df7f9f5ef3b09438c7f2123cf14be7d
7 changes: 5 additions & 2 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
@@ -19,9 +19,10 @@ on:
# Matches tags containing an arbitrary suffix starting with '-'.
- v[0-9]+.[0-9]+.[0-9]+-*

# Ensures only one build is run per branch, unless pushing to develop
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
# triggered (ref https://stackoverflow.com/a/72408109)
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/develop' && github.run_number || github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
@@ -105,6 +106,8 @@ jobs:
- name: Build ${{ matrix.runtime }}
id: srtool_build
uses: chevdor/srtool-actions@v0.9.2
env:
BUILD_OPTS: "--features on-chain-release-build"
with:
image: paritytech/srtool
chain: ${{ matrix.runtime }}
54 changes: 54 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ scale-info = { version = "2.1.1", default-features = false }
assets-common = { version = "0.14.0", default-features = false }
frame-benchmarking = { version = "35.0.0", default-features = false }
frame-benchmarking-cli = { version = "39.0.0" }
frame-metadata-hash-extension = { version = "0.3.0", default-features = false }
frame-executive = { version = "35.0.0", default-features = false }
frame-support = { version = "35.0.0", default-features = false }
frame-system = { version = "35.0.0", default-features = false }
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ parity-scale-codec = { workspace = true, features = ["std"] }
# Substrate
frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking-cli = { workspace = true }
frame-metadata-hash-extension = { workspace = true, features = ["std"] }
frame-support = { workspace = true, features = ["std"] }
frame-system-rpc-runtime-api = { workspace = true, features = ["std"] }
frame-try-runtime = { workspace = true, features = ["std"] }
15 changes: 14 additions & 1 deletion runtime/bajun/Cargo.toml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ repository.workspace = true
version.workspace = true

[build-dependencies]
substrate-wasm-builder = { workspace = true }
substrate-wasm-builder = { workspace = true, optional = true }

[dependencies]
# General
@@ -25,6 +25,7 @@ scale-info = { workspace = true, features = [ "derive" ] }
assets-common = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { workspace = true, optional = true }
@@ -126,6 +127,7 @@ std = [
"cumulus-primitives-utility/std",
"frame-benchmarking/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-benchmarking/std",
"frame-system-rpc-runtime-api/std",
@@ -183,6 +185,7 @@ std = [
"staging-xcm/std",
"staging-xcm-builder/std",
"staging-xcm-executor/std",
"substrate-wasm-builder",
# integritee
"pallet-asset-registry/std",
"xcm-primitives/std",
@@ -292,3 +295,13 @@ try-runtime = [
"pallet-ajuna-tournament/try-runtime",
"pallet-ajuna-nft-transfer/try-runtime",
]

# Enable metadata hash generation at compile time for the `CheckMetadataHash` extension.
# This pulls in some dependencies and add compile time, this is why we only do it for
# production builds.
metadata-hash = ["substrate-wasm-builder?/metadata-hash"]

# A feature that should be enabled when the runtime should be built for on-chain
# deployment. Hence, the CI building the release artifact should always enable this
# feature.
on-chain-release-build = ["metadata-hash"]
15 changes: 8 additions & 7 deletions runtime/bajun/build.rs
Original file line number Diff line number Diff line change
@@ -14,16 +14,17 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#[cfg(feature = "std")]
#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
substrate_wasm_builder::WasmBuilder::build_using_defaults()
}

#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("AJUN", 12)
.build()
}

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}
1 change: 1 addition & 0 deletions runtime/bajun/src/lib.rs
Original file line number Diff line number Diff line change
@@ -137,6 +137,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
6 changes: 3 additions & 3 deletions zombienet/rococo-local-with-bajun-runtime-upgrade.toml
Original file line number Diff line number Diff line change
@@ -41,19 +41,19 @@ cumulus_based = true
name = "bajun-collator"
# This should ideally be the old collator as this is used
# to build the modified chain-spec.
command = "~/bin/bajun-node-v500"
command = "~/bin/bajun-node-v600-rc1"

[[parachains.collators]]
name = "bajun-collator-1"
validator = true
command = "~/bin/bajun-node-v600-rc1"
command = "~/bin/bajun-node-v700-rc2"
args = ["-lxcm=trace,runtime=debug"]
ws_port = 9954

[[parachains.collators]]
name = "bajun-collator-2"
validator = true
command = "~/bin/bajun-node-v600-rc1"
command = "~/bin/bajun-node-v700-rc2"
args = ["-lxcm=trace,runtime=debug"]
ws_port = 9955