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.39 as a base for substrate related deps #829

Merged
merged 25 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d433821
Use locked/polkadot-v0.9.39 substrate and frontier deps
dmitrylavrenov Oct 31, 2023
f071b3d
Update frontier
dmitrylavrenov Oct 31, 2023
3d4e9bc
[substrate-apply] BlockId removal: CallApiAt::state_at #13394
dmitrylavrenov Oct 31, 2023
77ff6d7
[frontier-apply] chore: remove deprecated storage getter for all pall…
dmitrylavrenov Oct 31, 2023
4c7c709
Add missed evm related config params
dmitrylavrenov Oct 31, 2023
52d6d6e
[frontier-apply] populate parent hash for indexers (#1044)
dmitrylavrenov Oct 31, 2023
37aa5c9
[frontier-apply] Improve block import notification strategy (#1030)
dmitrylavrenov Nov 1, 2023
5aecd60
[frontier-apply] implement eth_call state override (#1027)
dmitrylavrenov Nov 1, 2023
2962134
[substrate-apply] add warp to target block for parachains (#12761)
dmitrylavrenov Nov 1, 2023
c476cb8
Fix occured move
dmitrylavrenov Nov 1, 2023
e84afdc
Fix mock env
dmitrylavrenov Nov 1, 2023
cfc430e
Fix tests for benchmarks
dmitrylavrenov Nov 1, 2023
89b166c
[substrate-apply] try-runtime::fast-forward (#12896)
dmitrylavrenov Nov 2, 2023
01840e7
Fix try-runtime build
dmitrylavrenov Nov 2, 2023
b2a9914
Make constants mod pub at humanode-runtime
dmitrylavrenov Nov 2, 2023
cabfcd5
Update frontier
dmitrylavrenov Nov 6, 2023
dad6f95
Update features snapshot
dmitrylavrenov Nov 6, 2023
18b4584
[substrate-apply] Improve Weight Template and API (#13355)
dmitrylavrenov Nov 8, 2023
4582ec6
remove deprecated trait Store for all pallets
dmitrylavrenov Nov 8, 2023
e985456
Improve docs at pallet-bioatuh
dmitrylavrenov Nov 8, 2023
d7be55f
Edit comment
dmitrylavrenov Nov 23, 2023
49cc501
Move CallApiAt to the same line with ProvideRuntimeApi
dmitrylavrenov Nov 23, 2023
510b971
Improve traits requirements
dmitrylavrenov Nov 23, 2023
99d9272
Merge branch 'master' into polkadot-v0.9.39
dmitrylavrenov Nov 28, 2023
c887894
Move ExtraDataLength to constants mod
dmitrylavrenov Nov 28, 2023
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
648 changes: 342 additions & 306 deletions Cargo.lock

Large diffs are not rendered by default.

176 changes: 88 additions & 88 deletions Cargo.toml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions crates/author-ext-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ where
.map_err(SetKeysError::KeyExtraction)
.map_err(errtype)?;

let at = sp_api::BlockId::Hash(self.client.info().best_hash);
let at = self.client.info().best_hash;

let signed_set_keys_extrinsic = self
.client
.runtime_api()
.create_signed_set_keys_extrinsic(&at, &validator_key, session_keys.0)
.create_signed_set_keys_extrinsic(at, &validator_key, session_keys.0)
.map_err(SetKeysError::RuntimeApi)
.map_err(errtype)?
.map_err(SetKeysError::ExtrinsicCreation)
.map_err(errtype)?;

self.pool
.submit_and_watch(
&at,
&sp_api::BlockId::Hash(at),
sp_runtime::transaction_validity::TransactionSource::Local,
signed_set_keys_extrinsic,
)
Expand Down
10 changes: 5 additions & 5 deletions crates/bioauth-flow-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ where
};

// Extract an id of the last imported block.
let at = sp_api::BlockId::Hash(self.client.info().best_hash);
let at = self.client.info().best_hash;

let status = self
.client
.runtime_api()
.bioauth_status(&at, &own_key)
.bioauth_status(at, &own_key)
.map_err(StatusError::RuntimeApi)?;

Ok(status.into())
Expand Down Expand Up @@ -354,21 +354,21 @@ where

info!(message = "We've obtained an auth ticket", auth_ticket = ?response.auth_ticket);

let at = sp_api::BlockId::Hash(self.client.info().best_hash);
let at = self.client.info().best_hash;

let ext = self
.client
.runtime_api()
.create_authenticate_extrinsic(
&at,
at,
response.auth_ticket.into(),
response.auth_ticket_signature.into(),
)
.map_err(AuthenticateError::RuntimeApi).map_err(errtype)?;

self.pool
.submit_and_watch(
&at,
&sp_api::BlockId::Hash(at),
sp_runtime::transaction_validity::TransactionSource::Local,
ext,
)
Expand Down
4 changes: 2 additions & 2 deletions crates/humanode-peer/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sp_consensus_babe::SlotDuration;
use sp_core::{Encode, Pair};
use sp_inherents::{InherentData, InherentDataProvider};
use sp_keyring::Sr25519Keyring;
use sp_runtime::{generic, OpaqueExtrinsic, SaturatedConversion};
use sp_runtime::{OpaqueExtrinsic, SaturatedConversion};

use crate::configuration::Configuration;
use crate::service::FullClient;
Expand Down Expand Up @@ -168,6 +168,6 @@ fn fetch_nonce(client: &FullClient, account: sp_core::sr25519::Pair) -> u32 {
let best_hash = client.chain_info().best_hash;
client
.runtime_api()
.account_nonce(&generic::BlockId::Hash(best_hash), account.public().into())
.account_nonce(best_hash, account.public().into())
.expect("Fetching account nonce failed")
}
10 changes: 9 additions & 1 deletion crates/humanode-peer/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ use humanode_runtime::Runtime;
use sc_service::PartialComponents;
#[cfg(feature = "runtime-benchmarks")]
use sp_core::Get;
#[cfg(feature = "try-runtime")]
use {
humanode_runtime::constants::babe::SLOT_DURATION,
try_runtime_cli::block_building_info::substrate_info,
};

use super::{bioauth, Root, Subcommand};
#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -248,11 +253,14 @@ pub async fn run() -> sc_cli::Result<()> {
registry,
)
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;

let info_provider = substrate_info(SLOT_DURATION);

Ok((
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<service::ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>>(),
>, _>(Some(info_provider)),
task_manager,
))
})
Expand Down
15 changes: 15 additions & 0 deletions crates/humanode-peer/src/service/frontier.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! The Frontier related stuff.

use humanode_runtime::opaque::Block;
use sc_cli::SubstrateCli;
use sc_client_api::backend::Backend;
use sc_service::BasePath;

/// Create frontier dir.
Expand All @@ -14,3 +16,16 @@ pub fn db_config_dir(config: &sc_service::Configuration) -> std::path::PathBuf {
.config_dir(config.chain_spec.id())
})
}

/// Default ethereum config.
pub struct DefaultEthConfig<C, BE>(std::marker::PhantomData<(C, BE)>);

impl<C, BE> fc_rpc::EthConfig<Block, C> for DefaultEthConfig<C, BE>
where
C: sc_client_api::StorageProvider<Block, BE> + Sync + Send + 'static,
BE: Backend<Block> + 'static,
{
type EstimateGasAdapter = ();
type RuntimeStorageOverride =
fc_rpc::frontier_backend_client::SystemAccountId20StorageOverride<Block, C, BE>;
}
28 changes: 24 additions & 4 deletions crates/humanode-peer/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use sc_client_api::{BlockBackend, BlockchainEvents};
use sc_consensus_babe::SlotProportion;
pub use sc_executor::NativeElseWasmExecutor;
use sc_finality_grandpa::SharedVoterState;
use sc_service::{Error as ServiceError, KeystoreContainer, PartialComponents, TaskManager};
use sc_service::{
Error as ServiceError, KeystoreContainer, PartialComponents, TaskManager, WarpSyncParams,
};
use sc_telemetry::{Telemetry, TelemetryWorker};
use tracing::*;

Expand Down Expand Up @@ -283,6 +285,10 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
let eth_fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
let eth_fee_history_limit = ethereum_rpc_config.fee_history_limit;
let eth_overrides = fc_storage::overrides_handle(Arc::clone(&client));
let eth_pubsub_notification_sinks =
Arc::new(fc_mapping_sync::EthereumBlockNotificationSinks::<
fc_mapping_sync::EthereumBlockNotification<Block>,
>::default());

let proposer_factory = sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
Expand All @@ -306,7 +312,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
spawn_handle: task_manager.spawn_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync: Some(warp_sync),
warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)),
})?;

if config.offchain_worker.enabled {
Expand Down Expand Up @@ -367,9 +373,19 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
config.prometheus_registry().cloned(),
));
let eth_fee_history_cache = Arc::clone(&eth_fee_history_cache);
let eth_pubsub_notification_sinks = Arc::clone(&eth_pubsub_notification_sinks);

Box::new(move |deny_unsafe, subscription_task_executor| {
Ok(humanode_rpc::create(humanode_rpc::Deps {
Ok(humanode_rpc::create::<
_,
_,
_,
_,
_,
_,
_,
frontier::DefaultEthConfig<_, _>,
>(humanode_rpc::Deps {
client: Arc::clone(&client),
pool: Arc::clone(&pool),
deny_unsafe,
Expand Down Expand Up @@ -408,6 +424,8 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
eth_block_data_cache: Arc::clone(&eth_block_data_cache),
eth_execute_gas_limit_multiplier: ethereum_rpc_config
.execute_gas_limit_multiplier,
eth_forced_parent_hashes: None,
eth_pubsub_notification_sinks: Arc::clone(&eth_pubsub_notification_sinks),
},
subscription_task_executor,
})?)
Expand Down Expand Up @@ -475,7 +493,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
let grandpa_config = sc_finality_grandpa::GrandpaParams {
config: grandpa_config,
link: grandpa_link,
network,
network: Arc::clone(&network),
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
shared_voter_state: SharedVoterState::empty(),
Expand Down Expand Up @@ -504,6 +522,8 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
// sync_from: <Block::Header as HeaderT>::Number,
0,
SyncStrategy::Normal,
network,
eth_pubsub_notification_sinks,
)
.for_each(|()| futures::future::ready(())),
);
Expand Down
2 changes: 2 additions & 0 deletions crates/humanode-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ humanode-runtime = { path = "../humanode-runtime" }
robonode-client = { path = "../robonode-client" }

fc-db = { workspace = true }
fc-mapping-sync = { workspace = true }
fc-rpc = { workspace = true, features = ["rpc-binary-search-estimate"] }
fc-rpc-core = { workspace = true }
fc-storage = { workspace = true }
Expand All @@ -38,6 +39,7 @@ sp-block-builder = { workspace = true }
sp-blockchain = { workspace = true }
sp-consensus = { workspace = true }
sp-consensus-babe = { workspace = true }
sp-core = { workspace = true }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }
substrate-frame-rpc-system = { workspace = true }
30 changes: 25 additions & 5 deletions crates/humanode-rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! RPC subsystem instantiation logic.

use std::sync::Arc;
use std::{collections::BTreeMap, sync::Arc};

use author_ext_api::AuthorExtApi;
use author_ext_rpc::{AuthorExt, AuthorExtServer};
use bioauth_flow_rpc::{Bioauth, BioauthServer, Signer, SignerFactory};
use bioauth_keys::traits::KeyExtractor as KeyExtractorT;
use fc_rpc::{
Eth, EthApiServer, EthBlockDataCacheTask, EthFilter, EthFilterApiServer, EthPubSub,
Eth, EthApiServer, EthBlockDataCacheTask, EthConfig, EthFilter, EthFilterApiServer, EthPubSub,
EthPubSubApiServer, Net, NetApiServer, Web3, Web3ApiServer,
};
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
Expand All @@ -33,11 +33,12 @@ pub use sc_rpc_api::DenyUnsafe;
use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer};
use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::TransactionPool;
use sp_api::{Encode, ProvideRuntimeApi};
use sp_api::{CallApiAt, Encode, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_consensus::SelectChain;
use sp_consensus_babe::BabeApi;
use sp_core::H256;
use sp_keystore::SyncCryptoStorePtr;

/// Extra dependencies for `AuthorExt`.
Expand Down Expand Up @@ -101,6 +102,18 @@ pub struct EvmDeps {
/// When using eth_call/eth_estimateGas, the maximum allowed gas limit will be
/// block.gas_limit * execute_gas_limit_multiplier.
pub eth_execute_gas_limit_multiplier: u64,
/// Mandated parent hashes for a given block hash.
pub eth_forced_parent_hashes: Option<BTreeMap<H256, H256>>,
/// Sinks for pubsub notifications.
///
/// Everytime a new subscription is created, a new mpsc channel is added to the sink pool.
/// The MappingSyncWorker sends through the channel on block import and the subscription
/// emits a notification to the subscriber on receiving a message through this channel.
pub eth_pubsub_notification_sinks: Arc<
fc_mapping_sync::EthereumBlockNotificationSinks<
fc_mapping_sync::EthereumBlockNotification<Block>,
>,
>,
}

/// RPC subsystem dependencies.
Expand Down Expand Up @@ -136,13 +149,14 @@ pub struct Deps<C, P, BE, VKE, VSF, A: ChainApi, SC> {
}

/// Instantiate all RPC extensions.
pub fn create<C, P, BE, VKE, VSF, A, SC>(
pub fn create<C, P, BE, VKE, VSF, A, SC, EC>(
deps: Deps<C, P, BE, VKE, VSF, A, SC>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
BE: Backend<Block> + 'static,
BE::State: StateBackend<sp_runtime::traits::HashFor<Block>>,
C: ProvideRuntimeApi<Block> + BlockBackend<Block> + StorageProvider<Block, BE> + AuxStore,
C: ProvideRuntimeApi<Block> + CallApiAt<Block>,
C: BlockBackend<Block> + StorageProvider<Block, BE> + AuxStore,
C: BlockchainEvents<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
C: Send + Sync + 'static,
Expand All @@ -164,6 +178,7 @@ where
std::error::Error + 'static,
A: ChainApi<Block = Block> + 'static,
SC: SelectChain<Block> + 'static,
EC: EthConfig<Block, C>,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
Expand Down Expand Up @@ -220,6 +235,8 @@ where
eth_overrides,
eth_block_data_cache,
eth_execute_gas_limit_multiplier,
eth_forced_parent_hashes,
eth_pubsub_notification_sinks,
} = evm;

let chain_name = chain_spec.name().to_string();
Expand Down Expand Up @@ -295,7 +312,9 @@ where
eth_fee_history_cache,
eth_fee_history_limit,
eth_execute_gas_limit_multiplier,
eth_forced_parent_hashes,
)
.replace_config::<EC>()
MOZGIII marked this conversation as resolved.
Show resolved Hide resolved
.into_rpc(),
)?;

Expand All @@ -308,6 +327,7 @@ where
Arc::clone(&network),
Arc::clone(&subscription_task_executor),
Arc::clone(&eth_overrides),
Arc::clone(&eth_pubsub_notification_sinks),
)
.into_rpc(),
)?;
Expand Down
8 changes: 8 additions & 0 deletions crates/humanode-runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,11 @@ pub mod evm_fees {
/// The value below is a nice round number that fits the requirements outlined above.
pub const FEE_PER_GAS: u128 = 10_000_000_000_000;
}

/// Ethereum related constants.
pub mod ethereum {
/// The maximum length of the extra data in the executed event.
///
/// Current value has been taken based on moonbeam runtime ethereum pallet configuration.
pub const EXTRA_DATA_LENGTH: u32 = 30;
}
Loading