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

Update SDK to stable 2409 with Rust 1.81 and EVM enhancements #976

Merged
merged 22 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
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
1,460 changes: 752 additions & 708 deletions Cargo.lock

Large diffs are not rendered by default.

297 changes: 149 additions & 148 deletions Cargo.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions node/src/chain_spec/laos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn create_test_genesis_config() -> serde_json::Value {
predefined_accounts::ALITH.into(),
template_session_keys(get_collator_keys_from_seed("Alice")),
)],
..Default::default()
},
polkadot_xcm: laos_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
21 changes: 8 additions & 13 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with LAOS. If not, see <http://www.gnu.org/licenses/>.

use std::net::SocketAddr;

use cumulus_client_service::storage_proof_size::HostFunctions as ReclaimHostFunctions;
use cumulus_primitives_core::ParaId;
use fc_db::kv::frontier_database_dir;
Expand All @@ -24,7 +22,7 @@ use laos_runtime::Block;
use log::info;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, SharedParams, SubstrateCli,
NetworkParams, Result, RpcEndpoint, SharedParams, SubstrateCli,
};
use sc_service::{
config::{BasePath, PrometheusConfig},
Expand Down Expand Up @@ -315,7 +313,10 @@ pub fn run() -> Result<()> {
let hwbench = (!cli.no_hardware_benchmarks)
.then_some(config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
sc_sysinfo::gather_hwbench(
Some(database_path),
&SUBSTRATE_REFERENCE_HARDWARE,
)
}))
.flatten();

Expand Down Expand Up @@ -398,7 +399,7 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| self.base_path.clone().map(Into::into)))
}

fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<Vec<RpcEndpoint>>> {
self.base.base.rpc_addr(default_listen_port)
}

Expand All @@ -410,15 +411,9 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.prometheus_config(default_listen_port, chain_spec)
}

fn init<F>(
&self,
_support_url: &String,
_impl_version: &String,
_logger_hook: F,
_config: &sc_service::Configuration,
) -> Result<()>
fn init<F>(&self, _support_url: &String, _impl_version: &String, _logger_hook: F) -> Result<()>
where
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
F: FnOnce(&mut sc_cli::LoggerBuilder),
{
unreachable!("PolkadotCli is never initialized; qed");
}
Expand Down
8 changes: 3 additions & 5 deletions node/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sc_client_api::{
client::BlockchainEvents,
UsageProvider,
};
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
pub use sc_rpc::SubscriptionTaskExecutor;
use sc_transaction_pool::ChainApi;
use sc_transaction_pool_api::TransactionPool;
use sp_api::{CallApiAt, ProvideRuntimeApi};
Expand All @@ -51,8 +51,6 @@ pub struct FullDeps<C, P, A: ChainApi, CT, CIDP> {
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// Ethereum-compatibility specific dependencies.
pub eth: EthDeps<C, P, A, CT, Block, CIDP>,
}
Expand Down Expand Up @@ -105,9 +103,9 @@ where
use substrate_frame_rpc_system::System;

let mut io = RpcExtension::new(());
let FullDeps { client, pool, deny_unsafe, eth } = deps;
let FullDeps { client, pool, eth } = deps;

io.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
io.merge(System::new(client.clone(), pool).into_rpc())?;
io.merge(TransactionPayment::new(client).into_rpc())?;

// Ethereum compatibility RPCs
Expand Down
24 changes: 13 additions & 11 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,15 @@ pub fn new_partial(
.transpose()?;

let heap_pages = config
.executor
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
let executor = ParachainExecutor::builder()
.with_execution_method(config.wasm_method)
.with_execution_method(config.executor.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.with_max_runtime_instances(config.executor.max_runtime_instances)
.with_runtime_cache_size(config.executor.runtime_cache_size)
.build();

let (client, backend, keystore_container, task_manager) =
Expand Down Expand Up @@ -256,11 +257,13 @@ async fn start_node_impl(

let validator = parachain_config.role.is_authority();
let prometheus_registry = parachain_config.prometheus_registry().cloned();
let maybe_registry = parachain_config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let import_queue_service = import_queue.service();
let net_config =
sc_network::config::FullNetworkConfiguration::<_, _, sc_network::NetworkWorker<_, _>>::new(
&parachain_config.network,
);
let net_config = sc_network::config::FullNetworkConfiguration::<
_,
_,
sc_network::NetworkWorker<_, _>,
>::new(&parachain_config.network, maybe_registry.cloned());

let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
build_network(BuildNetworkParams {
Expand Down Expand Up @@ -308,7 +311,7 @@ async fn start_node_impl(
let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks);

// for ethereum-compatibility rpc.
parachain_config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
parachain_config.rpc.id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));

let eth_rpc_params = crate::rpc::EthDeps {
client: client.clone(),
Expand Down Expand Up @@ -377,11 +380,10 @@ async fn start_node_impl(
let transaction_pool = transaction_pool.clone();
let pubsub_notification_sinks = pubsub_notification_sinks.clone();

Box::new(move |deny_unsafe, subscription_task_executor| {
Box::new(move |subscription_task_executor| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
deny_unsafe,
eth: eth_rpc_params.clone(),
};

Expand Down Expand Up @@ -428,7 +430,7 @@ async fn start_node_impl(
// Here you can check whether the hardware meets your chains' requirements. Putting a link
// in there and swapping out the requirements for your own are probably a good idea. The
// requirements for a para-chain are dictated by its relay-chain.
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) {
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench, validator) {
Err(err) if validator => {
log::warn!(
"⚠️ The hardware does not meet the minimal requirements {} for role 'Authority'.",
Expand Down
5 changes: 5 additions & 0 deletions pallets/asset-metadata-extender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
// along with LAOS. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO: This line is needed cause from frontier2409 and rust 1.81 onwards, manual inspect clippy
// flag is giving a false positive in all our pallets. From this issue: https://github.com/rust-lang/rust-clippy/issues/13185
// it seems that the flag --manual-inspect may not be 100% ready yet, as it's giving problems to
// different codes. Maybe we can remove this attribute in the future
#![allow(clippy::manual_inspect)]

mod benchmarking;
pub mod precompiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ impl pallet_evm::Config for Test {
type OnCreate = ();
type FindAuthor = FindAuthorTruncated;
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = ();
type SuicideQuickClearLimit = ();
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Test>;
}

pub const BLOCK_GAS_LIMIT: u64 = 15_000_000;
Expand All @@ -131,6 +132,7 @@ pub type LaosPrecompiles<Test> = PrecompileSetBuilder<
frame_support::parameter_types! {
pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
pub const GasLimitStorageGrowthRatio: u64 = 91;
/// 1 weight to 1 gas, for testing purposes
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(1, 0);
pub PrecompilesInstance: LaosPrecompiles<Test> = LaosPrecompiles::new();
Expand Down
5 changes: 5 additions & 0 deletions pallets/laos-evolution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
// along with LAOS. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO: This line is needed cause from frontier2409 and rust 1.81 onwards, manual inspect clippy
// flag is giving a false positive in all our pallets. From this issue: https://github.com/rust-lang/rust-clippy/issues/13185
// it seems that the flag --manual-inspect may not be 100% ready yet, as it's giving problems to
// different codes. Maybe we can remove this attribute in the future
#![allow(clippy::manual_inspect)]

use frame_support::ensure;
pub use pallet::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub type LaosPrecompiles<Test> = PrecompileSetBuilder<
frame_support::parameter_types! {
pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
pub const GasLimitStorageGrowthRatio: u64 = 91;
/// 1 weight to 1 gas, for testing purposes
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(1, 0);
pub PrecompilesInstance: LaosPrecompiles<Test> = LaosPrecompiles::<_>::new();
Expand All @@ -162,9 +163,10 @@ impl pallet_evm::Config for Test {
type OnCreate = ();
type FindAuthor = FindAuthorTruncated;
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = ();
type SuicideQuickClearLimit = ();
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Test>;
}

/// New Test Ext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub type LaosPrecompiles<Test> = PrecompileSetBuilder<
frame_support::parameter_types! {
pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
pub const GasLimitStorageGrowthRatio: u64 = 91;
/// 1 weight to 1 gas, for testing purposes
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(1, 0);
pub PrecompilesInstance: LaosPrecompiles<Test> = LaosPrecompiles::new();
Expand All @@ -159,9 +160,10 @@ impl pallet_evm::Config for Test {
type OnCreate = ();
type FindAuthor = FindAuthorTruncated;
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = ();
type SuicideQuickClearLimit = ();
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Test>;
}

/// New Test Ext
Expand Down
5 changes: 5 additions & 0 deletions pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
//! To leave the set of delegators and revoke all delegations, call `leave_delegators`.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO: This line is needed cause from frontier2409 and rust 1.81 onwards, manual inspect clippy
// flag is giving a false positive in all our pallets. From this issue: https://github.com/rust-lang/rust-clippy/issues/13185
// it seems that the flag --manual-inspect may not be 100% ready yet, as it's giving problems to
// different codes. Maybe we can remove this attribute in the future
#![allow(clippy::manual_inspect)]

mod auto_compound;
mod delegation_requests;
Expand Down
2 changes: 1 addition & 1 deletion pallets/parachain-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ pub(crate) fn set_block_author(acc: u64) {

/// fn to query the lock amount
pub(crate) fn query_lock_amount(account_id: u64, id: LockIdentifier) -> Option<Balance> {
for lock in Balances::locks(account_id) {
for lock in Balances::locks(&account_id) {
if lock.id == id {
return Some(lock.amount);
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/parachain-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3948,8 +3948,8 @@ fn multiple_delegations() {
assert_eq!(ParachainStaking::delegator_state(7).unwrap().delegations.0.len(), 2usize);
assert_eq!(ParachainStaking::delegator_state(6).unwrap().total(), 40);
assert_eq!(ParachainStaking::delegator_state(6).unwrap().delegations.0.len(), 4usize);
assert_eq!(Balances::locks(6)[0].amount, 40);
assert_eq!(Balances::locks(7)[0].amount, 90);
assert_eq!(Balances::locks(&6)[0].amount, 40);
assert_eq!(Balances::locks(&7)[0].amount, 90);
assert_eq!(ParachainStaking::get_delegator_stakable_free_balance(&6), 60);
assert_eq!(ParachainStaking::get_delegator_stakable_free_balance(&7), 10);
roll_to_round_begin(8);
Expand Down
6 changes: 6 additions & 0 deletions pallets/precompiles-benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
// along with LAOS. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO: This line is needed cause from frontier2409 and rust 1.81 onwards, manual inspect clippy
// flag is giving a false positive in all our pallets. From this issue: https://github.com/rust-lang/rust-clippy/issues/13185
// it seems that the flag --manual-inspect may not be 100% ready yet, as it's giving problems to
// different codes. Maybe we can remove this attribute in the future
#![allow(clippy::manual_inspect)]

use sp_core::H160;
use sp_runtime::traits::{Convert, ConvertBack};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ type BalanceOf<Runtime> = <<Runtime as pallet_vesting::Config>::Currency as Curr
<Runtime as frame_system::Config>::AccountId,
>>::Balance;

// TODO: We'll open a PR to parity to include this annotation in the macro expansion, as it's
// effectively creating multiple bounds locations
#[allow(clippy::multiple_bound_locations)]
#[benchmarks(
where
T: Config + pallet_vesting::Config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub type LaosPrecompiles<Test> =
frame_support::parameter_types! {
pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
pub const GasLimitStorageGrowthRatio: u64 = 91;
/// 1 weight to 1 gas, for testing purposes
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(1, 0);
pub PrecompilesInstance: LaosPrecompiles<Test> = LaosPrecompiles::new();
Expand All @@ -157,9 +158,10 @@ impl pallet_evm::Config for Test {
type OnCreate = ();
type FindAuthor = FindAuthorTruncated;
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = ();
type SuicideQuickClearLimit = ();
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Test>;
}

#[derive(Default)]
Expand Down
1 change: 0 additions & 1 deletion pallets/treasury-funding/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with LAOS. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking setup for pallet-treasury-funding
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use frame_benchmarking::v2::*;
Expand Down
5 changes: 5 additions & 0 deletions pallets/treasury-funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
//! - `fund_treasury`: Vest all funds of the vault account and transfer them to the treasury.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO: This line is needed cause from frontier2409 and rust 1.81 onwards, manual inspect clippy
// flag is giving a false positive in all our pallets. From this issue: https://github.com/rust-lang/rust-clippy/issues/13185
// it seems that the flag --manual-inspect may not be 100% ready yet, as it's giving problems to
// different codes. Maybe we can remove this attribute in the future
#![allow(clippy::manual_inspect)]

pub use pallet::*;

Expand Down
2 changes: 1 addition & 1 deletion precompiles/parachain-staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ derive_more = { workspace = true }
serde = { workspace = true }
sha3 = { workspace = true }

# Moonbeam
# Frontier
precompile-utils = { workspace = true, features = [ "std", "testing" ] }

# Substrate
Expand Down
Loading