Skip to content

Commit

Permalink
refactor(ethexe): Subscribe blocks when Observer is created (#4311)
Browse files Browse the repository at this point in the history
Co-authored-by: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com>
  • Loading branch information
techraed and StackOverflowExcept1on authored Dec 10, 2024
1 parent a967e29 commit ed59317
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 193 deletions.
14 changes: 7 additions & 7 deletions ethexe/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ impl Service {
}
}

pub async fn run(self) -> Result<()> {
self.run_inner().await.map_err(|err| {
log::error!("Service finished work with error: {err:?}");
err
})
}

async fn run_inner(self) -> Result<()> {
let Service {
db,
Expand Down Expand Up @@ -591,13 +598,6 @@ impl Service {
Ok(())
}

pub async fn run(self) -> Result<()> {
self.run_inner().await.map_err(|err| {
log::error!("Service finished work with error: {:?}", err);
err
})
}

async fn post_process_commitments(
code_commitments: Vec<CodeCommitment>,
block_commitments: Vec<BlockCommitment>,
Expand Down
9 changes: 0 additions & 9 deletions ethexe/cli/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,6 @@ async fn ping_reorg() {
assert_eq!(res.program_id, ping_id);
assert_eq!(res.reply_payload, b"PONG");

// Await for service block with user reply handling
// TODO: this is for better logs reading only, should find a better solution #4099
tokio::time::sleep(env.block_time).await;

log::info!("📗 Test after reverting to the program creation snapshot");
provider
.anvil_revert(program_created_snapshot_id)
Expand Down Expand Up @@ -546,10 +542,6 @@ async fn ping_reorg() {
let res = send_message.wait_for().await.unwrap();
assert_eq!(res.program_id, ping_id);
assert_eq!(res.reply_payload, b"PONG");

// Await for service block with user reply handling
// TODO: this is for better logs reading only, should find a better solution #4099
tokio::time::sleep(Duration::from_secs(1)).await;
}

// Mine 150 blocks - send message - mine 150 blocks.
Expand Down Expand Up @@ -1354,7 +1346,6 @@ mod utils {
None,
None,
);

let handle = task::spawn(service.run());
self.running_service_handle = Some(handle);

Expand Down
4 changes: 3 additions & 1 deletion ethexe/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ impl<T: Transport + Clone, N: Network> TryGetReceipt<T, N> for PendingTransactio
Err(err) => err,
};

for _ in 0..3 {
log::trace!("Failed to get transaction receipt for {tx_hash}. Retrying...");
for n in 0..3 {
log::trace!("Attempt {n}. Error - {err}");
match err {
PendingTransactionError::TransportError(RpcError::NullResp) => {}
_ => break,
Expand Down
Loading

0 comments on commit ed59317

Please sign in to comment.