Skip to content

Commit

Permalink
fix(fortuna): EIP1559 and script improvements (#1603)
Browse files Browse the repository at this point in the history
* fix(fortuna): improve eip1559 detection

In chiliz, rewards had negative values so the previous logic
was not working

* fix(fortuna): Minor improvements on latency script
  • Loading branch information
m30m authored May 23, 2024
1 parent 12730ca commit 3674f1c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
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

0 comments on commit 3674f1c

Please sign in to comment.