From 1b21d2d6dacf0ca81c4b027b8d03d8d2898bdc81 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 9 Dec 2024 15:31:27 +0100 Subject: [PATCH] Add options when sending tx with retry. --- crates/rpc/rpc-eth-types/src/error.rs | 1 - crates/telos/node/tests/live_test_runner.rs | 11 +++++++++-- crates/telos/rpc/src/eth/telos_client.rs | 10 ++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/rpc/rpc-eth-types/src/error.rs b/crates/rpc/rpc-eth-types/src/error.rs index 7a46327b038e..10fa3b716021 100644 --- a/crates/rpc/rpc-eth-types/src/error.rs +++ b/crates/rpc/rpc-eth-types/src/error.rs @@ -5,7 +5,6 @@ use std::time::Duration; use alloy_primitives::{Address, Bytes, U256}; use alloy_rpc_types::{error::EthRpcErrorCode, request::TransactionInputError, BlockError}; use alloy_sol_types::decode_revert_reason; -use jsonrpsee_core::ClientError; use reth_errors::RethError; use reth_primitives::{revm_primitives::InvalidHeader, BlockId}; use reth_rpc_server_types::result::{ diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index e3e6834ef262..6f21e4452875 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -236,6 +236,11 @@ pub async fn test_1559_tx( .with_max_fee_per_gas(20_000_000_000); let tx_result = provider.send_transaction(tx).await; + + info!("test_1559_tx"); + + + assert!(tx_result.is_err()); } @@ -266,6 +271,8 @@ pub async fn test_2930_tx( }])) .max_fee_per_gas(2e9 as u128); let tx_result = provider.send_transaction(tx).await; + info!("test_2930_tx"); + assert!(tx_result.is_err()); } @@ -320,9 +327,9 @@ pub async fn test_double_approve_erc20( let block_number = receipt2.unwrap().block_number.unwrap(); - // make sure the block is included + // make sure the block is included and there is a progress while let Some(block) = provider.get_block_by_number(Latest, false).await.unwrap() { - if block.header.number == block_number { + if block.header.number >= block_number { break; } } diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index 33c33f015409..2ad014b76337 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -76,7 +76,7 @@ fn parse_error_message(message: String) -> Option { } fn parse_server_error(server_error: SendTransactionResponse2Error) -> EthApiError { - let mut error_message = server_error.message; + let error_message = server_error.message; for detail in server_error.details.unwrap_or_default() { if let Some(error) = parse_error_message(detail.message) { return error; @@ -232,11 +232,17 @@ impl TelosClient { context_free_data: vec![], }; + let options = SendTransaction2Options{ + return_failure_trace: true, + retry_trx: true, + retry_trx_num_blocks: 2, + }; + let tx_response = self .inner .api_client .v1_chain - .send_transaction2(signed_telos_transaction.clone(), None) + .send_transaction2(signed_telos_transaction.clone(), Some(options)) .await; let tx = match tx_response {