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

Bump to polkadot-v0.9.42 as a base for substrate related deps #861

Merged
merged 56 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2e942c8
[substrate-apply] bioauth-keys: Keystore overhaul (#13615)
dmitrylavrenov Dec 26, 2023
91226d8
[substrate-apply] bioauth-keys: Keystore overhaul (final) #13683
dmitrylavrenov Dec 28, 2023
949f856
[substrate-apply] precompile-currency-swap Deprecate Currency; introd…
dmitrylavrenov Dec 28, 2023
7f5eaef
[substrate-apply] precompile-native-currency Deprecate Currency; intr…
dmitrylavrenov Dec 28, 2023
5fbc8cb
[substrate-apply] pallet-currency-swap Deprecate Currency; introduce …
dmitrylavrenov Dec 28, 2023
0001ff7
[substrate-apply] humanode-runtime: Keystore overhaul (final) (#13683)
dmitrylavrenov Dec 28, 2023
f21e283
[substrate-apply] humanode-runtime: Metadata V15: Expose API to fetch…
dmitrylavrenov Dec 28, 2023
1c0fcde
Derive TypeInfo for EvaluationError at pallet-vesting
dmitrylavrenov Dec 28, 2023
a36da7d
[substrate-apply] humanode-runtime:weights:pallet_balances Deprecate …
dmitrylavrenov Dec 28, 2023
5dd6b32
Draft addition of fungible related traits for currency type at pallet…
dmitrylavrenov Dec 29, 2023
a760c7c
[substrate-apply] humanode-rpc: Keystore overhaul (#13615)
dmitrylavrenov Jan 8, 2024
6847379
[substrate-apply] humanode-rpc: babe: replace usage of SharedEpochCha…
dmitrylavrenov Jan 8, 2024
425f36d
[substrate-apply] humanode-peer: Keystore overhaul (#13615)
dmitrylavrenov Jan 8, 2024
6c6df1a
[substrate-apply] humanode-peer: babe: replace usage of SharedEpochCh…
dmitrylavrenov Jan 8, 2024
4aab7cf
[substrate-apply]: humanode-peer: refactor(sc-executor): use wasm exe…
dmitrylavrenov Jan 8, 2024
2e5c5a2
[substrate-apply] humanode-peer: Keystore overhaul (final) (#13683)
dmitrylavrenov Jan 8, 2024
af2fde7
Rename FungibleAsset back to Currency at pallet-pot
dmitrylavrenov Jan 17, 2024
a2bbda8
Remove redundant trait deps at pallet-pot
dmitrylavrenov Jan 17, 2024
3176d0b
Fix partial index for extracting frontier backend
dmitrylavrenov Jan 17, 2024
b31811c
Properly handle resolve operation
dmitrylavrenov Jan 17, 2024
733d176
Add docs for OnUnbalancedOverCredit at pallet-pot
dmitrylavrenov Jan 17, 2024
4bbc61c
Mark unused variable
dmitrylavrenov Jan 17, 2024
0920dd9
Fix mock and test at pallet-currency-swap
dmitrylavrenov Feb 7, 2024
0dc8a28
Fix tests at precompile-currency-swap
dmitrylavrenov Feb 7, 2024
103e57f
Fix mock at pallet-balanced-currency-swap-bridges-initializer
dmitrylavrenov Feb 7, 2024
a9cf1c0
Fix mock and tests at pallet-erc20-support
dmitrylavrenov Feb 7, 2024
7dbd94f
Fix mock at pallet-dummy-precompiles-code
dmitrylavrenov Feb 7, 2024
43cb79c
Precompile-native-currency
dmitrylavrenov Feb 7, 2024
2b213d3
Fix mock at pallet-token-claims and pallet-vesting
dmitrylavrenov Feb 7, 2024
a6579e5
[substrate-apply] precompile-bioauth:mock,pallet-bioauth:testing Cryp…
dmitrylavrenov Feb 7, 2024
e6633f0
Fix tests at claims_and_vesting as usable_balance behaviour has been …
dmitrylavrenov Feb 9, 2024
f19e91e
Update WEIGHT_TO_FEE value
dmitrylavrenov Feb 9, 2024
8db1e13
Fix benchmarking tests
dmitrylavrenov Feb 9, 2024
9f7f42d
Fix tests at pallet-vesting
dmitrylavrenov Feb 9, 2024
3eb66b5
Remove unused dependency
dmitrylavrenov Feb 9, 2024
dadf7f0
Fix clippy
dmitrylavrenov Feb 9, 2024
41b7610
Unpack partial.other
dmitrylavrenov Feb 12, 2024
0f707b1
[substrate-apply] pallet-*: FRAME: inherited call weight syntax (#13932)
dmitrylavrenov Feb 12, 2024
6f6869c
Update weights
dmitrylavrenov Feb 15, 2024
492d00f
Update WEIGHT_TO_FEE constant
dmitrylavrenov Feb 15, 2024
f97810a
Improve handling unbalanced funds
dmitrylavrenov Apr 16, 2024
014e446
Fix clippy
dmitrylavrenov Apr 17, 2024
8871304
Rerun benchmark-all
dmitrylavrenov Apr 17, 2024
62b0fbd
Use block_in_place for keystore operations
dmitrylavrenov Apr 17, 2024
38df4d6
Fix help stdout fixtures
dmitrylavrenov Jun 6, 2024
9a7bffe
Fix typos
dmitrylavrenov Jun 6, 2024
1227906
Fix clippy
dmitrylavrenov Aug 21, 2024
a2ec0c2
Reset claims and vesting tests at runtime
MOZGIII Sep 10, 2024
361c4fc
Fixed tests
MOZGIII Sep 10, 2024
7b25e5d
Reformat runtime API traits
MOZGIII Sep 10, 2024
aa7ff58
Cleanup comment at crates/humanode-runtime/src/lib.rs
MOZGIII Sep 11, 2024
f9b0604
Use locked/polkadot-v0.9.42-2024-09-12 substrate and frontier forks
dmitrylavrenov Sep 12, 2024
79e51c8
Update fixtures for help-output
dmitrylavrenov Sep 12, 2024
16ead2c
Remove duplicated definitions
dmitrylavrenov Sep 23, 2024
b64beb5
Update features snapshot
dmitrylavrenov Sep 23, 2024
d5bf1c8
RuntimeEvent to be first at pallet_balances::Config
dmitrylavrenov Sep 23, 2024
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
813 changes: 386 additions & 427 deletions Cargo.lock

Large diffs are not rendered by default.

184 changes: 92 additions & 92 deletions Cargo.toml

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion crates/author-ext-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub enum CreateSignedSetKeysExtrinsicError {

sp_api::decl_runtime_apis! {
/// Runtime API for the author extension logic.
pub trait AuthorExtApi<Id: Encode> {
pub trait AuthorExtApi<Id>
where
Id: Encode,
{
/// Create signed set_keys extrinsic.
fn create_signed_set_keys_extrinsic(id: &Id, session_keys: Vec<u8>) -> Result<Block::Extrinsic, CreateSignedSetKeysExtrinsicError>;
}
Expand Down
6 changes: 5 additions & 1 deletion crates/bioauth-flow-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ pub enum BioauthStatus<Timestamp> {

sp_api::decl_runtime_apis! {
/// Runtime API for the bioauth flow.
pub trait BioauthFlowApi<Id: Encode, Timestamp: Decode> {
pub trait BioauthFlowApi<Id, Timestamp>
where
Id: Encode,
Timestamp: Decode,
{
/// Determine the bioauth status for the given `id` at the current block.
///
/// This call is intended for use in the bioauth flow, and the `id` passed is likely.
Expand Down
35 changes: 12 additions & 23 deletions crates/bioauth-keys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use std::marker::PhantomData;

use sp_application_crypto::{AppKey, CryptoTypePublicPair};
use sp_keystore::SyncCryptoStorePtr;
use sp_application_crypto::AppCrypto;
use sp_keystore::KeystorePtr;

pub mod traits;

Expand All @@ -19,7 +19,7 @@ pub trait KeySelector<Key> {
/// Extracts a public key of a certain type from the keystore.
pub struct KeyExtractor<Id, Selector> {
/// Keystore to extract author.
keystore: SyncCryptoStorePtr,
keystore: KeystorePtr,
/// The validator key selector.
selector: Selector,
/// The identity type.
Expand All @@ -42,7 +42,7 @@ pub enum KeyExtractorError<SelectorError> {

impl<Id, Selector> KeyExtractor<Id, Selector> {
/// Create a new [`KeyExtractor`].
pub fn new(keystore: SyncCryptoStorePtr, selector: Selector) -> Self {
pub fn new(keystore: KeystorePtr, selector: Selector) -> Self {
Self {
keystore,
selector,
Expand All @@ -53,34 +53,23 @@ impl<Id, Selector> KeyExtractor<Id, Selector> {

impl<Id, Selector> traits::KeyExtractor for KeyExtractor<Id, Selector>
where
Id: for<'a> TryFrom<&'a [u8]> + AppKey,
Id: for<'a> TryFrom<&'a [u8]> + AppCrypto,
Selector: KeySelector<Id>,
{
type Error = KeyExtractorError<Selector::Error>;
type PublicKeyType = Id;

fn extract_key(&self) -> Result<Option<Self::PublicKeyType>, Self::Error> {
let keystore_ref = self.keystore.as_ref();

let crypto_type_public_pairs = sp_keystore::SyncCryptoStore::keys(keystore_ref, Id::ID)
.map_err(KeyExtractorError::Keystore)?;

let matching_crypto_public_keys = crypto_type_public_pairs.into_iter().filter_map(
|CryptoTypePublicPair(crypto_type_id, public_key)| {
if crypto_type_id == Id::CRYPTO_ID {
Some(public_key)
} else {
None
}
},
);

let matching_keys =
matching_crypto_public_keys.filter_map(|bytes| Id::try_from(&bytes).ok());
let public_keys = self
.keystore
.keys(Id::ID)
.map_err(KeyExtractorError::Keystore)?
.into_iter()
.filter_map(|bytes| Id::try_from(&bytes).ok());

let key = self
.selector
.select_key(matching_keys)
.select_key(public_keys)
.map_err(KeyExtractorError::Selector)?;

Ok(key)
Expand Down
3 changes: 2 additions & 1 deletion crates/humanode-peer/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ pub async fn run() -> sc_cli::Result<()> {
let runner = root.create_humanode_runner(cmd)?;
runner.sync_run(|config| {
let partial = service::new_partial(&config)?;
let frontier_backend = match partial.other.4 {
let (_, _, _, _, _, frontier_backend, _) = partial.other;
let frontier_backend = match frontier_backend {
fc_db::Backend::KeyValue(kv_fb) => Arc::new(kv_fb),
_ => {
panic!("Only fc_db::Backend::KeyValue supported for FrontierDb command")
Expand Down
17 changes: 9 additions & 8 deletions crates/humanode-peer/src/cli/subcommand/bioauth/key/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::sync::Arc;

use sc_cli::{utils, CliConfiguration, KeystoreParams, SharedParams};
use sc_service::KeystoreContainer;
use sp_application_crypto::{AppKey, AppPublic};
use sp_application_crypto::{AppCrypto, AppPublic};
use sp_core::Pair;
use sp_keystore::CryptoStore;
use sp_keystore::Keystore;

use super::KeystoreBioauthId;
use crate::cli::CliConfigurationExt;
Expand Down Expand Up @@ -40,7 +40,7 @@ pub enum InsertKeyError {

/// A helper function to verify that there is no bioauth key at the keystore yet.
pub async fn ensure_bioauth_key_absent<PK: AppPublic>(
keystore: Arc<dyn CryptoStore>,
keystore: Arc<dyn Keystore>,
) -> Result<(), InsertKeyError> {
let mut current_keys = crate::validator_key::AppCryptoPublic::<PK>::list(keystore.as_ref())
.await
Expand All @@ -55,15 +55,16 @@ pub async fn ensure_bioauth_key_absent<PK: AppPublic>(
/// A helper function to insert bioauth key into the keystore.
pub async fn insert_bioauth_key<PK: AppPublic>(
suri: &str,
keystore: Arc<dyn CryptoStore>,
keystore: Arc<dyn Keystore>,
) -> sc_cli::Result<()> {
// We don't use a password for keystore at the current moment. That's why None is passed.
let pair = utils::pair_from_suri::<<PK as AppKey>::Pair>(suri, None)?;
let pair = tokio::task::block_in_place(move || {
utils::pair_from_suri::<<PK as AppCrypto>::Pair>(suri, None)
})?;
let public = pair.public().as_ref().to_vec();
keystore
MOZGIII marked this conversation as resolved.
Show resolved Hide resolved
.insert_unknown(PK::ID, suri, &public[..])
.await
.map_err(|_| sc_cli::Error::KeyStoreOperation)?;
.insert(PK::ID, suri, &public[..])
.map_err(|_| sc_cli::Error::KeystoreOperation)?;
Ok(())
}

Expand Down
49 changes: 18 additions & 31 deletions crates/humanode-peer/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ type FrontierBackend = fc_db::Backend<Block>;
pub fn keystore_container(
config: &Configuration,
) -> Result<(KeystoreContainer, TaskManager), ServiceError> {
let executor = Executor::new(
config.substrate.wasm_method,
config.substrate.default_heap_pages,
config.substrate.max_runtime_instances,
config.substrate.runtime_cache_size,
);
let executor = sc_service::new_native_or_wasm_executor::<ExecutorDispatch>(&config.substrate);

let (_client, _backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(&config.substrate, None, executor)?;
Expand All @@ -97,6 +92,7 @@ pub fn new_partial(
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
sc_consensus_babe::BabeWorkerHandle<Block>,
sc_consensus_babe::BabeLink<Block>,
EffectiveFullBlockImport,
inherents::Creator<FullClient>,
Expand Down Expand Up @@ -124,12 +120,7 @@ pub fn new_partial(
})
.transpose()?;

let executor = Executor::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
config.runtime_cache_size,
);
let executor = sc_service::new_native_or_wasm_executor(config);

let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
Expand Down Expand Up @@ -185,7 +176,7 @@ pub fn new_partial(
time_warp: time_warp_config.clone(),
};

let import_queue = sc_consensus_babe::import_queue(
let (import_queue, babe_worker_handle) = sc_consensus_babe::import_queue(
babe_link.clone(),
frontier_block_import.clone(),
Some(Box::new(grandpa_block_import)),
Expand All @@ -206,6 +197,7 @@ pub fn new_partial(
transaction_pool,
other: (
grandpa_link,
babe_worker_handle,
babe_link,
frontier_block_import,
inherent_data_providers_creator,
Expand All @@ -229,6 +221,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
other:
(
grandpa_link,
babe_worker_handle,
babe_link,
block_import,
inherent_data_providers_creator,
Expand Down Expand Up @@ -273,7 +266,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError

let role = config.role.clone();
let name = config.network.node_name.clone();
let keystore = Some(keystore_container.sync_keystore());
let keystore = Some(keystore_container.keystore());
let enable_grandpa = !config.disable_grandpa;
let force_authoring = config.force_authoring;
let backoff_authoring_blocks: Option<()> = None;
Expand All @@ -297,7 +290,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError

let account_validator_key_extractor =
Arc::new(bioauth_keys::KeyExtractor::<KeystoreBioauthId, _>::new(
keystore_container.sync_keystore(),
keystore_container.keystore(),
bioauth_keys::OneOfOneSelector,
));

Expand Down Expand Up @@ -355,10 +348,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
Some(grandpa_shared_authority_set.clone()),
);

let babe_config = babe_link.config().clone();
let babe_shared_epoch_changes = babe_link.epoch_changes().clone();

let keystore = keystore_container.sync_keystore();
let keystore = keystore_container.keystore();
let chain_spec = config.chain_spec.cloned_box();
let select_chain = select_chain.clone();

Expand Down Expand Up @@ -403,8 +393,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
bioauth_validator_key_extractor: Arc::clone(&bioauth_validator_key_extractor),
},
babe: humanode_rpc::BabeDeps {
babe_config: babe_config.clone(),
babe_shared_epoch_changes: babe_shared_epoch_changes.clone(),
babe_worker_handle: babe_worker_handle.clone(),
keystore: Arc::clone(&keystore),
},
grandpa: humanode_rpc::GrandpaDeps {
Expand Down Expand Up @@ -439,15 +428,15 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
};

{
let keystore = keystore_container.sync_keystore();
let keystore = keystore_container.keystore();
init_dev_bioauth_keystore_keys(keystore.as_ref(), config.dev_key_seed.as_deref())
.map_err(|err| sc_service::Error::Other(err.to_string()))?;
}

let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
network: Arc::clone(&network) as _,
client: Arc::clone(&client),
keystore: keystore_container.sync_keystore(),
keystore: keystore_container.keystore(),
task_manager: &mut task_manager,
transaction_pool: Arc::clone(&transaction_pool),
rpc_builder: rpc_extensions_builder,
Expand All @@ -460,7 +449,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
})?;

let babe_config = sc_consensus_babe::BabeParams {
keystore: keystore_container.sync_keystore(),
keystore: keystore_container.keystore(),
client: Arc::clone(&client),
select_chain,
env: proposer_factory,
Expand Down Expand Up @@ -610,17 +599,15 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
/// is not a part of the session keys set, so it wont be populated that way.
///
/// We need [`KeystoreBioauthId`] for the block production though, so we initialize it manually.
fn init_dev_bioauth_keystore_keys<Keystore: sp_keystore::SyncCryptoStore + ?Sized>(
fn init_dev_bioauth_keystore_keys<Keystore: sp_keystore::Keystore + ?Sized>(
keystore: &Keystore,
seed: Option<&str>,
) -> Result<(), sp_keystore::Error> {
if let Some(seed) = seed {
use sp_application_crypto::AppKey;
let _public = sp_keystore::SyncCryptoStore::sr25519_generate_new(
keystore,
KeystoreBioauthId::ID,
Some(seed),
)?;
use sp_application_crypto::AppCrypto;
let _public = tokio::task::block_in_place(move || {
sp_keystore::Keystore::sr25519_generate_new(keystore, KeystoreBioauthId::ID, Some(seed))
})?;
}
Ok(())
}
40 changes: 17 additions & 23 deletions crates/humanode-peer/src/validator_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::{fmt::Display, sync::Arc};

use bioauth_flow_rpc::Signer;
use sp_application_crypto::{AppPublic, CryptoTypePublicPair};
use sp_keystore::CryptoStore;
use sp_application_crypto::AppPublic;
use sp_keystore::Keystore;

/// The validator public key implementation using the app crypto public key.
#[derive(Clone)]
Expand All @@ -13,14 +13,14 @@ pub struct AppCryptoPublic<T>(pub T);
/// The validator signer implementation using the keystore and app crypto public key.
pub struct AppCryptoSigner<PK> {
/// The keystore to use for signing.
pub keystore: Arc<dyn CryptoStore>,
pub keystore: Arc<dyn Keystore>,
/// The public key to provide the signature for.
pub public_key: AppCryptoPublic<PK>,
}

impl<PK> AppCryptoSigner<PK> {
/// Create a new [`AppCryptoSigner`].
pub fn new(keystore: Arc<dyn CryptoStore>, public_key: AppCryptoPublic<PK>) -> Self {
pub fn new(keystore: Arc<dyn Keystore>, public_key: AppCryptoPublic<PK>) -> Self {
Self {
keystore,
public_key,
Expand Down Expand Up @@ -51,11 +51,11 @@ where
D: AsRef<[u8]> + Send + 'a,
{
let data = data.as_ref();
let outcome = self
.keystore
.sign_with(PK::ID, &self.public_key.0.to_public_crypto_pair(), data)
.await
.map_err(SignerError::Keystore)?;
let outcome = tokio::task::block_in_place(move || {
self.keystore
.sign_with(PK::ID, PK::CRYPTO_ID, self.public_key.0.as_slice(), data)
})
.map_err(SignerError::Keystore)?;

outcome.ok_or(SignerError::NoSignature)
}
Expand All @@ -76,21 +76,15 @@ where
{
/// List all public keys in the keystore.
pub async fn list(
keystore: &dyn CryptoStore,
keystore: &dyn Keystore,
) -> Result<impl Iterator<Item = Self>, sp_keystore::Error> {
let crypto_type_public_pairs = keystore.keys(T::ID).await?;
let filtered = crypto_type_public_pairs.into_iter().filter_map(
|CryptoTypePublicPair(crypto_type, public_key)| {
if crypto_type == T::CRYPTO_ID {
match T::from_slice(&public_key) {
Ok(id) => Some(Self(id)),
Err(_) => None,
}
} else {
None
}
},
);
let crypto_type_public_pairs = keystore.keys(T::ID)?;
let filtered = crypto_type_public_pairs
.into_iter()
.filter_map(|public_key| match T::from_slice(&public_key) {
Ok(id) => Some(Self(id)),
Err(_) => None,
});
Ok(filtered)
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/humanode-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ sc-chain-spec = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus-babe = { workspace = true }
sc-consensus-babe-rpc = { workspace = true }
sc-consensus-epochs = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-consensus-grandpa-rpc = { workspace = true }
sc-network = { workspace = true }
Expand Down
Loading