Skip to content

dtl: add query param based querying for txs#479

Merged
gakonst merged 6 commits intomasterfrom
dtl/query-params
Apr 21, 2021
Merged

dtl: add query param based querying for txs#479
gakonst merged 6 commits intomasterfrom
dtl/query-params

Conversation

@tynes
Copy link
Copy Markdown
Contributor

@tynes tynes commented Apr 16, 2021

Description
The DTL currently prioritizes transactions sourced from L2 instead of transactions sourced from L1. This was a quick patch required for sequencer maintenance, the source of truth should generally be L1. This allows the client to specify a query param that says to source the transaction from L1 or from L2

Additional context
Related to #477
Previously query params had no impact on the DTL. The DTL has a backing index for both transactions ingested from the L1 contracts (CTC + SCC) and an index for transactions pulled from a sequencer (eth_getBlockByNumber). The DTL has preferred different data sources over time. Before this PR, the config option showUnconfirmedTransactions being set to true would prefer the L2 sourced transactions but then fall back to L1 sourced transactions. After this PR, the client will specify the data source and then the server will only return that transaction sourced from that datasource.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 16, 2021

🦋 Changeset detected

Latest commit: e86ee09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/data-transport-layer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tynes tynes requested a review from smartcontracts April 16, 2021 02:31
Copy link
Copy Markdown
Contributor Author

@tynes tynes Apr 16, 2021

Choose a reason for hiding this comment

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

@smartcontracts Any thoughts on how to reduce complexity in this endpoint? We need to add the backend query param to this so that it can determine whether or not its sync'd L1 or L2. Ideally we refactor the db handlers now that we are moving away from confirmed/not confirmed as concepts in this codebase

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is backend in this case defaultSource or a different concept?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Based on the code, I believe it's the same thing @annieke. @tynes may want to use consistent language and call it backend everywhere.

@tynes what do you think is too complex here? This looks OK to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

what do you think is too complex here? This looks OK to me.

I'm talking about the crazy if/else nesting
https://github.com/ethereum-optimism/optimism/pull/479/files#diff-29a43f33722b902c31ee7224a372262d2b73f170ed0af5be6aca1b54aa505a72L183-L211

@tynes tynes force-pushed the dtl/query-params branch from 85086b4 to 2bbaa1f Compare April 17, 2021 00:10
@tynes tynes added M-dtl C-feature Category: features labels Apr 17, 2021
@tynes tynes force-pushed the dtl/query-params branch 3 times, most recently from e2efd16 to a129eeb Compare April 19, 2021 19:23
@tynes tynes marked this pull request as ready for review April 19, 2021 19:45
@tynes tynes requested a review from annieke as a code owner April 19, 2021 19:45
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do you mean to make the default 'batched' here instead of 'l1'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, this is the bug that is causing CI to fail

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

will we have more sources than batched or sequenced in the future? assuming no since it seems like they directly correspond to l1 and l2 right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we anticipate adding more sources

['batched', 'sequenced'].includes(val)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They don't necessarily correspond to L1 and L2 per say, really the abstraction is batched or batched + pre-batched. The batched transactions are currently batched to Ethereum L1 but will be batched to an Eth2 data shard in the future.

Working on unifying the language between the different codebases.

['batched', 'sequenced'].includes(val)

We only have 2 sources right now so I think its fine. I prefer writing JS using a subset of the language that is as C like as possible with Python sprinkled in, see https://github.com/handshake-org/hsd/blob/master/lib/blockchain/chain.js as an example

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is backend in this case defaultSource or a different concept?

@tynes tynes force-pushed the dtl/query-params branch from a129eeb to 5f6cf32 Compare April 20, 2021 23:38
@gakonst gakonst requested a review from annieke April 21, 2021 12:54
Copy link
Copy Markdown
Contributor

@annieke annieke left a comment

Choose a reason for hiding this comment

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

lgtm!

"@eth-optimism/data-transport-layer": patch
---

Add backwards compatible query params to REST API
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: May want to make your message a bit clearer, I do not understand what you changed just by reading this.

Something like: Allow the DTL to provide data from either L1 or L2, configurable via a query param sent by the client.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Based on the code, I believe it's the same thing @annieke. @tynes may want to use consistent language and call it backend everywhere.

@tynes what do you think is too complex here? This looks OK to me.

@gakonst gakonst merged commit 27f32ca into master Apr 21, 2021
@gakonst gakonst deleted the dtl/query-params branch April 21, 2021 20:01
InoMurko referenced this pull request in omgnetwork/optimism May 25, 2021
* dtl: remove stopL2SyncAtHeight config

* dtl: implement query param based backend

* dtl: remove dead comment

* dtl: add changeset

* dtl: standardize on backend query param

* changeset: update comment
bap2pecs added a commit to babylonlabs-io/optimism that referenced this pull request Jul 31, 2024
bap2pecs added a commit to babylonlabs-io/optimism that referenced this pull request Jul 31, 2024
emhane added a commit that referenced this pull request Feb 3, 2026
Closes op-rs/op-reth#467

- Adds `initialize-op-proofs` command to book
- Adds new op proofs flags for op-reth node command to book

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-feature Category: features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants