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

Check if relayer funds are enough to process submitted transaction (estimates). #53

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

piohei
Copy link
Contributor

@piohei piohei commented Sep 2, 2024

Transaction cost is estimated based on gas limit and current gas cost estimates based on chain.

@piohei piohei force-pushed the piohei/check_funds branch 4 times, most recently from 67e35d5 to 2588866 Compare September 2, 2024 08:38
.await?;

let block_fees = app.db.get_latest_block_fees_by_chain_id(relayer.chain_id).await?;
if let Some(block_fees) = block_fees {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to check funds only if estimates are available. Other option is to return error here if we think it is crucial for us.

@piohei piohei force-pushed the piohei/check_funds branch from 2588866 to 6879b43 Compare September 2, 2024 08:41
@piohei piohei force-pushed the piohei/check_funds branch from 6879b43 to 575d7cb Compare September 2, 2024 08:45
@piohei piohei marked this pull request as ready for review September 2, 2024 09:02
src/service.rs Outdated
@@ -82,6 +82,18 @@ impl Service {

Ok(())
}

pub async fn is_estimates_ready_for_chain(&self, chain_id: u64) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub async fn is_estimates_ready_for_chain(&self, chain_id: u64) -> bool {
pub async fn are_estimates_ready_for_chain(&self, chain_id: u64) -> bool {

?

@@ -94,6 +94,22 @@ impl ServiceBuilder {
let client =
TxSitterClient::new(format!("http://{}", service.local_addr()));

// Awaits for estimates to be ready
let mut is_estimates_ready = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut is_estimates_ready = false;
let mut are_estimates_ready = false;

src/service.rs Outdated

pub async fn is_estimates_ready_for_chain(&self, chain_id: u64) -> bool {
let res = self
._app
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change struct field to app

@piohei piohei merged commit e67fa99 into main Sep 5, 2024
8 checks passed
@piohei piohei deleted the piohei/check_funds branch September 5, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants