Skip to content

Commit

Permalink
Merge branch 'develop' into feat/setRollupTimestampRefresh
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Ho authored Jun 1, 2021
2 parents ae10f2e + 1293825 commit 068322f
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .changeset/nasty-dots-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@eth-optimism/l2geth': patch
'@eth-optimism/data-transport-layer': patch
---

Fix gasLimit overflow
4 changes: 2 additions & 2 deletions l2geth/rollup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type transaction struct {
BlockNumber uint64 `json:"blockNumber"`
Timestamp uint64 `json:"timestamp"`
Value hexutil.Uint64 `json:"value"`
GasLimit uint64 `json:"gasLimit"`
GasLimit uint64 `json:"gasLimit,string"`
Target common.Address `json:"target"`
Origin *common.Address `json:"origin"`
Data hexutil.Bytes `json:"data"`
Expand All @@ -84,7 +84,7 @@ type Enqueue struct {
Index *uint64 `json:"ctcIndex"`
Target *common.Address `json:"target"`
Data *hexutil.Bytes `json:"data"`
GasLimit *uint64 `json:"gasLimit"`
GasLimit *uint64 `json:"gasLimit,string"`
Origin *common.Address `json:"origin"`
BlockNumber *uint64 `json:"blockNumber"`
Timestamp *uint64 `json:"timestamp"`
Expand Down
29 changes: 26 additions & 3 deletions packages/data-transport-layer/src/db/transport-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,38 @@ export class TransportDB {
if (index === null) {
return null
}

return this.db.get<TEntry>(`${key}:index`, index)
let entry = await this.db.get<TEntry>(`${key}:index`, index)
entry = stringify(entry)
return entry
}

private async _getEntries<TEntry extends Indexed>(
key: string,
startIndex: number,
endIndex: number
): Promise<TEntry[] | []> {
return this.db.range<TEntry>(`${key}:index`, startIndex, endIndex)
const entries = await this.db.range<TEntry>(
`${key}:index`,
startIndex,
endIndex
)
const results = []
for (const entry of entries) {
results.push(stringify(entry))
}
return results
}
}

function stringify(entry) {
if (entry === null || entry === undefined) {
return entry
}
if (entry.gasLimit) {
entry.gasLimit = BigNumber.from(entry.gasLimit).toString()
}
if (entry.decoded) {
entry.decoded.gasLimit = BigNumber.from(entry.decoded.gasLimit).toString()
}
return entry
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const handleEventsSequencerBatchAppended: EventHandlerSet<
submitter: l1Transaction.from,
l1TransactionHash: l1Transaction.hash,
l1TransactionData: l1Transaction.data,
gasLimit: SEQUENCER_GAS_LIMIT,
gasLimit: `${SEQUENCER_GAS_LIMIT}`,

prevTotalElements: batchSubmissionEvent.args._prevTotalElements,
batchIndex: batchSubmissionEvent.args._batchIndex,
Expand Down Expand Up @@ -115,7 +115,7 @@ export const handleEventsSequencerBatchAppended: EventHandlerSet<
batchIndex: extraData.batchIndex.toNumber(),
blockNumber: BigNumber.from(context.blockNumber).toNumber(),
timestamp: BigNumber.from(context.timestamp).toNumber(),
gasLimit: BigNumber.from(extraData.gasLimit).toNumber(),
gasLimit: BigNumber.from(extraData.gasLimit).toString(),
target: SEQUENCER_ENTRYPOINT_ADDRESS,
origin: null,
data: toHexString(sequencerTransaction),
Expand Down Expand Up @@ -147,7 +147,7 @@ export const handleEventsSequencerBatchAppended: EventHandlerSet<
batchIndex: extraData.batchIndex.toNumber(),
blockNumber: BigNumber.from(0).toNumber(),
timestamp: BigNumber.from(0).toNumber(),
gasLimit: BigNumber.from(0).toNumber(),
gasLimit: BigNumber.from(0).toString(),
target: constants.AddressZero,
origin: constants.AddressZero,
data: '0x',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const handleEventsTransactionEnqueued: EventHandlerSet<
index: event.args._queueIndex.toNumber(),
target: event.args._target,
data: event.args._data,
gasLimit: event.args._gasLimit.toNumber(),
gasLimit: event.args._gasLimit.toString(),
origin: event.args._l1TxOrigin,
blockNumber: BigNumber.from(event.blockNumber).toNumber(),
timestamp: event.args._timestamp.toNumber(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const handleSequencerBlock = {

transactionEntry = {
...transactionEntry,
gasLimit: SEQUENCER_GAS_LIMIT, // ?
gasLimit: `${SEQUENCER_GAS_LIMIT}`, // ?
target: SEQUENCER_ENTRYPOINT_ADDRESS,
origin: null,
data: serialize(
Expand All @@ -82,7 +82,7 @@ export const handleSequencerBlock = {
} else {
transactionEntry = {
...transactionEntry,
gasLimit: BigNumber.from(transaction.gas).toNumber(),
gasLimit: BigNumber.from(transaction.gas).toString(),
target: ethers.utils.getAddress(transaction.to),
origin: ethers.utils.getAddress(transaction.l1TxOrigin),
data: transaction.input,
Expand Down
4 changes: 2 additions & 2 deletions packages/data-transport-layer/src/types/database-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface EnqueueEntry {
index: number
target: string
data: string
gasLimit: number
gasLimit: string
origin: string
blockNumber: number
timestamp: number
Expand All @@ -28,7 +28,7 @@ export interface TransactionEntry {
data: string
blockNumber: number
timestamp: number
gasLimit: number
gasLimit: string
target: string
origin: string
value: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface SequencerBatchAppendedExtraData {
submitter: string
l1TransactionData: string
l1TransactionHash: string
gasLimit: number
gasLimit: string

// Stuff from TransactionBatchAppended.
prevTotalElements: BigNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Event Handlers: OVM_CanonicalTransactionChain.SequencerBatchAppended',
submitter: '0xfd7d4de366850c08ee2cba32d851385a3071ec8d',
l1TransactionHash:
'0x6effe006836b841205ace4d99d7ae1b74ee96aac499a3f358b97fccd32ee9af2',
gasLimit: 548976,
gasLimit: '548976',
prevTotalElements: BigNumber.from(73677),
batchIndex: BigNumber.from(743),
batchSize: BigNumber.from(101),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Event Handlers: OVM_CanonicalTransactionChain.TransactionEnqueued', ()
}
})

it('should have a gasLimit equal to the integer value of the _gasLimit argument', () => {
it('should have a gasLimit equal to the string value of the _gasLimit argument', () => {
for (
let i = 0;
i < Number.MAX_SAFE_INTEGER;
Expand All @@ -113,7 +113,7 @@ describe('Event Handlers: OVM_CanonicalTransactionChain.TransactionEnqueued', ()

const output1 = handleEventsTransactionEnqueued.parseEvent(...input1)

const expected1 = BigNumber.from(i).toNumber()
const expected1 = BigNumber.from(i).toString()

expect(output1).to.have.property('gasLimit', expected1)
}
Expand Down

0 comments on commit 068322f

Please sign in to comment.