Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rust 1.88
rust 1.90
make 4.3
cmake 3.24.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ make start-frequency-with-offchain
2. Use [srtool](https://github.com/paritytech/srtool) and [srtool-cli](https://github.com/chevdor/srtool-cli) to verify
the runtime:
```sh
SRTOOL_TAG="1.88.0" srtool build \
SRTOOL_TAG="1.90.0" srtool build \
--build-opts="'--features on-chain-release-build,no-metadata-docs,frequency'" \
--profile=release \
--package=frequency-runtime \
Expand Down
22 changes: 10 additions & 12 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,16 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
} else if ChainIdentity::FrequencyPaseo == spec.identify() {
#[cfg(feature = "frequency-testnet")]
{
return Ok(Box::new(chain_spec::frequency_paseo::ChainSpec::from_json_file(
path_buf,
)?));
Ok(Box::new(chain_spec::frequency_paseo::ChainSpec::from_json_file(path_buf)?))
}
#[cfg(not(feature = "frequency-testnet"))]
return Err("Frequency Paseo runtime is not available.".into());
} else if ChainIdentity::FrequencyLocal == spec.identify() {
#[cfg(feature = "frequency-local")]
{
return Ok(Box::new(
chain_spec::frequency_paseo_local::ChainSpec::from_json_file(path_buf)?,
));
Ok(Box::new(chain_spec::frequency_paseo_local::ChainSpec::from_json_file(
path_buf,
)?))
}
#[cfg(not(feature = "frequency-local"))]
return Err("Frequency Local runtime is not available.".into());
Expand All @@ -189,23 +187,23 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
} else if ChainIdentity::FrequencyDev == spec.identify() {
#[cfg(feature = "frequency-no-relay")]
{
return Ok(Box::new(
chain_spec::frequency_paseo_local::ChainSpec::from_json_file(path_buf)?,
));
Ok(Box::new(chain_spec::frequency_paseo_local::ChainSpec::from_json_file(
path_buf,
)?))
}
#[cfg(not(feature = "frequency-no-relay"))]
return Err("Frequency Dev (no relay) runtime is not available.".into());
} else if ChainIdentity::FrequencyWestend == spec.identify() {
#[cfg(feature = "frequency-westend")]
{
return Ok(Box::new(chain_spec::frequency_westend::ChainSpec::from_json_file(
Ok(Box::new(chain_spec::frequency_westend::ChainSpec::from_json_file(
path_buf,
)?));
)?))
}
#[cfg(not(feature = "frequency-westend"))]
return Err("Frequency Westend runtime is not available.".into());
} else {
return Err("Unknown chain spec.".into());
Err("Unknown chain spec.".into())
}
},
}
Expand Down
6 changes: 3 additions & 3 deletions pallets/capacity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ pub mod pallet {

/// Storage for keeping a ledger of staked token amounts for accounts.
/// - Keys: AccountId
/// - Value: [`StakingDetails`](types::StakingDetails)
/// - Value: [`StakingDetails`]
Copy link
Copy Markdown
Collaborator Author

@aramikm aramikm Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated due to 1.90 required linting guidelines

#[pallet::storage]
pub type StakingAccountLedger<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, StakingDetails<T>>;

/// Storage to record how many tokens were targeted to an MSA.
/// - Keys: AccountId, MSA Id
/// - Value: [`StakingTargetDetails`](types::StakingTargetDetails)
/// - Value: [`StakingTargetDetails`]
#[pallet::storage]
pub type StakingTargetLedger<T: Config> = StorageDoubleMap<
_,
Expand All @@ -211,7 +211,7 @@ pub mod pallet {

/// Storage for target Capacity usage.
/// - Keys: MSA Id
/// - Value: [`CapacityDetails`](types::CapacityDetails)
/// - Value: [`CapacityDetails`]
#[pallet::storage]
pub type CapacityLedger<T: Config> =
StorageMap<_, Twox64Concat, MessageSourceId, CapacityDetails<BalanceOf<T>, T::EpochNumber>>;
Expand Down
28 changes: 1 addition & 27 deletions pallets/capacity/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ use crate as pallet_capacity;

use crate::{
tests::testing_utils::set_era_and_reward_pool, BalanceOf, Config, ProviderBoostRewardPools,
ProviderBoostRewardsProvider, RewardPoolHistoryChunk, STAKED_PERCENTAGE_TO_BOOST,
RewardPoolHistoryChunk,
};
use common_primitives::{
msa::IntentId,
node::{AccountId, ProposalProvider},
schema::{SchemaId, SchemaValidator},
};
use common_runtime::{constants::*, weights};
use core::ops::Mul;
use frame_support::{
construct_runtime, parameter_types,
traits::{
Expand Down Expand Up @@ -154,31 +153,6 @@ impl pallet_msa::Config for Test {
type Currency = pallet_balances::Pallet<Self>;
}

// not used yet
pub struct TestRewardsProvider {}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used


impl ProviderBoostRewardsProvider<Test> for TestRewardsProvider {
type Balance = BalanceOf<Test>;

// To reflect new economic model behavior of having a constant RewardPool amount.
fn reward_pool_size(_total_staked: Self::Balance) -> Self::Balance {
10_000u64
}

// use the pallet version of the era calculation.
fn era_staking_reward(
amount_staked: Self::Balance,
total_staked: Self::Balance,
reward_pool_size: Self::Balance,
) -> Self::Balance {
Capacity::era_staking_reward(amount_staked, total_staked, reward_pool_size)
}

fn capacity_boost(amount: Self::Balance) -> Self::Balance {
Perbill::from_percent(STAKED_PERCENTAGE_TO_BOOST).mul(amount)
}
}

// Needs parameter_types! for the Perbill
parameter_types! {
pub const TestCapacityPerToken: Perbill = Perbill::from_percent(10);
Expand Down
6 changes: 3 additions & 3 deletions pallets/messages/src/migration/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(crate) fn migrate_single_record<T: Config>(
false
};

if !messages_remain || cursor.3 % <u64>::from(T::MigrateEmitEvery::get()) == 0 {
if !messages_remain || cursor.3.is_multiple_of(<u64>::from(T::MigrateEmitEvery::get())) {
Comment thread
JoeCap08055 marked this conversation as resolved.
Pallet::<T>::deposit_event(Event::<T>::MessagesMigrated {
from_version: 2,
to_version: 3,
Expand All @@ -67,7 +67,7 @@ pub(crate) fn migrate_single_record<T: Config>(
messages_remain
}

/// Migrates the items of the [`v2::MessagesV2`] map to [`crate::MessagesV3`]
/// Migrates the items of the `MessagesV2` map to `MessagesV3`
///
/// The `step` function will be called once per block. It is very important that this function
/// *never* panics and never uses more weight than it got in its meter. The migrations should also
Expand Down Expand Up @@ -143,7 +143,7 @@ impl<T: Config, W: weights::WeightInfo> SteppedMigration for MigrateV2ToV3<T, W>
}
}

/// Finalize the migration of [`v2::MessagesV2`] map to [`crate::MessagesV3`]
/// Finalize the migration of `MessagesV2` map to `MessagesV3`
/// by updating the pallet storage version.
pub struct FinalizeV3Migration<T: Config, W: weights::WeightInfo>(PhantomData<(T, W)>);
impl<T: Config, W: weights::WeightInfo> SteppedMigration for FinalizeV3Migration<T, W> {
Expand Down
6 changes: 3 additions & 3 deletions pallets/msa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub mod pallet {

/// Storage type for mapping the relationship between a Delegator and its Provider.
/// - Keys: Delegator MSA, Provider MSA
/// - Value: [`Delegation`](common_primitives::msa::Delegation)
/// - Value: [`Delegation`]
#[pallet::storage]
pub type DelegatorAndProviderToDelegation<T: Config> = StorageDoubleMap<
_,
Expand All @@ -218,7 +218,7 @@ pub mod pallet {

/// Provider registration information
/// - Key: Provider MSA Id
/// - Value: [`ProviderRegistryEntry`](common_primitives::msa::ProviderRegistryEntry)
/// - Value: [`ProviderRegistryEntry`]
#[deprecated(
note = "Use ProviderToRegistryEntryV2 instead, this will removed from frequency version 1.17.6"
)]
Expand All @@ -233,7 +233,7 @@ pub mod pallet {

/// Provider registration information
/// - Key: Provider MSA Id
/// - Value: [`ProviderRegistryEntry`](common_primitives::msa::ProviderRegistryEntry)
/// - Value: [`ProviderRegistryEntry`]
#[pallet::storage]
pub type ProviderToRegistryEntryV2<T: Config> = StorageMap<
_,
Expand Down
2 changes: 1 addition & 1 deletion pallets/msa/src/offchain_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn offchain_index_initial_state<T: Config>(block_number: BlockNumberFor<T>) -> L

// extend the initial index lock
counter += 1;
if counter % 1000 == 0 {
if counter.is_multiple_of(1000) {
log::info!("Added {counter} more keys!");
if guard.extend_lock().is_err() {
log::warn!("lock is expired in block {block_number:?}");
Expand Down
20 changes: 2 additions & 18 deletions pallets/schemas/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use frame_support::{
assert_ok,
dispatch::RawOrigin,
traits::{ConstU16, ConstU32, EitherOfDiverse},
weights::{Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial},
weights::Weight,
BoundedVec,
};
use frame_system::EnsureRoot;
Expand All @@ -11,11 +11,10 @@ use parity_scale_codec::MaxEncodedLen;
use common_primitives::node::AccountId;
use common_runtime::constants::DAYS;
use pallet_collective::{self, Members};
use smallvec::smallvec;
use sp_core::{parameter_types, Encode, H256};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
AccountId32, BuildStorage, DispatchError, Perbill,
AccountId32, BuildStorage, DispatchError,
};

use crate as pallet_schemas;
Expand Down Expand Up @@ -69,21 +68,6 @@ impl pallet_collective::Config<CouncilCollective> for Test {

pub type MaxIntentsPerIntentGroup = ConstU32<10>;

pub struct WeightToFee;

impl WeightToFeePolynomial for WeightToFee {
type Balance = u64;

fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
smallvec![WeightToFeeCoefficient {
degree: 1,
coeff_frac: Perbill::zero(),
coeff_integer: 1,
negative: false,
}]
}
}

/// Interface to collective pallet to propose a proposal.
pub struct CouncilProposalProvider;

Expand Down
8 changes: 4 additions & 4 deletions pallets/stateful-storage/src/migration/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn process_paginated_page<T: Config, N: Get<u32>>(
cur: &mut ChildCursor<N>,
) -> Result<bool, SteppedMigrationError> {
let Some(k) = next_key(child, &cur.last_key).unwrap_or(None) else {
if cur.id % <u64>::from(T::MigrateEmitEvery::get()) == 0 {
if cur.id.is_multiple_of(<u64>::from(T::MigrateEmitEvery::get())) {
Pallet::<T>::deposit_event(Event::<T>::StatefulPagesMigrated {
last_trie: (cur.id, PayloadLocation::Paginated),
total_page_count: cur.cumulative_pages,
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn process_paginated_page<T: Config, N: Get<u32>>(
cur.last_key = k;
cur.cumulative_pages += 1;

if cur.cumulative_pages % <u64>::from(T::MigrateEmitEvery::get()) == 0 {
if cur.cumulative_pages.is_multiple_of(<u64>::from(T::MigrateEmitEvery::get())) {
Pallet::<T>::deposit_event(Event::<T>::StatefulPagesMigrated {
last_trie: (cur.id, PayloadLocation::Paginated),
total_page_count: cur.cumulative_pages,
Expand All @@ -107,7 +107,7 @@ pub fn process_itemized_page<T: Config, N: Get<u32>>(
cur: &mut ChildCursor<N>,
) -> Result<bool, SteppedMigrationError> {
let Some(k) = next_key(child, &cur.last_key).unwrap_or(None) else {
if cur.id % <u64>::from(T::MigrateEmitEvery::get()) == 0 {
if cur.id.is_multiple_of(<u64>::from(T::MigrateEmitEvery::get())) {
Pallet::<T>::deposit_event(Event::<T>::StatefulPagesMigrated {
last_trie: (cur.id, PayloadLocation::Paginated),
total_page_count: cur.cumulative_pages,
Expand Down Expand Up @@ -156,7 +156,7 @@ pub fn process_itemized_page<T: Config, N: Get<u32>>(
cur.last_key = k;
cur.cumulative_pages += 1;

if cur.cumulative_pages % <u64>::from(T::MigrateEmitEvery::get()) == 0 {
if cur.cumulative_pages.is_multiple_of(<u64>::from(T::MigrateEmitEvery::get())) {
Pallet::<T>::deposit_event(Event::<T>::StatefulPagesMigrated {
last_trie: (cur.id, PayloadLocation::Itemized),
total_page_count: cur.cumulative_pages,
Expand Down
4 changes: 2 additions & 2 deletions pallets/stateful-storage/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait ItemizedOperations<T: Config> {
) -> Result<ItemizedPage<T>, PageError>;

/// Parses all the items inside an ItemPage
fn try_parse(&self, include_header: bool) -> Result<ParsedItemPage, PageError>;
fn try_parse(&self, include_header: bool) -> Result<ParsedItemPage<'_>, PageError>;
}
/// Defines the actions that can be applied to an Itemized storage
#[derive(
Expand Down Expand Up @@ -582,7 +582,7 @@ impl<T: Config> ItemizedOperations<T> for ItemizedPage<T> {

/// Parses all the items inside an ItemPage
/// This has O(n) complexity when n is the number of all the bytes in that itemized storage
fn try_parse(&self, include_header: bool) -> Result<ParsedItemPage, PageError> {
fn try_parse(&self, include_header: bool) -> Result<ParsedItemPage<'_>, PageError> {
let mut count = 0u16;
let mut items = BTreeMap::new();
let mut page_slice = &self.data[..];
Expand Down
62 changes: 52 additions & 10 deletions resources/genesis-schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@
"payload_location": "IPFS",
"status": "Active",
"model": "[{\"name\":\"announcementType\",\"column_type\":{\"INTEGER\":{\"bit_width\":32,\"sign\":true}},\"compression\":\"GZIP\",\"bloom_filter\":false},{\"name\":\"fromId\",\"column_type\":{\"INTEGER\":{\"bit_width\":64,\"sign\":false}},\"compression\":\"GZIP\",\"bloom_filter\":true},{\"name\":\"subject\",\"column_type\":{\"INTEGER\":{\"bit_width\":64,\"sign\":false}},\"compression\":\"GZIP\",\"bloom_filter\":true},{\"name\":\"url\",\"column_type\":\"STRING\",\"compression\":\"GZIP\",\"bloom_filter\":false},{\"name\":\"contentHash\",\"column_type\":\"STRING\",\"compression\":\"GZIP\",\"bloom_filter\":true},{\"name\":\"attributeSetType\",\"column_type\":\"STRING\",\"compression\":\"GZIP\",\"bloom_filter\":true},{\"name\":\"issuer\",\"column_type\":\"STRING\",\"compression\":\"GZIP\",\"bloom_filter\":true}]"
},
{
"schema_id": 21,
"intent_id": 21,
"model_type": "AvroBinary",
"payload_location": "Itemized",
"status": "Active",
"model": "{\"type\":\"record\",\"name\":\"PublicKey\",\"namespace\":\"ics\",\"fields\":[{\"name\":\"publicKey\",\"doc\":\"Multicodec public key\",\"type\":\"bytes\"}]}"
},
{
"schema_id": 22,
"intent_id": 22,
"model_type": "AvroBinary",
"payload_location": "Itemized",
"status": "Active",
"model": "{\"type\":\"record\",\"name\":\"ContextGroupACL\",\"namespace\":\"ics\",\"fields\":[{\"name\":\"prid\",\"type\":\"fixed\",\"size\":8,\"doc\":\"Pseudonymous Relationship Identifier\"},{\"name\":\"keyId\",\"type\":\"long\",\"doc\":\"User-Assigned Key Identifier used for PRID and encryption\"},{\"name\":\"nonce\",\"type\":\"fixed\",\"size\":12,\"doc\":\"Nonce used in encryptedProviderMsaId encryption (12 bytes)\"},{\"name\":\"encryptedProviderId\",\"type\":\"bytes\",\"maxLength\":10,\"doc\":\"Encrypted provider Msa id\"}]}"
},
{
"schema_id": 23,
"intent_id": 23,
"model_type": "AvroBinary",
"payload_location": "Paginated",
"status": "Active",
"model": "{\"type\":\"record\",\"name\":\"ContextGroupMetadata\",\"namespace\":\"ics\",\"fields\":[{\"name\":\"prid\",\"type\":\"fixed\",\"size\":8,\"doc\":\"Pseudonymous Relationship Identifier\"},{\"name\":\"keyId\",\"type\":\"long\",\"doc\":\"User-Assigned Key Identifier used for PRID\"},{\"name\":\"locationUri\",\"type\":\"string\",\"maxLength\":800,\"doc\":\"URI pointing to the location of stored Context Group\"},{\"name\":\"contentHash\",\"type\":[\"null\",\"string\"],\"default\":null,\"maxLength\":128,\"doc\":\"Optional multihash of the content in base58 encoding\"}]}"
}
],
"intents": [
Expand All @@ -185,9 +209,7 @@
{
"intent_id": 14,
"payload_location": "Itemized",
"settings": [
"SignatureRequired"
],
"settings": ["SignatureRequired"],
"name": "dsnp.public-key-assertion-method"
},
{
Expand All @@ -199,9 +221,7 @@
{
"intent_id": 21,
"payload_location": "Itemized",
"settings": [
"SignatureRequired"
],
"settings": ["SignatureRequired"],
"name": "frequency.default-token-address"
},
{
Expand Down Expand Up @@ -255,10 +275,7 @@
{
"intent_id": 7,
"payload_location": "Itemized",
"settings": [
"AppendOnly",
"SignatureRequired"
],
"settings": ["AppendOnly", "SignatureRequired"],
"name": "dsnp.public-key-key-agreement"
},
{
Expand Down Expand Up @@ -302,6 +319,31 @@
"payload_location": "IPFS",
"settings": [],
"name": "dsnp.user-attribute-set"
},
{
"intent_id": 21,
"payload_location": "Itemized",
"settings": [
"AppendOnly",
"SignatureRequired"
],
"name": "ics.public-key-key-agreement"
},
{
"intent_id": 22,
"payload_location": "Itemized",
"settings": [
"SignatureRequired"
],
"name": "ics.context-group-acl"
},
{
"intent_id": 23,
"payload_location": "Paginated",
"settings": [
"SignatureRequired"
],
"name": "ics.context-group-metadata"
}
],
"intent_groups": []
Expand Down
Loading