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

feat: Update substrate to gear-polkadot-stable2409 #4289

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e2afa31
feat: Update substrate to gear-polkadot-stable2409
ukint-vs Oct 6, 2024
b56f2b3
chore(runtime-interface): enable wasmtime feature
ukint-vs Oct 14, 2024
7dcaec5
refactor(vara-runtime): Use frame_support::runtime
ukint-vs Oct 14, 2024
e4b9c9b
refactor(vara-runtime): Update sp_genesis_builder
ukint-vs Oct 14, 2024
b784b8a
refactor(vara-runtime): Update pallets configs
ukint-vs Oct 14, 2024
57842da
feat(rpc): Update jsonrpsee, update rpc extension and modules
ukint-vs Oct 17, 2024
e9115e5
feat(node): Update service, remove Native executor
ukint-vs Oct 17, 2024
6dc3970
feat(ethexe-ethereum): Update alloy to 0.4.2
ukint-vs Oct 17, 2024
0b40f83
fmt
ukint-vs Oct 17, 2024
fc07496
Merge branch 'master' into vs/alloy-0.4.2
ukint-vs Oct 17, 2024
c780799
Merge branch 'vs/alloy-0.4.2' into vs/substrate-stable2409
ukint-vs Oct 17, 2024
7001d9d
chore: Update mocks and tests
ukint-vs Oct 18, 2024
65f2b8d
spawn statement executor
ukint-vs Oct 18, 2024
2733973
Merge remote-tracking branch 'origin/master' into vs/substrate-stable…
ukint-vs Oct 18, 2024
12cd853
Revert "spawn statement executor"
ukint-vs Oct 18, 2024
c0c499b
rm statement client
ukint-vs Oct 18, 2024
d65ca7d
rm test
ukint-vs Oct 18, 2024
05d0a2c
update fuzzer tests
ukint-vs Oct 18, 2024
ca77917
current_storage_version -> in_code_storage_version
ukint-vs Oct 19, 2024
f736d11
feat(node): Spawn authority discovery module
ukint-vs Oct 19, 2024
1f68b4d
clippy
ukint-vs Oct 19, 2024
0227cfe
update test extensions
ukint-vs Oct 19, 2024
f89c2a1
add rust-src
ukint-vs Oct 19, 2024
0e4f8d5
update gsdk metadata
ukint-vs Oct 19, 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
5,211 changes: 2,861 additions & 2,350 deletions Cargo.lock

Large diffs are not rendered by default.

260 changes: 134 additions & 126 deletions Cargo.toml

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions common/src/pallet_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ macro_rules! impl_pallet_balances_inner {
($runtime:ty) => {
impl pallet_balances::Config for $runtime {
type MaxLocks = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
type MaxReserves = ();
type RuntimeFreezeReason = RuntimeFreezeReason;
Expand Down Expand Up @@ -112,6 +111,7 @@ macro_rules! impl_pallet_system_inner {
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type RuntimeTask = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
Expand All @@ -121,6 +121,11 @@ macro_rules! impl_pallet_system_inner {
type SS58Prefix = $crate::pallet_tests::SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MultiBlockMigrator = ();
type SingleBlockMigrations = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}
};

Expand Down Expand Up @@ -255,6 +260,7 @@ macro_rules! impl_pallet_staking_inner {
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub const HistoryDepth: u32 = 84;
pub const MaxNominations: u32 = 16;
pub const MaxControllersInDeprecationBatch: u32 = 5900;
}

impl pallet_staking::Config for Test {
Expand All @@ -276,7 +282,6 @@ macro_rules! impl_pallet_staking_inner {
type EraPayout = StakingConfigEraPayout;
type NextNewSession = StakingConfigNextNewSession;
type MaxExposurePageSize = MaxExposurePageSize;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type VoterList = pallet_staking::UseNominatorsAndValidatorsMap<Self>;
type TargetList = pallet_staking::UseValidatorsMap<Self>;
type NominationsQuota = pallet_staking::FixedNominationsQuota<16>;
Expand All @@ -285,6 +290,8 @@ macro_rules! impl_pallet_staking_inner {
type EventListeners = ();
type WeightInfo = ();
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
type DisablingStrategy = pallet_staking::UpToLimitDisablingStrategy;
}
};

Expand Down
2 changes: 1 addition & 1 deletion gsdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ serde_json.workspace = true
subxt.workspace = true
thiserror.workspace = true
sp-runtime = { workspace = true, features = [ "std" ] }
sp-core.workspace = true
sp-core = { workspace = true, features = [ "std" , "full_crypto"] }
gsdk-codegen.workspace = true
parking_lot.workspace = true

Expand Down
9 changes: 2 additions & 7 deletions gsdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use jsonrpsee::{
core::{
client::{ClientT, Subscription, SubscriptionClientT, SubscriptionKind},
traits::ToRpcParams,
Error as JsonRpseeError,
},
http_client::{HttpClient, HttpClientBuilder},
types::SubscriptionId,
Expand All @@ -50,7 +49,7 @@ const ONE_HUNDRED_MEGA_BYTES: u32 = 100 * 1024 * 1024;
struct Params(Option<Box<RawValue>>);

impl ToRpcParams for Params {
fn to_rpc_params(self) -> StdResult<Option<Box<RawValue>>, JsonRpseeError> {
fn to_rpc_params(self) -> StdResult<Option<Box<RawValue>>, serde_json::Error> {
Ok(self.0)
}
}
Expand All @@ -69,11 +68,7 @@ impl RpcClient {
if uri.starts_with("ws") {
Ok(Self::Ws(
WsClientBuilder::default()
// Actually that stand for the response too.
// *WARNING*:
// After updating jsonrpsee to 0.20.0 and higher
// use another method created only for that.
.max_request_body_size(ONE_HUNDRED_MEGA_BYTES)
.max_request_size(ONE_HUNDRED_MEGA_BYTES)
.connection_timeout(Duration::from_millis(timeout))
.request_timeout(Duration::from_millis(timeout))
.build(uri)
Expand Down
3,061 changes: 2,719 additions & 342 deletions gsdk/src/metadata/generated.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gsdk/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub enum Error {
#[error(transparent)]
Tx(#[from] TxError),
#[error(transparent)]
SubxtRpc(#[from] jsonrpsee::core::Error),
SubxtRpc(#[from] jsonrpsee::core::ClientError),
#[error("Page {0} of Program {1} was not found in the storage.")]
PageNotFound(u32, String),
#[error("Program has been terminated.")]
Expand Down
10 changes: 5 additions & 5 deletions gsdk/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use gear_core::{
};
use gear_core_errors::{ReplyCode, SuccessReplyReason};
use gsdk::{Api, Error, Result};
use jsonrpsee::types::error::{CallError, ErrorObject};
use jsonrpsee::types::error::ErrorObject;
use parity_scale_codec::Encode;
use std::{borrow::Cow, process::Command, str::FromStr, time::Instant};
use subxt::{error::RpcError, utils::H256, Error as SubxtError};
Expand All @@ -50,11 +50,11 @@ async fn pallet_errors_formatting() -> Result<()> {
.expect_err("Must return error");

let expected_err = Error::Subxt(SubxtError::Rpc(RpcError::ClientError(Box::new(
CallError::Custom(ErrorObject::owned(
ErrorObject::owned(
8000,
"Runtime error",
Some("Extrinsic `gear.upload_program` failed: 'ProgramConstructionFailed'"),
)),
),
))));

assert_eq!(format!("{err}"), format!("{expected_err}"));
Expand Down Expand Up @@ -285,11 +285,11 @@ async fn test_runtime_wasm_blob_version_history() -> Result<()> {
.runtime_wasm_blob_version(Some(no_method_block_hash))
.await;

let err = CallError::Custom(ErrorObject::owned(
let err = ErrorObject::owned(
9000,
"Unable to find WASM blob version in WASM blob",
None::<String>,
));
);
assert!(
matches!(
&wasm_blob_version_result,
Expand Down
1 change: 1 addition & 0 deletions node/authorship/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sc-service.workspace = true
sp-core = { workspace = true, features = ["std"] }
sp-api = { workspace = true, features = ["std"] }
sp-consensus.workspace = true
sp-io = { workspace = true, features = ["std"] }
sp-runtime = { workspace = true, features = ["std"] }
sp-blockchain.workspace = true
sp-inherents = { workspace = true, features = ["std"] }
Expand Down
24 changes: 13 additions & 11 deletions node/authorship/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use crate::{
block_builder::{BlockBuilder, BlockBuilderBuilder},
ProposerFactory,
};

use codec::{Decode, Encode};
use core::convert::TryFrom;
use demo_constructor::{Calls, Scheme, WASM_BINARY};
Expand All @@ -41,7 +40,7 @@ use pallet_gear_rpc_runtime_api::GearApi;
use parking_lot::{Mutex, RwLock};
use runtime_primitives::{Block as TestBlock, BlockNumber};
use sc_client_api::Backend as _;
use sc_executor::{NativeElseWasmExecutor, WasmExecutor};
use sc_executor::WasmExecutor;
use sc_service::client::Client;
use sc_transaction_pool::{BasicPool, FullPool};
use sc_transaction_pool_api::{
Expand Down Expand Up @@ -69,7 +68,7 @@ use std::{
};
use testing::{
client::{
Backend as TestBackend, Client as TestClient, ClientBlockImportExt, ExecutorDispatch,
Backend as TestBackend, Client as TestClient, ClientBlockImportExt, ExtendHostFunctions,
TestClientBuilder, TestClientBuilderExt,
},
keyring::{alice, bob, sign, signed_extra, CheckedExtrinsic},
Expand All @@ -78,15 +77,18 @@ use vara_runtime::{
AccountId, Runtime, RuntimeApi as RA, RuntimeCall, UncheckedExtrinsic, SLOT_DURATION, VERSION,
};

type RuntimeExecutor = sc_executor::WasmExecutor<
sc_executor::sp_wasm_interface::ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
ExtendHostFunctions,
>,
>;

type TestProposal = sp_consensus::Proposal<TestBlock, ()>;

fn get_executor() -> &'static RwLock<ExecutorDispatch> {
static EXECUTOR: OnceLock<RwLock<ExecutorDispatch>> = OnceLock::new();
EXECUTOR.get_or_init(|| {
RwLock::new(NativeElseWasmExecutor::new_with_wasm_executor(
WasmExecutor::builder().build(),
))
})
fn get_executor() -> &'static RwLock<RuntimeExecutor> {
static EXECUTOR: OnceLock<RwLock<RuntimeExecutor>> = OnceLock::new();
EXECUTOR.get_or_init(|| RwLock::new(WasmExecutor::builder().build()))
}

const SOURCE: TransactionSource = TransactionSource::External;
Expand Down Expand Up @@ -268,7 +270,7 @@ pub fn init() -> (
}

pub fn create_proposal<A>(
mut client: Arc<TestClient>,
client: Arc<TestClient>,
_backend: Arc<TestBackend>,
txpool: Arc<A>,
spawner: sp_core::testing::TaskExecutor,
Expand Down
1 change: 1 addition & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ sp-timestamp = { workspace = true, features = ["std"] }

# Substrate other (benchmarking etc)
frame-system = { workspace = true, features = ["std"] }
frame-metadata-hash-extension = { workspace = true, features = ["std"] }
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }
frame-benchmarking-cli = { workspace = true, optional = true }

Expand Down
2 changes: 2 additions & 0 deletions node/cli/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ macro_rules! with_signed_payload {
runtime::CustomCheckNonce::<runtime::Runtime>::from($nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_gear_payment::CustomChargeTransactionPayment::<runtime::Runtime>::from($tip),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
);

let $raw_payload = runtime::SignedPayload::from_raw(
Expand All @@ -99,6 +100,7 @@ macro_rules! with_signed_payload {
(),
(),
(),
None,
),
);

Expand Down
14 changes: 6 additions & 8 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::cli::{Cli, Subcommand};
use runtime_primitives::Block;
use sc_cli::{ChainSpec, SubstrateCli};
use sc_service::config::BasePath;
use service::{chain_spec, IdentifyVariant};
use service::{chain_spec, ExtendHostFunctions, IdentifyVariant};

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down Expand Up @@ -211,7 +211,7 @@ pub fn run() -> sc_cli::Result<()> {
use frame_benchmarking_cli::{
BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE,
};
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use sc_executor::sp_wasm_interface::ExtendedHostFunctions;
use sp_keyring::Sr25519Keyring;

let runner = cli.create_runner(cmd)?;
Expand All @@ -231,12 +231,10 @@ pub fn run() -> sc_cli::Result<()> {
match &config.chain_spec {
#[cfg(feature = "vara-native")]
spec if spec.is_vara() => cmd
.run::<service::vara_runtime::Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<service::VaraExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>>(
config,
),
.run_with_spec::<sp_runtime::traits::HashingFor<service::vara_runtime::Block>, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
ExtendHostFunctions,
>>(Some(config.chain_spec)),
_ => Err("invalid chain spec".into()),
}
}
Expand Down
6 changes: 3 additions & 3 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ gear-runtime-common = { workspace = true, features = ["std"] }
vara-runtime = { workspace = true, optional = true, features = ["std", "dev"] }

# Substrate Client
sc-authority-discovery.workspace = true
sc-chain-spec.workspace = true
sc-executor.workspace = true
sc-executor-common.workspace = true
Expand All @@ -47,7 +48,6 @@ sc-telemetry.workspace = true
sc-network.workspace = true
sc-network-common.workspace = true
sc-network-sync.workspace = true
sc-network-statement.workspace = true
sc-consensus-slots.workspace = true
sc-transaction-pool.workspace = true
sc-transaction-pool-api.workspace = true
Expand All @@ -72,6 +72,7 @@ sp-api = { workspace = true, features = ["std"] }
sp-authority-discovery = { workspace = true, optional = true, features = ["std"] }
sp-consensus.workspace = true
sp-consensus-babe = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }
sp-transaction-pool = { workspace = true, features = ["std"] }
sp-transaction-storage-proof = { workspace = true, features = ["std"] }
sp-consensus-grandpa = { workspace = true, features = ["std"] }
Expand All @@ -82,6 +83,7 @@ sp-block-builder = { workspace = true, features = ["std"] }
sp-keystore = { workspace = true, features = ["std"] }
sp-trie = { workspace = true, features = ["std"] }
sp-storage = { workspace = true, features = ["std"] }
sp-state-machine = { workspace = true, features = ["std"] }
sp-offchain = { workspace = true, features = ["std"] }
sp-session = { workspace = true, features = ["std"] }

Expand All @@ -96,7 +98,6 @@ frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking-cli.workspace = true
substrate-frame-rpc-system.workspace = true
substrate-state-trie-migration-rpc.workspace = true
try-runtime-cli = { workspace = true, optional = true }

[build-dependencies]
substrate-build-script-utils.workspace = true
Expand All @@ -118,5 +119,4 @@ runtime-benchmarks-checkers = [
]
try-runtime = [
"vara-runtime?/try-runtime",
"try-runtime-cli",
]
2 changes: 1 addition & 1 deletion node/service/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Extensions {
}

/// General `ChainSpec` used as a basis for a specialized config.
pub type RawChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type RawChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down
2 changes: 1 addition & 1 deletion node/service/src/chain_spec/vara.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use vara_runtime::{
};

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Returns the [`Properties`] for the Vara network.
pub fn vara_properties() -> Properties {
Expand Down
Loading
Loading