Skip to content

Commit c6f0c97

Browse files
committed
merge main
1 parent bcb0469 commit c6f0c97

File tree

11 files changed

+35
-126
lines changed

11 files changed

+35
-126
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/nix/store/i1k30qr48lvl8zyzymny3qy00ks9ihy2-pre-commit-config.json
1+
/nix/store/mm6z36vc1ss0scr9yf1gf40rp43ddj5j-pre-commit-config.json

catalyst-toolbox/src/bin/cli/rewards/community_advisors.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use chain_crypto::digest::DigestOf;
2-
use color_eyre::eyre::bail;
3-
use color_eyre::Report;
41
use serde::{Deserialize, Serialize};
52
use std::collections::{BTreeMap, BTreeSet};
63
use std::path::{Path, PathBuf};
@@ -15,10 +12,6 @@ use chain_crypto::digest::DigestOf;
1512
use color_eyre::eyre::{bail, eyre};
1613
use color_eyre::Report;
1714
use rust_decimal::prelude::ToPrimitive;
18-
use serde::Serialize;
19-
use std::collections::{BTreeMap, BTreeSet};
20-
use std::path::{Path, PathBuf};
21-
use std::str::FromStr;
2215

2316
use catalyst_toolbox::community_advisors::models::{
2417
AdvisorReviewRow, ApprovedProposalRow, ProposalStatus,

catalyst-toolbox/src/bin/cli/rewards/full/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use catalyst_toolbox::{
66
};
77
use color_eyre::Result;
88
use config::*;
9-
use log::info;
109
use serde_json::from_reader;
10+
use tracing::info;
1111

1212
mod config;
1313

catalyst-toolbox/src/bin/cli/rewards/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
mod community_advisors;
2+
mod dreps;
23
mod full;
34
mod proposers;
45
mod veterans;
56
mod voters;
67

7-
use std::path::PathBuf;
8+
use std::{collections::HashMap, path::PathBuf};
89

9-
use catalyst_toolbox::{http::default_http_client, rewards::proposers as proposers_lib};
10-
use color_eyre::Report;
10+
use catalyst_toolbox::{
11+
http::default_http_client,
12+
rewards::{proposers as proposers_lib, VoteCount},
13+
};
14+
use color_eyre::{eyre::eyre, Report};
15+
use jormungandr_lib::{
16+
crypto::{account::Identifier, hash::Hash},
17+
interfaces::AccountVotes,
18+
};
1119
use structopt::StructOpt;
1220
use vit_servicing_station_lib::db::models::proposals::FullProposalInfo;
1321

catalyst-toolbox/src/bin/cli/rewards/veterans.rs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use catalyst_toolbox::community_advisors::models::VeteranRankingRow;
22
use catalyst_toolbox::rewards::veterans::{self, VcaRewards, VeteranAdvisorIncentive};
3-
use catalyst_toolbox::rewards::Rewards;
43
use catalyst_toolbox::utils::csv;
54
use color_eyre::eyre::{bail, eyre};
65
use color_eyre::Report;
@@ -20,7 +19,7 @@ pub struct VeteransRewards {
2019

2120
/// Reward to be distributed (integer value)
2221
#[structopt(long = "total-rewards")]
23-
total_rewards: u64,
22+
total_rewards: Decimal,
2423

2524
/// Minimum number of rankings for each vca to be considered for reputation and rewards
2625
/// distribution
@@ -119,34 +118,14 @@ pub fn vca_rewards(
119118
bail!(
120119
"Expected same number of reputation_agreement_rate_cutoffs and reputation_agreement_rate_modifiers"
121120
);
122-
}
123-
124-
if !is_descending(&rewards_agreement_rate_cutoffs) {
125-
bail!("Expected rewards_agreement_rate_cutoffs to be descending");
126-
}
127-
128-
if !is_descending(&reputation_agreement_rate_cutoffs) {
129-
bail!("Expected rewards_agreement_rate_cutoffs to be descending");
130-
}
131-
132-
let results = veterans::calculate_veteran_advisors_incentives(
133-
&reviews,
134-
Rewards::from(total_rewards),
135-
min_rankings..=max_rankings_rewards,
136-
min_rankings..=max_rankings_reputation,
137-
rewards_agreement_rate_cutoffs
138-
.into_iter()
139-
.zip(rewards_agreement_rate_modifiers.into_iter())
140-
.collect(),
141-
reputation_agreement_rate_cutoffs
142-
.into_iter()
143-
.zip(reputation_agreement_rate_modifiers.into_iter())
144-
.collect(),
145-
);
146-
147-
csv::dump_data_to_csv(rewards_to_csv_data(results)?.iter(), &to).unwrap();
148-
149-
Ok(())
121+
}
122+
123+
if !is_descending(&rewards_agreement_rate_cutoffs) {
124+
bail!("Expected rewards_agreement_rate_cutoffs to be descending");
125+
}
126+
127+
if !is_descending(&reputation_agreement_rate_cutoffs) {
128+
bail!("Expected rewards_agreement_rate_cutoffs to be descending");
150129
}
151130

152131
if !is_descending(&rewards_agreement_rate_cutoffs) {

catalyst-toolbox/src/bin/cli/rewards/voters.rs

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use catalyst_toolbox::rewards::voters::calc_voter_rewards;
2-
use catalyst_toolbox::rewards::{Rewards, Threshold};
2+
use catalyst_toolbox::rewards::{Rewards, Threshold, VoteCount};
33
use catalyst_toolbox::utils::assert_are_close;
44

55
use color_eyre::eyre::eyre;
66
use color_eyre::{Report, Result};
77
use jcli_lib::block::open_output;
88
use jcli_lib::jcli_lib::block::Common;
99

10+
use snapshot_lib::registration::MainnetRewardAddress;
11+
use snapshot_lib::SnapshotInfo;
1012
use structopt::StructOpt;
11-
use vit_servicing_station_lib::db::models::proposals::FullProposalInfo;
1213

1314
use std::collections::BTreeMap;
1415
use std::path::{Path, PathBuf};
@@ -35,7 +36,7 @@ pub struct VotersRewards {
3536

3637
/// Number of global votes required to be able to receive voter rewards
3738
#[structopt(long, default_value)]
38-
vote_threshold: usize,
39+
vote_threshold: u64,
3940

4041
/// Path to a json-encoded map from challenge id to an optional required threshold
4142
/// per-challenge in order to receive rewards.
@@ -77,7 +78,6 @@ impl VotersRewards {
7778
proposals,
7879
} = self;
7980

80-
<<<<<<< HEAD
8181
voter_rewards(
8282
common
8383
.output_file
@@ -88,42 +88,6 @@ impl VotersRewards {
8888
vote_threshold,
8989
total_rewards,
9090
)
91-
=======
92-
let proposals = serde_json::from_reader::<_, Vec<FullProposalInfo>>(
93-
jcli_lib::utils::io::open_file_read(&Some(proposals))?,
94-
)?;
95-
96-
let vote_count = super::extract_individual_votes(
97-
proposals.clone(),
98-
serde_json::from_reader::<_, HashMap<Identifier, Vec<AccountVotes>>>(
99-
jcli_lib::utils::io::open_file_read(&Some(votes_count_path))?,
100-
)?,
101-
)?;
102-
103-
let snapshot: Vec<SnapshotInfo> = serde_json::from_reader(
104-
jcli_lib::utils::io::open_file_read(&Some(snapshot_info_path))?,
105-
)?;
106-
107-
let additional_thresholds: HashMap<i32, usize> = if let Some(file) = per_challenge_threshold
108-
{
109-
serde_json::from_reader(jcli_lib::utils::io::open_file_read(&Some(file))?)?
110-
} else {
111-
HashMap::new()
112-
};
113-
114-
let results = calc_voter_rewards(
115-
vote_count,
116-
snapshot,
117-
Threshold::new(vote_threshold, additional_thresholds, proposals)?,
118-
Rewards::from(total_rewards),
119-
)?;
120-
121-
let actual_rewards = results.values().sum::<Rewards>();
122-
assert_are_close(actual_rewards, Rewards::from(total_rewards));
123-
124-
write_rewards_results(common, &results)?;
125-
Ok(())
126-
>>>>>>> main
12791
}
12892
}
12993

@@ -143,8 +107,12 @@ pub fn voter_rewards(
143107

144108
let results = calc_voter_rewards(
145109
vote_count,
146-
vote_threshold,
147110
snapshot,
111+
Threshold::new(
112+
vote_threshold as usize,
113+
Default::default(),
114+
Default::default(),
115+
)?,
148116
Rewards::from(total_rewards),
149117
)?;
150118

catalyst-toolbox/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod archive;
22
pub mod community_advisors;
3+
pub mod http;
34
pub mod ideascale;
45
pub mod kedqr;
56
pub mod logs;
@@ -10,10 +11,6 @@ pub mod stats;
1011
pub mod utils;
1112
pub mod vca_reviews;
1213
pub mod vote_check;
13-
pub mod http;
14-
15-
#[cfg(feature = "test-api")]
16-
pub mod testing;
1714

1815
#[macro_use]
1916
extern crate tracing;

catalyst-toolbox/src/rewards/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub mod community_advisors;
2-
pub mod proposers;
32
pub mod dreps;
3+
pub mod proposers;
44
pub mod veterans;
55
pub mod voters;
66

catalyst-toolbox/src/rewards/proposers/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use jormungandr_lib::{
44
crypto::hash::Hash,
55
interfaces::{VotePlanStatus, VoteProposalStatus},
66
};
7-
use log::{info, warn};
87
use std::{collections::HashMap, fs::File, io::BufWriter, path::Path};
8+
use tracing::{info, warn};
99
use vit_servicing_station_lib::db::models::{challenges::Challenge, proposals::Proposal};
1010

1111
use serde::Deserialize;

catalyst-toolbox/src/rewards/proposers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use jormungandr_lib::{
1212
Address, Block0Configuration, Initial, Tally, VotePlanStatus, VoteProposalStatus,
1313
},
1414
};
15-
use log::debug;
15+
use tracing::debug;
1616
use vit_servicing_station_lib::db::models::{challenges::Challenge, proposals::Proposal};
1717

1818
pub use types::*;

0 commit comments

Comments
 (0)