diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62c77282..547cf5e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - uses: dtolnay/rust-toolchain@nightly with: targets: wasm32-unknown-unknown - components: rustfmt + components: rust-src, rustfmt - name: Install build dependencies run: sudo apt-get install protobuf-compiler - name: Rust Cache diff --git a/Cargo.toml b/Cargo.toml index 7887f931..2555c9f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ ] [workspace.dependencies] -array-bytes = "4.2.0" +array-bytes = "6.2.2" base64ct = { version = "1.6.0", default-features = false } bech32 = { version = "0.9.1", default-features = false } clap = { version = "4.0.9", features = ["derive"] } @@ -25,66 +25,66 @@ num_enum = { version = "0.6.1", default-features = false } parity-scale-codec = { version = "3.2.0", default-features = false } ripemd = { version = "0.1.3", default-features = false } scale-info = { version = "2.3.0", default-features = false } -secp256k1 = { version = "0.24.0", default-features = false } +secp256k1 = { version = "0.28.1", default-features = false } serde = { version = "1.0.0", default-features = false } serde_json = { version = "1.0.94", default-features = false } # Substrate FRAME -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } +frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } # Substrate -sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } +sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false } +substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } +substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0" } # Frontier -fp-self-contained = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fp-self-contained = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.6.0", default-features = false } # Horizon -hc-rpc = { path = "client/rpc", default-features = false } +hc-rpc = { path = "client/rpc" } hp-account = { path = "primitives/account", default-features = false } hp-cosmos = { path = "primitives/cosmos", default-features = false } hp-crypto = { path = "primitives/crypto", default-features = false } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index da017ddb..70e0cde4 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -3,7 +3,7 @@ name = "hc-rpc" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -16,13 +16,11 @@ hex = { workspace = true } # Substrate sc-chain-spec = { workspace = true } sc-transaction-pool-api = { workspace = true } -sp-api = { workspace = true } +sp-api = { workspace = true, features = ["std"] } sp-blockchain = { workspace = true } -sp-core = { workspace = true } -sp-runtime = { workspace = true } +sp-core = { workspace = true, features = ["std"] } +sp-runtime = { workspace = true, features = ["std"] } # Horizon -hp-cosmos = { workspace = true } -hp-rpc = { workspace = true, features = ["default"] } - -[dev-dependencies] +hp-cosmos = { workspace = true, features = ["std"] } +hp-rpc = { workspace = true, features = ["std"] } diff --git a/client/rpc/src/cosm.rs b/client/rpc/src/cosm.rs index f8fddffc..8b9d4420 100644 --- a/client/rpc/src/cosm.rs +++ b/client/rpc/src/cosm.rs @@ -26,9 +26,7 @@ use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_core::{Bytes, H256}; -use sp_runtime::{ - generic::BlockId, traits::Block as BlockT, transaction_validity::TransactionSource, -}; +use sp_runtime::{traits::Block as BlockT, transaction_validity::TransactionSource}; use std::{marker::PhantomData, sync::Arc}; #[rpc(server)] @@ -79,7 +77,7 @@ where .convert_tx(block_hash, tx.clone()) .map_err(|_| internal_err("cannot access runtime api"))?; self.pool - .submit_one(&BlockId::Hash(block_hash), TransactionSource::Local, extrinsic) + .submit_one(block_hash, TransactionSource::Local, extrinsic) .map_ok(move |_| tx.hash.into()) .map_err(|e| internal_err(e.to_string())) .await diff --git a/frame/cosmos-accounts/Cargo.toml b/frame/cosmos-accounts/Cargo.toml index f4097a4b..d09d39a4 100644 --- a/frame/cosmos-accounts/Cargo.toml +++ b/frame/cosmos-accounts/Cargo.toml @@ -3,7 +3,7 @@ name = "pallet-cosmos-accounts" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/frame/cosmos-accounts/src/lib.rs b/frame/cosmos-accounts/src/lib.rs index 8603eba6..5b3ce671 100644 --- a/frame/cosmos-accounts/src/lib.rs +++ b/frame/cosmos-accounts/src/lib.rs @@ -18,13 +18,12 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::comparison_chain, clippy::large_enum_variant)] -#![deny(unused_crate_dependencies)] pub mod weights; use crate::weights::WeightInfo; #[cfg(feature = "std")] -use frame_support::{sp_runtime, traits::BuildGenesisConfig}; +use frame_support::traits::BuildGenesisConfig; use hp_crypto::EcdsaExt; pub use pallet::*; use sp_core::H160; diff --git a/frame/cosmos/Cargo.toml b/frame/cosmos/Cargo.toml index b77a8b3f..df10ac85 100644 --- a/frame/cosmos/Cargo.toml +++ b/frame/cosmos/Cargo.toml @@ -3,7 +3,7 @@ name = "pallet-cosmos" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/frame/cosmos/src/lib.rs b/frame/cosmos/src/lib.rs index 36a71147..abafbe16 100644 --- a/frame/cosmos/src/lib.rs +++ b/frame/cosmos/src/lib.rs @@ -18,7 +18,6 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::comparison_chain, clippy::large_enum_variant)] -#![deny(unused_crate_dependencies)] pub mod errors; pub mod handler; @@ -378,11 +377,16 @@ impl Pallet { }) } let origin = T::AddressMapping::into_account_id(*source); - T::Currency::withdraw(&origin, fee, WithdrawReasons::FEE, ExistenceRequirement::AllowDeath) - .map_err(|_| CosmosError { - weight: total_weight, - error: CosmosErrorCode::ErrInsufficientFee, - })?; + let _ = T::Currency::withdraw( + &origin, + fee, + WithdrawReasons::FEE, + ExistenceRequirement::AllowDeath, + ) + .map_err(|_| CosmosError { + weight: total_weight, + error: CosmosErrorCode::ErrInsufficientFee, + })?; frame_system::Pallet::::inc_account_nonce(origin); Ok(total_weight) } diff --git a/primitives/account/Cargo.toml b/primitives/account/Cargo.toml index 2be9eb77..61139a26 100644 --- a/primitives/account/Cargo.toml +++ b/primitives/account/Cargo.toml @@ -3,7 +3,7 @@ name = "hp-account" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [dependencies] array-bytes = { workspace = true, optional = true } diff --git a/primitives/cosmos/Cargo.toml b/primitives/cosmos/Cargo.toml index 8099d681..0d34e1d0 100644 --- a/primitives/cosmos/Cargo.toml +++ b/primitives/cosmos/Cargo.toml @@ -3,7 +3,7 @@ name = "hp-cosmos" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/primitives/crypto/Cargo.toml b/primitives/crypto/Cargo.toml index 59aed78f..8c2cf445 100644 --- a/primitives/crypto/Cargo.toml +++ b/primitives/crypto/Cargo.toml @@ -3,7 +3,7 @@ name = "hp-crypto" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -19,5 +19,6 @@ default = ["std"] std = [ "ripemd/std", "secp256k1/std", + "secp256k1/global-context", "sp-core/std" ] diff --git a/primitives/crypto/src/secp256k1.rs b/primitives/crypto/src/secp256k1.rs index 1d3cf55d..012f04f1 100644 --- a/primitives/crypto/src/secp256k1.rs +++ b/primitives/crypto/src/secp256k1.rs @@ -25,7 +25,7 @@ pub fn secp256k1_ecdsa_verify(sig: &[u8], msg: &[u8], pub_key: &[u8]) -> bool { Ok(v) => v, Err(_) => return false, }; - let msg = match Message::from_slice(msg) { + let msg = match Message::from_digest_slice(msg) { Ok(v) => v, Err(_) => return false, }; diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index d0ce8669..6d04312f 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -3,7 +3,7 @@ name = "hp-io" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml index 6ee32fce..a58be3f8 100644 --- a/primitives/rpc/Cargo.toml +++ b/primitives/rpc/Cargo.toml @@ -3,7 +3,7 @@ name = "hp-rpc" version = "0.1.0" edition = "2021" license = "Apache-2.0" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/primitives/rpc/src/lib.rs b/primitives/rpc/src/lib.rs index 38f932eb..d5ae111f 100644 --- a/primitives/rpc/src/lib.rs +++ b/primitives/rpc/src/lib.rs @@ -17,7 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::too_many_arguments)] -#![deny(unused_crate_dependencies)] +//#![deny(unused_crate_dependencies)] use sp_runtime::traits::Block as BlockT; diff --git a/template/node/Cargo.toml b/template/node/Cargo.toml index f112a755..601e1239 100644 --- a/template/node/Cargo.toml +++ b/template/node/Cargo.toml @@ -3,7 +3,7 @@ name = "horizon-temaplte-node" version = "0.0.0" edition = "2021" license = "Unlicense" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" build = "build.rs" [package.metadata.docs.rs] @@ -18,6 +18,7 @@ clap = { workspace = true } futures = { workspace = true } hex = { workspace = true } jsonrpsee = { workspace = true } +serde_json = { workspace = true } # Substrate FRAME frame-system-rpc-runtime-api = { workspace = true } diff --git a/template/node/src/chain_spec.rs b/template/node/src/chain_spec.rs index d7ad32f8..8df14957 100644 --- a/template/node/src/chain_spec.rs +++ b/template/node/src/chain_spec.rs @@ -16,10 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use horizon_template_runtime::{ - AccountId, AuraConfig, BalancesConfig, CosmosAccountsConfig, GrandpaConfig, - RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY, -}; +use horizon_template_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY}; use sc_service::ChainType; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_grandpa::AuthorityId as GrandpaId; @@ -57,119 +54,79 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { pub fn development_config() -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; - Ok(ChainSpec::from_genesis( - // Name - "Development", - // ID - "dev", - ChainType::Development, - move || { - testnet_genesis( - wasm_binary, - // Initial PoA authorities - vec![authority_keys_from_seed("Alice")], - // Sudo account + Ok(ChainSpec::builder(wasm_binary, None) + .with_name("Development") + .with_id("dev") + .with_chain_type(ChainType::Development) + .with_genesis_config_patch(testnet_genesis( + // Initial PoA authorities + vec![authority_keys_from_seed("Alice")], + // Sudo account + get_account_id_from_seed::("Alice"), + // Pre-funded accounts + vec![ get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - ], - true, - ) - }, - // Bootnodes - vec![], - // Telemetry - None, - // Protocol ID - None, - None, - // Properties - None, - // Extensions - None, - )) + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + ], + true, + )) + .build()) } pub fn local_testnet_config() -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; - Ok(ChainSpec::from_genesis( - // Name - "Local Testnet", - // ID - "local_testnet", - ChainType::Local, - move || { - testnet_genesis( - wasm_binary, - // Initial PoA authorities - vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], - // Sudo account + Ok(ChainSpec::builder(wasm_binary, None) + .with_name("Local Testnet") + .with_id("local_testnet") + .with_chain_type(ChainType::Local) + .with_genesis_config_patch(testnet_genesis( + // Initial PoA authorities + vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], + // Sudo account + get_account_id_from_seed::("Alice"), + // Pre-funded accounts + vec![ get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - ], - true, - ) - }, - // Bootnodes - vec![], - // Telemetry - None, - // Protocol ID - None, - // Properties - None, - None, - // Extensions - None, - )) + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Alice//stash"), + get_account_id_from_seed::("Bob//stash"), + ], + true, + )) + .build()) } /// Configure initial storage state for FRAME modules. fn testnet_genesis( - wasm_binary: &[u8], initial_authorities: Vec<(AuraId, GrandpaId)>, root_key: AccountId, endowed_accounts: Vec, _enable_println: bool, -) -> RuntimeGenesisConfig { - RuntimeGenesisConfig { - system: SystemConfig { - // Add Wasm runtime to storage. - code: wasm_binary.to_vec(), - ..Default::default() - }, - balances: BalancesConfig { - // Configure endowed accounts with initial balance of (1 << 52) - (1 << 50). - balances: endowed_accounts - .iter() - .cloned() - .map(|k| (k, (1 << 52) - (1 << 50))) - .collect(), +) -> serde_json::Value { + serde_json::json!({ + // Configure endowed accounts with initial balance of (1 << 52) - (1 << 50). + "balances": { + "balances": endowed_accounts + .iter() + .cloned() + .map(|k| (k, (1u64 << 52) - (1u64 << 50))) + .collect::>(), }, - cosmos_accounts: CosmosAccountsConfig { - accounts: endowed_accounts.iter().cloned().map(|k| k.clone()).collect(), + "cosmos_accounts": { + "accounts": endowed_accounts.iter().cloned().map(|k| k.clone()).collect::>(), }, - aura: AuraConfig { - authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), + "aura": { + "authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::>(), }, - grandpa: GrandpaConfig { - authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), - ..Default::default() + "grandpa": { + "authorities": initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect::>(), }, - sudo: SudoConfig { + "sudo": { // Assign network admin rights. - key: Some(root_key), + "key": Some(root_key), }, - transaction_payment: Default::default(), - } + }) } diff --git a/template/node/src/service.rs b/template/node/src/service.rs index bcb71780..53370fd6 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -174,9 +174,10 @@ pub fn new_full(config: Configuration) -> Result { &config.chain_spec, ); - net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config( - grandpa_protocol_name.clone(), - )); + let (grandpa_protocol_config, grandpa_notification_service) = + sc_consensus_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()); + net_config.add_notification_protocol(grandpa_protocol_config); + let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( backend.clone(), grandpa_link.shared_authority_set().clone(), @@ -193,6 +194,7 @@ pub fn new_full(config: Configuration) -> Result { import_queue, block_announce_validator_builder: None, warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)), + block_relay: None, })?; if config.offchain_worker.enabled { @@ -329,6 +331,7 @@ pub fn new_full(config: Configuration) -> Result { link: grandpa_link, network, sync: sync_service, + notification_service: grandpa_notification_service, voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(), prometheus_registry, shared_voter_state: SharedVoterState::empty(), diff --git a/template/runtime/Cargo.toml b/template/runtime/Cargo.toml index b005d06c..9951402a 100644 --- a/template/runtime/Cargo.toml +++ b/template/runtime/Cargo.toml @@ -3,7 +3,7 @@ name = "horizon-template-runtime" version = "0.0.0" edition = "2021" license = "Unlicense" -repository = "https://github.com/NoirHQ/horizon/" +repository = "https://github.com/noirhq/horizon/" build = "build.rs" [package.metadata.docs.rs] diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index abcf7b75..26c6f97f 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -29,7 +29,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod compat; use frame_support::{ - construct_runtime, parameter_types, + construct_runtime, derive_impl, parameter_types, traits::{ tokens::{fungible, Fortitude, Preservation}, ConstBool, ConstU32, ConstU8, OnTimestampSet, @@ -156,6 +156,7 @@ impl frame_support::traits::OnNewAccount for OnNewAccount { } } +#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = frame_support::traits::Everything; @@ -249,6 +250,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = (); + type RuntimeFreezeReason = (); type FreezeIdentifier = (); type MaxHolds = (); type MaxFreezes = ();