Skip to content

Commit

Permalink
Merge pull request #853 from galacticcouncil/metadata_hash
Browse files Browse the repository at this point in the history
feat: enable metadata hash verification
  • Loading branch information
Roznovjak authored Jul 15, 2024
2 parents 769c33d + 438f2da commit 29f7568
Show file tree
Hide file tree
Showing 7 changed files with 451 additions and 429 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Run tests
run: make test-release
- name: Build release
run: time make build
run: time make build-release
- name: Version info
run: ./target/release/hydradx --version
- name: Upload release binary
Expand Down
833 changes: 415 additions & 418 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "r
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
Expand Down Expand Up @@ -344,6 +345,7 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "r
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
Expand Down Expand Up @@ -487,3 +489,7 @@ westend-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch =
cumulus-client-pov-recovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }
cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }

# Check issue: https://github.com/paritytech/arkworks-substrate/issues/9
[patch."https://github.com/paritytech/polkadot-sdk"]
sp-crypto-ec-utils = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.7.2" }
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
build:
cargo build --release --locked

.PHONY: build-release
build-release:
cargo build --release --locked --features metadata-hash

.PHONY: check
check:
cargo check --release
Expand Down Expand Up @@ -60,9 +64,9 @@ checksum:
cp target/release/wbuild/hydradx-runtime/hydradx_runtime.compact.compressed.wasm target/release/
sha256sum target/release/hydradx_runtime.compact.compressed.wasm > target/release/hydradx_runtime.compact.compressed.wasm.sha256

release: build checksum
release: build-release checksum

all: clippy build-benchmarks test-benchmarks test build checksum

chopstics: release
npx @acala-network/chopsticks xcm --parachain=launch-configs/chopsticks/hydradx.yml --parachain=launch-configs/chopsticks/assethub.yml
npx @acala-network/chopsticks xcm --parachain=launch-configs/chopsticks/hydradx.yml --parachain=launch-configs/chopsticks/assethub.yml
9 changes: 8 additions & 1 deletion runtime/hydradx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx-runtime"
version = "245.0.0"
version = "246.0.0"
authors = ["GalacticCouncil"]
edition = "2021"
license = "Apache 2.0"
Expand Down Expand Up @@ -126,6 +126,7 @@ frame-system = { workspace = true }
frame-system-benchmarking = { workspace = true, optional = true }
frame-system-rpc-runtime-api = { workspace = true }
frame-try-runtime = { workspace = true, optional = true }
frame-metadata-hash-extension = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-genesis-builder = { workspace = true }
Expand Down Expand Up @@ -223,6 +224,7 @@ std = [
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"frame-try-runtime/std",
"frame-metadata-hash-extension/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-aura-ext/std",
"cumulus-primitives-core/std",
Expand Down Expand Up @@ -393,3 +395,8 @@ try-runtime= [
"pallet-message-queue/try-runtime",
"pallet-state-trie-migration/try-runtime",
]

metadata-hash = [
"substrate-wasm-builder/metadata-hash",
"sp-api/disable-logging",
]
19 changes: 13 additions & 6 deletions runtime/hydradx/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
use substrate_wasm_builder::WasmBuilder;
#[cfg(all(feature = "std", feature = "release-build"))]
fn main() {
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("HDX", 12)
.build();
}

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

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 2 additions & 1 deletion runtime/hydradx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("hydradx"),
impl_name: create_runtime_str!("hydradx"),
authoring_version: 1,
spec_version: 245,
spec_version: 246,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -256,6 +256,7 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
pallet_claims::ValidateClaim<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
Expand Down

0 comments on commit 29f7568

Please sign in to comment.