diff --git a/packages/core-db/package.json b/packages/core-db/package.json index 815d9ee5e237..d8a48cf8d720 100644 --- a/packages/core-db/package.json +++ b/packages/core-db/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/core-db", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "Optimism DB Utils", "main": "build/index.js", "files": [ @@ -29,7 +29,7 @@ "url": "https://github.com/ethereum-optimism/optimism-monorepo.git" }, "dependencies": { - "@eth-optimism/core-utils": "^0.0.1-alpha.15", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", "abstract-leveldown": "^6.2.2", "async-lock": "^1.2.2", "chai": "^4.2.0", diff --git a/packages/core-utils/package.json b/packages/core-utils/package.json index 85ba5572bd41..e940504a7a46 100644 --- a/packages/core-utils/package.json +++ b/packages/core-utils/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/core-utils", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "Optimism Core Utils", "main": "build/index.js", "files": [ diff --git a/packages/core-utils/src/app/transport/server/json-rpc-errors.ts b/packages/core-utils/src/app/transport/server/json-rpc-errors.ts index e658c86110d5..a6bc89093426 100644 --- a/packages/core-utils/src/app/transport/server/json-rpc-errors.ts +++ b/packages/core-utils/src/app/transport/server/json-rpc-errors.ts @@ -21,6 +21,10 @@ export const JSONRPC_ERRORS = { code: -32603, message: 'Internal error', }, + REVERT_ERROR: { + code: -32015, + message: 'revert: requested action reverted', + }, } /** diff --git a/packages/docs/package.json b/packages/docs/package.json index 2142b01c8466..16a518ded3ba 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,7 +1,7 @@ { "name": "@eth-optimism/docs", "private": true, - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "Optimism docs", "author": "Optimism", "license": "MIT", diff --git a/packages/optimistic-game-semantics/package.json b/packages/optimistic-game-semantics/package.json index 64f2e61ae740..194181b2994f 100644 --- a/packages/optimistic-game-semantics/package.json +++ b/packages/optimistic-game-semantics/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/optimistic-game-semantics", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "Optimism Optimistic Game Semantics", "main": "build/index.js", "files": [ @@ -29,8 +29,8 @@ "url": "https://github.com/ethereum-optimism/optimism-monorepo.git" }, "dependencies": { - "@eth-optimism/core-db": "^0.0.1-alpha.15", - "@eth-optimism/core-utils": "^0.0.1-alpha.15", + "@eth-optimism/core-db": "^0.0.1-alpha.16", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "debug": "^4.1.1", diff --git a/packages/ovm-truffle-provider-wrapper/package.json b/packages/ovm-truffle-provider-wrapper/package.json index 487e940edd7d..b4890ab5eef1 100644 --- a/packages/ovm-truffle-provider-wrapper/package.json +++ b/packages/ovm-truffle-provider-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/ovm-truffle-provider-wrapper", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "Optimism Truffle Provider Wrapper", "main": "build/index.js", "files": [ @@ -28,7 +28,7 @@ "url": "https://github.com/ethereum-optimism/optimism-monorepo.git" }, "dependencies": { - "@eth-optimism/rollup-full-node": "^0.0.1-alpha.15" + "@eth-optimism/rollup-full-node": "^0.0.1-alpha.16" }, "devDependencies": { "@types/node": "^12.0.7", diff --git a/packages/ovm/package.json b/packages/ovm/package.json index ab1426d1c9f7..424bcf0e198b 100644 --- a/packages/ovm/package.json +++ b/packages/ovm/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/ovm", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "An optimistic execution-compatible EVM", "main": "build/index.js", "files": [ @@ -50,9 +50,9 @@ "typescript": "^3.3.3333" }, "dependencies": { - "@eth-optimism/core-db": "^0.0.1-alpha.15", - "@eth-optimism/core-utils": "^0.0.1-alpha.15", - "@eth-optimism/rollup-core": "^0.0.1-alpha.15", + "@eth-optimism/core-db": "^0.0.1-alpha.16", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", + "@eth-optimism/rollup-core": "^0.0.1-alpha.16", "@types/sinon-chai": "^3.2.2", "chai": "^4.2.0", "ethereum-waffle": "2.1.0", diff --git a/packages/ovm/src/app/utils.ts b/packages/ovm/src/app/utils.ts index abd27088d19d..03cfecec8502 100644 --- a/packages/ovm/src/app/utils.ts +++ b/packages/ovm/src/app/utils.ts @@ -105,7 +105,6 @@ export const getOvmTransactionMetadata = ( /** * Converts an EVM receipt to an OVM receipt. * - * @param executionManager The EM contract to use to parse th logs. * @param internalTxReceipt The EVM tx receipt to convert to an OVM tx receipt * @returns The converted receipt */ diff --git a/packages/rollup-contracts/package.json b/packages/rollup-contracts/package.json index f25dc5c0cd9e..5229725f8ba0 100644 --- a/packages/rollup-contracts/package.json +++ b/packages/rollup-contracts/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/rollup-contracts", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "Optimistic Rollup smart contracts", "main": "build/index.js", "files": [ @@ -43,9 +43,9 @@ "typescript": "^3.3.3333" }, "dependencies": { - "@eth-optimism/core-db": "^0.0.1-alpha.15", - "@eth-optimism/core-utils": "^0.0.1-alpha.15", - "@eth-optimism/rollup-core": "^0.0.1-alpha.15", + "@eth-optimism/core-db": "^0.0.1-alpha.16", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", + "@eth-optimism/rollup-core": "^0.0.1-alpha.16", "@types/sinon-chai": "^3.2.2", "chai": "^4.2.0", "ethereum-waffle": "2.1.0", diff --git a/packages/rollup-core/package.json b/packages/rollup-core/package.json index c0cc4796b844..56bf22ac6967 100644 --- a/packages/rollup-core/package.json +++ b/packages/rollup-core/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/rollup-core", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "[Optimism] Optimistic Rollup Core Library", "main": "build/index.js", "files": [ @@ -29,8 +29,8 @@ "url": "https://github.com/ethereum-optimism/optimism-monorepo.git" }, "dependencies": { - "@eth-optimism/core-db": "^0.0.1-alpha.15", - "@eth-optimism/core-utils": "^0.0.1-alpha.15", + "@eth-optimism/core-db": "^0.0.1-alpha.16", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", "async-lock": "^1.2.2", "ethers": "^4.0.39" }, diff --git a/packages/rollup-dev-tools/package.json b/packages/rollup-dev-tools/package.json index fb93efd794e6..fc6d7356c00b 100644 --- a/packages/rollup-dev-tools/package.json +++ b/packages/rollup-dev-tools/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/rollup-dev-tools", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "[Optimism] Optimistic Rollup Dev Tools Library", "main": "build/index.js", "files": [ @@ -33,8 +33,8 @@ "url": "https://github.com/ethereum-optimism/optimism-monorepo.git" }, "dependencies": { - "@eth-optimism/core-utils": "^0.0.1-alpha.15", - "@eth-optimism/rollup-core": "^0.0.1-alpha.15", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", + "@eth-optimism/rollup-core": "^0.0.1-alpha.16", "async-lock": "^1.2.2", "bn.js": "^5.1.1", "dotenv": "^8.2.0", diff --git a/packages/rollup-full-node/package.json b/packages/rollup-full-node/package.json index d1b98333b05c..b9f489f04f18 100644 --- a/packages/rollup-full-node/package.json +++ b/packages/rollup-full-node/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/rollup-full-node", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "[Optimism] Optimistic Rollup Full Node Library", "main": "build/index.js", "files": [ @@ -34,10 +34,10 @@ "url": "https://github.com/ethereum-optimism/optimism-monorepo.git" }, "dependencies": { - "@eth-optimism/core-db": "^0.0.1-alpha.15", - "@eth-optimism/core-utils": "^0.0.1-alpha.15", - "@eth-optimism/ovm": "^0.0.1-alpha.15", - "@eth-optimism/rollup-core": "^0.0.1-alpha.15", + "@eth-optimism/core-db": "^0.0.1-alpha.16", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", + "@eth-optimism/ovm": "^0.0.1-alpha.16", + "@eth-optimism/rollup-core": "^0.0.1-alpha.16", "async-lock": "^1.2.2", "axios": "^0.19.0", "cors": "^2.8.5", @@ -47,7 +47,7 @@ "fastpriorityqueue": "^0.6.3" }, "devDependencies": { - "@eth-optimism/solc-transpiler": "^0.0.1-alpha.15", + "@eth-optimism/solc-transpiler": "^0.0.1-alpha.16", "@types/abstract-leveldown": "^5.0.1", "@types/chai": "^4.1.7", "@types/mocha": "^5.2.7", diff --git a/packages/rollup-full-node/src/app/fullnode-rpc-server.ts b/packages/rollup-full-node/src/app/fullnode-rpc-server.ts index e73de886be11..586c701f0097 100644 --- a/packages/rollup-full-node/src/app/fullnode-rpc-server.ts +++ b/packages/rollup-full-node/src/app/fullnode-rpc-server.ts @@ -13,6 +13,7 @@ import { import { FullnodeHandler, InvalidParametersError, + RevertError, UnsupportedMethodError, } from '../types' @@ -65,6 +66,10 @@ export class FullnodeRpcServer extends ExpressHttpServer { result, }) } catch (err) { + if (err instanceof RevertError) { + log.debug(`Request reverted. Request: ${JSON.stringify(request)}`) + return res.json(buildJsonRpcError('REVERT_ERROR', request.id)) + } if (err instanceof UnsupportedMethodError) { log.debug( `Received request with unsupported method: [${JSON.stringify( diff --git a/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts b/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts index 581ea0c65a17..c71ede899e17 100644 --- a/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts +++ b/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts @@ -64,6 +64,8 @@ export class TestWeb3Handler extends DefaultWeb3Handler { case Web3RpcMethods.getTimestamp: this.assertParameters(params, 0) return add0x(this.getTimestamp().toString(16)) + case Web3RpcMethods.mine: + return this.provider.send(Web3RpcMethods.mine, params) case Web3RpcMethods.snapshot: this.assertParameters(params, 0) return this.snapshot() diff --git a/packages/rollup-full-node/src/app/web3-rpc-handler.ts b/packages/rollup-full-node/src/app/web3-rpc-handler.ts index 9b7f431a9591..98c7539976df 100644 --- a/packages/rollup-full-node/src/app/web3-rpc-handler.ts +++ b/packages/rollup-full-node/src/app/web3-rpc-handler.ts @@ -16,7 +16,7 @@ import { } from '@eth-optimism/ovm' import { Contract, ethers, utils, Wallet } from 'ethers' -import { Web3Provider } from 'ethers/providers' +import { TransactionReceipt, Web3Provider } from 'ethers/providers' import { createMockProvider, deployContract, getWallets } from 'ethereum-waffle' import AsyncLock from 'async-lock' @@ -26,6 +26,7 @@ import { DEFAULT_ETHNODE_GAS_LIMIT } from '.' import { FullnodeHandler, InvalidParametersError, + RevertError, UnsupportedMethodError, Web3Handler, Web3RpcMethods, @@ -272,7 +273,10 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { defaultBlock: string ): Promise { if (defaultBlock !== 'latest') { - throw new Error('No support for historical code lookups!') + log.info( + `No support for historical code lookups! Anything returned from this may be very wrong.` + ) + //throw new Error('No support for historical code lookups!') } log.debug( `Getting code for address: [${address}], defaultBlock: [${defaultBlock}]` @@ -396,6 +400,17 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { throw Error(msg) } + const receipt: TransactionReceipt = await this.getTransactionReceipt( + ovmTxHash + ) + log.info( + `Transaction receipt for ${rawOvmTx}: ${JSON.stringify(receipt)}` + ) + if (!receipt || !receipt.status) { + log.debug(`Transaction reverted: ${rawOvmTx}, ovmTxHash: ${ovmTxHash}`) + throw new RevertError() + } + log.debug(`Completed send raw tx [${rawOvmTx}]. Response: [${ovmTxHash}]`) // Return the *OVM* tx hash. We can do this because we store a mapping to the ovmTxHashs in the EM contract. return ovmTxHash diff --git a/packages/rollup-full-node/src/exec/fullnode.ts b/packages/rollup-full-node/src/exec/fullnode.ts index b17fd935d656..37baaa07386e 100644 --- a/packages/rollup-full-node/src/exec/fullnode.ts +++ b/packages/rollup-full-node/src/exec/fullnode.ts @@ -17,6 +17,7 @@ export const runFullnode = async ( const host = '0.0.0.0' const port = 8545 + log.info(`Starting fullnode in ${testFullnode ? 'TEST' : 'LIVE'} mode`) const fullnodeHandler = testFullnode ? await TestWeb3Handler.create() : await DefaultWeb3Handler.create() diff --git a/packages/rollup-full-node/src/types/errors.ts b/packages/rollup-full-node/src/types/errors.ts index 9a4898a3adf7..358f691b594c 100644 --- a/packages/rollup-full-node/src/types/errors.ts +++ b/packages/rollup-full-node/src/types/errors.ts @@ -17,3 +17,9 @@ export class InvalidParametersError extends Error { ) } } + +export class RevertError extends Error { + constructor(message?: string) { + super(message || 'Revert: The provided transaction reverted.') + } +} diff --git a/packages/rollup-full-node/src/types/web3-rpc-handler.ts b/packages/rollup-full-node/src/types/web3-rpc-handler.ts index 9024eba674d3..898bb1f9f8e6 100644 --- a/packages/rollup-full-node/src/types/web3-rpc-handler.ts +++ b/packages/rollup-full-node/src/types/web3-rpc-handler.ts @@ -37,10 +37,11 @@ export enum Web3RpcMethods { getTransactionReceipt = 'eth_getTransactionReceipt', networkVersion = 'net_version', sendRawTransaction = 'eth_sendRawTransaction', - snapshot = 'evm_snapshot', - revert = 'evm_revert', // Test methods: + snapshot = 'evm_snapshot', + revert = 'evm_revert', + mine = 'evm_mine', increaseTimestamp = 'evm_increaseTime', getTimestamp = 'evm_getTime', } diff --git a/packages/rollup-full-node/test/app/fullnode-rpc-server.spec.ts b/packages/rollup-full-node/test/app/fullnode-rpc-server.spec.ts index ed6695b389e4..d29255f47a4b 100644 --- a/packages/rollup-full-node/test/app/fullnode-rpc-server.spec.ts +++ b/packages/rollup-full-node/test/app/fullnode-rpc-server.spec.ts @@ -1,10 +1,18 @@ /* External Imports */ -import { AxiosHttpClient, getLogger } from '@eth-optimism/core-utils/build/src' +import { + AxiosHttpClient, + getLogger, + JSONRPC_ERRORS, +} from '@eth-optimism/core-utils/build/src' import { AxiosResponse } from 'axios' /* Internal Imports */ import { FullnodeRpcServer } from '../../src/app' -import { FullnodeHandler, UnsupportedMethodError } from '../../src/types' +import { + FullnodeHandler, + RevertError, + UnsupportedMethodError, +} from '../../src/types' import { should } from '../setup' const log = getLogger('fullnode-rpc-server', true) @@ -12,6 +20,7 @@ const log = getLogger('fullnode-rpc-server', true) const dummyResponse: string = 'Dummy Response =D' const unsupportedMethod: string = 'unsupported!' +const revertMethod: string = 'revert!' class DummyFullnodeHandler implements FullnodeHandler { public async handleRequest( method: string, @@ -20,6 +29,9 @@ class DummyFullnodeHandler implements FullnodeHandler { if (method === unsupportedMethod) { throw new UnsupportedMethodError() } + if (method === revertMethod) { + throw new RevertError() + } return dummyResponse } } @@ -114,4 +126,26 @@ describe('FullnodeHandler RPC Server', () => { r.data['jsonrpc'].should.equal('2.0') }) }) + + it('reverts properly', async () => { + const result: AxiosResponse = await request(client, { + id: 1, + jsonrpc: '2.0', + method: revertMethod, + }) + + result.status.should.equal(200) + + result.data.should.haveOwnProperty('id') + result.data.should.haveOwnProperty('jsonrpc') + result.data.should.haveOwnProperty('error') + result.data['error'].should.haveOwnProperty('message') + result.data['error'].should.haveOwnProperty('code') + result.data['error']['message'].should.equal( + JSONRPC_ERRORS.REVERT_ERROR.message + ) + result.data['error']['code'].should.equal(JSONRPC_ERRORS.REVERT_ERROR.code) + + result.data['jsonrpc'].should.equal('2.0') + }) }) diff --git a/packages/rollup-full-node/test/app/test-handler.spec.ts b/packages/rollup-full-node/test/app/test-handler.spec.ts index 5361226c8dd0..f99f5c9fd4fe 100644 --- a/packages/rollup-full-node/test/app/test-handler.spec.ts +++ b/packages/rollup-full-node/test/app/test-handler.spec.ts @@ -10,7 +10,7 @@ import { FullnodeRpcServer, DefaultWeb3Handler, } from '../../src' -import * as SimpleStorage from '../contracts/build/SimpleStorage.json' +import * as SimpleStorage from '../contracts/build/untranspiled/SimpleStorage.json' const log = getLogger('test-web3-handler', true) @@ -18,7 +18,7 @@ const secondsSinceEopch = (): number => { return Math.round(Date.now() / 1000) } const host = '0.0.0.0' -const port = 9999 +const port = 9998 const baseUrl = `http://${host}:${port}` describe('TestHandler', () => { diff --git a/packages/solc-transpiler/package.json b/packages/solc-transpiler/package.json index 26ae85e35962..4085cf197fae 100644 --- a/packages/solc-transpiler/package.json +++ b/packages/solc-transpiler/package.json @@ -1,6 +1,6 @@ { "name": "@eth-optimism/solc-transpiler", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.16", "description": "Optimism Transpiler Solc Compiler Wrapper", "main": "build/index.js", "files": [ @@ -29,8 +29,8 @@ "url": "https://github.com/ethereum-optimism/optimism-monorepo.git" }, "dependencies": { - "@eth-optimism/core-utils": "^0.0.1-alpha.15", - "@eth-optimism/rollup-dev-tools": "^0.0.1-alpha.15", + "@eth-optimism/core-utils": "^0.0.1-alpha.16", + "@eth-optimism/rollup-dev-tools": "^0.0.1-alpha.16", "ethers": "^4.0.45", "require-from-string": "^2.0.2", "solc": "^0.5.12"