Commit d6e309be authored by Mark Tyneway's avatar Mark Tyneway

itests: add coverage for compressed batches

Update the docker compose config such that the
batch submitters submit type 0 batches (zlib compressed)
and then add an integration test for that functionality.
parent fe680568
---
'@eth-optimism/integration-tests': patch
---
Add test coverage for zlib compressed batches
...@@ -14,3 +14,4 @@ l2geth/signer/fourbyte ...@@ -14,3 +14,4 @@ l2geth/signer/fourbyte
l2geth/cmd/puppeth l2geth/cmd/puppeth
l2geth/cmd/clef l2geth/cmd/clef
go/gas-oracle/gas-oracle go/gas-oracle/gas-oracle
go/batch-submitter/batch-submitter
...@@ -108,6 +108,9 @@ const procEnv = cleanEnv(process.env, { ...@@ -108,6 +108,9 @@ const procEnv = cleanEnv(process.env, {
MOCHA_BAIL: bool({ MOCHA_BAIL: bool({
default: false, default: false,
}), }),
BATCH_SUBMITTER_SEQUENCER_BATCH_TYPE: str({
default: 'zlib',
}),
}) })
export const envConfig = procEnv export const envConfig = procEnv
......
import { SequencerBatch, BatchType } from '@eth-optimism/core-utils'
import { expect } from './shared/setup'
import { OptimismEnv } from './shared/env'
import { envConfig } from './shared/utils'
describe('Batch Serialization', () => {
let env: OptimismEnv
// Allow for each type to be tested. The env var here must be
// the same value that is passed to the batch submitter
const batchType = envConfig.BATCH_SUBMITTER_SEQUENCER_BATCH_TYPE.toUpperCase()
before(async () => {
env = await OptimismEnv.new()
})
it('should fetch batches', async () => {
const tip = await env.l1Provider.getBlockNumber()
const logs = await env.ctc.queryFilter(
env.ctc.filters.TransactionBatchAppended(),
0,
tip
)
// collect all of the batches
const batches = []
for (const log of logs) {
const tx = await env.l1Provider.getTransaction(log.transactionHash)
batches.push(tx.data)
}
expect(batches.length).to.be.gt(0, 'Submit some batches first')
let latest = 0
// decode all of the batches
for (const batch of batches) {
// Typings don't work?
const decoded = (SequencerBatch as any).fromHex(batch)
expect(decoded.type).to.eq(BatchType[batchType])
// Iterate over all of the transactions, fetch them
// by hash and make sure their blocknumbers are in
// ascending order. This lets us skip handling deposits here
for (const transaction of decoded.transactions) {
const tx = transaction.toTransaction()
const got = await env.l2Provider.getTransaction(tx.hash)
expect(got).to.not.eq(null)
expect(got.blockNumber).to.be.gt(latest)
latest = got.blockNumber
}
}
})
})
...@@ -15,3 +15,4 @@ BATCH_SUBMITTER_RUN_TX_BATCH_SUBMITTER=true ...@@ -15,3 +15,4 @@ BATCH_SUBMITTER_RUN_TX_BATCH_SUBMITTER=true
BATCH_SUBMITTER_RUN_STATE_BATCH_SUBMITTER=true BATCH_SUBMITTER_RUN_STATE_BATCH_SUBMITTER=true
BATCH_SUBMITTER_SAFE_MINIMUM_ETHER_BALANCE=0 BATCH_SUBMITTER_SAFE_MINIMUM_ETHER_BALANCE=0
BATCH_SUBMITTER_CLEAR_PENDING_TXS=false BATCH_SUBMITTER_CLEAR_PENDING_TXS=false
BATCH_SUBMITTER_SEQUENCER_BATCH_TYPE=zlib
...@@ -17,3 +17,4 @@ MAX_BATCH_SUBMISSION_TIME=0 ...@@ -17,3 +17,4 @@ MAX_BATCH_SUBMISSION_TIME=0
SAFE_MINIMUM_ETHER_BALANCE=0 SAFE_MINIMUM_ETHER_BALANCE=0
CLEAR_PENDING_TXS=false CLEAR_PENDING_TXS=false
RETRIES=80 RETRIES=80
BATCH_SUBMITTER_USE_ZLIB_COMPRESSION=true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment