Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Commit

Permalink
Move wallet repo and development to monorepo (#35)
Browse files Browse the repository at this point in the history
* Merge omgx_contracts into /optimism monorepo; integrate message-relayer-fast; and connect up message-relayer-fast with the Dockers/ops

* further cleanup

* get address from addressManager; add tests for the message-relayer-fast

* testing contract deployments to the new stack

* Deployment working....

* Add fast and slow message contracts (#38)

* wip - simplify system - remove message-relayer-fast

* Update L1LiquidityPool.sol

* message relay working

* almost there

* major wallet functions confirmed working - ready

* fix integration tests

* minor tweaks to get everything to run on rebased develop branch

* Integrate #37, confirm compilation and function

* update .env.example for stable rinkeby endpoint

* adds the message-relayer-fast - goal is to end up with self contained folder for this service and associated tests

* Added whitelist (#44)

* wip - disable npm publish until that's set up

* Update publish-develop.yml

* fix formatting via yarn run lint:fix

* more lint cleanup

* assorted and sundry linting issues

* final lint/GH/yarn actions fixes

* remove unneeded spreadsheet code

* fix truffle networkID and more linting

* Updated addresses (#45)

* update fraud-prover .env and accomodate L2 fee = enabled

* Update addresses.json

* fixes tslint<>prettier clash which breaks the GH actions

* delete deployment files

Co-authored-by: cby3149 <[email protected]>
Co-authored-by: cby3149 <[email protected]>
  • Loading branch information
3 people authored Jun 8, 2021
1 parent b623a7c commit 4a7e3cf
Show file tree
Hide file tree
Showing 109 changed files with 10,323 additions and 2,274 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/publish-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ jobs:

- name: Setup Canary Snapshot
run: yarn changeset version --snapshot

- name: Publish To NPM
uses: changesets/action@master
id: changesets
with:
publish: yarn changeset publish --tag canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Conditional on the release being executed, we unbundle the publishedPackages to specific
# job outputs
- name: Get version tags from each published version
id: packages
run: |
node ops/scripts/ci-versions.js ${{ toJSON(steps.changesets.outputs.publishedPackages) }}
# #Turn off until we have npm set up
# - name: Publish To NPM
# uses: changesets/action@master
# id: changesets
# with:
# publish: yarn changeset publish --tag canary
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
#
# #Conditional on the release being executed, we unbundle the publishedPackages to specific
# #job outputs
# - name: Get version tags from each published version
# id: packages
# run: |
# node ops/scripts/ci-versions.js ${{ toJSON(steps.changesets.outputs.publishedPackages) }}

# The below code is duplicated, would be ideal if we could use a matrix with a
# key/value being dynamically generated from the `publishedPackages` output
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ packages/contracts/hardhat*

packages/data-transport-layer/db

packages/omgx/wallet/wallet/build

# vim
*.swp

.env
env.js
env.js
env.yml
env.js

.serverless
packages/omgx/wallet/deployment/local/addresses.json
packages/omgx/wallet/wallet/src/deployment/local/addresses.json
8,064 changes: 8,064 additions & 0 deletions examples/hardhat/yarn.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/l1-l2-deposit-withdrawal/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ module.exports = {
solcVersion: '0.7.6'
},
mocha: {
timeout: 60000
timeout: 300000
}
}
2 changes: 1 addition & 1 deletion examples/truffle/truffle-config-ovm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
providerOrUrl: 'http://127.0.0.1:8545'
})
},
network_id: 420,
network_id: 28,
host: '127.0.0.1',
port: 8545,
gasPrice: 0,
Expand Down
11 changes: 11 additions & 0 deletions integration-tests/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
L1_URL=http://localhost:9545
L2_URL=http://localhost:8545
VERIFIER_URL=http://localhost:8547
URL=http://localhost:8080/addresses.json
ENABLE_GAS_REPORT=1
NO_NETWORK=1
L1_POLLING_INTERVAL=10
L2_POLLING_INTERVAL=10
VERIFIER_POLLING_INTERVAL=10
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
ADDRESS_MANAGER=0x809d550fca64d94Bd9F66E60752A544199cfAC3D
3 changes: 2 additions & 1 deletion integration-tests/sync-tests/sync-verifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ describe('Syncing a verifier', () => {
})

it('should sync dummy transaction', async () => {
const totalElementsBefore = (await env.ctc.getTotalElements()) as BigNumber
const totalElementsBefore =
(await env.ctc.getTotalElements()) as BigNumber

const tx = {
to: '0x' + '1234'.repeat(10),
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/test/basic-l1-l2-communication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('Basic L1<>L2 Communication', async () => {
const transaction = await env.l1Messenger.sendMessage(
predeploys.Lib_AddressManager,
getContractInterface(
'Lib_AddressManager'
'Lib_AddressManager' // tslint:disable-line
).encodeFunctionData('getAddress', ['whatever']),
5000000
)
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/test/fee-payment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('Fee Payment Integration Tests', async () => {
other,
utils.parseEther('0.5')
)
const executionGas = await (env.ovmEth
.provider as any).send('eth_estimateExecutionGas', [tx, true])
const executionGas = await (env.ovmEth // tslint:disable-line
.provider as any).send('eth_estimateExecutionGas', [tx, true]) // tslint:disable-line
const decoded = TxGasLimit.decode(gas)
expect(BigNumber.from(executionGas)).deep.eq(decoded)
})
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/test/ovmcontext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('OVM Context: Layer 2 EVM Context', () => {
'OVM_CanonicalTransactionChain'
)

CanonicalTransactionChain = CanonicalTransactionChainFactory.connect(
CanonicalTransactionChain = CanonicalTransactionChainFactory.connect( // tslint:disable-line
l1Wallet
).attach(ctcAddress)

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/test/rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ describe('Basic RPC tests', () => {
describe('eth_chainId', () => {
it('should get the correct chainid', async () => {
const { chainId } = await provider.getNetwork()
expect(chainId).to.be.eq(420)
expect(chainId).to.be.eq(28)
})
})

Expand Down
21 changes: 17 additions & 4 deletions ops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Also available for testing is the `rpc-proxy` service in the `docker-compose-rpc

The base stack can be started and stopped with a command like this (there is no need to specify the default docker-compose.yml)
```
docker-compose \
up --build --detach
docker-compose up --build --detach
```

To start the stack with monitoring enabled, just add the metric composition file.
Expand All @@ -32,8 +33,9 @@ docker-compose \

Optionally, run a verifier along the rest of the stack.
```
docker-compose up --scale verifier=1 \
--build --detach
docker-compose up --scale verifier=1 --build --detach
```

A Makefile has been provided for convience. The following targets are available.
Expand All @@ -42,6 +44,17 @@ A Makefile has been provided for convience. The following targets are available.
- make up-metrics
- make down-metrics

Running the integration tests

```
docker-compose run integration_tests
```

```
## Authentication
Influxdb has authentication disabled.
Expand Down
10 changes: 6 additions & 4 deletions ops/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ services:
environment:
FRAUD_PROOF_WINDOW_SECONDS: 0
L1_NODE_WEB3_URL: http://l1_chain:8545
# these keys are hardhat's first 2 accounts, DO NOT use in production
# these keys are hardhat's first 3 accounts, DO NOT use in production
DEPLOYER_PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
SEQUENCER_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
RELAYER_PRIVATE_KEY: "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
# skip compilation when run in docker-compose, since the contracts
# were already compiled in the builder step
NO_COMPILE: 1
Expand Down Expand Up @@ -62,7 +63,7 @@ services:
# connect to the 2 layers
DATA_TRANSPORT_LAYER__L1_RPC_ENDPOINT: http://l1_chain:8545
DATA_TRANSPORT_LAYER__L2_RPC_ENDPOINT: http://l2geth:8545
DATA_TRANSPORT_LAYER__L2_CHAIN_ID: 420
DATA_TRANSPORT_LAYER__L2_CHAIN_ID: 28
ports:
- ${DTL_PORT:-7878}:7878

Expand Down Expand Up @@ -106,10 +107,11 @@ services:
L1_NODE_WEB3_URL: http://l1_chain:8545
L2_NODE_WEB3_URL: http://l2geth:8545
URL: http://deployer:8081/addresses.json
WHITELIST_ENDPOINT: https://api-message-relayer.rinkeby.omgx.network/get.whitelist
# a funded hardhat account
L1_WALLET_KEY: "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97"
L1_WALLET_KEY: "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
RETRIES: 60
POLLING_INTERVAL: 500
POLLING_INTERVAL: 1500
GET_LOGS_INTERVAL: 500

batch_submitter:
Expand Down
4 changes: 2 additions & 2 deletions ops/envs/geth.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ WS_PORT=8546
WS_API=eth,net,rollup,web3
WS_ORIGINS=*

CHAIN_ID=420
CHAIN_ID=28
DATADIR=/root/.ethereum
DEV=true
GASPRICE=0
GCMODE=archive
IPC_DISABLE=true
NETWORK_ID=420
NETWORK_ID=28
NO_USB=true
NO_DISCOVER=true
TARGET_GAS_LIMIT=9000000
Expand Down
55 changes: 22 additions & 33 deletions packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
}

public async _onSync(): Promise<TransactionReceipt> {
const pendingQueueElements = await this.chainContract.getNumPendingQueueElements()
const pendingQueueElements =
await this.chainContract.getNumPendingQueueElements()
this.logger.debug('Got number of pending queue elements', {
pendingQueueElements,
})
Expand Down Expand Up @@ -228,10 +229,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return
}

const [
batchParams,
wasBatchTruncated,
] = await this._generateSequencerBatchParams(startBlock, endBlock)
const [batchParams, wasBatchTruncated] =
await this._generateSequencerBatchParams(startBlock, endBlock)
const batchSizeInBytes = encodeAppendSequencerBatch(batchParams).length / 2
this.logger.debug('Sequencer batch generated', {
batchSizeInBytes,
Expand Down Expand Up @@ -386,11 +385,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
}

let isEqual = true
const [
queueEleHash,
timestamp,
blockNumber,
] = await this.chainContract.getQueueElement(queueIndex)
const [queueEleHash, timestamp, blockNumber] =
await this.chainContract.getQueueElement(queueIndex)

// TODO: Verify queue element hash equality. The queue element hash can be computed with:
// keccak256( abi.encode( msg.sender, _target, _gasLimit, _data))
Expand Down Expand Up @@ -454,19 +450,18 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
for (const ele of b) {
// Look for skipped deposits
while (true) {
const pendingQueueElements = await this.chainContract.getNumPendingQueueElements()
const nextRemoteQueueElements = await this.chainContract.getNextQueueIndex()
const pendingQueueElements =
await this.chainContract.getNumPendingQueueElements()
const nextRemoteQueueElements =
await this.chainContract.getNextQueueIndex()
const totalQueueElements =
pendingQueueElements + nextRemoteQueueElements
// No more queue elements so we clearly haven't skipped anything
if (nextQueueIndex >= totalQueueElements) {
break
}
const [
queueEleHash,
timestamp,
blockNumber,
] = await this.chainContract.getQueueElement(nextQueueIndex)
const [queueEleHash, timestamp, blockNumber] =
await this.chainContract.getQueueElement(nextQueueIndex)

if (timestamp < ele.timestamp || blockNumber < ele.blockNumber) {
this.logger.error('Fixing skipped deposit', {
Expand Down Expand Up @@ -502,10 +497,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
const fixMonotonicity = async (b: Batch): Promise<Batch> => {
this.logger.debug('Fixing monotonicity...')
// The earliest allowed timestamp/blockNumber is the last timestamp submitted on chain.
const {
lastTimestamp,
lastBlockNumber,
} = await this._getLastTimestampAndBlockNumber()
const { lastTimestamp, lastBlockNumber } =
await this._getLastTimestampAndBlockNumber()
let earliestTimestamp = lastTimestamp
let earliestBlockNumber = lastBlockNumber
this.logger.debug('Determined earliest timestamp and blockNumber', {
Expand All @@ -521,16 +514,15 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
// updateLatestTimestampAndBlockNumber is a helper which updates
// the latest timestamp and block number based on the pending queue elements.
const updateLatestTimestampAndBlockNumber = async () => {
const pendingQueueElements = await this.chainContract.getNumPendingQueueElements()
const nextRemoteQueueElements = await this.chainContract.getNextQueueIndex()
const pendingQueueElements =
await this.chainContract.getNumPendingQueueElements()
const nextRemoteQueueElements =
await this.chainContract.getNextQueueIndex()
const totalQueueElements =
pendingQueueElements + nextRemoteQueueElements
if (nextQueueIndex < totalQueueElements) {
const [
queueEleHash,
queueTimestamp,
queueBlockNumber,
] = await this.chainContract.getQueueElement(nextQueueIndex)
const [queueEleHash, queueTimestamp, queueBlockNumber] =
await this.chainContract.getQueueElement(nextQueueIndex)
latestTimestamp = queueTimestamp
latestBlockNumber = queueBlockNumber
} else {
Expand Down Expand Up @@ -655,11 +647,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
queueIndex: number,
queueElement: BatchElement
): Promise<BatchElement> {
const [
queueEleHash,
timestamp,
blockNumber,
] = await this.chainContract.getQueueElement(queueIndex)
const [queueEleHash, timestamp, blockNumber] =
await this.chainContract.getQueueElement(queueIndex)

if (
timestamp > queueElement.timestamp &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ describe('BatchSubmitter', () => {
let OVM_StateCommitmentChain: Contract
let l2Provider: MockchainProvider
beforeEach(async () => {
const unwrapped_OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy(
AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS
)
const unwrapped_OVM_CanonicalTransactionChain =
await Factory__OVM_CanonicalTransactionChain.deploy(
AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS
)
await unwrapped_OVM_CanonicalTransactionChain.init()

await AddressManager.setAddress(
Expand All @@ -170,11 +171,12 @@ describe('BatchSubmitter', () => {
sequencer
)

const unwrapped_OVM_StateCommitmentChain = await Factory__OVM_StateCommitmentChain.deploy(
AddressManager.address,
0, // fraudProofWindowSeconds
0 // sequencerPublishWindowSeconds
)
const unwrapped_OVM_StateCommitmentChain =
await Factory__OVM_StateCommitmentChain.deploy(
AddressManager.address,
0, // fraudProofWindowSeconds
0 // sequencerPublishWindowSeconds
)

await unwrapped_OVM_StateCommitmentChain.init()

Expand Down
1 change: 1 addition & 0 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ npx hardhat deploy \
--ovm-proposer-address ... \
--ovm-relayer-address ... \
--ovm-sequencer-address ... \
--ovm-relayer-address ... \
--scc-fraud-proof-window ... \
--scc-sequencer-publish-window ...
```
Expand Down
Loading

0 comments on commit 4a7e3cf

Please sign in to comment.