Skip to content

feat: Update substrate to gear-polkadot-stable-2412 #4673

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

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
3,446 changes: 2,281 additions & 1,165 deletions Cargo.lock

Large diffs are not rendered by default.

258 changes: 129 additions & 129 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/src/auxiliary/gas_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
};
use alloc::collections::BTreeMap;
use core::{cell::RefCell, ops::DerefMut};
use sp_core::H256;
use primitive_types::H256;

/// Balance type used in the gas tree.
pub(crate) type Balance = u64;
Expand Down
4 changes: 2 additions & 2 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use frame_support::{
sp_runtime::{
self,
generic::{CheckedExtrinsic, UncheckedExtrinsic},
traits::{Dispatchable, SignedExtension},
traits::Dispatchable,
},
traits::Get,
};
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<Address, Call, Signature, Extra> ExtractCall<Call>
for UncheckedExtrinsic<Address, Call, Signature, Extra>
where
Call: Dispatchable + Clone,
Extra: SignedExtension,
Extra: Decode,
{
fn extract_call(&self) -> Call {
self.function.clone()
Expand Down
6 changes: 3 additions & 3 deletions ethexe/common/src/gear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl ToDigest for OperatorRewardsCommitment {
fn update_hasher(&self, hasher: &mut sha3::Keccak256) {
let OperatorRewardsCommitment { amount, root } = self;

hasher.update(<[u8; 32]>::from(*amount));
hasher.update(amount.to_little_endian());
hasher.update(root);
}
}
Expand Down Expand Up @@ -144,10 +144,10 @@ impl ToDigest for StakerRewardsCommitment {
.iter()
.for_each(|StakerRewards { vault, amount }| {
hasher.update(vault);
hasher.update(<[u8; 32]>::from(*amount));
hasher.update(amount.to_little_endian());
});

hasher.update(<[u8; 32]>::from(*total_amount));
hasher.update(total_amount.to_little_endian());
hasher.update(token);
}
}
Expand Down
3 changes: 1 addition & 2 deletions ethexe/ethereum/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ pub(crate) mod utils {
}

pub fn u256_to_uint256(value: U256) -> Uint256 {
let mut bytes = [0u8; Uint256::BYTES];
value.to_little_endian(&mut bytes);
let bytes = value.to_little_endian();
Uint256::from_le_bytes(bytes)
}

Expand Down
1 change: 1 addition & 0 deletions gclient/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
//! }
//! ```

#![allow(clippy::result_large_err)]
#![warn(missing_docs)]
#![doc(html_logo_url = "https://docs.gear.rs/logo.svg")]
#![doc(html_favicon_url = "https://gear-tech.io/favicons/favicon.ico")]
Expand Down
2 changes: 1 addition & 1 deletion gsdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository.workspace = true
rust-version.workspace = true

[dependencies]
anyhow.workspace = true
anyhow = { workspace = true, features = ["std"] }
base64.workspace = true
colored.workspace = true
futures-util.workspace = true
Expand Down
1 change: 1 addition & 0 deletions gsdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#![doc(html_logo_url = "https://docs.gear.rs/logo.svg")]
#![doc(html_favicon_url = "https://gear-tech.io/favicons/favicon.ico")]
#![allow(clippy::result_large_err)]

//! Gear api
pub use crate::{
Expand Down
258 changes: 216 additions & 42 deletions gsdk/src/metadata/generated.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions gsdk/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub(crate) fn write_storage_address_root_bytes(addr: &impl Address, out: &mut Ve

/// Outputs the [`storage_address_root_bytes`] as well as any additional bytes that represent
/// a lookup in a storage map at that location.
#[allow(clippy::result_large_err)]
pub(crate) fn storage_address_bytes(
addr: &impl Address,
metadata: &Metadata,
Expand Down
4 changes: 2 additions & 2 deletions node/authorship/src/authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ where
let mut skipped = 0;
let mut unqueue_invalid = Vec::new();

let mut t1 = self.transaction_pool.ready_at(self.parent_number).fuse();
let mut t1 = self.transaction_pool.ready_at(self.parent_hash).fuse();
let mut t2 =
futures_timer::Delay::new(deadline.saturating_duration_since((self.now)()) / 8).fuse();

Expand Down Expand Up @@ -567,7 +567,7 @@ where
}

trace!(target: LOG_TARGET, "[{:?}] Pushing to the block.", pending_tx_hash);
match block_builder.push(pending_tx_data) {
match block_builder.push((*pending_tx_data).clone()) {
Ok(()) => {
transaction_pushed = true;
debug!(target: LOG_TARGET, "[{:?}] Pushed to the block.", pending_tx_hash);
Expand Down
30 changes: 14 additions & 16 deletions node/authorship/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use parking_lot::{Mutex, RwLock};
use runtime_primitives::{Block as TestBlock, BlockNumber};
use sc_client_api::Backend as _;
use sc_service::client::Client;
use sc_transaction_pool::{BasicPool, FullPool};
use sc_transaction_pool::{BasicPool, FullChainApi};
use sc_transaction_pool_api::{
ChainEvent, MaintainedTransactionPool, TransactionPool, TransactionSource,
};
Expand All @@ -53,7 +53,7 @@ use sp_consensus_babe::{
};
use sp_inherents::InherentDataProvider;
use sp_runtime::{
generic::BlockId,
generic::{BlockId, ExtrinsicFormat},
traits::{Block as BlockT, Header as HeaderT, NumberFor},
Digest, DigestItem, OpaqueExtrinsic, Perbill, Percent,
};
Expand All @@ -69,7 +69,7 @@ use testing::{
Backend as TestBackend, Client as TestClient, ClientBlockImportExt, RuntimeExecutor,
TestClientBuilder, TestClientBuilderExt,
},
keyring::{alice, bob, sign, signed_extra, CheckedExtrinsic},
keyring::{alice, bob, sign, tx_ext, CheckedExtrinsic},
};
use vara_runtime::{
AccountId, Runtime, RuntimeApi as RA, RuntimeCall, UncheckedExtrinsic, SLOT_DURATION, VERSION,
Expand Down Expand Up @@ -120,7 +120,7 @@ where
let last_nonce = starting_nonce + n;
(starting_nonce..last_nonce)
.map(|nonce| CheckedExtrinsic {
signed: Some((signer.clone(), signed_extra(nonce))),
format: ExtrinsicFormat::Signed(signer.clone(), tx_ext(nonce)),
function: f(),
})
.collect()
Expand Down Expand Up @@ -221,7 +221,7 @@ pub(crate) fn init_logger() {
pub fn init() -> (
Arc<TestClient>,
Arc<TestBackend>,
Arc<FullPool<TestBlock, TestClient>>,
Arc<BasicPool<FullChainApi<TestClient, TestBlock>, TestBlock>>,
sp_core::testing::TaskExecutor,
[u8; 32],
) {
Expand All @@ -230,13 +230,13 @@ pub fn init() -> (
let executor = get_executor().read();
let client = Arc::new(client_builder.build(Some(executor.clone())));
let spawner = sp_core::testing::TaskExecutor::new();
let txpool = BasicPool::new_full(
let txpool = Arc::from(BasicPool::new_full(
Default::default(),
true.into(),
None,
spawner.clone(),
client.clone(),
);
));

let genesis_hash =
<[u8; 32]>::try_from(&client.info().best_hash[..]).expect("H256 is a 32 byte type");
Expand Down Expand Up @@ -385,7 +385,7 @@ fn test_queue_remains_intact_if_processing_fails() {

// Disable queue processing in Gear pallet as the root
checked.push(CheckedExtrinsic {
signed: Some((alice(), signed_extra(0))),
format: ExtrinsicFormat::Signed(alice(), tx_ext(0)),
function: CallBuilder::toggle_run_queue(false).build(),
});
let extrinsics = sign_extrinsics(
Expand Down Expand Up @@ -605,12 +605,10 @@ fn test_pseudo_inherent_discarded_from_txpool() {

// Create Gear::run() extrinsic - both unsigned and signed
let unsigned_gear_run_xt =
UncheckedExtrinsic::new_unsigned(RuntimeCall::Gear(pallet_gear::Call::run {
max_gas: None,
}));
UncheckedExtrinsic::new_bare(RuntimeCall::Gear(pallet_gear::Call::run { max_gas: None }));
let signed_gear_run_xt = sign(
CheckedExtrinsic {
signed: Some((bob(), signed_extra(0))),
format: ExtrinsicFormat::Signed(bob(), tx_ext(0)),
function: RuntimeCall::Gear(pallet_gear::Call::run { max_gas: None }),
},
VERSION.spec_version,
Expand All @@ -621,7 +619,7 @@ fn test_pseudo_inherent_discarded_from_txpool() {
// A `DispatchClass::Normal` extrinsic - supposed to end up in the txpool
let legit_xt = sign(
CheckedExtrinsic {
signed: Some((alice(), signed_extra(0))),
format: ExtrinsicFormat::Signed(alice(), tx_ext(0)),
function: CallBuilder::noop().build(),
},
VERSION.spec_version,
Expand Down Expand Up @@ -734,7 +732,7 @@ fn test_proposal_timing_consistent() {

// Disable queue processing in block #1
let mut checked = vec![CheckedExtrinsic {
signed: Some((alice(), signed_extra(0))),
format: ExtrinsicFormat::Signed(alice(), tx_ext(0)),
function: CallBuilder::toggle_run_queue(false).build(),
}];

Expand Down Expand Up @@ -787,7 +785,7 @@ fn test_proposal_timing_consistent() {
// Re-enable queue processing in block #2
let extrinsics = sign_extrinsics(
vec![CheckedExtrinsic {
signed: Some((alice(), signed_extra(1))),
format: ExtrinsicFormat::Signed(alice(), tx_ext(1)),
function: CallBuilder::toggle_run_queue(true).build(),
}],
VERSION.spec_version,
Expand Down Expand Up @@ -917,7 +915,7 @@ mod basic_tests {
{
sign_extrinsics::<E>(
vec![CheckedExtrinsic {
signed: Some((alice(), signed_extra(nonce))),
format: ExtrinsicFormat::Signed(alice(), tx_ext(nonce)),
function: CallBuilder::toggle_run_queue(false).build(),
}],
VERSION.spec_version,
Expand Down
39 changes: 23 additions & 16 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use sc_service::{
TaskManager,
};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool::TransactionPoolHandle;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::ConstructRuntimeApi;
use sp_runtime::{
Expand Down Expand Up @@ -73,7 +74,8 @@ type FullGrandpaBlockImport<RuntimeApi, ChainSelection = FullSelectChain> =
>;

/// The transaction pool type definition.
type TransactionPool<RuntimeApi> = sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi>>;
pub type TransactionPool =
sc_transaction_pool::TransactionPoolHandle<Block, FullClient<crate::vara_runtime::RuntimeApi>>;

/// The minimum period of blocks on which justifications will be
/// imported and generated.
Expand Down Expand Up @@ -145,7 +147,7 @@ pub fn new_partial<RuntimeApi>(
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi>>,
sc_transaction_pool::TransactionPoolHandle<Block, FullClient<RuntimeApi>>,
(
impl Fn(
sc_rpc::SubscriptionTaskExecutor,
Expand Down Expand Up @@ -215,12 +217,15 @@ where

let select_chain = sc_consensus::LongestChain::new(backend.clone());

let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
config.role.is_authority().into(),
config.prometheus_registry(),
task_manager.spawn_essential_handle(),
client.clone(),
let transaction_pool = Arc::from(
sc_transaction_pool::Builder::new(
task_manager.spawn_essential_handle(),
client.clone(),
config.role.is_authority().into(),
)
.with_options(config.transaction_pool.clone())
.with_prometheus(config.prometheus_registry())
.build(),
);

let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
Expand Down Expand Up @@ -345,7 +350,7 @@ where
/// The syncing service of the node.
pub sync: Arc<SyncingService<Block>>,
/// The transaction pool of the node.
pub transaction_pool: Arc<TransactionPool<RuntimeApi>>,
pub transaction_pool: Arc<TransactionPoolHandle<Block, FullClient<RuntimeApi>>>,
/// The rpc handlers of the node.
pub rpc_handlers: RpcHandlers,
}
Expand Down Expand Up @@ -638,23 +643,25 @@ where
}

if enable_offchain_worker {
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-worker",
let offchain_workers =
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
is_validator: role.is_authority(),
keystore: Some(keystore_container.keystore()),
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: Arc::new(network.clone()),
is_validator: role.is_authority(),
enable_http_requests: true,
custom_extensions: |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
})?;
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
offchain_workers
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
);
}

Expand Down
Loading
Loading