Account for all tokens at genesis (#7350)
* Towards accounting for all tokens * Move 5m tokens back into the big pool * Flesh out batch 4 * Add a script to generate ValidatorInfo structs from a CSV file * Remove commented out code and improve test
This commit is contained in:
		
							
								
								
									
										42
									
								
								scripts/src/csv_to_validator_infos.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								scripts/src/csv_to_validator_infos.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
// Utility to print ValidatorInfo structs for `genesis_accounts.rs`
 | 
			
		||||
//
 | 
			
		||||
// Usage:
 | 
			
		||||
//   cargo run --bin solana-csv-to-validator-infos < validators.csv
 | 
			
		||||
 | 
			
		||||
use serde::Deserialize;
 | 
			
		||||
use std::error::Error;
 | 
			
		||||
use std::io;
 | 
			
		||||
use std::process;
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
struct ValidatorRecord {
 | 
			
		||||
    id: u64,
 | 
			
		||||
    tokens: f64,
 | 
			
		||||
    adjective: String,
 | 
			
		||||
    noun: String,
 | 
			
		||||
    identity_pubkey: String,
 | 
			
		||||
    vote_pubkey: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn parse_csv() -> Result<(), Box<dyn Error>> {
 | 
			
		||||
    let mut rdr = csv::Reader::from_reader(io::stdin());
 | 
			
		||||
    for result in rdr.deserialize() {
 | 
			
		||||
        let record: ValidatorRecord = result?;
 | 
			
		||||
        println!(
 | 
			
		||||
        r#"ValidatorInfo {{name: "{adjective} {noun}", node: "{identity_pubkey}", node_sol: {tokens:.1}, vote: "{vote_pubkey}", commission: 0}},"#,
 | 
			
		||||
            tokens = &record.tokens,
 | 
			
		||||
            adjective = &record.adjective,
 | 
			
		||||
            noun = &record.noun,
 | 
			
		||||
            identity_pubkey = &record.identity_pubkey,
 | 
			
		||||
            vote_pubkey = &record.vote_pubkey,
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn main() {
 | 
			
		||||
    if let Err(err) = parse_csv() {
 | 
			
		||||
        println!("error: {}", err);
 | 
			
		||||
        process::exit(1);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user