Unverified Commit 8ea5d861 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #868 from ethereum/merge_remix_core

merge remix-core with remix-debug; move decoder code to remix-debug
parents 3f802726 c306e0e1
......@@ -13,17 +13,7 @@ jobs:
- checkout
- run: npm install && npm run bootstrap
- run: cd remix-lib && npm test
remix-core:
docker:
- image: circleci/node:7.10
environment:
working_directory: ~/repo
steps:
- checkout
- run: npm install && npm run bootstrap
- run: cd remix-core && npm test
remix-solidity:
docker:
- image: circleci/node:7.10
......@@ -33,7 +23,7 @@ jobs:
- checkout
- run: npm install && npm run bootstrap
- run: cd remix-solidity && npm test
remix-debug:
docker:
- image: circleci/node:7.10
......@@ -43,13 +33,12 @@ jobs:
- checkout
- run: npm install && npm run bootstrap
- run: cd remix-debug && npm test
workflows:
version: 2
build_all:
jobs:
- remix-lib
- remix-core
- remix-solidity
- remix-debug
......@@ -7,4 +7,5 @@ test-browser/reports/*
babelify-src
docs/_build
package-lock.json
.DS_Store
\ No newline at end of file
.DS_Store
.tern-port
......@@ -2,10 +2,9 @@ language: node_js
node_js:
- stable
env:
- TEST_DIR=remix-core
- TEST_DIR=remix-lib
- TEST_DIR=remix-solidity
- TEST_DIR=remix-debugger
- TEST_DIR=remix-debug
script:
- cd $TEST_DIR && npm install && npm test
deploy:
......
......@@ -41,8 +41,7 @@ Remix is built out of 4 different modules:
+ [`remix-solidity`](remix-solidity/README.md) provides Solidity analysis and decoding functions.
+ [`remix-lib`](remix-lib/README.md)
+ [`remix-core`](remix-core/README.md) is a utility package, providing high-level abstractions to work with the Ethereum VM.
+ [`remix-debugger`](remix-debugger/README.md) contains the **debugging webapp**.
+ [`remix-debug`](remix-debugger/README.md) contains the debugger.
## Contributing
......
{
"lerna": "2.10.2",
"packages": [
"remix-core",
"remix-debug",
"remix-debugger",
"remix-lib",
......
# `remix-core`
Provides:
```javascript
{
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
storage: {
StorageViewer: StorageViewer,
StorageResolver: StorageResolver
},
trace: {
TraceManager: TraceManager
}
}
```
TraceManager is a convenient way to access a VM Trace and resolve some value from it.
`TraceManager()` :
`function resolveTrace(stepIndex, tx)`
`function init(stepIndex, tx)`
`function inRange(stepIndex, tx)`
`function isLoaded(stepIndex, tx)`
`function getLength(stepIndex, tx)`
`function accumulateStorageChanges(stepIndex, tx)`
`function getAddresses(stepIndex, tx)`
`function getCallDataAt(stepIndex, tx)`
`function getCallStackAt(stepIndex, tx)`
`function getStackAt(stepIndex, tx)`
`function getLastCallChangeSince(stepIndex, tx)`
`function getCurrentCalledAddressAt(stepIndex, tx)`
`function getContractCreationCode(stepIndex, tx)`
`function getMemoryAt(stepIndex, tx)`
`function getCurrentPC(stepIndex, tx)`
`function getReturnValue(stepIndex, tx)`
`function getCurrentStep(stepIndex, tx)`
`function getMemExpand(stepIndex, tx)`
`function getStepCost(stepIndex, tx)`
`function getRemainingGas(stepIndex, tx)`
`function getStepCost(stepIndex, tx)`
`function isCreationStep(stepIndex, tx)`
`function findStepOverBack(stepIndex, tx)`
`function findStepOverForward(stepIndex, tx)`
`function findStepOverBack(stepIndex, tx)`
`function findNextCall(stepIndex, tx)`
`function findStepOut(stepIndex, tx)`
`function checkRequestedStep(stepIndex, tx)`
`function waterfall(stepIndex, tx)`
- - - -
`CodeManager(_traceManager)` :
`function getCode(stepIndex, tx)` :
Resolve the code of the given @arg stepIndex and trigger appropriate event
`function resolveStep(address, cb)` :
Retrieve the code located at the given @arg address
`function getFunctionFromStep(stepIndex, sourceMap, ast)` :
Retrieve the called function for the current vm step
`function getInstructionIndex(address, step, callback)` :
Retrieve the instruction index of the given @arg step
`function getFunctionFromPC(address, pc, sourceMap, ast)` :
Retrieve the called function for the given @arg pc and @arg address
- - - -
`BreakpointManager(_ethdebugger, _locationToRowConverter)` :
`function jumpNextBreakpoint(defaultToLimit)` :
start looking for the next breakpoint
`function jumpPreviousBreakpoint(defaultToLimit)` :
start looking for the previous breakpoint
`function jump(direction, defaultToLimit)` :
start looking for the previous or next breakpoint
`function hasBreakpointAtLine((fileIndex, line)` :
check the given pair fileIndex/line against registered breakpoints
`function hasBreakpoint()` :
return true if current manager has breakpoint
`function add(sourceLocation)` :
add a new breakpoint to the manager
`function remove(sourceLocation)` :
remove a breakpoint from the manager
- - - -
`StorageViewer(_context, _storageResolver, _traceManager)` :
`function storageRange(defaultToLimit)` :
return the storage for the current context (address and vm trace index)
`function storageSlot(defaultToLimit)` :
return a slot value for the current context (address and vm trace index)
`function isComplete(direction, defaultToLimit)` :
return True if the storage at @arg address is complete
`function initialMappingsLocation((fileIndex, line)` :
return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction
`function mappingsLocation()` :
return all the possible mappings locations for the current context (cached) and current mapping slot. returns state changes during the current transaction
`function extractMappingsLocationChanges(sourceLocation)` :
retrieve mapping location changes from the storage changes.
- - - -
`StorageResolver()` :
`function storageRange(tx, stepIndex, address, callback)` :
return the storage for the current context (address and vm trace index)
`function initialPreimagesMappings(tx, stepIndex, address, callback)` :
return a slot value for the current context (address and vm trace index)
`function storageSlot(slot, tx, stepIndex, address, callback)` :
return True if the storage at @arg address is complete
`function isComplete(address)` :
return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction
var CodeManager = require('./src/code/codeManager')
var BreakpointManager = require('./src/code/breakpointManager')
var StorageViewer = require('./src/storage/storageViewer')
var StorageResolver = require('./src/storage/storageResolver')
var TraceManager = require('./src/trace/traceManager')
module.exports = {
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
storage: {
StorageViewer: StorageViewer,
StorageResolver: StorageResolver
},
trace: {
TraceManager: TraceManager
}
}
{
"name": "remix-core",
"version": "0.0.15",
"description": "Ethereum IDE and tools for the web",
"contributors": [
{
"name": "Yann Levreau",
"email": "yann@ethereum.com"
},
{
"name": "Liana Husikyan",
"email": "liana@ethereum.com"
}
],
"main": "./index.js",
"dependencies": {
"babel-eslint": "^7.1.1",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-es2015": "^6.24.0",
"babelify": "^7.3.0",
"fast-async": "^6.1.2",
"remix-lib": "^0.2.9",
"standard": "^7.0.1",
"tape": "^4.6.0"
},
"scripts": {
"test": "standard && tape ./test/tests.js"
},
"standard": {
"ignore": [
"node_modules/*",
"build/*",
"test/resources/*"
],
"parser": "babel-eslint"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ethereum/remix.git"
},
"author": "cpp-ethereum team",
"license": "MIT",
"bugs": {
"url": "https://github.com/ethereum/remix/issues"
},
"homepage": "https://github.com/ethereum/remix#readme",
"browserify": {
"transform": [
[
"babelify",
{
"plugins": [
[
"fast-async",
{
"runtimePatten": null,
"compiler": {
"promises": true,
"es7": true,
"noRuntime": true,
"wrapAwait": true
}
}
],
"transform-object-assign"
]
}
],
[
"babelify",
{
"presets": [
"es2015"
]
}
]
]
}
}
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')
......@@ -63,3 +63,170 @@ debugger.callTree.register('callTreeReady', () => {
})
```
## Library
Provides:
```javascript
{
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
storage: {
StorageViewer: StorageViewer,
StorageResolver: StorageResolver
},
trace: {
TraceManager: TraceManager
}
}
```
TraceManager is a convenient way to access a VM Trace and resolve some value from it.
`TraceManager()` :
`function resolveTrace(stepIndex, tx)`
`function init(stepIndex, tx)`
`function inRange(stepIndex, tx)`
`function isLoaded(stepIndex, tx)`
`function getLength(stepIndex, tx)`
`function accumulateStorageChanges(stepIndex, tx)`
`function getAddresses(stepIndex, tx)`
`function getCallDataAt(stepIndex, tx)`
`function getCallStackAt(stepIndex, tx)`
`function getStackAt(stepIndex, tx)`
`function getLastCallChangeSince(stepIndex, tx)`
`function getCurrentCalledAddressAt(stepIndex, tx)`
`function getContractCreationCode(stepIndex, tx)`
`function getMemoryAt(stepIndex, tx)`
`function getCurrentPC(stepIndex, tx)`
`function getReturnValue(stepIndex, tx)`
`function getCurrentStep(stepIndex, tx)`
`function getMemExpand(stepIndex, tx)`
`function getStepCost(stepIndex, tx)`
`function getRemainingGas(stepIndex, tx)`
`function getStepCost(stepIndex, tx)`
`function isCreationStep(stepIndex, tx)`
`function findStepOverBack(stepIndex, tx)`
`function findStepOverForward(stepIndex, tx)`
`function findStepOverBack(stepIndex, tx)`
`function findNextCall(stepIndex, tx)`
`function findStepOut(stepIndex, tx)`
`function checkRequestedStep(stepIndex, tx)`
`function waterfall(stepIndex, tx)`
- - - -
`CodeManager(_traceManager)` :
`function getCode(stepIndex, tx)` :
Resolve the code of the given @arg stepIndex and trigger appropriate event
`function resolveStep(address, cb)` :
Retrieve the code located at the given @arg address
`function getFunctionFromStep(stepIndex, sourceMap, ast)` :
Retrieve the called function for the current vm step
`function getInstructionIndex(address, step, callback)` :
Retrieve the instruction index of the given @arg step
`function getFunctionFromPC(address, pc, sourceMap, ast)` :
Retrieve the called function for the given @arg pc and @arg address
- - - -
`BreakpointManager(_ethdebugger, _locationToRowConverter)` :
`function jumpNextBreakpoint(defaultToLimit)` :
start looking for the next breakpoint
`function jumpPreviousBreakpoint(defaultToLimit)` :
start looking for the previous breakpoint
`function jump(direction, defaultToLimit)` :
start looking for the previous or next breakpoint
`function hasBreakpointAtLine((fileIndex, line)` :
check the given pair fileIndex/line against registered breakpoints
`function hasBreakpoint()` :
return true if current manager has breakpoint
`function add(sourceLocation)` :
add a new breakpoint to the manager
`function remove(sourceLocation)` :
remove a breakpoint from the manager
- - - -
`StorageViewer(_context, _storageResolver, _traceManager)` :
`function storageRange(defaultToLimit)` :
return the storage for the current context (address and vm trace index)
`function storageSlot(defaultToLimit)` :
return a slot value for the current context (address and vm trace index)
`function isComplete(direction, defaultToLimit)` :
return True if the storage at @arg address is complete
`function initialMappingsLocation((fileIndex, line)` :
return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction
`function mappingsLocation()` :
return all the possible mappings locations for the current context (cached) and current mapping slot. returns state changes during the current transaction
`function extractMappingsLocationChanges(sourceLocation)` :
retrieve mapping location changes from the storage changes.
- - - -
`StorageResolver()` :
`function storageRange(tx, stepIndex, address, callback)` :
return the storage for the current context (address and vm trace index)
`function initialPreimagesMappings(tx, stepIndex, address, callback)` :
return a slot value for the current context (address and vm trace index)
`function storageSlot(slot, tx, stepIndex, address, callback)` :
return True if the storage at @arg address is complete
`function isComplete(address)` :
return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction
'use strict'
var remixCore = require('remix-core')
var EthDebugger = require('./src/Ethdebugger')
var CodeManager = require('./src/code/codeManager')
var BreakpointManager = require('./src/code/breakpointManager')
var StorageViewer = require('./src/storage/storageViewer')
var StorageResolver = require('./src/storage/storageResolver')
var TraceManager = require('./src/trace/traceManager')
/*
Use of breakPointManager :
......@@ -12,11 +17,23 @@ var EthDebugger = require('./src/Ethdebugger')
*/
module.exports = {
EthDebugger: EthDebugger,
/**
* constructor
*
* @param {Object} _debugger - type of EthDebugger
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/
BreakpointManager: remixCore.code.BreakpointManager
/**
* constructor
*
* @param {Object} _debugger - type of EthDebugger
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/
BreakpointManager: BreakpointManager,
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
storage: {
StorageViewer: StorageViewer,
StorageResolver: StorageResolver
},
trace: {
TraceManager: TraceManager
}
}
......@@ -26,9 +26,8 @@
"ethereumjs-vm": "^2.3.3",
"notify-error": "^1.2.0",
"npm-run-all": "^4.1.2",
"remix-core": "^0.0.15",
"fast-async": "^6.1.2",
"remix-lib": "^0.2.9",
"remix-solidity": "^0.1.11",
"solc": "https://github.com/ethereum/solc-js"
},
"devDependencies": {
......@@ -57,7 +56,8 @@
"node_modules/*",
"build/*",
"test/resources/*"
]
],
"parser": "babel-eslint"
},
"babel": {
"plugins": [
......@@ -91,6 +91,18 @@
"sourceMaps": true,
"plugins": [
[
[
"fast-async",
{
"runtimePatten": null,
"compiler": {
"promises": true,
"es7": true,
"noRuntime": true,
"wrapAwait": true
}
}
],
"transform-object-assign"
]
],
......
'use strict'
var remixCore = require('remix-core')
var TraceManager = remixCore.trace.TraceManager
var StorageViewer = remixCore.storage.StorageViewer
var CodeManager = require('./code/codeManager')
var StorageViewer = require('./storage/storageViewer')
var StorageResolver = require('./storage/storageResolver')
var TraceManager = require('./trace/traceManager')
var SolidityProxy = require('./decoder/solidityProxy')
var stateDecoder = require('./decoder/stateDecoder')
var localDecoder = require('./decoder/localDecoder')
var InternalCallTree = require('./decoder/internalCallTree')
var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace
var init = remixLib.init
......@@ -9,13 +17,6 @@ var executionContext = remixLib.execution.executionContext
var EventManager = remixLib.EventManager
var Web3Providers = remixLib.vm.Web3Providers
var DummyProvider = remixLib.vm.DummyProvider
var CodeManager = remixCore.code.CodeManager
var remixSolidity = require('remix-solidity')
var SolidityProxy = remixSolidity.SolidityProxy
var stateDecoder = remixSolidity.stateDecoder
var localDecoder = remixSolidity.localDecoder
var InternalCallTree = remixSolidity.InternalCallTree
var StorageResolver = remixCore.storage.StorageResolver
/**
* Ethdebugger is a wrapper around a few classes that helps debugging a transaction
......
'use strict'
var remixCore = require('remix-core')
var TraceManager = remixCore.trace.TraceManager
var CodeManager = remixCore.code.CodeManager
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall')
var remixLib = require('remix-lib')
......
'use strict'
var remixCore = require('remix-core')
var TraceManager = remixCore.trace.TraceManager
var CodeManager = remixCore.code.CodeManager
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall')
var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace
......
'use strict'
var remixCore = require('remix-core')
var TraceManager = remixCore.trace.TraceManager
var CodeManager = remixCore.code.CodeManager
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall')
var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace
......
'use strict'
var remixCore = require('remix-core')
var TraceManager = remixCore.trace.TraceManager
var CodeManager = remixCore.code.CodeManager
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall')
var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace
......
......@@ -4,6 +4,10 @@ var compiler = require('solc')
var stateDecoder = require('../../../src/decoder/stateDecoder')
var vmCall = require('../vmCall')
var TraceManager = require('../../../src/trace/traceManager')
var StorageResolver = require('../../../src/storage/storageResolver')
var StorageViewer = require('../../../src/storage/storageViewer')
module.exports = function testMappingStorage (st, cb) {
var mappingStorage = require('../contracts/mappingStorage')
var privateKey = new Buffer('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex')
......@@ -40,11 +44,8 @@ function testMapping (st, vm, privateKey, contractAddress, output, cb) {
console.log(error)
st.end(error)
} else {
var TraceManager = require('remix-core').trace.TraceManager
var traceManager = new TraceManager({web3: vm.web3})
traceManager.resolveTrace(tx, () => {
var StorageResolver = require('remix-core').storage.StorageResolver
var StorageViewer = require('remix-core').storage.StorageViewer
var storageViewer = new StorageViewer({
stepIndex: 213,
tx: tx,
......
'use strict'
var tape = require('tape')
var remixLib = require('remix-lib')
var remixCore = require('remix-core')
var compilerInput = remixLib.helpers.compiler.compilerInput
var vmCall = require('./vmCall')
var Debugger = require('../src/Ethdebugger')
var compiler = require('solc')
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')
require('./decoder/decodeInfo.js')
require('./decoder/storageLocation.js')
require('./decoder/storageDecoder.js')
require('./decoder/localDecoder.js')
var BreakpointManager = require('../src/code/breakpointManager')
tape('debug contract', function (t) {
t.plan(12)
var privateKey = new Buffer('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex')
......@@ -95,7 +105,7 @@ function testDebugging (t, debugManager) {
})
var sourceMappingDecoder = new remixLib.SourceMappingDecoder()
var breakPointManager = new remixCore.code.BreakpointManager(debugManager, (rawLocation) => {
var breakPointManager = new BreakpointManager(debugManager, (rawLocation) => {
return sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, sourceMappingDecoder.getLinebreakPositions(ballot))
})
......
var InternalCallTree = require('./src/decoder/internalCallTree')
var SolidityProxy = require('./src/decoder/solidityProxy')
var localDecoder = require('./src/decoder/localDecoder')
var stateDecoder = require('./src/decoder/stateDecoder')
var CodeAnalysis = require('./src/analysis/staticAnalysisRunner')
var Compiler = require('./src/compiler/compiler')
var CompilerInput = require('./src/compiler/compiler-input')
module.exports = {
InternalCallTree: InternalCallTree,
SolidityProxy: SolidityProxy,
localDecoder: localDecoder,
stateDecoder: stateDecoder,
CodeAnalysis: CodeAnalysis,
Compiler: Compiler,
CompilerInput: CompilerInput
......
......@@ -22,7 +22,6 @@
"ethereumjs-vm": "^2.3.3",
"fast-async": "^6.1.2",
"npm-run-all": "^4.0.2",
"remix-core": "^0.0.15",
"remix-lib": "^0.2.9",
"solc": "https://github.com/ethereum/solc-js",
"standard": "^7.0.1",
......
require('./decoder/decodeInfo.js')
require('./decoder/storageLocation.js')
require('./decoder/storageDecoder.js')
require('./decoder/localDecoder.js')
require('./analysis/staticAnalysisCommon-test.js')
require('./analysis/staticAnalysisIntegration-test.js')
......
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