Skip to content

Conversation

@willmeister
Copy link

@willmeister willmeister commented Sep 17, 2020

Description

Changes Canonical Transaction Chain Batch Creator config from accepting a min / max number of transactions to accepting a min / max number of transaction calldata bytes. This allows it to control the ultimate size of the L1 tx to be posted.

Also fixes:

  • Issue where L1 block subscription does not upsert re-orgs when it should
  • Issue where microservices will not start if only running L1 and/or L2 chain data persisters and no consumers

Metadata

Fixes

Contributing Agreement

…max rollup calldata size instead of number of transactions
Copy link
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Overall makes sense, left a few comments for you

maxBatchCalldataBytes: number
): Promise<number> {
// TODO: ADD SOME SIZE LIMIT
const txRes = await this.rdb.select(
Copy link
Contributor

Choose a reason for hiding this comment

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

Verifying that I understand this change: calldata is stored in the db with the 0x prefix, so LENGTH(calldata)-2 accounts for the prefix. The division by 2 here: (LENGTH(calldata)-2) / 2 is converting from string size to byte size. Is there any chance that an odd size of calldata could end up in the database? I saw that ethers sometimes uses 0x0 as 0, the chainId is returned as a single character following 0x. That is a different codepath but noting it here just in case. Empty calldata should be 0x, if LENGTH(calldata) is 0 then there would be a bug here.

The SUM statement will add the calldata size (in bytes) of the 2 earliest transactions (ORDER BY block_timestamp ASC)

Copy link
Author

@willmeister willmeister Sep 17, 2020

Choose a reason for hiding this comment

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

calldata is stored in the db with the 0x prefix, so LENGTH(calldata)-2 accounts for the prefix

Yep!

The division by 2 here: (LENGTH(calldata)-2) / 2 is converting from string size to byte size.

Yep!

Is there any chance that an odd size of calldata could end up in the database? I saw that ethers sometimes uses 0x0 as 0, the chainId is returned as a single character following 0x.

Yes and no. Yes, bad data can get into the DB (at which point we have way bigger problems -- we commit fraud), but no, calldata is always bytes, and bytes are always an even number of hex chars. Shortcuts used in JSON representation of some fields should not apply here.

Empty calldata should be 0x, if LENGTH(calldata) is 0 then there would be a bug here.

Even empty calldata should be 0x in the DB, but I'll make it GREATEST(LENGTH(calldata)-2, 0) just in case.

The SUM statement will add the calldata size (in bytes) of the 2 earliest transactions (ORDER BY block_timestamp ASC)

This is the block timestamp of our L2 node, which we update infrequently, so there will be many txs with the same block timestamp. Two txs with different timestamps cannot be in the same rollup batch, though. So if this query returns 2 results, we know the first batch cannot get any bigger and must be submitted. Regardless, this query is summing up all of the calldata of all of the txs that could possibly be in each batch (divided by block timestamp).

let lastId = -1
for (const row of res) {
totalCalldataBytes += parseInt(row['calldata_bytes'], 10)
if (totalCalldataBytes > maxBatchCalldataBytes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This codepath wouldn't be impacted from a ton of transactions being included in a batch? The batch size would be selected by the sequencer? So users submitting tons of txs wouldn't be able to trigger this?

Copy link
Author

Choose a reason for hiding this comment

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

It's possible that we'd handle a ton of txs with the same block timestamp, at which point this collection would be very large, but we'll eagerly exit this loop as soon as our max gets hit, so we should be good. Might be good to add an arbitrary [but large] limit to the query, though, just in case we have a burst of txs with 0 calldata.

Copy link
Author

Choose a reason for hiding this comment

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

Worth noting, I created a query that does this calc in the query itself, but it's slow and would get slower as more records get added (stupid CROSS JOIN 😆 )

Copy link
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Might be good to add an arbitrary [but large] limit to the query, though, just in case we have a burst of txs with 0 calldata.

This sounds like a nice addition and would be a good safety precaution. If you want to add it, I'd be on board with it.

Looks good to me 23884b2

@willmeister willmeister merged commit 753e2cd into master Sep 18, 2020
@willmeister willmeister deleted the YAS-677/RollupBlockCalldataLimit branch September 18, 2020 15:08
snario pushed a commit that referenced this pull request Apr 14, 2021
mslipper pushed a commit that referenced this pull request Feb 6, 2025
mslipper added a commit that referenced this pull request Feb 6, 2025
* feat: add shared lockbox (#126)

* feat: create shared lockbox contract with its interface and unit tests

* chore: polish tests and interfaces

* chore: run pre-pr

* chore: improve natspec

* chore: run pre-pr

* chore: update compiler version

* feat: integrate portal to lockbox (#139)

* feat: integrate portal to lockbox

* fix: pr fixes

* test: refactor assert

* feat: add liquidity migrator contract with its unit test and interface (#128)

* feat: create shared lockbox contract with its interface and unit tests

* chore: polish tests and interfaces

* chore: run pre-pr

* chore: improve natspec

* chore: run pre-pr

* feat: add liqudity migrator contract with its unit test and interface

* chore: remove underscore on stack var

* chore: add todo

* chore: run pre-pr

* chore: add contract title natspec and proxied

* refactor: integrate testing suite with common test

* chore: pre-pr

* chore: add spec test

* feat: integrate system config with superchain config (#140)

* feat: integrate portal to lockbox

* fix: pr fixes

* test: refactor assert

* feat: integrate system config with superchain config

* fix: remove OPCM interop

* test: add dependency counter test

* feat: manage dependency set on superchain config (#138)

* chore: add zero dependencies check (#142)

* fix: pre pr

* feat: Add pause check (#145)

* feat: Add pause check

Co-authored-by: 0xParticle <[email protected]>
Co-authored-by: gotzenx <[email protected]>
Co-authored-by: Joxess <[email protected]>

* test: add tests natspecs

---------

Co-authored-by: 0xParticle <[email protected]>
Co-authored-by: gotzenx <[email protected]>
Co-authored-by: Joxess <[email protected]>

* fix: pre pr and interfaces imports

* feat: add upgrader role to superchain config (#163)

* feat: use superchain config lockbox in portal (#164)

* feat: use superchain config lockbox in portal

* test: add new sharedlockbox test

* fix: pre pr

* feat: liquidity migrator deployment (#166)

* feat: liquidity migrator deployment

* test: fix comment

* test: fix internal variables names

* feat: dependency set refactor (#170)

* feat: dependency set refactor

* fix: deploy script variable name

* fix: pr

* fix: pr

* fix: pre pr

* fix: semgrep

* fix: merge conflict

* [WIP] feat: new lockbox (#192)

* chore: partial implementation comments

* feat: new lockbox

* feat: introduce dependency manager predeploy

* feat: remove timestamp check from CrossL2Inbox

* feat: introduce cluster manager role and remove immutables

* fix: remove unnecessary code, fix tests and setup

* feat: use unstructured storage and OZ v5

* fix: L2ToL2CDM dependency set check

* fix: dependency manager gas limit

* feat: refactor interop feature contracts (#200)

* feat: refactor interop feature contracts

* fix: add noops comment

* feat: adds OptimismPortal migrated flag

* test: add missing tests

* fix: portal interop storage naming

---------

Co-authored-by: Skeletor Spaceman <[email protected]>

* fix: pre pr, setup and tests

* fix: remove system config interop and add interop portal target check (#205)

* fix: remove system config interop and add interop portal check

* fix: interop portal target check order

* fix: remove wrong comment

* fix: refactor portal noops function (#206)

* test: add dependency manager and portal interop tests (#209)

* feat: initialize shared lockbox in interop portal (#211)

* feat: initialize shared lockbox in interop portal

* fix: refactor shared lockbox storage getter

* fix: lockbox pr fixes (#214)

* fix: pre pr

* fix: semver lock

* fix: semver lock

* feat: descope dependency manager (#242)

* feat: descope dependency manager

* test: fix tests

* test: fix tests

* chore: improve eth liquidity test (#248)

* fix: internal review fixes (#243)

* fix: I-0

* fix: I-1

* fix: I-2

* fix: I-3

* fix: I-6

* fix: I-7

* fix: I-9

* fix: pre pr

* fix: pre pr

* fix: portal withdrawal checks (#255)

* fix: portal withdrawal checks

* fix: include current withdrawal check

* fix: remove unused interop contracts (#256)

* test: fix flake tests (#257)

* fix: adjust op-deployer interop scripts (#262)

* fix: pre pr

* fix op-deployer tests

* remove dependency code

* fix lint

* use Bob account

---------

Co-authored-by: Disco <[email protected]>
Co-authored-by: AgusDuha <[email protected]>
Co-authored-by: agusduha <[email protected]>
Co-authored-by: 0xParticle <[email protected]>
Co-authored-by: gotzenx <[email protected]>
Co-authored-by: Joxess <[email protected]>
Co-authored-by: Skeletor Spaceman <[email protected]>
xibao-nr pushed a commit to node-real/combo-optimism that referenced this pull request Feb 17, 2025
Zena-park pushed a commit to tokamak-network/optimism that referenced this pull request Dec 30, 2025
We advise this restriction to be imposed solely when the implementation is being set to an _alive status of true, ensuring that a "deleted" implementation (such as an EIP-7702 delegated address) can still be removed.
Zena-park added a commit to tokamak-network/optimism that referenced this pull request Dec 30, 2025
theochap pushed a commit that referenced this pull request Jan 15, 2026
Closes #262

---------

Co-authored-by: Matthias Seitz <[email protected]>
theochap pushed a commit that referenced this pull request Jan 21, 2026
Closes #262

---------

Co-authored-by: Matthias Seitz <[email protected]>
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