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

feat: change application cost #68

Closed
wants to merge 4 commits into from
Closed
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
42 changes: 31 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Building
name: Build Torus Runtime

on:
workflow_dispatch:
push:
branches: [github-ci-test]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steinerkelvin marked this conversation as resolved.
Show resolved Hide resolved
tags:
- "v*"
- "runtime-*"
- "runtime/*"
branches:
- github-ci-test
- build-runtime

jobs:
build:
Expand All @@ -23,15 +25,33 @@ jobs:
run: |
rustup set profile minimal
rustup show
rustc --version

- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: 3.20.1
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run build
env:
SKIP_WASM_BUILD: 1
run: cargo build
- name: Build runtime
run: |
cargo build --release --timings --package torus-runtime

export SHA256SUM=$(sha256sum target/release/wbuild/torus-runtime/torus_runtime.compact.compressed.wasm | cut -d ' ' -f1)
echo Hash of compact and compressed WASM: $SHA256SUM

mkdir out
mv target/release/wbuild/torus-runtime/torus_runtime.compact.compressed.wasm out/
touch out/$SHA256SUM

- uses: actions/upload-artifact@v4
with:
name: torus_runtime.compact.compressed
path: out/
if-no-files-found: error
overwrite: true

- uses: actions/upload-artifact@v4
with:
name: torus-runtime-timings
path: target/cargo-timings/cargo-timing.html
overwrite: true
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()
}
}
}
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: 1,
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