Skip to content
Draft
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
10 changes: 3 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
toolchain: nightly-2025-02-19
- name: Install Protobuf Compiler
run: |
sudo apt-get update
Expand All @@ -47,7 +43,7 @@ jobs:
version: 1.0.9
- run: cargo sort --workspace --check
- run: cargo fmt --all --check
- run: cargo +nightly-2025-02-19 clippy --all-features --all-targets --tests -- -D warnings
- run: cargo clippy --all-features --all-targets --tests -- -D warnings

udeps:
name: udeps
Expand All @@ -62,13 +58,13 @@ jobs:
sudo apt-get install -y protobuf-compiler libudev-dev libclang-dev
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly-2025-02-19
toolchain: nightly
- name: Install cargo-udeps from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-udeps
version: "0.1.57"
- run: cargo +nightly-2025-02-19 udeps --all-features --all-targets --tests
- run: cargo +nightly udeps --all-features --all-targets --tests

build_release:
name: build_release
Expand Down
27 changes: 10 additions & 17 deletions keepers/stakenet-keeper/src/entries/crank_steward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ pub fn _get_update_stake_pool_ixs(

if vote_account.epoch_credits.iter().last().is_none() {
error!(
"🆘 ⁉️ Error: Epoch credits has no entries? \nStake Account\n{:?}\nVote Account\n{:?}\n",
stake_account,
vote_account
"🆘 ⁉️ Error: Epoch credits has no entries? \nStake Account\n{stake_account:?}\nVote Account\n{vote_account:?}\n"
);
false
} else {
Expand Down Expand Up @@ -290,16 +288,15 @@ async fn _handle_instant_removal_validators(
for i in 0..all_steward_accounts.validator_list_account.validators.len() as u64 {
if validators_to_remove.get(i as usize).map_err(|e| {
JitoTransactionError::Custom(format!(
"Error fetching bitmask index for immediate removed validator: {}/{} - {}",
i, num_validators, e
"Error fetching bitmask index for immediate removed validator: {i}/{num_validators} - {e}"
))
})? {
validator_index_to_remove = Some(i);
break;
}
}

info!("Validator Index to Remove: {:?}", validator_index_to_remove);
info!("Validator Index to Remove: {validator_index_to_remove:?}");

let directed_stake_meta =
get_directed_stake_meta_address(&all_steward_accounts.config_address, program_id);
Expand Down Expand Up @@ -451,7 +448,7 @@ async fn _handle_adding_validators(
return None;
}
} else {
info!("Validator {} below liveness minimum", vote_address);
info!("Validator {vote_address} below liveness minimum");
return None;
}
}
Expand Down Expand Up @@ -632,16 +629,15 @@ async fn _handle_epoch_maintenance(
for i in 0..num_validators {
if validators_to_remove.get(i as usize).map_err(|e| {
JitoTransactionError::Custom(format!(
"Error fetching bitmask index for removed validator: {}/{} - {}",
i, num_validators, e
"Error fetching bitmask index for removed validator: {i}/{num_validators} - {e}"
))
})? {
validator_index_to_remove = Some(i);
break;
}
}

info!("Validator Index to Remove: {:?}", validator_index_to_remove);
info!("Validator Index to Remove: {validator_index_to_remove:?}");

let directed_stake_meta =
get_directed_stake_meta_address(&all_steward_accounts.config_address, program_id);
Expand Down Expand Up @@ -689,10 +685,7 @@ async fn _handle_epoch_maintenance(
state_epoch = updated_state_account.state.current_epoch;
current_epoch = client.get_epoch_info().await?.epoch;

info!(
"State Epoch: {} | Current Epoch: {}",
state_epoch, current_epoch
);
info!("State Epoch: {state_epoch} | Current Epoch: {current_epoch}");
}

Ok(stats)
Expand Down Expand Up @@ -1304,18 +1297,18 @@ pub async fn crank_steward(
match error {
JitoSendTransactionError::ExceededRetries => {
// Continue
error!("Exceeded Retries: {:?}", error);
error!("Exceeded Retries: {error:?}");
}
JitoSendTransactionError::TransactionError(e) => {
// Flag
error!("Transaction: {:?}", e);
error!("Transaction: {e:?}");
}
JitoSendTransactionError::RpcSimulateTransactionResult(e) => {
// Recover
error!("\n\nERROR: ");
e.logs.iter().for_each(|log| {
log.iter().enumerate().for_each(|(i, log)| {
error!("{}: {:?}", i, log);
error!("{i}: {log:?}");
});
});
}
Expand Down
16 changes: 8 additions & 8 deletions keepers/stakenet-keeper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn random_cooldown(range: u8) {
let mut rng = rand::thread_rng();
let sleep_duration = rng.gen_range(0..=60 * (range as u64 + 1));

info!("\n\n⏰ Cooldown for {} seconds\n", sleep_duration);
info!("\n\n⏰ Cooldown for {sleep_duration} seconds\n");
sleep(Duration::from_secs(sleep_duration)).await;
}

Expand Down Expand Up @@ -133,13 +133,13 @@ async fn run_keeper(keeper_config: KeeperConfig) {
// The fetch ( update ) functions fetch everything we need for the operations from the blockchain
// Additionally, this function will update the keeper state. If update fails - it will skip the fire functions.
if should_update(tick, &intervals) {
info!("Pre-fetching data for update...({})", tick);
info!("Pre-fetching data for update...({tick})");
match pre_create_update(&keeper_config, &mut keeper_state).await {
Ok(_) => {
keeper_state.increment_update_run_for_epoch(KeeperOperations::PreCreateUpdate);
}
Err(e) => {
error!("Failed to pre create update: {:?}", e);
error!("Failed to pre create update: {e:?}");

keeper_state
.increment_update_error_for_epoch(KeeperOperations::PreCreateUpdate);
Expand All @@ -150,7 +150,7 @@ async fn run_keeper(keeper_config: KeeperConfig) {
}

if keeper_config.pay_for_new_accounts {
info!("Creating missing accounts...({})", tick);
info!("Creating missing accounts...({tick})");
match create_missing_accounts(&keeper_config, &keeper_state).await {
Ok(new_accounts_created) => {
keeper_state.increment_update_run_for_epoch(
Expand All @@ -174,7 +174,7 @@ async fn run_keeper(keeper_config: KeeperConfig) {
});
}
Err(e) => {
error!("Failed to create missing accounts: {:?}", e);
error!("Failed to create missing accounts: {e:?}");

keeper_state.increment_update_error_for_epoch(
KeeperOperations::CreateMissingAccounts,
Expand All @@ -186,13 +186,13 @@ async fn run_keeper(keeper_config: KeeperConfig) {
}
}

info!("Post-fetching data for update...({})", tick);
info!("Post-fetching data for update...({tick})");
match post_create_update(&keeper_config, &mut keeper_state).await {
Ok(_) => {
keeper_state.increment_update_run_for_epoch(KeeperOperations::PostCreateUpdate);
}
Err(e) => {
error!("Failed to post create update: {:?}", e);
error!("Failed to post create update: {e:?}");

keeper_state
.increment_update_error_for_epoch(KeeperOperations::PostCreateUpdate);
Expand Down Expand Up @@ -329,7 +329,7 @@ fn main() {
let flag_args = Args::parse();
let run_flags = set_run_flags(&flag_args);

info!("{}\n\n", args);
info!("{args}\n\n");

let gossip_entrypoints =
args.gossip_entrypoints
Expand Down
22 changes: 9 additions & 13 deletions keepers/stakenet-keeper/src/operations/block_metadata/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ impl DBSlotInfoState {
}

Err(BlockMetadataKeeperError::OtherError(format!(
"Could not map state {}",
state
"Could not map state {state}"
)))
}
}
Expand Down Expand Up @@ -217,7 +216,7 @@ impl DBSlotInfo {
}
transaction.commit()?;
transaction = connection.transaction()?;
info!("Wrote {} Mappings", write_counter);
info!("Wrote {write_counter} Mappings");
}

Ok(write_counter)
Expand Down Expand Up @@ -536,27 +535,27 @@ impl DBSlotInfo {
starting_offset: usize,
) -> Result<u64, BlockMetadataKeeperError> {
let client = reqwest::blocking::Client::new();
let base_url = format!("https://api.dune.com/api/v1/query/{}/results", query_id);
let base_url = format!("https://api.dune.com/api/v1/query/{query_id}/results");

let mut total_written = 0u64;
let mut offset = starting_offset;
let mut has_more = true;

info!("Starting Dune API fetch for query {}", query_id);
info!("Starting Dune API fetch for query {query_id}");

while has_more {
// Build URL with pagination
let url = format!("{}?limit={}&offset={}", base_url, batch_size, offset);
let url = format!("{base_url}?limit={batch_size}&offset={offset}");

info!("Fetching batch from Dune API, offset: {}", offset);
info!("Fetching batch from Dune API, offset: {offset}");

// Make API request
let response = client
.get(&url)
.header("X-Dune-API-Key", api_key)
.send()
.map_err(|e| {
BlockMetadataKeeperError::OtherError(format!("API request failed: {}", e))
BlockMetadataKeeperError::OtherError(format!("API request failed: {e}"))
})?;

if !response.status().is_success() {
Expand All @@ -567,7 +566,7 @@ impl DBSlotInfo {
}

let api_response: DuneApiResponse = response.json().map_err(|e| {
BlockMetadataKeeperError::OtherError(format!("Failed to parse JSON: {}", e))
BlockMetadataKeeperError::OtherError(format!("Failed to parse JSON: {e}"))
})?;

let rows = api_response.result.rows;
Expand Down Expand Up @@ -623,10 +622,7 @@ impl DBSlotInfo {
std::thread::sleep(std::time::Duration::from_millis(100));
}

info!(
"Completed Dune API fetch. Total entries written: {}",
total_written
);
info!("Completed Dune API fetch. Total entries written: {total_written}");
Ok(total_written)
}

Expand Down
40 changes: 13 additions & 27 deletions keepers/stakenet-keeper/src/operations/block_metadata/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,17 @@ async fn update_block_metadata(
// Check if slot exists
if DBSlotInfo::check_random_slot_exists_in_epoch(sqlite_connection, epoch, epoch_schedule)?
{
info!("Epoch {} already exists", epoch);
info!("Epoch {epoch} already exists");
continue;
} else {
info!("Updating epoch {}", epoch)
info!("Updating epoch {epoch}")
}

let epoch_leader_schedule_result =
get_leader_schedule_safe(client, epoch_starting_slot).await;

if epoch_leader_schedule_result.is_err() {
info!("Could not find leader schedule for epoch {}", epoch);
info!("Could not find leader schedule for epoch {epoch}");
continue;
}

Expand All @@ -244,14 +244,14 @@ async fn update_block_metadata(
time_ms as f64 / 1000.0
)
}
Err(err) => error!("Error writing leaders {:?}", err),
Err(err) => error!("Error writing leaders {err:?}"),
}

// 1.b Log out missing vote accounts
for leader in epoch_leader_schedule.keys() {
if !identity_to_vote_map.contains_key(leader) {
// TODO
error!("TODO Could not find Vote for {} in epoch {}", leader, epoch)
error!("TODO Could not find Vote for {leader} in epoch {epoch}")
}
}
}
Expand All @@ -275,7 +275,7 @@ async fn update_block_metadata(
time_ms as f64 / 1000.0
)
}
Err(err) => error!("Error updating identity/vote mapping {:?}", err),
Err(err) => error!("Error updating identity/vote mapping {err:?}"),
}
}

Expand Down Expand Up @@ -320,10 +320,7 @@ async fn update_block_metadata(
DBSlotInfo::set_block_dne(sqlite_connection, slot)?;
}
_ => {
info!(
"Could not get block info for slot {} - skipping: {:?}",
slot, err
)
info!("Could not get block info for slot {slot} - skipping: {err:?}")
}
},
}
Expand All @@ -342,7 +339,7 @@ async fn update_block_metadata(
blocks_per_second
)
}
Err(err) => error!("Error writing blocks {:?}", err),
Err(err) => error!("Error writing blocks {err:?}"),
}
}

Expand Down Expand Up @@ -374,7 +371,7 @@ async fn update_block_metadata(
) {
Ok(map) => map,
Err(err) => {
error!("Could not get update map - skipping... {:?}", err);
error!("Could not get update map - skipping... {err:?}");
continue;
}
};
Expand Down Expand Up @@ -483,7 +480,7 @@ async fn update_block_metadata(
ixs.len(),
time_ms as f64 / 1000.0,
);
info!("Block Metadata: {}", needs_update_counter);
info!("Block Metadata: {needs_update_counter}");
}

// 5. Submit TXs
Expand Down Expand Up @@ -540,12 +537,7 @@ pub async fn get_priority_fee_distribution_account_info(
),
Err(error) => {
let error_string = format!(
"Could not deserialize account data {}-{}-{} = {}: {:?}",
priority_fee_distribution_program_id,
vote_account,
epoch,
priority_fee_distribution_account,
error
"Could not deserialize account data {priority_fee_distribution_program_id}-{vote_account}-{epoch} = {priority_fee_distribution_account}: {error:?}"
);
(
priority_fee_distribution_account,
Expand All @@ -558,12 +550,7 @@ pub async fn get_priority_fee_distribution_account_info(
}
Err(error) => {
let error_string = format!(
"Could not fetch account {}-{}-{} = {}: {:?}",
priority_fee_distribution_program_id,
vote_account,
epoch,
priority_fee_distribution_account,
error
"Could not fetch account {priority_fee_distribution_program_id}-{vote_account}-{epoch} = {priority_fee_distribution_account}: {error:?}"
);
(
priority_fee_distribution_account,
Expand All @@ -582,8 +569,7 @@ pub async fn get_leader_schedule_safe(
match rpc_client.get_leader_schedule(Some(starting_slot)).await? {
Some(schedule) => Ok(schedule),
None => Err(BlockMetadataKeeperError::OtherError(format!(
"Could not get leader schedule for starting slot {}",
starting_slot
"Could not get leader schedule for starting slot {starting_slot}"
))),
}
}
Expand Down
Loading
Loading