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

fix(fortuna): EIP1559 and script improvements #1603

Merged
merged 2 commits into from
May 23, 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 apps/fortuna/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/fortuna/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fortuna"
version = "5.4.3"
version = "5.4.4"
edition = "2021"

[dependencies]
Expand Down
11 changes: 4 additions & 7 deletions apps/fortuna/src/chain/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,10 @@ impl SignablePythContract {
) -> Result<SignablePythContract> {
let provider = Provider::<Http>::try_from(&chain_config.geth_rpc_addr)?;
let chain_id = provider.get_chainid().await?;
let eip1559_supported = !provider
.get_block(ethers::prelude::BlockNumber::Latest)
.await?
.ok_or_else(|| anyhow!("Latest block not found"))?
.base_fee_per_gas
.unwrap_or(U256::zero())
.is_zero(); // sei testnet returns 0 instead of None
let eip1559_supported = match provider.estimate_eip1559_fees(None).await {
Ok((max_fee, max_priority_fee)) => !max_fee.is_zero() && !max_priority_fee.is_zero(),
Err(_) => false,
};
let gas_oracle = EthProviderOracle::new(provider.clone());
let transformer = LegacyTxTransformer {
use_legacy_tx: !eip1559_supported,
Expand Down
10 changes: 6 additions & 4 deletions contract_manager/scripts/latency_entropy_with_callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ async function testLatency(

const startTime = Date.now();

let fromBlock = requestResponse.blockNumber;
const fromBlock = requestResponse.blockNumber;
const web3 = new Web3(contract.chain.getRpcUrl());
const entropyContract = contract.getContract();

// eslint-disable-next-line no-constant-condition
while (true) {
await new Promise((resolve) => setTimeout(resolve, 1000));
const currentBlock = await web3.eth.getBlockNumber();

if (fromBlock > currentBlock) {
Expand All @@ -70,7 +71,6 @@ async function testLatency(
fromBlock: fromBlock,
toBlock: currentBlock,
});
fromBlock = currentBlock + 1;

const event = events.find(
(event) => event.returnValues.request[1] == sequenceNumber
Expand All @@ -87,8 +87,10 @@ async function testLatency(
);
break;
}

await new Promise((resolve) => setTimeout(resolve, 300));
if (Date.now() - startTime > 60000) {
console.log("Timeout: 60s passed without the callback being called.");
break;
}
}
}

Expand Down
Loading