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

feat: send cannot execute event to amplifier #6

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
25 changes: 13 additions & 12 deletions Cargo.lock

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

34 changes: 31 additions & 3 deletions crates/effective-tx-sender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'a> EffectiveTxSender<'a, Unevaluated> {
impl<'a> EffectiveTxSender<'a, Evaluated> {
/// Signs and sends the transaction.
#[tracing::instrument(skip_all, err)]
pub async fn send_tx(self) -> eyre::Result<Signature> {
pub async fn send_tx(self) -> Result<Signature, ComputeBudgetError> {
let valid_slice = self.ixs.as_slices().0;
let tx = solana_sdk::transaction::Transaction::new_signed_with_payer(
valid_slice,
Expand All @@ -114,10 +114,28 @@ impl<'a> EffectiveTxSender<'a, Evaluated> {
self.hash,
);

let signature = self
let signature = match self
.solana_rpc_client
.send_and_confirm_transaction(&tx)
.await?;
.await
{
Ok(signature) => signature,
Err(err) if err.get_transaction_error().is_some() => {
let signature = tx
.signatures
.first()
.expect("Signed transaction should have a signature");

return Err(ComputeBudgetError::TransactionError {
source: err
.get_transaction_error()
.expect("Value shouldn't disapper after is_some returns true"),
frenzox marked this conversation as resolved.
Show resolved Hide resolved
signature: *signature,
});
}
Err(err) => return Err(ComputeBudgetError::Generic(eyre::Error::from(err))),
};

Ok(signature)
}
}
Expand All @@ -128,6 +146,16 @@ pub enum ComputeBudgetError {
/// Error occurred during transaction simulation.
#[error("Simulation error: {0:?}")]
SimulationError(RpcSimulateTransactionResult),

/// An error occurred during the transaction RPC call.
#[error("TransactionError: {source}")]
TransactionError {
/// The transaction error that occurred.
source: solana_sdk::transaction::TransactionError,
/// The signature of the transaction that caused the error.
signature: Signature,
},

/// Generic, non-recoverable error.
#[error("Generic error: {0}")]
Generic(eyre::Error),
Expand Down
1 change: 1 addition & 0 deletions crates/solana-axelar-relayer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async fn main() {
name_on_amplifier.clone(),
Arc::clone(&rpc_client),
amplifier_task_receiver,
amplifier_client.clone(),
file_based_storage,
);
let (solana_listener_component, solana_listener_client) = solana_listener::SolanaListener::new(
Expand Down
1 change: 1 addition & 0 deletions crates/solana-gateway-task-processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ axelar-executable.workspace = true
num-traits.workspace = true
relayer-amplifier-state.workspace = true
its-instruction-builder.workspace = true
solana-listener.workspace = true

[dev-dependencies]
serde_json.workspace = true
Expand Down
Loading
Loading