Quick calling L1 view functions from L2

Jun 20, 2023
Closed
Closed
Draft Project
  • Links

What is a Draft Project Idea?

A Draft Project Idea is a concept for a project within the Optimism ecosystem that is generally considered valuable but has not yet been fleshed out into a clearly defined product. Draft Project Ideas may be converted into Ecosystem Project Ideas as they are explored further and more thoroughly specified.

Summary

Add a feature to L2 that lets a smart contract call an L1 contract as long as it's a view or abstract function (a call, not a transaction). It may work something like this:

  1. An L2 contract calls a precompile with these parameters:
  2. L1 address
  3. Block number
  4. Calldata
  5. Max gas that the call can cost (and appropriate payment, to prevent DoS attacks)
  6. Callback data (for a deposit transaction with the results)
  7. The sequencer runs an eth_call with the appropriate block number, address, and calldata and creates the appropriate L2 transaction. This transaction becomes part of the L2 chain state, just as deposits submitted on L1 are, so it is as secure as everything else on L2.
  8. On L2 the callback specified is called with the result of the call.

Impact

Every free oracle on L1 becomes available on L2 in a matter of minutes, rather than after a seven day roundtrip.

Resources

  • More Information
  • Tag 1
    Protocol
  • Tag2
    OP Stack
  • Tag3
    Contracts