File tree Expand file tree Collapse file tree 4 files changed +44
-8
lines changed
catalyst-toolbox/src/bin/cli/rewards Expand file tree Collapse file tree 4 files changed +44
-8
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,23 @@ pub(super) struct Inputs {
2222 pub ( super ) proposal_bonus_output : Option < PathBuf > ,
2323 pub ( super ) approved_proposals_path : PathBuf ,
2424 pub ( super ) proposer_script_path : PathBuf ,
25+ pub ( super ) csv_merger_script_path : PathBuf ,
2526 pub ( super ) active_voteplans : PathBuf ,
2627 pub ( super ) challenges : PathBuf ,
2728 pub ( super ) proposals_path : PathBuf ,
2829}
2930
31+ /// A set of files required to calculate proposer rewards. There is one set per proposal, which are
32+ /// then later merged with csv_merger.py
33+ pub ( super ) struct ProposalFiles {
34+
35+ }
36+
37+
38+
3039#[ derive( Debug , Deserialize ) ]
3140pub ( super ) struct Outputs {
41+ pub ( super ) voter_rewards_output : PathBuf ,
3242 pub ( super ) veterans_rewards_output : PathBuf ,
3343 pub ( super ) ca_rewards_output : PathBuf ,
3444 pub ( super ) proposer_rewards_output : PathBuf ,
Original file line number Diff line number Diff line change @@ -22,12 +22,14 @@ pub(super) fn full_rewards(path: &Path) -> Result<()> {
2222 proposal_bonus_output,
2323 approved_proposals_path,
2424 proposer_script_path,
25+ csv_merger_script_path,
2526 active_voteplans,
2627 challenges,
2728 proposals_path,
2829 } ,
2930 outputs :
3031 Outputs {
32+ voter_rewards_output,
3133 veterans_rewards_output,
3234 ca_rewards_output,
3335 proposer_rewards_output,
@@ -55,8 +57,9 @@ pub(super) fn full_rewards(path: &Path) -> Result<()> {
5557 info ! ( "calculating voter rewards" ) ;
5658 super :: voters:: voter_rewards (
5759 & block_file,
58- vote_count_path,
59- snapshot_path,
60+ & voter_rewards_output,
61+ & vote_count_path,
62+ & snapshot_path,
6063 registration_threshold,
6164 vote_threshold,
6265 total_rewards,
Original file line number Diff line number Diff line change 11use std:: { ffi:: OsStr , path:: Path } ;
22
3+ use assert_fs:: TempDir ;
34use color_eyre:: Result ;
45
56use super :: python:: exec_python_script;
67
78#[ allow( clippy:: too_many_arguments) ]
89pub ( super ) fn proposers_rewards (
910 proposer_reward_script : & Path ,
11+ csv_merger_script : & Path ,
1012 block0 : & Path ,
1113 output : & Path ,
1214 stake_threshold : f64 ,
1315 approval_threshold : f64 ,
1416 proposals : & Path ,
1517 active_voteplans : & Path ,
1618 challenges : & Path ,
19+ pattern : & str
1720) -> Result < ( ) > {
21+ let temp = TempDir :: new ( ) ?;
22+ exec_python_script (
23+ csv_merger_script,
24+ [
25+ OsStr :: new ( "--output-file" ) ,
26+ temp. path ( ) . as_ref ( ) ,
27+ OsStr :: new ( "--pattern" ) ,
28+ OsStr :: new ( pattern) ,
29+ OsStr :: new ( "--pattern" ) ,
30+ OsStr :: new ( pattern) ,
31+
32+ ] ,
33+ ) ?;
34+
1835 exec_python_script (
1936 proposer_reward_script,
2037 [
Original file line number Diff line number Diff line change @@ -71,11 +71,16 @@ impl VotersRewards {
7171
7272 voter_rewards (
7373 common
74- . output_file
74+ . input
75+ . input_file
7576 . as_deref ( )
7677 . ok_or ( eyre ! ( "missing block file" ) ) ?,
77- votes_count_path,
78- snapshot_path,
78+ common
79+ . output_file
80+ . as_deref ( )
81+ . ok_or ( eyre ! ( "missing output file" ) ) ?,
82+ & votes_count_path,
83+ & snapshot_path,
7984 registration_threshold,
8085 vote_threshold,
8186 total_rewards,
@@ -85,8 +90,9 @@ impl VotersRewards {
8590
8691pub fn voter_rewards (
8792 block_file : & Path ,
88- votes_count_path : PathBuf ,
89- snapshot_path : PathBuf ,
93+ output : & Path ,
94+ votes_count_path : & Path ,
95+ snapshot_path : & Path ,
9096 registration_threshold : u64 ,
9197 vote_threshold : u64 ,
9298 total_rewards : u64 ,
@@ -113,6 +119,6 @@ pub fn voter_rewards(
113119 let actual_rewards = results. values ( ) . sum :: < Rewards > ( ) ;
114120 assert_are_close ( actual_rewards, Rewards :: from ( total_rewards) ) ;
115121
116- write_rewards_results ( & Some ( block_file . to_path_buf ( ) ) , & results) ?;
122+ write_rewards_results ( & Some ( output . to_path_buf ( ) ) , & results) ?;
117123 Ok ( ( ) )
118124}
You can’t perform that action at this time.
0 commit comments