Skip to content

Commit

Permalink
feat: send cannot execute event to amplifier (#6)
Browse files Browse the repository at this point in the history
* feat(effective-tx-sender): return tx signature on tx err

The signature is useful in case we need to retrieve logs for the
transaction.

Signed-off-by: Guilherme Felipe da Silva <[email protected]>

* feat: send task execution feedback on failure

Signed-off-by: Guilherme Felipe da Silva <[email protected]>

* fix: typo

* refactor: drop fetch_logs usage

Using fetch_logs won't work here because it doesn't return the data for
failed transactions. Besides that, we're lot really using the logs
whereas fetch_logs fails if there is not logs.

Signed-off-by: Guilherme Felipe da Silva <[email protected]>

* fix: typo

Co-authored-by: Roberts Pumpurs <[email protected]>

---------

Signed-off-by: Guilherme Felipe da Silva <[email protected]>
Co-authored-by: Roberts Pumpurs <[email protected]>
  • Loading branch information
frenzox and roberts-pumpurs authored Dec 20, 2024
1 parent 9fbde23 commit cccb9fc
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 34 deletions.
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 disappear after is_some returns true"),
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-transaction-status.workspace = true

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

0 comments on commit cccb9fc

Please sign in to comment.