Skip to content

Commit 1bab5cd

Browse files
authored
Merge branch 'main' into start-typestate
2 parents 2961ac3 + e3abf2d commit 1bab5cd

File tree

9 files changed

+47
-24
lines changed

9 files changed

+47
-24
lines changed

.github/workflows/check.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
steps:
3232
- name: Harden the runner (Audit all outbound calls)
33-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
33+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
3434
with:
3535
egress-policy: audit
3636

@@ -49,7 +49,7 @@ jobs:
4949

5050
steps:
5151
- name: Harden the runner (Audit all outbound calls)
52-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
52+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
5353
with:
5454
egress-policy: audit
5555

@@ -71,7 +71,7 @@ jobs:
7171

7272
steps:
7373
- name: Harden the runner (Audit all outbound calls)
74-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
74+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
7575
with:
7676
egress-policy: audit
7777

@@ -92,7 +92,7 @@ jobs:
9292

9393
steps:
9494
- name: Harden the runner (Audit all outbound calls)
95-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
95+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
9696
with:
9797
egress-policy: audit
9898

@@ -113,7 +113,7 @@ jobs:
113113

114114
steps:
115115
- name: Harden the runner (Audit all outbound calls)
116-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
116+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
117117
with:
118118
egress-policy: audit
119119

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: Harden the runner (Audit all outbound calls)
25-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
25+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
2626
with:
2727
egress-policy: audit
2828

.github/workflows/scorecard.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
# actions: read
3131
steps:
3232
- name: Harden Runner
33-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
33+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
3434
with:
3535
egress-policy: audit
3636
- name: Checkout code
@@ -46,12 +46,12 @@ jobs:
4646
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
4747
# format to the repository Actions tab.
4848
- name: Upload artifact
49-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
49+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
5050
with:
5151
name: SARIF file
5252
path: results.sarif
5353
retention-days: 5
5454
- name: Upload SARIF to GitHub Code Scanning
55-
uses: github/codeql-action/upload-sarif@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v3.29.5
55+
uses: github/codeql-action/upload-sarif@1b168cd39490f61582a9beae412bb7057a6b2c4e # v3.29.5
5656
with:
5757
sarif_file: results.sarif

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: Harden the runner (Audit all outbound calls)
26-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
26+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
2727
with:
2828
egress-policy: audit
2929

@@ -34,18 +34,18 @@ jobs:
3434
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
3535

3636
- name: Install Foundry
37-
uses: foundry-rs/foundry-toolchain@50d5a8956f2e319df19e6b57539d7e2acb9f8c1e # v1.5.0
37+
uses: foundry-rs/foundry-toolchain@8b0419c685ef46cb79ec93fbdc131174afceb730 # v1.6.0
3838

3939
- name: Cache cargo-nextest binary
4040
id: cache-cargo-nextest
41-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
41+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
4242
with:
4343
path: ~/.cargo/bin/cargo-nextest
4444
key: ${{ runner.os }}-cargo-nextest-${{ hashFiles('**/Cargo.lock') }}
4545

4646
- name: Install cargo-nextest
4747
if: steps.cache-cargo-nextest.outputs.cache-hit != 'true'
48-
uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2.62.63
48+
uses: taiki-e/install-action@d850aa816998e5cf15f67a78c7b933f2a5033f8a # v2.63.3
4949
with:
5050
tool: cargo-nextest
5151

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ authors = ["OpenZeppelin"]
1414
edition = "2024"
1515
license = "MIT"
1616
repository = "https://github.com/OpenZeppelin/Event-Scanner"
17-
version = "0.8.0-alpha"
17+
version = "0.9.0-alpha"
1818

1919
[workspace.lints.clippy]
2020
pedantic = "warn"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Add `event-scanner` to your `Cargo.toml`:
5353

5454
```toml
5555
[dependencies]
56-
event-scanner = "0.8.0-alpha"
56+
event-scanner = "0.9.0-alpha"
5757
```
5858

5959
Create an event stream for the given event filters registered with the `EventScanner`:

src/event_scanner/scanner/mod.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,42 @@ mod latest;
2121
mod live;
2222
mod sync;
2323

24-
/// Maximum number of concurrent fetches for block ranges in the current scanner mode.
24+
/// Default number of maximum concurrent fetches for each scanner mode.
2525
pub const DEFAULT_MAX_CONCURRENT_FETCHES: usize = 24;
2626

2727
#[derive(Default)]
2828
pub struct Unspecified;
2929
pub struct Historic {
3030
pub(crate) from_block: BlockId,
3131
pub(crate) to_block: BlockId,
32+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
3233
pub(crate) max_concurrent_fetches: usize,
3334
}
3435
pub struct Live {
3536
pub(crate) block_confirmations: u64,
37+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
3638
pub(crate) max_concurrent_fetches: usize,
3739
}
3840
pub struct LatestEvents {
3941
pub(crate) count: usize,
4042
pub(crate) from_block: BlockId,
4143
pub(crate) to_block: BlockId,
4244
pub(crate) block_confirmations: u64,
45+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
4346
pub(crate) max_concurrent_fetches: usize,
4447
}
4548
#[derive(Default)]
4649
pub struct Synchronize;
4750
pub struct SyncFromLatestEvents {
4851
pub(crate) count: usize,
4952
pub(crate) block_confirmations: u64,
53+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
5054
pub(crate) max_concurrent_fetches: usize,
5155
}
5256
pub struct SyncFromBlock {
5357
pub(crate) from_block: BlockId,
5458
pub(crate) block_confirmations: u64,
59+
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
5560
pub(crate) max_concurrent_fetches: usize,
5661
}
5762

@@ -138,18 +143,24 @@ impl EventScannerBuilder<Unspecified> {
138143
///
139144
/// The scanner streams events in chronological order (oldest to newest) within the specified
140145
/// block range. Events are delivered in batches as they are fetched from the provider, with
141-
/// batch sizes controlled by the `max_block_range` configuration.
146+
/// batch sizes controlled by the [`max_block_range`][max_block_range] configuration.
142147
///
143148
/// # Key behaviors
144149
///
145150
/// * **Continuous streaming**: Events are delivered in multiple messages as they are fetched
146151
/// * **Chronological order**: Events are always delivered oldest to newest
152+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the execution time.
153+
/// The maximum number of concurrent RPC calls is controlled by
154+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
147155
/// * **Default range**: By default, scans from `Earliest` to `Latest` block
148-
/// * **Batch control**: Use `.max_block_range(n)` to control how many blocks are queried per
149-
/// RPC call
156+
/// * **Batch control**: Use [`max_block_range`][max_block_range] to control how many blocks are
157+
/// queried per RPC call
150158
/// * **Reorg handling**: Performs reorg checks when streaming events from non-finalized blocks;
151159
/// if a reorg is detected, streams events from the reorged blocks
152160
/// * **Completion**: The scanner completes when the entire range has been processed.
161+
///
162+
/// [max_block_range]: crate::EventScannerBuilder::max_block_range
163+
/// [max_concurrent_fetches]: crate::EventScannerBuilder::max_concurrent_fetches
153164
#[must_use]
154165
pub fn historic() -> EventScannerBuilder<Historic> {
155166
EventScannerBuilder::default()
@@ -308,6 +319,9 @@ impl EventScannerBuilder<Unspecified> {
308319
/// message, chronologically ordered
309320
/// * **One-shot operation**: The scanner completes after delivering messages; it does not
310321
/// continue streaming
322+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the execution time.
323+
/// The maximum number of concurrent RPC calls is controlled by
324+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
311325
/// * **Flexible count**: If fewer than `count` events exist in the range, returns all available
312326
/// events
313327
/// * **Default range**: By default, scans from `Earliest` to `Latest` block
@@ -349,6 +363,7 @@ impl EventScannerBuilder<Unspecified> {
349363
/// [sync_from_latest]: EventScannerBuilder::from_latest
350364
/// [reorg]: crate::Notification::ReorgDetected
351365
/// [no_logs]: crate::Notification::NoPastLogsFound
366+
/// [max_concurrent_fetches]: crate::EventScannerBuilder#method.max_concurrent_fetches-1
352367
#[must_use]
353368
pub fn latest(count: usize) -> EventScannerBuilder<LatestEvents> {
354369
EventScannerBuilder::<LatestEvents>::new(count)

src/event_scanner/scanner/sync/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ impl EventScannerBuilder<Synchronize> {
7474
///
7575
/// * **No duplicates**: Events are not delivered twice across the phase transition
7676
/// * **Flexible count**: If fewer than `count` events exist, returns all available events
77+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the sync phase
78+
/// execution time. The maximum number of concurrent RPC calls is controlled by
79+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
7780
/// * **Reorg handling**: Both phases handle reorgs appropriately:
7881
/// - Latest events phase: resets and rescans on reorg detection
7982
/// - Live phase: resets stream to the first post-reorg block that satisfies the configured
@@ -115,6 +118,7 @@ impl EventScannerBuilder<Synchronize> {
115118
/// [reorg]: crate::types::Notification::ReorgDetected
116119
/// [switch_to_live]: crate::types::Notification::SwitchingToLive
117120
/// [no_logs]: crate::types::Notification::NoPastLogsFound
121+
/// [max_concurrent_fetches]: crate::EventScannerBuilder#method.block_confirmations-4
118122
#[must_use]
119123
pub fn from_latest(self, count: usize) -> EventScannerBuilder<SyncFromLatestEvents> {
120124
EventScannerBuilder::<SyncFromLatestEvents>::new(count)
@@ -201,6 +205,9 @@ impl EventScannerBuilder<Synchronize> {
201205
///
202206
/// * **No duplicates**: Events are not delivered twice across the phase transition
203207
/// * **Chronological order**: Historical events are delivered oldest to newest
208+
/// * **Concurrent log fetching**: Logs are fetched concurrently to reduce the sync phase
209+
/// execution time. The maximum number of concurrent RPC calls is controlled by
210+
/// [`max_concurrent_fetches`][max_concurrent_fetches]
204211
/// * **Seamless transition**: Automatically switches to live mode when caught up
205212
/// * **Continuous operation**: Live phase continues indefinitely until the scanner is dropped
206213
/// * **Reorg detection**: When a reorg is detected, [`Notification::ReorgDetected`][reorg] is
@@ -219,6 +226,7 @@ impl EventScannerBuilder<Synchronize> {
219226
/// [start]: crate::event_scanner::EventScanner::start
220227
/// [reorg]: crate::types::Notification::ReorgDetected
221228
/// [switch_to_live]: crate::types::Notification::SwitchingToLive
229+
/// [max_concurrent_fetches]: crate::EventScannerBuilder#method.block_confirmations-3
222230
#[must_use]
223231
pub fn from_block(self, block_id: impl Into<BlockId>) -> EventScannerBuilder<SyncFromBlock> {
224232
EventScannerBuilder::<SyncFromBlock>::new(block_id.into())

0 commit comments

Comments
 (0)