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

[CSUB-874] Update bag thresholds #1383

Merged
merged 8 commits into from
Nov 6, 2023
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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ updates:
schedule:
interval: "monthly"

- package-ecosystem: "cargo"
directory: "/runtime/generate-bags"
schedule:
interval: "monthly"

- package-ecosystem: "cargo"
directory: "/sha3pow"
schedule:
Expand Down
101 changes: 74 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ members = [
"test/client",
"test/runtime-utils",
"test/traced-test",
'runtime/generate-bags',
]

resolver = "2"

[workspace.package]
version = '2.234.0'
version = '2.235.0'
authors = ['Gluwa Inc.', 'Nathan Whitaker <nathan.whitaker@gluwa.com>']
edition = '2021'
license = 'Unlicense'
Expand Down Expand Up @@ -152,3 +153,4 @@ pallet-proxy = { branch = "pos-keep-history-polkadot-v0.9.41", git = "https://gi
pallet-fast-unstake = { branch = "pos-keep-history-polkadot-v0.9.41", git = "https://github.com/gluwa/substrate.git", default-features = false }
pallet-nomination-pools = { branch = "pos-keep-history-polkadot-v0.9.41", git = "https://github.com/gluwa/substrate.git", default-features = false }
pallet-identity = { branch = "pos-keep-history-polkadot-v0.9.41", git = "https://github.com/gluwa/substrate.git", default-features = false }
generate-bags = { branch = "pos-keep-history-polkadot-v0.9.41", git = "https://github.com/gluwa/substrate.git" } # Utils
2 changes: 1 addition & 1 deletion creditcoin-js/creditcoin.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ sp-staking = { workspace = true }
pallet-staking-reward-fn = { workspace = true }
pallet-offences = { workspace = true }
log = { workspace = true }
sp-io = { workspace = true }

# Pallets necessary for use with the Staking Dashboard
# CSUB-503 https://gluwa.atlassian.net/browse/CSUB-503?atlOrigin=eyJpIjoiODY0NGFjOTkzZjE1NGFkYTg1OTNkZmYxZGU1NjlmYjIiLCJwIjoiaiJ9
Expand Down Expand Up @@ -132,6 +133,7 @@ std = [
'sp-block-builder/std',
'sp-core/std',
'sp-inherents/std',
'sp-io/std',
'sp-offchain/std',
'sp-runtime/std',
'sp-session/std',
Expand Down
11 changes: 11 additions & 0 deletions runtime/generate-bags/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "generate-bags"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
creditcoin-node-runtime = { path = "../" }
generate-bags = { workspace = true }
clap = { version = "4.4.6", features = ["derive"] }
atodorov marked this conversation as resolved.
Show resolved Hide resolved
55 changes: 55 additions & 0 deletions runtime/generate-bags/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use std::path::PathBuf;

use clap::Parser;
use generate_bags::generate_thresholds;

#[derive(Parser)]
struct Cli {
/// Total issuance of the currency in millions
#[clap(short, long)]
total_issuance: u128,

/// Minimum account balance
#[clap(short, long, default_value_t = 8456776)]
minimum_balance: u128,

#[clap(long, default_value_t = 200)]
n_bags: usize,

#[clap(long)]
output: PathBuf,
}

/*
pub struct U128CurrencyToVote;

impl U128CurrencyToVote {
fn factor(issuance: u128) -> u128 {
(issuance / u64::MAX as u128).max(1)
}
}

impl CurrencyToVote<u128> for U128CurrencyToVote {
fn to_vote(value: u128, issuance: u128) -> u64 {
(value / Self::factor(issuance)).saturated_into()
}

fn to_currency(value: u128, issuance: u128) -> u128 {
value.saturating_mul(Self::factor(issuance))
}
} */

fn main() -> Result<(), std::io::Error> {
let Cli { total_issuance, minimum_balance, n_bags, output } = Cli::parse();

let issuance_ctc = total_issuance * creditcoin_node_runtime::CTC * 1_000_000;

println!("Issuance ctc = {issuance_ctc}; factor = {}", (issuance_ctc / u64::MAX as u128));

generate_thresholds::<creditcoin_node_runtime::Runtime>(
n_bags,
&output,
issuance_ctc,
minimum_balance,
)
}
Loading
Loading