Skip to content

Commit

Permalink
Merge branch 'dev' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
steinerkelvin committed Jan 30, 2025
2 parents a7807f3 + 0915902 commit 3c26c43
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ on:
tags:
- "runtime/*"
branches:
- "testnet"
- "github-ci-test"
- "build-runtime*"
- "testnet"

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## Spec 2

- fix: expired expire applications only if they are Open
- fix: `torus0` on_initialize hook
4 changes: 2 additions & 2 deletions data/mainnet/spec.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions pallets/governance/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,18 @@ pub fn deny_application<T: crate::Config>(application_id: u32) -> DispatchResult

pub(crate) fn resolve_expired_applications<T: crate::Config>(current_block: Block) {
for application in crate::AgentApplications::<T>::iter_values() {
if current_block < application.expires_at {
// Skip if not expired yet or if not in Open status
if current_block < application.expires_at
|| !matches!(application.status, ApplicationStatus::Open)
{
continue;
}

crate::AgentApplications::<T>::mutate(application.id, |application| {
if let Some(app) = application {
app.status = ApplicationStatus::Expired;
if matches!(app.status, ApplicationStatus::Open) {
app.status = ApplicationStatus::Expired;
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion pallets/governance/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<T: crate::Config> Default for GovernanceConfiguration<T> {
Self {
proposal_cost: T::DefaultProposalCost::get(),
proposal_expiration: T::DefaultProposalExpiration::get(), //130_000,
agent_application_cost: T::DefaultAgentApplicationCost::get(), //1_000_000_000_000_000_000_000,
agent_application_cost: T::DefaultAgentApplicationCost::get(), //100_000_000_000_000_000_000,
agent_application_expiration: T::DefaultAgentApplicationExpiration::get(), //2_000,
proposal_reward_treasury_allocation: T::DefaultProposalRewardTreasuryAllocation::get(), //Percent::from_percent(2),
max_proposal_reward_treasury_allocation:
Expand Down
4 changes: 4 additions & 0 deletions pallets/governance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pub mod application;
pub mod config;
pub mod ext;
pub mod migrations;
pub mod proposal;
pub mod roles;
pub mod voting;
Expand Down Expand Up @@ -136,7 +137,10 @@ pub mod pallet {
type WeightInfo: WeightInfo;
}

const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

#[pallet::hooks]
Expand Down
16 changes: 16 additions & 0 deletions pallets/governance/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pub mod next {
use crate::{Config, GlobalGovernanceConfig, Pallet};
use polkadot_sdk::frame_support::{
migrations::VersionedMigration, traits::UncheckedOnRuntimeUpgrade, weights::Weight,
};

pub type Migration<T, W> = VersionedMigration<0, 1, MigrateToNext<T>, Pallet<T>, W>;
pub struct MigrateToNext<T>(core::marker::PhantomData<T>);

impl<T: Config> UncheckedOnRuntimeUpgrade for MigrateToNext<T> {
fn on_runtime_upgrade() -> Weight {
GlobalGovernanceConfig::<T>::put(crate::config::GovernanceConfiguration::default());
Weight::zero()
}
}
}
1 change: 0 additions & 1 deletion pallets/torus0/src/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ where
}
}

#[allow(dead_code)]
pub fn adjust_burn<T: crate::Config>(current_block: u64) {
let BurnConfiguration {
min_burn,
Expand Down
23 changes: 10 additions & 13 deletions pallets/torus0/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,19 @@ pub mod pallet {
#[pallet::storage]
pub type BurnConfig<T: Config> = StorageValue<_, BurnConfiguration<T>, ValueQuery>;

#[pallet_section]
pub mod hooks {
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(block_number: BlockNumberFor<T>) -> Weight {
let current_block: u64 = block_number
.try_into()
.ok()
.expect("blockchain won't pass 2 ^ 64 blocks");
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(block_number: BlockNumberFor<T>) -> Weight {
let current_block: u64 = block_number
.try_into()
.ok()
.expect("blockchain won't pass 2 ^ 64 blocks");

burn::adjust_burn::<T>(current_block);
burn::adjust_burn::<T>(current_block);

RegistrationsThisBlock::<T>::set(0);
RegistrationsThisBlock::<T>::set(0);

Weight::default()
}
Weight::default()
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl pallet_governance::Config for Runtime {

type DefaultProposalExpiration = ConstU64<75_600>;

type DefaultAgentApplicationCost = ConstU128<{ as_tors(1_000) }>;
type DefaultAgentApplicationCost = ConstU128<{ as_tors(100) }>;

type DefaultAgentApplicationExpiration = ConstU64<216_000>;

Expand Down
6 changes: 3 additions & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use interface::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use weights::constants::RocksDbWeight;

use polkadot_sdk::{
frame_executive, frame_support, frame_system,
Expand Down Expand Up @@ -38,7 +39,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("torus-runtime"),
impl_name: create_runtime_str!("torus-runtime"),
authoring_version: 1,
spec_version: 0,
spec_version: 2,
impl_version: 1,
apis: apis::RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -82,8 +83,7 @@ pub type SignedPayload = sp_runtime::generic::SignedPayload<RuntimeCall, SignedE
/// All migrations of the runtime, aside from the ones declared in the pallets.
///
/// This can be a tuple of types, each implementing `OnRuntimeUpgrade`.
#[allow(unused_parens)]
type Migrations = ();
type Migrations = (pallet_governance::migrations::next::Migration<Runtime, RocksDbWeight>,);

/// Executive: handles dispatch to the various modules.
pub type RuntimeExecutive = frame_executive::Executive<
Expand Down

0 comments on commit 3c26c43

Please sign in to comment.