Skip to content

Commit

Permalink
fix: 🩹 fix merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
TDemeco committed Oct 4, 2024
1 parent d697a9b commit 22cf3ab
Show file tree
Hide file tree
Showing 34 changed files with 70,240 additions and 74,243 deletions.
38,470 changes: 17,947 additions & 20,523 deletions Cargo.lock

Large diffs are not rendered by default.

9,226 changes: 4,503 additions & 4,723 deletions api-augment/dist/interfaces/lookup.js

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions api-augment/dist/interfaces/lookup.js.map

Large diffs are not rendered by default.

1,124 changes: 562 additions & 562 deletions api-augment/dist/types/interfaces/augment-api-consts.d.ts

Large diffs are not rendered by default.

2,390 changes: 1,195 additions & 1,195 deletions api-augment/dist/types/interfaces/augment-api-errors.d.ts

Large diffs are not rendered by default.

4,748 changes: 2,374 additions & 2,374 deletions api-augment/dist/types/interfaces/augment-api-events.d.ts

Large diffs are not rendered by default.

4,051 changes: 2,024 additions & 2,027 deletions api-augment/dist/types/interfaces/augment-api-query.d.ts

Large diffs are not rendered by default.

1,469 changes: 663 additions & 806 deletions api-augment/dist/types/interfaces/augment-api-runtime.d.ts

Large diffs are not rendered by default.

8,040 changes: 4,020 additions & 4,020 deletions api-augment/dist/types/interfaces/augment-api-tx.d.ts

Large diffs are not rendered by default.

5,245 changes: 2,621 additions & 2,624 deletions api-augment/dist/types/interfaces/augment-types.d.ts

Large diffs are not rendered by default.

8,574 changes: 4,177 additions & 4,397 deletions api-augment/dist/types/interfaces/lookup.d.ts

Large diffs are not rendered by default.

1,078 changes: 539 additions & 539 deletions api-augment/dist/types/interfaces/registry.d.ts

Large diffs are not rendered by default.

392 changes: 196 additions & 196 deletions api-augment/dist/types/interfaces/storagehubclient/types.d.ts

Large diffs are not rendered by default.

10,904 changes: 5,344 additions & 5,560 deletions api-augment/dist/types/interfaces/types-lookup.d.ts

Large diffs are not rendered by default.

1,140 changes: 570 additions & 570 deletions api-augment/src/interfaces/augment-api-consts.ts

Large diffs are not rendered by default.

2,406 changes: 1,203 additions & 1,203 deletions api-augment/src/interfaces/augment-api-errors.ts

Large diffs are not rendered by default.

3,648 changes: 1,824 additions & 1,824 deletions api-augment/src/interfaces/augment-api-events.ts

Large diffs are not rendered by default.

3,935 changes: 1,966 additions & 1,969 deletions api-augment/src/interfaces/augment-api-query.ts

Large diffs are not rendered by default.

1,351 changes: 631 additions & 720 deletions api-augment/src/interfaces/augment-api-runtime.ts

Large diffs are not rendered by default.

6,836 changes: 3,418 additions & 3,418 deletions api-augment/src/interfaces/augment-api-tx.ts

Large diffs are not rendered by default.

5,259 changes: 2,628 additions & 2,631 deletions api-augment/src/interfaces/augment-types.ts

Large diffs are not rendered by default.

9,228 changes: 4,504 additions & 4,724 deletions api-augment/src/interfaces/lookup.ts

Large diffs are not rendered by default.

1,092 changes: 546 additions & 546 deletions api-augment/src/interfaces/registry.ts

Large diffs are not rendered by default.

462 changes: 231 additions & 231 deletions api-augment/src/interfaces/storagehubclient/types.ts

Large diffs are not rendered by default.

11,452 changes: 5,616 additions & 5,836 deletions api-augment/src/interfaces/types-lookup.ts

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions api-augment/storagehub.json

Large diffs are not rendered by default.

65 changes: 16 additions & 49 deletions runtime/src/apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use pallet_payment_streams_runtime_api::*;
use pallet_proofs_dealer::types::{KeyFor, ProviderIdFor, RandomnessOutputFor};
use pallet_proofs_dealer_runtime_api::*;
use pallet_storage_providers::types::{
BackupStorageProvider, BackupStorageProviderId, ProviderId, StorageDataUnit, StorageProviderId,
BackupStorageProvider, BackupStorageProviderId, BucketId, MainStorageProviderId, ProviderId,
StorageDataUnit, StorageProviderId,
};
use pallet_storage_providers_runtime_api::*;
use shp_file_metadata::ChunkId;
Expand All @@ -24,13 +25,6 @@ use sp_runtime::{
};
use sp_std::prelude::Vec;
use sp_version::RuntimeVersion;
use xcm::{
latest::prelude::AssetId, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
};
use xcm_fee_payment_runtime_api::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
};

// Local module imports
use super::{
Expand Down Expand Up @@ -186,45 +180,6 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {

let acceptable_assets = vec![AssetId(configs::xcm_config::RelayLocation::get())];
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}
fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
match asset.try_as::<AssetId>() {
Ok(asset_id) if asset_id.0 == configs::xcm_config::RelayLocation::get() => {
// for native token
Ok(<WeightToFee as sp_weights::WeightToFee>::weight_to_fee(&weight))
},
Ok(asset_id) => {
log::trace!(target: "xcm::xcm_fee_payment_runtime_api", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");
Err(XcmPaymentApiError::AssetNotFound)
},
Err(_) => {
log::trace!(target: "xcm::xcm_fee_payment_runtime_api", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");
Err(XcmPaymentApiError::VersionedConversionFailed)
}
}
}
fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
PolkadotXcm::query_xcm_weight(message)
}
fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
PolkadotXcm::query_delivery_fees(destination, message)
}
}

impl xcm_fee_payment_runtime_api::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, configs::xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
}
fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_xcm::<Runtime, configs::xcm_config::XcmRouter, RuntimeCall, configs::xcm_config::XcmConfig>(origin_location, xcm)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
Expand Down Expand Up @@ -314,14 +269,18 @@ impl_runtime_apis! {
}
}

impl pallet_file_system_runtime_api::FileSystemApi<Block, BackupStorageProviderId<Runtime>, H256, BlockNumber, ChunkId> for Runtime {
impl pallet_file_system_runtime_api::FileSystemApi<Block, BackupStorageProviderId<Runtime>, MainStorageProviderId<Runtime>, H256, BlockNumber, ChunkId> for Runtime {
fn query_earliest_file_volunteer_tick(bsp_id: BackupStorageProviderId<Runtime>, file_key: H256) -> Result<BlockNumber, QueryFileEarliestVolunteerTickError> {
FileSystem::query_earliest_file_volunteer_tick(bsp_id, file_key)
}

fn query_bsp_confirm_chunks_to_prove_for_file(bsp_id: BackupStorageProviderId<Runtime>, file_key: H256) -> Result<Vec<ChunkId>, QueryBspConfirmChunksToProveForFileError> {
FileSystem::query_bsp_confirm_chunks_to_prove_for_file(bsp_id, file_key)
}

fn query_msp_confirm_chunks_to_prove_for_file(msp_id: MainStorageProviderId<Runtime>, file_key: H256) -> Result<Vec<ChunkId>, QueryMspConfirmChunksToProveForFileError> {
FileSystem::query_msp_confirm_chunks_to_prove_for_file(msp_id, file_key)
}
}

impl pallet_payment_streams_runtime_api::PaymentStreamsApi<Block, ProviderIdFor<Runtime>, Balance, AccountId> for Runtime {
Expand Down Expand Up @@ -377,7 +336,7 @@ impl_runtime_apis! {
}
}

impl pallet_storage_providers_runtime_api::StorageProvidersApi<Block, BlockNumber, BackupStorageProviderId<Runtime>, BackupStorageProvider<Runtime>, AccountId, ProviderId<Runtime>, StorageProviderId<Runtime>, StorageDataUnit<Runtime>, Balance> for Runtime {
impl pallet_storage_providers_runtime_api::StorageProvidersApi<Block, BlockNumber, BackupStorageProviderId<Runtime>, BackupStorageProvider<Runtime>, AccountId, ProviderId<Runtime>, StorageProviderId<Runtime>, StorageDataUnit<Runtime>, Balance, BucketId<Runtime>> for Runtime {
fn get_bsp_info(bsp_id: &BackupStorageProviderId<Runtime>) -> Result<BackupStorageProvider<Runtime>, GetBspInfoError> {
Providers::get_bsp_info(bsp_id)
}
Expand All @@ -386,6 +345,10 @@ impl_runtime_apis! {
Providers::get_storage_provider_id(who)
}

fn query_msp_id_of_bucket_id(bucket_id: &BucketId<Runtime>) -> Result<ProviderId<Runtime>, QueryMspIdOfBucketIdError> {
Providers::query_msp_id_of_bucket_id(bucket_id)
}

fn query_storage_provider_capacity(provider_id: &ProviderId<Runtime>) -> Result<StorageDataUnit<Runtime>, QueryStorageProviderCapacityError> {
Providers::query_storage_provider_capacity(provider_id)
}
Expand All @@ -401,5 +364,9 @@ impl_runtime_apis! {
fn get_worst_case_scenario_slashable_amount(provider_id: ProviderId<Runtime>) -> Option<Balance> {
Providers::get_worst_case_scenario_slashable_amount(&provider_id).ok()
}

fn get_slash_amount_per_max_file_size() -> Balance {
Providers::get_slash_amount_per_max_file_size()
}
}
}
50 changes: 21 additions & 29 deletions runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pub mod xcm_config;

// Substrate and Polkadot dependencies
use core::marker::PhantomData;
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use cumulus_pallet_parachain_system::{RelayChainStateProof, RelayNumberMonotonicallyIncreases};
use cumulus_primitives_core::{relay_chain::well_known_keys, AggregateMessageOrigin, ParaId};
use frame_support::{
derive_impl,
dispatch::DispatchClass,
Expand Down Expand Up @@ -58,7 +58,7 @@ use shp_file_metadata::{ChunkId, FileMetadata};
use shp_forest_verifier::ForestVerifier;
use shp_traits::{CommitmentVerifier, MaybeDebug};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{blake2_256, ConstU128, Get, Hasher, H256};
use sp_core::{ConstU128, Get, Hasher, H256};
use sp_runtime::{
traits::{BlakeTwo256, Convert, ConvertBack, Verify},
AccountId32, DispatchError, Perbill, SaturatedConversion,
Expand All @@ -73,8 +73,8 @@ use xcm::latest::prelude::BodyId;
use crate::{
weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
AccountId, Aura, Balance, Balances, Block, BlockNumber, BucketNfts, CollatorSelection, Hash,
MessageQueue, Nfts, Nonce, PalletInfo, ParachainSystem, PaymentStreams, PolkadotXcm,
ProofsDealer, Providers, Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason,
MessageQueue, Nfts, Nonce, PalletInfo, ParachainInfo, ParachainSystem, PaymentStreams,
PolkadotXcm, ProofsDealer, Providers, Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason,
RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, SessionKeys, Signature, System,
WeightToFee, XcmpQueue, AVERAGE_ON_INITIALIZE_RATIO, BLOCK_PROCESSING_VELOCITY, DAYS,
EXISTENTIAL_DEPOSIT, HOURS, MAXIMUM_BLOCK_WEIGHT, MICROUNIT, MINUTES, NORMAL_DISPATCH_RATIO,
Expand Down Expand Up @@ -393,7 +393,7 @@ fn relay_chain_state_proof() -> RelayChainStateProof {
.expect("set in `set_validation_data`");
RelayChainStateProof::new(ParachainInfo::get(), relay_storage_root, relay_chain_state)
.expect("Invalid relay chain state proof, already constructed in `set_validation_data`")
} */
}

pub struct BabeDataGetter;
impl pallet_randomness::GetBabeData<u64, Hash> for BabeDataGetter {
Expand All @@ -408,13 +408,11 @@ impl pallet_randomness::GetBabeData<u64, Hash> for BabeDataGetter {
const BENCHMARKING_NEW_EPOCH: u64 = 10u64;
return BENCHMARKING_NEW_EPOCH;
}
// CRITICAL TODO: Uncomment this after upgrading to polkadot-sdk v1.13.0 and remove frame_system::Pallet::<Runtime>::block_number().into()
/* relay_chain_state_proof()
.read_optional_entry(well_known_keys::EPOCH_INDEX)
.ok()
.flatten()
.expect("expected to be able to read epoch index from relay chain state proof") */
frame_system::Pallet::<Runtime>::block_number().into()
relay_chain_state_proof()
.read_optional_entry(well_known_keys::EPOCH_INDEX)
.ok()
.flatten()
.expect("expected to be able to read epoch index from relay chain state proof")
}
fn get_epoch_randomness() -> Hash {
if cfg!(feature = "runtime-benchmarks") {
Expand All @@ -426,13 +424,11 @@ impl pallet_randomness::GetBabeData<u64, Hash> for BabeDataGetter {
let benchmarking_babe_output = Hash::default();
return benchmarking_babe_output;
}
// CRITICAL TODO: Uncomment this after upgrading to polkadot-sdk v1.13.0 and remove H256::from_slice(&blake2_256(&Self::get_epoch_index().to_le_bytes()))
/* relay_chain_state_proof()
.read_optional_entry(well_known_keys::ONE_EPOCH_AGO_RANDOMNESS)
.ok()
.flatten()
.expect("expected to be able to read epoch randomness from relay chain state proof") */
H256::from_slice(&blake2_256(&Self::get_epoch_index().to_le_bytes()))
relay_chain_state_proof()
.read_optional_entry(well_known_keys::ONE_EPOCH_AGO_RANDOMNESS)
.ok()
.flatten()
.expect("expected to be able to read epoch randomness from relay chain state proof")
}
fn get_parent_randomness() -> Hash {
if cfg!(feature = "runtime-benchmarks") {
Expand All @@ -446,15 +442,11 @@ impl pallet_randomness::GetBabeData<u64, Hash> for BabeDataGetter {
}
// Note: we use the `CURRENT_BLOCK_RANDOMNESS` key here as it also represents the parent randomness, the only difference
// is the block since this randomness is valid, but we don't care about that because we are setting that directly in the `randomness` pallet.
/* relay_chain_state_proof()
.read_optional_entry(well_known_keys::CURRENT_BLOCK_RANDOMNESS)
.ok()
.flatten()
.expect("expected to be able to read parent randomness from relay chain state proof") */
// CRITICAL TODO: Uncomment this after upgrading to polkadot-sdk v1.13.0 and remove H256::from_slice(&blake2_256(&Self::get_epoch_index().saturating_sub(1).to_le_bytes()))
H256::from_slice(&blake2_256(
&Self::get_epoch_index().saturating_sub(1).to_le_bytes(),
))
relay_chain_state_proof()
.read_optional_entry(well_known_keys::CURRENT_BLOCK_RANDOMNESS)
.ok()
.flatten()
.expect("expected to be able to read parent randomness from relay chain state proof")
}
}

Expand Down
Loading

0 comments on commit 22cf3ab

Please sign in to comment.