Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzejkop committed Dec 21, 2023
1 parent 2f0b25d commit 8793850
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 40 deletions.
9 changes: 0 additions & 9 deletions src/broadcast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@ pub fn calculate_gas_fees_from_estimates(
tx_priority_index: usize,
max_base_fee_per_gas: U256,
) -> (U256, U256) {
println!("estimates = {estimates:#?}");

let max_priority_fee_per_gas = estimates.percentile_fees[tx_priority_index];

let max_fee_per_gas = max_base_fee_per_gas + max_priority_fee_per_gas;

println!(
"max_base_fee_per_gas = {max_base_fee_per_gas}, max_priority_fee_per_gas = {max_priority_fee_per_gas}, max_fee_per_gas = {max_fee_per_gas}",
max_base_fee_per_gas = max_base_fee_per_gas,
max_priority_fee_per_gas = max_priority_fee_per_gas,
max_fee_per_gas = max_fee_per_gas,
);

(max_fee_per_gas, max_priority_fee_per_gas)
}

Expand Down
2 changes: 1 addition & 1 deletion src/tasks/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::time::Duration;
use ethers::providers::Middleware;
use ethers::types::transaction::eip2718::TypedTransaction;
use ethers::types::transaction::eip2930::AccessList;
use ethers::types::{Address, Eip1559TransactionRequest, NameOrAddress, H256, U256};
use ethers::types::{Address, Eip1559TransactionRequest, NameOrAddress, H256};
use eyre::ContextCompat;
use futures::stream::FuturesUnordered;
use futures::StreamExt;
Expand Down
43 changes: 15 additions & 28 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use ethers::providers::{Http, Middleware, Provider};
use ethers::signers::{LocalWallet, Signer};
use ethers::types::{Address, Eip1559TransactionRequest, H160, U256};
use ethers::utils::{Anvil, AnvilInstance};
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use postgres_docker_utils::DockerContainerGuard;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::layer::SubscriberExt;
Expand Down Expand Up @@ -73,7 +71,7 @@ pub fn setup_tracing() {
EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
// Logging from fake_rpc can get very messy so we set it to warn only
.parse_lossy("info,fake_rpc=warn"),
.parse_lossy("info,tx_sitter=debug,fake_rpc=warn"),
)
.init();
}
Expand All @@ -92,32 +90,21 @@ pub async fn setup_anvil(block_time: u64) -> eyre::Result<AnvilInstance> {
let middleware =
setup_middleware(anvil.endpoint(), SECONDARY_ANVIL_PRIVATE_KEY).await?;

// Wait for the chain to start and produce at least one block
tokio::time::sleep(Duration::from_secs(block_time)).await;

// We need to seed some transactions so we can get fee estimates on the first block
// let mut nonce = 0;
// let mut futures = FuturesUnordered::new();
// for i in 0..100 {
// let tx = middleware
// .send_transaction(
// Eip1559TransactionRequest {
// nonce: Some(U256::from(nonce)),
// to: Some(DEFAULT_ANVIL_ACCOUNT.into()),
// value: Some(U256::from(100u64)),
// max_fee_per_gas: Some(U256::from(40_000_000_000u64)),
// max_priority_fee_per_gas: Some(U256::from(10_000u64)),
// ..Default::default()
// },
// None,
// )
// .await?;

// futures.push(tx);

// nonce += 1;
// }

// while let Some(tx) = futures.next().await {
// tx?;
// }
middleware
.send_transaction(
Eip1559TransactionRequest {
to: Some(DEFAULT_ANVIL_ACCOUNT.into()),
value: Some(U256::from(100u64)),
..Default::default()
},
None,
)
.await?
.await?;

Ok(anvil)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/escalation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ async fn escalation() -> eyre::Result<()> {
)
.await?;

for _ in 0..10 {
for _ in 0..24 {
let balance = provider.get_balance(ARBITRARY_ADDRESS, None).await?;

if balance == value {
return Ok(());
} else {
tokio::time::sleep(Duration::from_secs(5)).await;
tokio::time::sleep(Duration::from_secs(3)).await;
}
}

Expand Down

0 comments on commit 8793850

Please sign in to comment.