Skip to content

Commit

Permalink
Revert "Revert "Add CheckMetadataHash extension (#337)""
Browse files Browse the repository at this point in the history
This reverts commit 5bc25e5.
  • Loading branch information
ggwpez committed Jun 24, 2024
1 parent 3557c59 commit 52c7c17
Show file tree
Hide file tree
Showing 34 changed files with 160 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
RUSTFLAGS: "-C debug-assertions -D warnings"

- name: Test all features ${{ matrix.runtime.name }}
run: cargo test -p ${{ matrix.runtime.package }} --release --locked -q --features=runtime-benchmarks,try-runtime
run: cargo test -p ${{ matrix.runtime.package }} --release --locked -q --all-features
env:
RUSTFLAGS: "-C debug-assertions -D warnings"
SKIP_WASM_BUILD: 1
Expand Down
10 changes: 8 additions & 2 deletions relay/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pallet-conviction-voting = { workspace = true }
pallet-election-provider-multi-phase = { workspace = true }
pallet-fast-unstake = { workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
pallet-grandpa = { workspace = true }
pallet-nis = { workspace = true }
pallet-delegated-staking = { workspace = true }
Expand Down Expand Up @@ -113,7 +114,7 @@ tokio = { features = ["macros"], workspace = true }
sp-tracing = { workspace = true }

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

[features]
default = ["std"]
Expand All @@ -128,6 +129,7 @@ std = [
"frame-benchmarking?/std",
"frame-election-provider-support/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 @@ -184,6 +186,7 @@ std = [
"polkadot-runtime-common/std",
"runtime-parachains/std",
"scale-info/std",
"substrate-wasm-builder",
"sp-api/std",
"sp-application-crypto/std",
"sp-arithmetic/std",
Expand Down Expand Up @@ -309,10 +312,13 @@ try-runtime = [
"pallet-delegated-staking/try-runtime"
]

# Enable metadata hash generation at compile time for the `CheckMetadataHash` extension.
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 = ["sp-api/disable-logging", "metadata-hash"]

# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []
Expand Down
15 changes: 10 additions & 5 deletions relay/kusama/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

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

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

#[cfg(not(feature = "std"))]
fn main() {}
2 changes: 2 additions & 0 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ where
frame_system::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
frame_metadata_hash_extension::CheckMetadataHash::new(false),
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
Expand Down Expand Up @@ -1775,6 +1776,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

pub struct NominationPoolsMigrationV4OldPallet;
Expand Down
10 changes: 8 additions & 2 deletions relay/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pallet-conviction-voting = { workspace = true }
pallet-election-provider-multi-phase = { workspace = true }
pallet-fast-unstake = { workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
pallet-grandpa = { workspace = true }
pallet-identity = { workspace = true }
pallet-indices = { workspace = true }
Expand Down Expand Up @@ -111,7 +112,7 @@ tokio = { features = ["macros"], workspace = true }
sp-tracing = { workspace = true }

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

[features]
default = ["std"]
Expand All @@ -126,6 +127,7 @@ std = [
"frame-benchmarking?/std",
"frame-election-provider-support/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 @@ -181,6 +183,7 @@ std = [
"polkadot-runtime-constants/std",
"runtime-parachains/std",
"scale-info/std",
"substrate-wasm-builder",
"sp-api/std",
"sp-application-crypto/std",
"sp-arithmetic/std",
Expand Down Expand Up @@ -302,10 +305,13 @@ try-runtime = [
"pallet-delegated-staking/try-runtime"
]

# Enable metadata hash generation at compile time for the `CheckMetadataHash` extension.
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 = ["sp-api/disable-logging", "metadata-hash"]

# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []
Expand Down
17 changes: 11 additions & 6 deletions relay/polkadot/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Substrate is distributed in the hope that it will be useful,
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

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

#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
WasmBuilder::new()
.with_current_project()
.import_memory()
.export_heap_base()
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("DOT", 10)
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 3 additions & 0 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ where
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
claims::PrevalidateAttests::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::new(false),
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
Expand Down Expand Up @@ -1832,6 +1833,7 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
claims::PrevalidateAttests<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

pub struct NominationPoolsMigrationV4OldPallet;
Expand Down Expand Up @@ -2891,6 +2893,7 @@ mod test_fees {
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
claims::PrevalidateAttests::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
);
let uxt = UncheckedExtrinsic {
function: call,
Expand Down
7 changes: 6 additions & 1 deletion system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ polkadot-runtime-constants = { workspace = true }
# Substrate
frame-benchmarking = { optional = true, workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { optional = true, workspace = true }
Expand Down Expand Up @@ -209,6 +210,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 @@ -270,7 +272,10 @@ std = [
"xcm/std",
]

# Enable metadata hash generation at compile time for the `CheckMetadataHash` extension.
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 = ["sp-api/disable-logging", "metadata-hash"]
13 changes: 8 additions & 5 deletions system-parachains/asset-hubs/asset-hub-kusama/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[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("KSM", 12)
.build()
}

Expand Down
1 change: 1 addition & 0 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
Expand Down
7 changes: 6 additions & 1 deletion system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ polkadot-runtime-constants = { workspace = true }
# Substrate
frame-benchmarking = { optional = true, workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { optional = true, workspace = true }
Expand Down Expand Up @@ -194,6 +195,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 @@ -254,7 +256,10 @@ std = [
"xcm/std",
]

# Enable metadata hash generation at compile time for the `CheckMetadataHash` extension.
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 = ["sp-api/disable-logging", "metadata-hash"]
13 changes: 8 additions & 5 deletions system-parachains/asset-hubs/asset-hub-polkadot/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[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("DOT", 10)
.build()
}

Expand Down
1 change: 1 addition & 0 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
Expand Down
7 changes: 6 additions & 1 deletion system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ polkadot-runtime-constants = { workspace = true }
# Substrate
frame-benchmarking = { optional = true, workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { optional = true, workspace = true }
Expand Down Expand Up @@ -154,6 +155,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 @@ -297,7 +299,10 @@ try-runtime = [
"sp-runtime/try-runtime",
]

# Enable metadata hash generation at compile time for the `CheckMetadataHash` extension.
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 = ["sp-api/disable-logging", "metadata-hash"]
13 changes: 8 additions & 5 deletions system-parachains/bridge-hubs/bridge-hub-kusama/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[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("KSM", 12)
.build()
}

Expand Down
1 change: 1 addition & 0 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub type SignedExtra = (
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
BridgeRejectObsoleteHeadersAndMessages,
bridge_to_polkadot_config::RefundBridgeHubPolkadotMessages,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ fn construct_extrinsic(
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
BridgeRejectObsoleteHeadersAndMessages,
(RefundBridgeHubPolkadotMessages::default()),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fn construct_extrinsic(
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
BridgeRejectObsoleteHeadersAndMessages,
(RefundBridgeHubPolkadotMessages::default()),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
Expand Down
Loading

0 comments on commit 52c7c17

Please sign in to comment.