Skip to content

Add svm bid data extraction from transaction #136

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

Merged
merged 7 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion auction-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ serde_path_to_error = "0.1.16"
solana-sdk = "2.0.7"
bincode = "1.3.3"
serde_with = "3.9.0"
anchor-lang-idl = { version = "0.1.1", features = ["convert"] }
anchor-lang = "0.30.1"
express-relay = { path = "../contracts/svm/programs/express_relay" }

Expand Down
50 changes: 27 additions & 23 deletions auction-server/src/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,30 +923,34 @@ fn extract_account_svm(
instruction: CompiledInstruction,
position: usize,
) -> Result<Pubkey, RestError> {
if instruction.accounts.len() <= position {
tracing::error!(
"Account position not found in instruction: {:?} - {}",
instruction,
position,
);
return Err(RestError::BadParameters(
"Permission account not found in submit_bid instruction".to_string(),
));
}

let account_position = instruction.accounts[position] as usize;
if account_position >= accounts.len() {
tracing::error!(
"Account not found in transaction accounts: {:?} - {}",
accounts,
account_position,
);
return Err(RestError::BadParameters(
"Permission account not found in transaction accounts".to_string(),
));
match instruction.accounts.get(position) {
None => {
tracing::error!(
"Account position not found in instruction: {:?} - {}",
instruction,
position,
);
Err(RestError::BadParameters(
"Account not found in submit_bid instruction".to_string(),
))
}
Some(account_position) => {
let account_position: usize = (*account_position).into();
match accounts.get(position) {
None => {
tracing::error!(
"Account not found in transaction accounts: {:?} - {}",
accounts,
account_position,
);
Err(RestError::BadParameters(
"Account not found in transaction accounts".to_string(),
))
}
Some(account) => Ok(*account),
}
}
}

Ok(accounts[account_position])
}

fn extract_bid_data_svm(
Expand Down
12 changes: 0 additions & 12 deletions auction-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ use {
},
traced_client::TracedClient,
},
anchor_lang_idl::{
convert::convert_idl,
types::Idl,
},
anyhow::anyhow,
axum_prometheus::{
metrics_exporter_prometheus::{
Expand Down Expand Up @@ -69,7 +65,6 @@ use {
},
std::{
collections::HashMap,
fs,
sync::{
atomic::{
AtomicBool,
Expand Down Expand Up @@ -233,12 +228,6 @@ async fn setup_chain_store(
.collect()
}

pub fn load_express_relay_idl() -> anyhow::Result<Idl> {
let idl = fs::read("../contracts/svm/target/idl/express_relay.json")?;
convert_idl(idl.as_slice())
.map_err(|err| anyhow!("Failed to convert express relay idl: {:?}", err))
}

const NOTIFICATIONS_CHAN_LEN: usize = 1000;
pub async fn start_server(run_options: RunOptions) -> anyhow::Result<()> {
tokio::spawn(async move {
Expand Down Expand Up @@ -269,7 +258,6 @@ pub async fn start_server(run_options: RunOptions) -> anyhow::Result<()> {

let chains_svm = setup_chain_store_svm(config_map);
let express_relay_svm = ExpressRelaySvm {
idl: load_express_relay_idl()?,
permission_account_position: env!("SUBMIT_BID_PERMISSION_ACCOUNT_POSITION")
.parse::<usize>()
.expect("Failed to parse permission account position"),
Expand Down
2 changes: 0 additions & 2 deletions auction-server/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use {
models,
traced_client::TracedClient,
},
anchor_lang_idl::types::Idl,
axum::Json,
axum_prometheus::metrics_exporter_prometheus::PrometheusHandle,
base64::{
Expand Down Expand Up @@ -298,7 +297,6 @@ pub struct BidStatusWithId {

#[derive(Clone)]
pub struct ExpressRelaySvm {
pub idl: Idl,
pub permission_account_position: usize,
pub router_account_position: usize,
}
Expand Down
Loading