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

Multiply gas usage by 2 when setting up the provider #1291

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion fortuna/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fortuna"
version = "3.2.1"
version = "3.2.2"
edition = "2021"

[dependencies]
Expand Down
34 changes: 18 additions & 16 deletions fortuna/src/command/register_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ use {
state::PebbleHashChain,
},
anyhow::Result,
ethers::signers::{
LocalWallet,
Signer,
ethers::{
signers::{
LocalWallet,
Signer,
},
types::U256,
},
std::sync::Arc,
};
Expand Down Expand Up @@ -52,19 +55,18 @@ pub async fn register_provider(opts: &RegisterProviderOptions) -> Result<()> {
seed: random,
chain_length: commitment_length,
};

if let Some(r) = contract
.register(
fee_in_wei,
commitment,
bincode::serialize(&commitment_metadata)?.into(),
commitment_length,
bincode::serialize(&opts.uri)?.into(),
)
.send()
.await?
.await?
{
let call = contract.register(
fee_in_wei,
commitment,
bincode::serialize(&commitment_metadata)?.into(),
commitment_length,
bincode::serialize(&opts.uri)?.into(),
);
let mut gas_estimate = call.estimate_gas().await?;
let gas_multiplier = U256::from(2); //TODO: smarter gas estimation
gas_estimate = gas_estimate * gas_multiplier;
let call_with_gas = call.gas(gas_estimate);
if let Some(r) = call_with_gas.send().await?.await? {
tracing::info!("Registered provider: {:?}", r);
}

Expand Down
Loading