Skip to content

Commit

Permalink
fix: node for release
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach authored Jun 24, 2024
2 parents efce288 + 5a77207 commit 955f1bd
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 94 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 18 additions & 14 deletions node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,24 @@ fn genesis_patch() -> serde_json::Value {
.collect::<Vec<_>>(),
},

"session": {
"keys": invulnerables.into_iter()
.map(|name| {
let account = get_account_id_from_seed::<sr25519::Public>(name);
let aura = get_from_seed::<AuraId>(name);

(
/* account id: */ account.clone(),
/* validator id: */ account,
/* session keys: */ SessionKeys { aura },
)
})
.collect::<Vec<_>>()
},
// We don't have Session pallet in production anywhere,
// Adding this config makes baedeker think we have pallet-session, and it tries to
// reconfigure chain using it, which makes no sense, because then aura knows no
// authority, as baedeker expects them to be configured by session pallet.
// "session": {
// "keys": invulnerables.into_iter()
// .map(|name| {
// let account = get_account_id_from_seed::<sr25519::Public>(name);
// let aura = get_from_seed::<AuraId>(name);
//
// (
// /* account id: */ account.clone(),
// /* validator id: */ account,
// /* session keys: */ SessionKeys { aura },
// )
// })
// .collect::<Vec<_>>()
// },

"sudo": {
"key": get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand Down
14 changes: 3 additions & 11 deletions node/cli/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ use crate::service::RuntimeApiDep;
type FullBackend = sc_service::TFullBackend<Block>;

/// Full client dependencies.
pub struct FullDeps<C, P, SC> {
pub struct FullDeps<C, P> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// The SelectChain Strategy
pub select_chain: SC,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,

/// Runtime identification (read from the chain spec)
pub runtime_id: RuntimeId,
/// Executor params for PoV estimating
#[cfg(feature = "pov-estimate")]
pub exec_params: uc_rpc::pov_estimate::ExecutorParams,
Expand All @@ -64,9 +59,9 @@ pub struct FullDeps<C, P, SC> {
}

/// Instantiate all Full RPC extensions.
pub fn create_full<C, P, SC, R, B>(
pub fn create_full<C, P, R, B>(
io: &mut RpcModule<()>,
deps: FullDeps<C, P, SC>,
deps: FullDeps<C, P>,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,
Expand All @@ -93,11 +88,8 @@ where
let FullDeps {
client,
pool,
select_chain: _,
deny_unsafe,

runtime_id: _,

#[cfg(feature = "pov-estimate")]
exec_params,

Expand Down
69 changes: 25 additions & 44 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ use cumulus_client_consensus_aura::collators::lookahead::{
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, DARecoveryProfile,
StartRelayChainTasksParams,
build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
};
use cumulus_primitives_core::ParaId;
use cumulus_primitives_parachain_inherent::ParachainInherentData;
Expand Down Expand Up @@ -85,10 +85,7 @@ pub type ParachainHostFunctions = (
use cumulus_primitives_core::PersistedValidationData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;

use crate::{
chain_spec::RuntimeIdentification,
rpc::{create_eth, create_full, EthDeps, FullDeps},
};
use crate::rpc::{create_eth, create_full, EthDeps, FullDeps};

/// Unique native executor instance.
#[cfg(feature = "unique-runtime")]
Expand Down Expand Up @@ -238,7 +235,7 @@ ez_bounds!(
pub trait LookaheadApiDep: cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> {}
);

fn ethereum_parachain_inherent() -> ParachainInherentData {
fn ethereum_parachain_inherent() -> (sp_timestamp::InherentDataProvider, ParachainInherentData) {
let (relay_parent_storage_root, relay_chain_state) =
RelayStateSproofBuilder::default().into_state_root_and_proof();
let vfp = PersistedValidationData {
Expand All @@ -249,12 +246,15 @@ fn ethereum_parachain_inherent() -> ParachainInherentData {
..Default::default()
};

ParachainInherentData {
validation_data: vfp,
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
}
(
sp_timestamp::InherentDataProvider::from_system_time(),
ParachainInherentData {
validation_data: vfp,
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
},
)
}

/// Starts a `ServiceBuilder` for a full service.
Expand Down Expand Up @@ -426,33 +426,25 @@ where
.await
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;

// Aura is sybil-resistant, collator-selection is generally too.
let block_announce_validator =
cumulus_client_network::AssumeSybilResistance::allow_seconded_messages();

let validator = parachain_config.role.is_authority();
let prometheus_registry = parachain_config.prometheus_registry().cloned();
let transaction_pool = params.transaction_pool.clone();
let import_queue_service = params.import_queue.service();

let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &parachain_config,
cumulus_client_service::build_network(cumulus_client_service::BuildNetworkParams {
parachain_config: &parachain_config,
net_config,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
para_id,
spawn_handle: task_manager.spawn_handle(),
relay_chain_interface: relay_chain_interface.clone(),
import_queue: params.import_queue,
block_announce_validator_builder: Some(Box::new(|_| {
Box::new(block_announce_validator)
})),
warp_sync_params: None,
block_relay: None,
})?;

let select_chain = params.select_chain.clone();

let runtime_id = parachain_config.chain_spec.runtime_id();
// Aura is sybil-resistant, collator-selection is generally too.
sybil_resistance_level: CollatorSybilResistance::Resistant,
})
.await?;

// Frontier
let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
Expand Down Expand Up @@ -505,9 +497,7 @@ where
fee_history_cache,
eth_block_data_cache,
network,
runtime_id,
transaction_pool,
select_chain,
overrides,
);

Expand All @@ -518,7 +508,6 @@ where

let full_deps = FullDeps {
client: client.clone(),
runtime_id,

#[cfg(feature = "pov-estimate")]
exec_params: uc_rpc::pov_estimate::ExecutorParams {
Expand All @@ -533,10 +522,9 @@ where

deny_unsafe,
pool: transaction_pool.clone(),
select_chain,
};

create_full::<_, _, _, Runtime, _>(&mut rpc_handle, full_deps)?;
create_full::<_, _, Runtime, _>(&mut rpc_handle, full_deps)?;

let eth_deps = EthDeps {
client,
Expand All @@ -557,7 +545,7 @@ where
overrides,
sync: sync_service.clone(),
pending_create_inherent_data_providers: |_, ()| async move {
Ok((ethereum_parachain_inherent(),))
Ok(ethereum_parachain_inherent())
},
};

Expand Down Expand Up @@ -1041,8 +1029,6 @@ where
#[cfg(feature = "pov-estimate")]
let rpc_backend = backend.clone();

let runtime_id = config.chain_spec.runtime_id();

// Frontier
let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
let fee_history_limit = 2048;
Expand Down Expand Up @@ -1094,9 +1080,7 @@ where
fee_history_cache,
eth_block_data_cache,
network,
runtime_id,
transaction_pool,
select_chain,
overrides,
);

Expand All @@ -1106,8 +1090,6 @@ where
let mut rpc_module = RpcModule::new(());

let full_deps = FullDeps {
runtime_id,

#[cfg(feature = "pov-estimate")]
exec_params: uc_rpc::pov_estimate::ExecutorParams {
wasm_method: config.wasm_method,
Expand All @@ -1122,10 +1104,9 @@ where
deny_unsafe,
client: client.clone(),
pool: transaction_pool.clone(),
select_chain,
};

create_full::<_, _, _, Runtime, _>(&mut rpc_module, full_deps)?;
create_full::<_, _, Runtime, _>(&mut rpc_module, full_deps)?;

let eth_deps = EthDeps {
client,
Expand All @@ -1147,7 +1128,7 @@ where
sync: sync_service.clone(),
// We don't have any inherents except parachain built-ins, which we can't even extract from inside `run_aura`.
pending_create_inherent_data_providers: |_, ()| async move {
Ok((ethereum_parachain_inherent(),))
Ok(ethereum_parachain_inherent())
},
};

Expand Down
24 changes: 4 additions & 20 deletions runtime/common/config/substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

use frame_support::{
derive_impl,
dispatch::DispatchClass,
ord_parameter_types, parameter_types,
traits::{
Expand Down Expand Up @@ -42,8 +43,8 @@ use up_common::{constants::*, types::*};

use crate::{
runtime_common::DealWithFees, Balances, Block, OriginCaller, PalletInfo, Runtime, RuntimeCall,
RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, SS58Prefix, System,
Treasury, Version,
RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, SS58Prefix,
System, Treasury, Version,
};

parameter_types! {
Expand Down Expand Up @@ -72,13 +73,12 @@ parameter_types! {
.build_or_panic();
}

#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
/// The data to be stored in an account.
type AccountData = pallet_balances::AccountData<Balance>;
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The basic call filter to use in dispatchable.
type BaseCallFilter = Everything;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
type BlockHashCount = BlockHashCount;
/// The block type.
Expand All @@ -87,12 +87,8 @@ impl frame_system::Config for Runtime {
type BlockLength = RuntimeBlockLength;
/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.
type BlockWeights = RuntimeBlockWeights;
/// The aggregated dispatch type that is available for extrinsics.
type RuntimeCall = RuntimeCall;
/// The weight of database operations that the runtime can invoke.
type DbWeight = RocksDbWeight;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
/// The type for hashing blocks and tries.
type Hash = Hash;
/// The hashing algorithm used.
Expand All @@ -101,10 +97,6 @@ impl frame_system::Config for Runtime {
type Nonce = Nonce;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
/// What to do if an account is fully reaped from the system.
type OnKilledAccount = ();
/// What to do if a new account is created.
type OnNewAccount = ();
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
/// The ubiquitous origin type.
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -117,14 +109,6 @@ impl frame_system::Config for Runtime {
/// Version of the runtime.
type Version = Version;
type MaxConsumers = ConstU32<16>;

type RuntimeTask = ();

type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down

0 comments on commit 955f1bd

Please sign in to comment.