Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine step size in Steel history commitments #309

Open
Wollac opened this issue Oct 28, 2024 · 4 comments
Open

Determine step size in Steel history commitments #309

Wollac opened this issue Oct 28, 2024 · 4 comments
Labels

Comments

@Wollac
Copy link
Contributor

Wollac commented Oct 28, 2024

The Beacon roots contract in Ethereum stores the historical roots of the last 8191 slots. When building the chain of state_commits, we need to pinpoint the latest (or near-latest) block within each 8191 slot window. Simply incrementing the block number by 8191 works if no slots are missed, but this approach fails when slots are skipped. To guarantee accuracy, we need a more sophisticated mechanism to identify the correct block within the time window, accounting for potential missed slots.

Copy link

linear bot commented Oct 28, 2024

@Wollac Wollac added the steel label Oct 28, 2024 — with Linear
Copy link
Contributor Author

Wollac commented Oct 28, 2024

Possible Solution 1: Adaptive Block Increment

One approach is to assume a maximum percentage (x%) of missed blocks within an 8191 slot window. The block number increment would then be adjusted to 8191 * (1 - x).

Drawbacks:

  • Inflexible: This method struggles to adapt to varying network conditions. On stable networks like Ethereum Mainnet, where missed blocks are rare, it unnecessarily shortens the step size, increasing proving costs. Conversely, on testnets or experimental chains with higher block miss rates, it may consistently fail to find the correct block.

Copy link
Contributor Author

Wollac commented Oct 28, 2024

Possible Solution 2: Timestamp-based Lookup

If the block time is known (since this commitment pattern only works on Ethereum and not L2, it might be reasonable to always assume 12 seconds), we could determine the target block by calculating its timestamp: current_timestamp + (8191 * 12).

Drawbacks:

  • RPC Limitations: Ethereum's standard JSON-RPC API doesn't offer a direct way to query blocks by timestamp. This would necessitate a binary search (or similar method) to find the block with the closest timestamp, potentially increasing load on RPC nodes and incurring higher costs.
  • Block Time Variations: While Ethereum uses a 12-second block time, hardcoding this value could cause issues on testnets or forks with different block times. Adding block time to the chain configuration is not ideal, as this information is only relevant for history commitments and only on the host.

Copy link
Contributor Author

Wollac commented Oct 28, 2024

Possible Solution 3: Beacon API

Leverage the Beacon API to directly query consensus blocks by slot number. This allows us to identify the last block within the 8191 slot window by iteratively decrementing the slot number until a valid block is found. The corresponding execution block can then be extracted from the returned consensus block's ExecutionPayload.

Drawbacks:

  • Beacon Node Load: Repeatedly querying a Beacon API node, especially when potentially traversing numerous slots to find a valid block, can impose significant load and cost on the node. This is particularly concerning because the eth/v2/beacon/blocks/{block_id} API call (used to retrieve block data by slot) is typically one of the most expensive calls in the entire Beacon API. This could be exacerbated by concurrent requests or if multiple clients adopt this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant