Skip to content

Commit

Permalink
closing #6
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed May 9, 2024
1 parent 6127483 commit 5405e2a
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 164 deletions.
40 changes: 40 additions & 0 deletions .buildkite/close-settlements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
agents:
queue: "snapshots"

steps:
- command: echo "--> Start of concurrency gate"
concurrency_group: 'validator-bonds/close-settlements'
concurrency: 1

- wait: ~

- label: ":hammer_and_wrench: :rust: Build"
commands:
- '. "$HOME/.cargo/env"'
- 'cargo build --release --bin close-settlement'
artifact_paths:
- target/release/close-settlement

- wait: ~

- label: ":campfire: Close settlements"
env:
RUST_LOG: solana_transaction_builder_executor=debug,solana_transaction_builder=debug,solana_transaction_executor=debug,settlement_pipelines=debug
# RUST_BACKTRACE: full
commands:
- |
- '. "$HOME/.cargo/env"'
- 'buildkite-agent artifact download --include-retried-jobs target/release/close-settlement .'
- 'chmod +x target/release/close-settlement'
- |
./target/release/claim-settlement \
--rpc-url $$RPC_URL \
--operator-authority "$$VALIDATOR_BONDS_OPERATOR_AUTHORITY" \
--fee-payer "$$VALIDATOR_BONDS_FUNDING_WALLET"
--marinade-wallet "$$VALIDATOR_BONDS_FUNDING_WALLET"
- wait: ~

- command: echo "End of concurrency gate <--"
concurrency_group: 'validator-bonds/close-settlements'
concurrency: 1
4 changes: 2 additions & 2 deletions common-rs/src/settlements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub async fn get_settlements_for_pubkeys(

pub async fn get_bonds_for_settlements(
rpc_client: Arc<RpcClient>,
settlements: &Vec<(Pubkey, Settlement)>,
settlements: &[(Pubkey, Settlement)],
) -> anyhow::Result<Vec<(Pubkey, Option<Bond>)>> {
let bond_pubkeys = settlements
.iter()
Expand All @@ -37,7 +37,7 @@ pub async fn get_bonds_for_settlements(
let bonds = get_bonds_for_pubkeys(rpc_client, &bond_pubkeys).await?;

let settlements_bonds = settlements
.into_iter()
.iter()
.map(|(pubkey, settlement)| {
bonds
.iter()
Expand Down
19 changes: 17 additions & 2 deletions settlement-pipelines/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ pub struct TipPolicyOpts {
tip_multiplier: Option<u64>,
}

pub fn load_default_keypair(s: Option<&str>) -> Result<Option<Rc<Keypair>>, anyhow::Error> {
pub fn load_default_keypair(s: Option<&str>) -> anyhow::Result<Option<Rc<Keypair>>> {
if s.is_none() || s.unwrap().is_empty() {
load_keypair(DEFAULT_KEYPAIR_PATH).map_or_else(|_e| Ok(None), |keypair| Ok(Some(keypair)))
} else {
Ok(Some(load_keypair(s.unwrap())?))
}
}

pub fn load_keypair(s: &str) -> Result<Rc<Keypair>, anyhow::Error> {
pub fn load_keypair(s: &str) -> anyhow::Result<Rc<Keypair>> {
// loading directly as the json keypair data (format [u8; 64])
let parsed_json = parse_keypair_as_json_data(s);
if let Ok(key_bytes) = parsed_json {
Expand All @@ -96,6 +96,21 @@ pub fn load_keypair(s: &str) -> Result<Rc<Keypair>, anyhow::Error> {
Ok(Rc::new(k))
}

pub fn load_pubkey(s: &str) -> anyhow::Result<Pubkey> {
let parsed_keypair_data = parse_keypair_as_json_data(s);
if let Ok(keypair_data) = parsed_keypair_data {
if let Ok(keypair) = Keypair::from_bytes(&keypair_data) {
Ok(keypair.pubkey())
} else {
Err(anyhow!(
"Could not read pubkey from json data that seems to be a keypair"
))
}
} else {
Pubkey::from_str(s).map_err(|e| anyhow!("Could not parse pubkey from '{}': {}", s, e))
}
}

fn create_clap_error(message: &str, context_value: &str) -> clap::Error {
let mut err = clap::Error::raw(clap::error::ErrorKind::ValueValidation, message);
err.insert(
Expand Down
2 changes: 1 addition & 1 deletion settlement-pipelines/src/bin/claim_settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use validator_bonds::instructions::ClaimSettlementArgs;
use validator_bonds::state::bond::find_bond_address;
use validator_bonds::state::config::{find_bonds_withdrawer_authority, Config};
use validator_bonds::state::config::find_bonds_withdrawer_authority;
use validator_bonds::state::settlement::find_settlement_address;
use validator_bonds::state::settlement_claim::find_settlement_claim_address;
use validator_bonds::ID as validator_bonds_id;
Expand Down
Loading

0 comments on commit 5405e2a

Please sign in to comment.