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

Make on demand modules compatible with lower versions #133

Open
wants to merge 43 commits into
base: main-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c52044a
upgrade to subxt 0.37.0
sulijia Jul 21, 2024
1e3769a
upgrade RegionRecord struct
sulijia Jul 23, 2024
2bb12e5
make on demand module compatible with lower versions
sulijia Jul 24, 2024
c1f8c5f
decode low version RegionRecord
sulijia Jul 25, 2024
3a8e621
Merge branch 'main-develop' into features/OndemandMode
sulijia Jul 30, 2024
22ae5ea
don't delete lock file
sulijia Jul 31, 2024
9857cea
don't run cargo update
sulijia Jul 31, 2024
9d37284
Fixed: excessive deductions
toints Jul 31, 2024
40f8d04
Merge pull request #134 from toints/Magnet-Stack
toints Jul 31, 2024
83e175a
Update rust.yml
toints Jul 31, 2024
f9d7bfe
Merge branch 'refs/heads/main-develop' into Magnet-Stack
toints Jul 31, 2024
c743e0a
Merge branch 'Magnet-Stack-toints' into Magnet-Stack
toints Jul 31, 2024
da068d2
Merge pull request #138 from toints/Magnet-Stack
toints Jul 31, 2024
90c2361
Merge pull request #42 from Magport/Magnet-Stack-toints
toints Jul 31, 2024
529cf8b
optimism the asset-bridge
Acaishiba Aug 1, 2024
6b439f1
Revert "optimism the asset-bridge"
Acaishiba Aug 1, 2024
4feb584
optimism asset-bridge
Acaishiba Aug 1, 2024
fa8a543
Update rust.yml
zachary0809 Aug 1, 2024
a223fcd
Merge pull request #140 from zachary0809/Magnet-release-v0.7.2
Acaishiba Aug 1, 2024
34ab546
adjust fmt
Acaishiba Aug 1, 2024
e802f24
apply ensure_admin
Acaishiba Aug 1, 2024
f95d805
apply ensure_admin
Acaishiba Aug 2, 2024
5d07e5f
Merge pull request #139 from Magport/Magnet-release-0.7.2
wd30130 Aug 2, 2024
f497371
Merge pull request #141 from Magport/main-develop
sulijia Aug 2, 2024
4b652f8
Merge pull request #142 from Magport/Iteration/Assetbridge-optimism
sulijia Aug 2, 2024
3d01897
Merge branch 'Magport:main' into Magnet-Stack
toints Aug 9, 2024
102c486
Ability to configure whether to check GenesisHash, add configuration …
sulijia Aug 11, 2024
a368e2e
recover move pallet bechmark
sulijia Aug 11, 2024
44a1ab8
block time need set 12000 when async backing turn off
sulijia Aug 12, 2024
85526b8
Modify the gas threshold type, representing value/100
sulijia Aug 15, 2024
7216b6b
fixup cargo fmt error
sulijia Aug 15, 2024
537f32d
Modify the judgment logic of gas threshold
sulijia Aug 17, 2024
7a7250e
Fix coretime task's rpc connection
sulijia Aug 18, 2024
5135ad0
Merge pull request #150 from Magport/main-develop
toints Sep 5, 2024
a47caa1
Merge pull request #43 from Magport/Magnet-Stack-toints
toints Sep 5, 2024
896b4a1
fix: fixed relychain and parachain has different token decimals
toints Sep 5, 2024
e99734b
Merge pull request #151 from toints/Magnet-Stack
toints Sep 5, 2024
ba0f70c
style: format code with rustc-1.81.0
toints Sep 10, 2024
62cc00b
Merge pull request #153 from toints/Magnet-Stack
toints Sep 10, 2024
6efd0f7
Merge pull request #154 from Magport/Magnet-Stack-toints
sulijia Sep 13, 2024
4386a62
1.Modify move dependencies 2.In ondemand mode, only the information o…
sulijia Sep 13, 2024
e57bad5
fix cargo fmt bug
sulijia Sep 13, 2024
4740494
Fixed the bug that multiple collators do not create order when genera…
sulijia Sep 13, 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
1,792 changes: 1,158 additions & 634 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ schnellru = "0.2.1"
serde = { version = "1.0.188", default-features = false, features = ["derive", "alloc"] }
serde_json = "1.0.105"
smallvec = "1.11.0"
subxt = {version = "0.33.0"}
subxt-signer = {version = "0.33.0"}
subxt = {version = "0.37.0"}
subxt-signer = {version = "0.37.0"}
tracing = "0.1.37"
url = "2.4.0"
termcolor = "1.1.3"
Expand Down Expand Up @@ -118,7 +118,7 @@ sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "rel
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.0", default-features = false }
pallet-broker = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.0", default-features = false }
sp-storage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.0", default-features = false }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.0", default-features = false }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.0"}

# Substrate FRAME
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.0", default-features = false }
Expand Down
43 changes: 28 additions & 15 deletions client/coretime/bulk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ use futures::{lock::Mutex, select, FutureExt};
use mc_coretime_common::is_parathread;
use mp_coretime_bulk::{
self, well_known_keys::broker_regions, BulkMemRecord, BulkMemRecordItem, BulkRuntimeApi,
BulkStatus,
BulkStatus, RegionRecord, RegionRecordV0,
};
use mp_coretime_common::{
chain_state_snapshot::GenericStateProof, well_known_keys::SYSTEM_BLOCKHASH_GENESIS,
};
use pallet_broker::{CoreMask, RegionId, RegionRecord};
use pallet_broker::{CoreMask, RegionId};
use polkadot_primitives::{AccountId, Balance};
use sc_client_api::UsageProvider;
use sc_service::TaskManager;
Expand Down Expand Up @@ -80,7 +80,7 @@ where

let api = OnlineClient::<PolkadotConfig>::from_url(rpc_url).await?;

let mut blocks_sub = api.blocks().subscribe_best().await?;
let mut blocks_sub = api.blocks().subscribe_finalized().await?;

// For each block, print a bunch of information about it:
while let Some(block) = blocks_sub.next().await {
Expand All @@ -93,6 +93,7 @@ where
continue;
}
let block_number = block.header().number;
let block_hash = block.hash();

let mut bulk_record_local = bulk_record.lock().await;
bulk_record_local.coretime_para_height = block_number;
Expand Down Expand Up @@ -136,10 +137,8 @@ where
relevant_keys.push(region_key.as_slice());
relevant_keys.push(block_hash_key);

let proof = rpc
.state_get_read_proof(relevant_keys, Some(events.block_hash()))
.await
.unwrap();
let proof =
rpc.state_get_read_proof(relevant_keys, Some(block_hash)).await?;
let storage_proof =
StorageProof::new(proof.proof.into_iter().map(|bytes| bytes.to_vec()));

Expand All @@ -155,8 +154,23 @@ where
None,
)
.ok();
let mut proof_gen = false;
// Check proof is ok.
if head_data.is_some() {
proof_gen = true;
} else {
// decode to lower version
let head_data = relay_storage_rooted_proof
.read_entry::<RegionRecordV0<AccountId, Balance>>(
region_key.as_slice(),
None,
)
.ok();
if head_data.is_some() {
proof_gen = true;
}
}
if proof_gen {
// Record some data.
let record_item = BulkMemRecordItem {
storage_proof,
Expand All @@ -176,7 +190,6 @@ where

// Query CoreAssigned event.
let ev_core_assigned = event.as_event::<metadata::CoreAssigned>();

if let Ok(core_assigned_event) = ev_core_assigned {
if let Some(ev) = core_assigned_event {
log::info!(
Expand All @@ -198,12 +211,13 @@ where
let constant_query =
subxt::dynamic::constant("Broker", "TimeslicePeriod");

let time_slice =
api.constants()
.at(&constant_query)?
.to_value()?
.as_u128()
.expect("coretime parachain time slice none") as u32;
let time_slice = api
.constants()
.at(&constant_query)?
.to_value()?
.as_u128()
.expect("coretime parachain time slice none")
as u32;

item.end_relaychain_height =
ev.when + item.duration * time_slice;
Expand All @@ -219,7 +233,6 @@ where
}
}
}

Ok(())
}
pub async fn run_coretime_bulk_task<P, R, Block>(
Expand Down
74 changes: 37 additions & 37 deletions client/coretime/bulk/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
//! The data type here is generated by the subxt tool and represents the event-related data of the coretime parachain.
//!
#[derive(
:: subxt :: ext :: codec :: Decode,
:: subxt :: ext :: codec :: Encode,
:: subxt :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: scale_encode :: EncodeAsType,
:: subxt :: ext :: subxt_core :: ext :: codec :: Decode,
:: subxt :: ext :: subxt_core :: ext :: codec :: Encode,
:: subxt :: ext :: subxt_core :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: subxt_core :: ext :: scale_encode :: EncodeAsType,
Debug,
)]
# [codec (crate = :: subxt :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")]
# [codec (crate = :: subxt :: ext :: subxt_core :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_encode")]
pub enum CoreAssignment {
#[codec(index = 0)]
Idle,
Expand All @@ -38,71 +38,71 @@ pub enum CoreAssignment {
}

#[derive(
:: subxt :: ext :: codec :: Decode,
:: subxt :: ext :: codec :: Encode,
:: subxt :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: scale_encode :: EncodeAsType,
:: subxt :: ext :: subxt_core :: ext :: codec :: Decode,
:: subxt :: ext :: subxt_core :: ext :: codec :: Encode,
:: subxt :: ext :: subxt_core :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: subxt_core :: ext :: scale_encode :: EncodeAsType,
Debug,
)]
# [codec (crate = :: subxt :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")]
# [codec (crate = :: subxt :: ext :: subxt_core :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_encode")]
pub struct CoreAssigned {
pub core: u16,
pub when: u32,
pub assignment: Vec<(CoreAssignment, u16)>,
}

impl subxt::events::StaticEvent for CoreAssigned {
impl ::subxt::ext::subxt_core::events::StaticEvent for CoreAssigned {
const PALLET: &'static str = "Broker";
const EVENT: &'static str = "CoreAssigned";
}

#[derive(
:: subxt :: ext :: codec :: Decode,
:: subxt :: ext :: codec :: Encode,
:: subxt :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: scale_encode :: EncodeAsType,
:: subxt :: ext :: subxt_core :: ext :: codec :: Decode,
:: subxt :: ext :: subxt_core :: ext :: codec :: Encode,
:: subxt :: ext :: subxt_core :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: subxt_core :: ext :: scale_encode :: EncodeAsType,
Debug,
)]
# [codec (crate = :: subxt :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")]
# [codec (crate = :: subxt :: ext :: subxt_core :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_encode")]
pub struct CoreMask(pub [u8; 10usize]);

#[derive(
:: subxt :: ext :: codec :: Decode,
:: subxt :: ext :: codec :: Encode,
:: subxt :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: scale_encode :: EncodeAsType,
:: subxt :: ext :: subxt_core :: ext :: codec :: Decode,
:: subxt :: ext :: subxt_core :: ext :: codec :: Encode,
:: subxt :: ext :: subxt_core :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: subxt_core :: ext :: scale_encode :: EncodeAsType,
Debug,
)]
# [codec (crate = :: subxt :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")]
# [codec (crate = :: subxt :: ext :: subxt_core :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_encode")]
pub struct RegionId {
pub begin: u32,
pub core: u16,
pub mask: CoreMask,
}

#[derive(
:: subxt :: ext :: codec :: Decode,
:: subxt :: ext :: codec :: Encode,
:: subxt :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: scale_encode :: EncodeAsType,
:: subxt :: ext :: subxt_core :: ext :: codec :: Decode,
:: subxt :: ext :: subxt_core :: ext :: codec :: Encode,
:: subxt :: ext :: subxt_core :: ext :: scale_decode :: DecodeAsType,
:: subxt :: ext :: subxt_core :: ext :: scale_encode :: EncodeAsType,
Debug,
)]
# [codec (crate = :: subxt :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")]
# [codec (crate = :: subxt :: ext :: subxt_core :: ext :: codec)]
#[decode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_decode")]
#[encode_as_type(crate_path = ":: subxt :: ext :: subxt_core :: ext :: scale_encode")]
pub struct Assigned {
pub region_id: RegionId,
pub duration: u32,
pub task: u32,
}

impl ::subxt::events::StaticEvent for Assigned {
impl ::subxt::ext::subxt_core::events::StaticEvent for Assigned {
const PALLET: &'static str = "Broker";
const EVENT: &'static str = "Assigned";
}
2 changes: 2 additions & 0 deletions client/coretime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ tracing = { workspace = true }
schnellru = { workspace = true }
log = { workspace = true }
subxt = { workspace = true, features = ["substrate-compat"]}
scale-info = { workspace = true, features = ["derive", "serde"] }

mp-coretime-common = { path = "../../../primitives/coretime/common"}

Expand All @@ -42,6 +43,7 @@ substrate-prometheus-endpoint = { workspace = true }
sc-service = { workspace = true }
pallet-broker = { workspace = true}
sp-storage = { workspace = true }
frame-support = { workspace = true }

# Cumulus
cumulus-client-consensus-common = { workspace = true }
Expand Down
Loading
Loading