Skip to content

echonet: L1Manager gas price target and mock L1 head#13621

Open
ron-starkware wants to merge 1 commit intoayelet/echonet/l1-gas-price/funcfrom
ron/echonet/l1-manager-gas-prices
Open

echonet: L1Manager gas price target and mock L1 head#13621
ron-starkware wants to merge 1 commit intoayelet/echonet/l1-gas-price/funcfrom
ron/echonet/l1-manager-gas-prices

Conversation

@ron-starkware
Copy link
Copy Markdown
Contributor

@ron-starkware ron-starkware commented Mar 31, 2026

Note

Medium Risk
Changes mock eth_blockNumber semantics and introduces threaded long-polling plus synthetic fee fields, which may impact scraper behavior/timing if assumptions differ. Test coverage was updated, but integration timing/race conditions are the main risk.

Overview
L1Manager now maintains a monotonically increasing mock L1 head (backed by new DEFAULT_L1_BLOCK_NUMBER) and changes get_block_number to long-poll on a condition variable, reducing tight-loop polling load while still unblocking scrapers promptly.

Adds set_gas_price_target() and extends the default/fallback L1 block returned by get_block_by_number to include EIP-1559 base fee and blob fee context (baseFeePerGas, derived excessBlobGas, timestamp), and syncs the mock head upward when real L1 blocks are stored/reset when clearing state. Unit tests are updated/expanded to assert the new head behavior, cleanup semantics, and reset/increment flows.

Written by Cursor Bugbot for commit 4786a92. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

ron-starkware commented Mar 31, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ron-starkware ron-starkware self-assigned this Mar 31, 2026
@ron-starkware ron-starkware marked this pull request as ready for review March 31, 2026 08:49
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread echonet/l1_logic/l1_manager.py
Comment thread echonet/l1_logic/tests/test_l1_manager.py
@ron-starkware ron-starkware force-pushed the ayelet/echonet/l1-gas-price/func branch from 740b659 to fcdfb7a Compare March 31, 2026 09:10
@ron-starkware ron-starkware force-pushed the ron/echonet/l1-manager-gas-prices branch from f0be778 to 2ece522 Compare March 31, 2026 09:10
@ron-starkware ron-starkware force-pushed the ron/echonet/l1-manager-gas-prices branch from 2ece522 to 4786a92 Compare March 31, 2026 09:35
Copy link
Copy Markdown
Contributor

@ayeletstarkware ayeletstarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayeletstarkware reviewed 1 file and made 5 comments.
Reviewable status: 1 of 3 files reviewed, 5 unresolved discussions (waiting on ron-starkware).


echonet/l1_logic/l1_manager.py line 28 at r2 (raw file):

    It is incremented by set_gas_price_target (once per L2 block) and synced upward by set_new_tx
    when real L1 block numbers are stored.
    """

let's move the rest to the functions descriptions

Suggestion:

    """
    Manages L1 block data and provides mock RPC responses for the L1 gas price scraper and L1 events scraper.
    """

echonet/l1_logic/l1_manager.py line 55 at r2 (raw file):

            # (T_next ≈ T_current + block_interval). The mock L1 timestamp must be ≤ T_current
            # so the Rust lag-margin lookup (lag=0) finds a qualifying block. 30s is safely
            # above the ~2s block interval and well below the 900s max_time_gap.

can you rephrase that? I don't understand

Code quote:

            # set_gas_price_target is called with the NEXT feeder block's timestamp
            # (T_next ≈ T_current + block_interval). The mock L1 timestamp must be ≤ T_current
            # so the Rust lag-margin lookup (lag=0) finds a qualifying block. 30s is safely
            # above the ~2s block interval and well below the 900s max_time_gap.

echonet/l1_logic/l1_manager.py line 73 at r2 (raw file):

        return block

    def __init__(

move up, above default_l1_block

Code quote:

def __init__(

echonet/l1_logic/l1_manager.py line 91 at r2 (raw file):

        # Condition used to implement long-polling in get_block_number.
        # Notified whenever _mock_l1_head_number changes so waiting scrapers wake up
        # immediately instead of hammering echonet with rapid polls.

I think the documentation related to the long polling should be in get_block_number

Suggestion:

# long-poll condition for get_block_number

echonet/l1_logic/l1_manager.py line 94 at r2 (raw file):

        self._mock_l1_head_updated = threading.Condition()

    def _set_mock_l1_head_number(self, value: int) -> None:

Suggestion:

 def _set_mock_l1_head_number(self, value: int) -> None:
    """Update the mock L1 head and wake any threads blocked in get_block_number."""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants