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

feat(provider): add cached DA oracles for bedrock/nitro #842

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

dancoombs
Copy link
Collaborator

Proposed Changes

  • Bedrock DA oracle with caching
    • Add a local DA provider for optimism bedrock chains. This requires a single network call per block to calculate the required DA gas for every user operation.
    • The DA provider contains an LRU cache to ensure that we only issue 1 network call update per block.
    • Compression happens locally now, via a fastlz binding at a specific commit. This commit is specifically the same used by LibZip.sol, which is used by the optimism DA oracle contract.
  • Nitro DA oracle with caching
    • The oracle only makes 1 network call per new UO + 1 network call per block
    • Due to the nitro implementation, there is the possibility of rounding errors, which are reduced here by scaling. Errors should underestimate by a small margin

crates/provider/src/alloy/da/local/bedrock.rs Outdated Show resolved Hide resolved
feat(provider): add a local bedrock DA provider

feat(provider): add a cached arbitrum nitro da gas oracle
@dancoombs
Copy link
Collaborator Author

Will add more tests in this ticket: #845

Want to get the mempool usage PR up quickly.

Ok(DAGasBlockData::Empty)
}

async fn uo_data(
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: I get the idea of this method and above are for impl the trait. could we move those impl in the trait definition so they by default return empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I typically don't like default method implementations, especially when they can cause panics, typically means the interface is wrong.

I think the better way to fix this would be to move the 3 new methods into a new trait: DAGasOracleSync so that we can be sure they only get called if they're implemented.

Then instead of using the da_tracking_enabled bool we pass an Option<DAGasOracleSync> to the pool/builder which uses it if populated.

For the sake of time I'm going to add a ticket to clean this up. Might move it to v0.5

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dancoombs dancoombs merged commit 557f24a into feat/v0.4 Oct 15, 2024
9 checks passed
@dancoombs dancoombs deleted the danc/cached-da branch October 15, 2024 14:26
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.

2 participants