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

Implement CheckMetadataHash extension (#4274) #4619

Merged
merged 1 commit into from
May 29, 2024
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/check-semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
run: |
export CARGO_TARGET_DIR=target
export RUSTFLAGS='-A warnings -A missing_docs'
export SKIP_WASM_BUILD=1
if ! parity-publish --color always prdoc --since old --validate prdoc/pr_$PR.prdoc --toolchain nightly-2024-03-01 -v; then
cat <<EOF
👋 Hello developer! The SemVer information that you declared in the prdoc file did not match what the CI detected.
Expand Down
11 changes: 11 additions & 0 deletions .gitlab/pipeline/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,17 @@ check-tracing:
- time cargo test --locked --manifest-path ./substrate/primitives/tracing/Cargo.toml --no-default-features
- time cargo test --locked --manifest-path ./substrate/primitives/tracing/Cargo.toml --no-default-features --features=with-tracing

# Check that `westend-runtime` compiles with the `metadata-hash` feature enabled.
check-metadata-hash:
stage: test
extends:
- .docker-env
- .common-refs
- .run-immediately
- .pipeline-stopper-artifacts
script:
- time cargo build --locked -p westend-runtime --features metadata-hash

# more information about this job can be found here:
# https://github.com/paritytech/substrate/pull/3778
test-full-crypto-feature:
Expand Down
85 changes: 85 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
Expand Up @@ -360,6 +360,7 @@ members = [
"substrate/frame/membership",
"substrate/frame/merkle-mountain-range",
"substrate/frame/message-queue",
"substrate/frame/metadata-hash-extension",
"substrate/frame/migrations",
"substrate/frame/mixnet",
"substrate/frame/multisig",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ assert_matches = "1.5.0"
sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false }
sp-keyring = { path = "../../../../../../../substrate/primitives/keyring", default-features = false }
sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false }
frame-metadata-hash-extension = { path = "../../../../../../../substrate/frame/metadata-hash-extension" }
frame-support = { path = "../../../../../../../substrate/frame/support", default-features = false }
frame-system = { path = "../../../../../../../substrate/frame/system", default-features = false }
pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ fn construct_extrinsic_westend(
),
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
);
let raw_payload = westend_runtime::SignedPayload::new(call, extra).unwrap();
let signature = raw_payload.using_encoded(|payload| sender.sign(payload));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ scale-info = { version = "2.11.1", default-features = false, features = ["derive
# Substrate
frame-benchmarking = { path = "../../../../../substrate/frame/benchmarking", default-features = false, optional = true }
frame-executive = { path = "../../../../../substrate/frame/executive", default-features = false }
frame-metadata-hash-extension = { path = "../../../../../substrate/frame/metadata-hash-extension", default-features = false }
frame-support = { path = "../../../../../substrate/frame/support", default-features = false }
frame-system = { path = "../../../../../substrate/frame/system", default-features = false }
frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
Expand Down Expand Up @@ -189,6 +190,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",
Expand Down Expand Up @@ -248,7 +250,10 @@ std = [
"xcm/std",
]

# Enable the metadata hash generation in the wasm builder.
metadata-hash = ["substrate-wasm-builder/metadata-hash"]

# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
on-chain-release-build = ["sp-api/disable-logging"]
on-chain-release-build = ["metadata-hash", "sp-api/disable-logging"]
9 changes: 8 additions & 1 deletion cumulus/parachains/runtimes/assets/asset-hub-rococo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

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

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

#[cfg(not(feature = "std"))]
fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_version: 1_012_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 15,
transaction_version: 16,
state_version: 1,
};

Expand Down Expand Up @@ -970,6 +970,7 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ scale-info = { version = "2.11.1", default-features = false, features = ["derive
# Substrate
frame-benchmarking = { path = "../../../../../substrate/frame/benchmarking", default-features = false, optional = true }
frame-executive = { path = "../../../../../substrate/frame/executive", default-features = false }
frame-metadata-hash-extension = { path = "../../../../../substrate/frame/metadata-hash-extension", default-features = false }
frame-support = { path = "../../../../../substrate/frame/support", default-features = false }
frame-system = { path = "../../../../../substrate/frame/system", default-features = false }
frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
Expand Down Expand Up @@ -189,6 +190,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",
Expand Down Expand Up @@ -247,7 +249,10 @@ std = [
"xcm/std",
]

# Enable the metadata hash generation in the wasm builder.
metadata-hash = ["substrate-wasm-builder/metadata-hash"]

# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
on-chain-release-build = ["sp-api/disable-logging"]
on-chain-release-build = ["metadata-hash", "sp-api/disable-logging"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

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

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

#[cfg(not(feature = "std"))]
fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_version: 1_012_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 15,
transaction_version: 16,
state_version: 1,
};

Expand Down Expand Up @@ -965,6 +965,7 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
Expand Down
1 change: 1 addition & 0 deletions docs/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ frame-system = { path = "../../substrate/frame/system", default-features = false
frame-support = { path = "../../substrate/frame/support", default-features = false }
frame-executive = { path = "../../substrate/frame/executive", default-features = false }
pallet-example-single-block-migrations = { path = "../../substrate/frame/examples/single-block-migrations" }
frame-metadata-hash-extension = { path = "../../substrate/frame/metadata-hash-extension" }

# Substrate Client
sc-network = { path = "../../substrate/client/network" }
Expand Down
Loading
Loading