Skip to content

Commit 275891b

Browse files
committed
remove txn limit
1 parent 19800a4 commit 275891b

File tree

5 files changed

+33
-39
lines changed

5 files changed

+33
-39
lines changed

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mkconfig_docker_full NUM_NODES RPC_URL PARENT_CHAIN_ID PARENT_INBOX_ADDRESS *ARG
110110
--mode "increment-address" {{ARGS}} | jq
111111

112112
verify_blocks:
113-
cargo run --bin block_verifier
113+
cargo run --release --bin block_verifier
114114

115115
####################
116116
####TEST COMMANDS###

tests/block-verifier/src/main.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ use futures::future::join_all;
1010
use timeboost_utils::types::logging::init_logging;
1111
use tracing::{error, info};
1212

13+
/// Max. Difference between l2 block heights for potential race conditions when heights are fetched
14+
/// from the sequencers
15+
const MAX_BLOCK_HEIGHT_DIFF: u64 = 2;
16+
1317
#[derive(Parser, Debug)]
1418
struct Cli {
15-
/// Nitro node URLs used for gas estimations and getting nonce when sending transactions
16-
/// Can be specified multiple times: --nitro-url url1 --nitro-url url2
19+
/// Nitro node URLs use to check state for different sequencers to ensure consistency
1720
#[clap(
1821
long,
1922
default_value = "http://localhost:8547;http://localhost:8647",
@@ -23,7 +26,7 @@ struct Cli {
2326
nitro_urls: Vec<String>,
2427
}
2528

26-
async fn connect_to_chain<N: Network>(urls: &[String]) -> Result<Vec<RootProvider<N>>> {
29+
async fn connect_to_nitro<N: Network>(urls: &[String]) -> Result<Vec<RootProvider<N>>> {
2730
let mut p = Vec::new();
2831
for url in urls {
2932
p.push(RootProvider::<N>::connect(url).await?)
@@ -36,23 +39,34 @@ async fn main() -> Result<()> {
3639
init_logging();
3740
let cli = Cli::parse();
3841

39-
let providers = connect_to_chain::<Ethereum>(&cli.nitro_urls).await?;
42+
let providers = connect_to_nitro::<Ethereum>(&cli.nitro_urls).await?;
4043

41-
// take the minimum block in to avoid race conditions
42-
let min_block = join_all(providers.iter().map(|p| async {
44+
let block_numbers = join_all(providers.iter().map(|p| async {
4345
p.get_block_number()
4446
.await
4547
.context("provider request failed")
4648
}))
4749
.await
4850
.into_iter()
49-
.collect::<Result<Vec<u64>>>()?
50-
.into_iter()
51-
.min()
52-
.context("failed to get min block")?;
51+
.collect::<Result<Vec<u64>>>()?;
52+
53+
let min = *block_numbers.iter().min().context("no blocks received")?;
54+
let max = *block_numbers.iter().max().context("no blocks received")?;
55+
let diff = max - min;
56+
57+
// ensure the max - min is within MAX_BLOCK_HEIGHT_DIFF
58+
if diff > MAX_BLOCK_HEIGHT_DIFF {
59+
error!(%max, %min, %diff, max_diff = %MAX_BLOCK_HEIGHT_DIFF, "❌ block numbers too far apart");
60+
anyhow::bail!(
61+
"block numbers too far apart (min: {}, max: {}, diff: {})",
62+
min,
63+
max,
64+
diff
65+
);
66+
}
5367

54-
for i in 0..=min_block {
55-
info!(num = %i, "getting block number");
68+
// use minimum block in to avoid race conditions
69+
for i in 0..=min {
5670
let blocks = join_all(providers.iter().map(|p| async {
5771
p.get_block_by_number(BlockNumberOrTag::Number(i))
5872
.await
@@ -71,6 +85,7 @@ async fn main() -> Result<()> {
7185
.ok_or_else(|| anyhow::anyhow!("provider returned no block"))?;
7286
if b != first_block {
7387
error!(
88+
num = %b.number(),
7489
block_a = ?b,
7590
block_b = ?first_block,
7691
"❌ block mismatch between state"
@@ -82,7 +97,7 @@ async fn main() -> Result<()> {
8297
);
8398
}
8499
if i == blocks.len() - 1 {
85-
info!(block_hash = %b.hash(), txns = ?b.transactions, "✅ verified block");
100+
info!(num = %b.number(), block_hash = %b.hash(), txns = ?b.transactions, "✅ verified block");
86101
}
87102
}
88103
}

yapper/src/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ pub(crate) struct YapperConfig {
1111
pub(crate) nitro_integration: bool,
1212
/// URL of nitro chain that is configured
1313
pub(crate) nitro_url: String,
14-
/// Limit on the number of transactions we want to send
15-
pub(crate) txn_limit: u64,
1614
/// Chain id for l2 chain
1715
pub(crate) chain_id: u64,
1816
}

yapper/src/main.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ struct Cli {
4545
#[clap(long, default_value_t = false)]
4646
nitro_integration: bool,
4747

48-
/// How many txns to send before terminating yapper
49-
#[clap(long, default_value_t = 20)]
50-
nitro_txn_limit: u64,
51-
5248
/// Chain id for l2 chain
5349
/// default: https://docs.arbitrum.io/run-arbitrum-node/run-local-full-chain-simulation#default-endpoints-and-addresses
5450
#[clap(long, default_value_t = 412346)]
@@ -85,7 +81,6 @@ async fn main() -> Result<()> {
8581
.addresses(addresses)
8682
.nitro_integration(cli.nitro_integration)
8783
.tps(cli.tps)
88-
.txn_limit(cli.nitro_txn_limit)
8984
.nitro_url(cli.nitro_url)
9085
.chain_id(cli.chain_id)
9186
.build();

yapper/src/yapper.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub(crate) struct Yapper {
4141
interval: Duration,
4242
chain_id: u64,
4343
provider: Option<RootProvider>,
44-
txn_limit: Option<u64>,
4544
}
4645

4746
impl Yapper {
@@ -63,23 +62,16 @@ impl Yapper {
6362
});
6463
}
6564
let client = Client::builder().timeout(Duration::from_secs(1)).build()?;
66-
let (provider, interval, txn_limit) = if cfg.nitro_integration {
67-
(
68-
Some(RootProvider::<Ethereum>::connect(&cfg.nitro_url).await?),
69-
Duration::from_secs(1),
70-
// For nitro running in ci, avoid race conditions with block height by setting txn
71-
// limit
72-
Some(cfg.txn_limit),
73-
)
65+
let provider = if cfg.nitro_integration {
66+
Some(RootProvider::<Ethereum>::connect(&cfg.nitro_url).await?)
7467
} else {
75-
(None, Duration::from_millis(tps_to_millis(cfg.tps)), None)
68+
None
7669
};
7770
Ok(Self {
7871
urls,
79-
interval,
72+
interval: Duration::from_millis(tps_to_millis(cfg.tps)),
8073
client,
8174
provider,
82-
txn_limit,
8375
chain_id: cfg.chain_id,
8476
})
8577
}
@@ -93,7 +85,6 @@ impl Yapper {
9385
self.urls.iter().map(|url| url.enckey_url.clone()),
9486
);
9587

96-
let mut txn_sent = 0;
9788
loop {
9889
let b = if let Some(ref p) = self.provider {
9990
// For testing just send from the dev account to the validator address
@@ -119,11 +110,6 @@ impl Yapper {
119110
.await
120111
}))
121112
.await;
122-
txn_sent += 1;
123-
if self.txn_limit == Some(txn_sent) {
124-
warn!("hit txn limit, terminating yapper");
125-
return Ok(());
126-
}
127113

128114
interval.tick().await;
129115
}

0 commit comments

Comments
 (0)