Skip to content

Comments

feat: raw transaction batch submitter#527

Merged
karlfloersch merged 8 commits intomasterfrom
feat/raw_transaction_batch_submitter
Apr 22, 2021
Merged

feat: raw transaction batch submitter#527
karlfloersch merged 8 commits intomasterfrom
feat/raw_transaction_batch_submitter

Conversation

@karlfloersch
Copy link
Contributor

Description
Re-introduce raw tx based batch submitter first implemented here: ethereum-optimism/batch-submitter#56

Additional context
This contributes to #496

@karlfloersch karlfloersch requested a review from annieke as a code owner April 21, 2021 00:00
@changeset-bot
Copy link

changeset-bot bot commented Apr 21, 2021

🦋 Changeset detected

Latest commit: 2a17bcb

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

This PR includes changesets to release 2 packages
Name Type
@eth-optimism/batch-submitter Minor
@eth-optimism/core-utils 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

Fix tests

Add chainset
@karlfloersch karlfloersch force-pushed the feat/raw_transaction_batch_submitter branch from f146a12 to 8c825d4 Compare April 21, 2021 00:08
@@ -202,9 +202,10 @@ export class StateBatchSubmitter extends BatchSubmitter {
[...Array(blockRange).keys()],
Copy link
Contributor

Choose a reason for hiding this comment

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

If blockRange is negative, an error will be thrown

Copy link
Contributor

Choose a reason for hiding this comment

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

that should never happen since we do this check in _getBatchStartAndEnd:

if (startBlock >= endBlock) {
if (startBlock > endBlock) {
this.log.error(
'State commitment chain is larger than transaction chain. This should never happen!'
)
}
this.log.info(
'No state commitments to submit. Skipping batch submission...'
)
return

Copy link
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.

reviewed this with the original PR, everything else looks good!

@@ -202,9 +202,10 @@ export class StateBatchSubmitter extends BatchSubmitter {
[...Array(blockRange).keys()],
Copy link
Contributor

Choose a reason for hiding this comment

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

that should never happen since we do this check in _getBatchStartAndEnd:

if (startBlock >= endBlock) {
if (startBlock > endBlock) {
this.log.error(
'State commitment chain is larger than transaction chain. This should never happen!'
)
}
this.log.info(
'No state commitments to submit. Skipping batch submission...'
)
return

Comment on lines +81 to +86
case 'eth_getBlockByNumber':
if (params.length === 0) {
throw new Error(`Invalid params for ${endpoint}`)
}
const blockNumber = BigNumber.from((params as any)[0]).toNumber()
return this.mockBlocks[blockNumber]
Copy link
Contributor

Choose a reason for hiding this comment

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

we might be able to remove this if injectL2Context lets us call getBlockWithTransactions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mockchain provider refactor is going to be a beast -- thinking that we should just lump that into the big testing overhaul

Copy link
Contributor

Choose a reason for hiding this comment

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

noted!

…r.ts

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
@tynes
Copy link
Contributor

tynes commented Apr 21, 2021

Who owns pushing this over the finishline? @karlfloersch @annieke

@karlfloersch
Copy link
Contributor Author

karlfloersch commented Apr 22, 2021

Who owns pushing this over the finishline? @karlfloersch @annieke

@tynes I'll own it

Update: Looking for re-review! @gakonst @annieke

@karlfloersch karlfloersch force-pushed the feat/raw_transaction_batch_submitter branch from ecd05f8 to f43dd4f Compare April 22, 2021 01:09
/* Internal Imports */
import { EIP155TxData, TxType } from '@eth-optimism/core-utils'

export enum QueueOrigin {
Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially out of scope of this PR but this enum should be moved to core-utils

Copy link
Contributor

Choose a reason for hiding this comment

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

I notice there is another change to core-utils as part of this PR

QueueOrigin,
queueOriginPlainText,
} from '..'
import { L2Block, BatchElement, Batch, QueueOrigin } from '..'
Copy link
Contributor

Choose a reason for hiding this comment

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

These types could all go in core-utils, not opinionated on if its as part of this PR or not

Copy link
Contributor Author

@karlfloersch karlfloersch Apr 22, 2021

Choose a reason for hiding this comment

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

Agree they should definitely go into core-utils. That said there's a bunch of type & utility cleanup that we could do and so I'd lean against doing a potentially big refactor in the same PR that we're adding this new feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

^happy to help with the utility cleanup!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙏🙏🙏

@@ -1,20 +1,13 @@
/* External Imports */
import { Promise as bPromise } from 'bluebird'
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of removing bluebird as a dependency in the future? Concurrent async calls are easy with Promise.all

Copy link
Contributor

Choose a reason for hiding this comment

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

I had the same thought when I read that code before, here's a post providing good reasoning on "why bluebird" https://blog.kuzzle.io/bluebird-native-async_await-javascript-promises-performances-2020

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.

The big one is adding the changeset for core-utils

@karlfloersch karlfloersch force-pushed the feat/raw_transaction_batch_submitter branch 2 times, most recently from edeaf80 to 5f68d9a Compare April 22, 2021 04:31
@karlfloersch karlfloersch force-pushed the feat/raw_transaction_batch_submitter branch from 5f68d9a to fc22647 Compare April 22, 2021 04:46
Copy link
Contributor

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

Code changes LGTM - assuming they are not breaking Kovan or Mainnet.

"@eth-optimism/core-utils": patch
---

- Use raw transaction in batch submitter -- incompatible with L2Geth v0.1.2.1
Copy link
Contributor

Choose a reason for hiding this comment

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

What is geth 0.1.2.1? Is it deployed / being used anywhere right now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah it is the version of Geth that we were running before our last regenesis ~2/3 weeks ago. This should not be breaking Kovan or Mainnet now that we've got rawTransaction in mainnet

Copy link
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.

looks good! yay for deleted code, only concern is whether isSequencerTx is set correctly

QueueOrigin,
queueOriginPlainText,
} from '..'
import { L2Block, BatchElement, Batch, QueueOrigin } from '..'
Copy link
Contributor

Choose a reason for hiding this comment

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

^happy to help with the utility cleanup!

Comment on lines +81 to +86
case 'eth_getBlockByNumber':
if (params.length === 0) {
throw new Error(`Invalid params for ${endpoint}`)
}
const blockNumber = BigNumber.from((params as any)[0]).toNumber()
return this.mockBlocks[blockNumber]
Copy link
Contributor

Choose a reason for hiding this comment

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

noted!

…r.ts

Co-authored-by: Annie Ke <annieke8@gmail.com>
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.

Looks good to me!

@karlfloersch karlfloersch merged commit 5077441 into master Apr 22, 2021
@karlfloersch karlfloersch deleted the feat/raw_transaction_batch_submitter branch April 22, 2021 18:30
InoMurko referenced this pull request in omgnetwork/optimism May 25, 2021
* feat: use raw transaction

Fix tests

Add chainset

* Update packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>

* Remove raw eth_getBlock, delete dead code, & lint

* Remove txTypePlaintext and queueOriginPlaintext

* style: return promise; no await

* Update changeset & fix lint error

* Remove stray newline

* Update packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts

Co-authored-by: Annie Ke <annieke8@gmail.com>

Co-authored-by: Annie Ke <annie@address.com>
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
Co-authored-by: Annie Ke <annieke8@gmail.com>
OptimismBot pushed a commit that referenced this pull request Sep 4, 2025
emhane pushed a commit that referenced this pull request Feb 4, 2026
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.

4 participants