Skip to content

Commit 5dcf5ca

Browse files
authored
Multiply gas usage by 2 when setting up the provider (#1291)
1 parent 6a32844 commit 5dcf5ca

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "3.2.1"
3+
version = "3.2.2"
44
edition = "2021"
55

66
[dependencies]

fortuna/src/command/register_provider.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ use {
88
state::PebbleHashChain,
99
},
1010
anyhow::Result,
11-
ethers::signers::{
12-
LocalWallet,
13-
Signer,
11+
ethers::{
12+
signers::{
13+
LocalWallet,
14+
Signer,
15+
},
16+
types::U256,
1417
},
1518
std::sync::Arc,
1619
};
@@ -52,19 +55,18 @@ pub async fn register_provider(opts: &RegisterProviderOptions) -> Result<()> {
5255
seed: random,
5356
chain_length: commitment_length,
5457
};
55-
56-
if let Some(r) = contract
57-
.register(
58-
fee_in_wei,
59-
commitment,
60-
bincode::serialize(&commitment_metadata)?.into(),
61-
commitment_length,
62-
bincode::serialize(&opts.uri)?.into(),
63-
)
64-
.send()
65-
.await?
66-
.await?
67-
{
58+
let call = contract.register(
59+
fee_in_wei,
60+
commitment,
61+
bincode::serialize(&commitment_metadata)?.into(),
62+
commitment_length,
63+
bincode::serialize(&opts.uri)?.into(),
64+
);
65+
let mut gas_estimate = call.estimate_gas().await?;
66+
let gas_multiplier = U256::from(2); //TODO: smarter gas estimation
67+
gas_estimate = gas_estimate * gas_multiplier;
68+
let call_with_gas = call.gas(gas_estimate);
69+
if let Some(r) = call_with_gas.send().await?.await? {
6870
tracing::info!("Registered provider: {:?}", r);
6971
}
7072

0 commit comments

Comments
 (0)