Skip to content

Commit

Permalink
Merge branch 'develop' into regenesis/0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcontracts committed Jun 2, 2021
2 parents c4c7bea + 5e3c5d1 commit e410362
Show file tree
Hide file tree
Showing 23 changed files with 1,085 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-baboons-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/smock': patch
---

Fixes a bug that would break call assertions for overloaded smocked functions
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
5 changes: 5 additions & 0 deletions .changeset/sharp-files-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/message-relayer': patch
---

Adds a new set of tools for generating messages to be relayed and their proofs
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 @@ -83,7 +83,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
15 changes: 15 additions & 0 deletions packages/message-relayer/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { HardhatUserConfig } from 'hardhat/config'

import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'

const config: HardhatUserConfig = {
paths: {
sources: './test/test-contracts',
},
solidity: {
version: '0.7.6',
},
}

export default config
17 changes: 15 additions & 2 deletions packages/message-relayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"clean": "rimraf dist/ ./tsconfig.build.tsbuildinfo",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config .prettierrc.json --write \"{src,exec,test}/**/*.ts\"",
"lint:check": "tslint --format stylish --project ."
"lint:check": "tslint --format stylish --project .",
"test": "hardhat test --show-stack-traces"
},
"keywords": [
"optimism",
Expand All @@ -30,16 +31,28 @@
},
"dependencies": {
"@eth-optimism/common-ts": "^0.1.2",
"bcfg": "^0.1.6",
"@eth-optimism/contracts": "^0.3.3",
"@eth-optimism/core-utils": "^0.4.3",
"bcfg": "^0.1.6",
"dotenv": "^8.2.0",
"ethers": "^5.1.0",
"google-spreadsheet": "^3.1.15",
"merkletreejs": "^0.2.18",
"rlp": "^2.2.6"
},
"devDependencies": {
"@eth-optimism/smock": "^1.1.4",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@types/chai": "^4.2.18",
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^8.2.2",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"ethereum-waffle": "^3.3.0",
"hardhat": "^2.3.0",
"lodash": "^4.17.21",
"mocha": "^8.4.0",
"prettier": "^2.2.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
Expand Down
1 change: 1 addition & 0 deletions packages/message-relayer/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './relay-tx'
Loading

0 comments on commit e410362

Please sign in to comment.