From 68d455430ac0e88f6b5d8121a88d24e8b3699bf3 Mon Sep 17 00:00:00 2001 From: Cyrill Leutwiler Date: Tue, 9 Jan 2024 12:17:12 +0100 Subject: [PATCH] enable our chain extension Signed-off-by: Cyrill Leutwiler --- Cargo.lock | 2 ++ parachain-runtime/Cargo.toml | 4 ++++ runtime/Cargo.toml | 4 ++-- runtime/src/chain_ext.rs | 2 +- runtime/src/contracts_config.rs | 2 +- runtime/src/lib.rs | 4 ++++ 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0dfdc87..41046d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1446,6 +1446,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", + "ff_wasm_unknown_unknown", "frame-benchmarking", "frame-executive", "frame-support", @@ -1490,6 +1491,7 @@ dependencies = [ "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", + "substrate-bn", "substrate-wasm-builder", ] diff --git a/parachain-runtime/Cargo.toml b/parachain-runtime/Cargo.toml index 5f8a55c..6c9c654 100644 --- a/parachain-runtime/Cargo.toml +++ b/parachain-runtime/Cargo.toml @@ -76,6 +76,10 @@ pallet-contracts-primitives = { workspace = true } pallet-insecure-randomness-collective-flip = { workspace = true } pallet-assets = { workspace = true } +# Chain extension +bn = { workspace = true, default-features = false } +ff_wasm_unknown_unknown = { workspace = true, features = ["derive"] } + [features] default = [ "std", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 311025a..7ce5041 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -53,8 +53,8 @@ pallet-insecure-randomness-collective-flip = { workspace = true } pallet-assets = { workspace = true } # Chain extension -bn = { package = "substrate-bn", version = "0.6", default-features = false } -ff_wasm_unknown_unknown = { features = ["derive"], version = "0.12.2" } +bn = { workspace = true, default-features = false } +ff_wasm_unknown_unknown = { workspace = true, features = ["derive"] } # Used for the node template's RPCs frame-system-rpc-runtime-api = { workspace = true } diff --git a/runtime/src/chain_ext.rs b/runtime/src/chain_ext.rs index ef3a6b7..fad180c 100644 --- a/runtime/src/chain_ext.rs +++ b/runtime/src/chain_ext.rs @@ -8,8 +8,8 @@ use pallet_contracts::chain_extension::{ use sp_core::crypto::UncheckedFrom; use sp_runtime::DispatchError; -use super::Randomness; use crate::{mimc::mimc_feistel, Runtime}; +use frame_support::traits::Randomness; pub(crate) enum InvalidArgument { NotInField = 1, diff --git a/runtime/src/contracts_config.rs b/runtime/src/contracts_config.rs index 93e34ca..dc6c38f 100644 --- a/runtime/src/contracts_config.rs +++ b/runtime/src/contracts_config.rs @@ -61,7 +61,7 @@ impl pallet_contracts::Config for Runtime { type CallStack = [pallet_contracts::Frame; 23]; type WeightPrice = pallet_transaction_payment::Pallet; type WeightInfo = pallet_contracts::weights::SubstrateWeight; - type ChainExtension = (); + type ChainExtension = crate::chain_ext::FetchRandomExtension; type Schedule = Schedule; type AddressGenerator = pallet_contracts::DefaultAddressGenerator; // This node is geared towards development and testing of contracts. diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 1c49387..5ed0188 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -9,6 +9,10 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod assets_config; mod contracts_config; +mod bn128; +mod chain_ext; +mod mimc; + use frame_support::dispatch::DispatchClass; use frame_system::limits::{BlockLength, BlockWeights}; use polkadot_runtime_common::SlowAdjustingFeeUpdate;