Skip to content

Commit

Permalink
add check to avoid 0x3 error
Browse files Browse the repository at this point in the history
  • Loading branch information
HardhatChad committed Apr 8, 2024
1 parent 3ac91db commit b0ade94
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ore-cli"
version = "0.4.9"
version = "0.4.10"
description = "A command line interface for the Ore program."
license = "Apache-2.0"
edition = "2021"
Expand Down
9 changes: 8 additions & 1 deletion src/mine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ impl Miner {
// Submit mine tx.
// Use busses randomly so on each epoch, transactions don't pile on the same busses
println!("\n\nSubmitting hash for validation...");
loop {
'submit: loop {
// Double check we're submitting for the right challenge
let proof_ = get_proof(self.cluster.clone(), signer.pubkey()).await;
if proof_.hash.ne(&proof.hash) {
println!("Hash already validated! An earlier transaction must have landed.");
break 'submit;
}

// Reset epoch, if needed
let treasury = get_treasury(self.cluster.clone()).await;
let clock = get_clock_account(self.cluster.clone()).await;
Expand Down
10 changes: 6 additions & 4 deletions src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ impl Miner {

// Sign and send transaction.
println!("Generating challenge...");
let ix = ore::instruction::register(signer.pubkey());
self.send_and_confirm(&[ix], true, false)
.await
.expect("Transaction failed");
'send: loop {
let ix = ore::instruction::register(signer.pubkey());
if self.send_and_confirm(&[ix], true, false).await.is_ok() {
break 'send;
}
}
}
}
7 changes: 5 additions & 2 deletions src/send_and_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const SIMULATION_RETRIES: usize = 4;
const GATEWAY_RETRIES: usize = 4;
const CONFIRM_RETRIES: usize = 4;

const CONFIRM_DELAY: u64 = 5000;
const GATEWAY_DELAY: u64 = 2000;

impl Miner {
pub async fn send_and_confirm(
&self,
Expand Down Expand Up @@ -135,7 +138,7 @@ impl Miner {
return Ok(sig);
}
for _ in 0..CONFIRM_RETRIES {
std::thread::sleep(Duration::from_millis(2000));
std::thread::sleep(Duration::from_millis(CONFIRM_DELAY));
match client.get_signature_statuses(&sigs).await {
Ok(signature_statuses) => {
println!("Confirms: {:?}", signature_statuses.value);
Expand Down Expand Up @@ -178,7 +181,7 @@ impl Miner {
stdout.flush().ok();

// Retry
std::thread::sleep(Duration::from_millis(2000));
std::thread::sleep(Duration::from_millis(GATEWAY_DELAY));
(hash, slot) = client
.get_latest_blockhash_with_commitment(CommitmentConfig::confirmed())
.await
Expand Down

0 comments on commit b0ade94

Please sign in to comment.