Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add bloxroute #151

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dec6b92
add bloxroute v1
Lanikean Aug 16, 2024
6f9430c
change url
Lanikean Aug 16, 2024
a688cc6
refactor
Lanikean Aug 19, 2024
03975b1
priority fee -> tip
Lanikean Aug 19, 2024
03c51b5
switch url remote
Lanikean Aug 19, 2024
1ccd987
adjust re-submit logic
Lanikean Aug 20, 2024
f1c6620
err 6 refactor
Lanikean Aug 20, 2024
9f09333
fix build
Lanikean Aug 20, 2024
af4d40e
add more logging
Lanikean Aug 20, 2024
ec74f1a
retry on endpoint fail
Lanikean Aug 21, 2024
a74899b
switch endpoint
Lanikean Aug 21, 2024
a3c4301
add rpc fallback & refactor
Lanikean Aug 21, 2024
ab2696f
rm hanging log
Lanikean Aug 22, 2024
121c143
add more logging
Lanikean Aug 22, 2024
278e534
add more logging
Lanikean Aug 22, 2024
d7689b3
fix attempts logic
Lanikean Aug 22, 2024
0be6343
mv tx outside of loop
Lanikean Aug 22, 2024
5d2f31a
add jito + rpc backup
Lanikean Aug 23, 2024
a0d1f03
Merge branch 'master' into feat/ore-2.3-blxr
Lanikean Aug 23, 2024
e4113cd
refactor endpoint code outer loop
Lanikean Aug 25, 2024
330168f
more logging
Lanikean Aug 25, 2024
896065c
refactor jito & fallback submissions, only update hash/balance on suc…
Lanikean Aug 26, 2024
c787d3b
Merge branch 'master' into feat/ore-2.3-blxr
Lanikean Aug 30, 2024
67dcae1
cleanup
Lanikean Aug 30, 2024
b45cbce
cleanup
Lanikean Aug 30, 2024
21a6ff1
cleanup
Lanikean Aug 30, 2024
367ead3
cleanup
Lanikean Aug 30, 2024
b22cd6f
cleanup
Lanikean Aug 30, 2024
e4145c6
cleanup
Lanikean Aug 30, 2024
2aab858
Merge pull request #1 from bloXroute-Labs/add-blxr
Lanikean Aug 30, 2024
678ca47
add sample command
Lanikean Sep 4, 2024
af27638
Merge pull request #2 from bloXroute-Labs/add-blxr
Lanikean Sep 4, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ admin = []
[dependencies]
bincode = "1.3.3"
bs58 = "0.5.1"
base64 = "0.22.1"
bytemuck = "1.16"
cached = "0.46.1"
chrono = "0.4.38"
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ To build the codebase from scratch, checkout the repo and use cargo to build:
cargo build --release
```

## Bloxroute

To run using Trader Api use the following command:

```
ore \
--rpc <RPC_ENDPOINT> \
--priority-fee 30000 \
--jito mine \
--cores 8 \
--bxr \
--buffer-time 4
```

## Help

You can use the `-h` flag on any command to pull up a help menu with documentation:
Expand Down
8 changes: 8 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ pub struct MineArgs {
default_value = "5"
)]
pub buffer_time: u64,

#[arg(
long = "bxr",
value_name = "BLOXROUTE",
help = "Enable bloxroute routing",
default_value = "false"
)]
pub bloxroute: bool,
}

#[derive(Parser, Debug)]
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod open;
mod proof;
mod rewards;
mod send_and_confirm;
mod send_and_confirm_bx;
mod stake;
mod transfer;
mod upgrade;
Expand Down Expand Up @@ -150,7 +151,7 @@ struct Args {
global = true
)]
jito: bool,

#[command(subcommand)]
command: Commands,
}
Expand Down
40 changes: 34 additions & 6 deletions src/mine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl Miner {
let proof =
get_updated_proof_with_authority(&self.rpc_client, signer.pubkey(), last_hash_at)
.await;

println!(
"\n\nStake: {} ORE\n{} Multiplier: {:12}x",
amount_u64_to_string(proof.balance),
Expand All @@ -55,8 +56,6 @@ impl Miner {
},
calculate_multiplier(proof.balance, config.top_balance)
);
last_hash_at = proof.last_hash_at;
last_balance = proof.balance;

// Calculate cutoff time
let cutoff_time = self.get_cutoff(proof, args.buffer_time).await;
Expand All @@ -82,10 +81,39 @@ impl Miner {
solution,
));

// Submit transaction
self.send_and_confirm(&ixs, ComputeBudget::Fixed(compute_budget), false)
.await
.ok();
if args.bloxroute {
// submit transaction to bloxroute
match self
.send_and_confirm_bx(&ixs, ComputeBudget::Fixed(compute_budget))
.await
{
Ok(signature) => {
last_hash_at = proof.last_hash_at;
last_balance = proof.balance;
println!(
"Transaction submitted successfully. Signature: {}",
signature
)
}
Err(e) => println!("Error submitting transaction: {:?}", e),
}
} else {
// Submit transaction
match self
.send_and_confirm(&ixs, ComputeBudget::Fixed(compute_budget), false)
.await
{
Ok(signature) => {
last_hash_at = proof.last_hash_at;
last_balance = proof.balance;
println!(
"Transaction submitted successfully. Signature: {}",
signature
)
}
Err(e) => println!("Error submitting transaction: {:?}", e),
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/send_and_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,14 @@ impl Miner {
}
}

fn log_error(progress_bar: &ProgressBar, err: &str, finish: bool) {
pub fn log_error(progress_bar: &ProgressBar, err: &str, finish: bool) {
if finish {
progress_bar.finish_with_message(format!("{} {}", "ERROR".bold().red(), err));
} else {
progress_bar.println(format!(" {} {}", "ERROR".bold().red(), err));
}
}

fn log_warning(progress_bar: &ProgressBar, msg: &str) {
pub fn log_warning(progress_bar: &ProgressBar, msg: &str) {
progress_bar.println(format!(" {} {}", "WARNING".bold().yellow(), msg));
}
Loading