linting fixed for remix-debug

pull/4771/head
lianahus 6 months ago
parent f5cdc389a7
commit e5920ae3b2
  1. 10
      libs/remix-debug/src/Ethdebugger.ts
  2. 10
      libs/remix-debug/src/debugger/VmDebugger.ts
  3. 8
      libs/remix-debug/src/debugger/debugger.ts
  4. 2
      libs/remix-debug/src/debugger/solidityState.ts
  5. 2
      libs/remix-debug/src/debugger/stepManager.ts
  6. 4
      libs/remix-debug/src/init.ts
  7. 18
      libs/remix-debug/src/solidity-decoder/internalCallTree.ts
  8. 2
      libs/remix-debug/src/solidity-decoder/solidityProxy.ts
  9. 2
      libs/remix-debug/src/trace/traceAnalyser.ts
  10. 2
      libs/remix-debug/src/trace/traceManager.ts
  11. 2
      libs/remix-debug/test.ts
  12. 2
      libs/remix-debug/test/codeManager.ts
  13. 12
      libs/remix-debug/test/debugger.ts
  14. 2
      libs/remix-debug/test/decoder/contracts/calldata.ts
  15. 2
      libs/remix-debug/test/decoder/contracts/intLocal.ts
  16. 2
      libs/remix-debug/test/decoder/contracts/miscLocal.ts
  17. 2
      libs/remix-debug/test/decoder/contracts/structArrayLocal.ts
  18. 6
      libs/remix-debug/test/decoder/localDecoder.ts
  19. 7
      libs/remix-debug/test/decoder/localsTests/calldata.ts
  20. 28
      libs/remix-debug/test/decoder/localsTests/int.ts
  21. 12
      libs/remix-debug/test/decoder/localsTests/misc.ts
  22. 10
      libs/remix-debug/test/decoder/localsTests/misc2.ts
  23. 26
      libs/remix-debug/test/decoder/localsTests/structArray.ts
  24. 8
      libs/remix-debug/test/decoder/stateTests/mapping.ts
  25. 4
      libs/remix-debug/test/helpers/compilerHelper.ts
  26. 41
      libs/remix-debug/test/resources/ast.ts
  27. 4
      libs/remix-debug/test/resources/testWeb3.ts
  28. 30
      libs/remix-debug/test/sourceLocationTracker.ts
  29. 2
      libs/remix-debug/test/traceManager.ts
  30. 3
      libs/remix-debug/test/vmCall.ts

@ -44,10 +44,10 @@ export class Ethdebugger {
this.event = new EventManager()
this.traceManager = new TraceManager({ web3: this.web3 })
this.codeManager = new CodeManager(this.traceManager)
this.solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager),
this.solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager),
getCode: this.codeManager.getCode.bind(this.codeManager),
compilationResult: this.compilationResult
compilationResult: this.compilationResult
})
this.storageResolver = null
@ -63,8 +63,8 @@ export class Ethdebugger {
setManagers () {
this.traceManager = new TraceManager({ web3: this.web3 })
this.codeManager = new CodeManager(this.traceManager)
this.solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager),
this.solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager),
getCode: this.codeManager.getCode.bind(this.codeManager),
compilationResult: this.compilationResult
})

@ -110,7 +110,7 @@ export class VmDebuggerLogic {
} catch (e) {
console.log(e)
}
try {
const memory = this._traceManager.getMemoryAt(index)
if (this.stepManager.currentStepIndex === index) {
@ -122,9 +122,9 @@ export class VmDebuggerLogic {
try {
const address = this._traceManager.getCurrentCalledAddressAt(index)
if (!this.storageResolver) return
const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager)
storageViewer.storageRange().then((storage) => {
if (this.stepManager.currentStepIndex === index) {
const header = storageViewer.isComplete(address) ? '[Completely Loaded]' : '[Partially Loaded]'
@ -145,8 +145,8 @@ export class VmDebuggerLogic {
} catch (error) {
this.event.trigger('traceReturnValueUpdate', [[error]])
}
})()
}, 1000)
})()
}, 1000)
try {
const step = this._traceManager.getCurrentStep(index)

@ -84,10 +84,10 @@ export class Debugger {
const generatedSources = this.debugger.callTree.sourceLocationTracker.getGeneratedSourcesFromAddress(address)
const lineColumnPos = rawLocationAndOpcode.lineColumnPos
let lineGasCostObj = null
try {
lineGasCostObj = await this.debugger.callTree.getGasCostPerLine(rawLocation.file, lineColumnPos.start.line)
lineGasCostObj = await this.debugger.callTree.getGasCostPerLine(rawLocation.file, lineColumnPos.start.line)
} catch (e) {
console.log(e)
}
@ -97,9 +97,9 @@ export class Debugger {
const instructionIndexes = lineGasCostObj.indexes.map((index) => { // translate from vmtrace index to instruction index
return this.debugger.codeManager.getInstructionIndex(address, index)
})
this.vmDebuggerLogic.event.trigger('lineGasCostChanged', [instructionIndexes, lineColumnPos.start.line ])
this.vmDebuggerLogic.event.trigger('lineGasCostChanged', [instructionIndexes, lineColumnPos.start.line])
this.currentFile = rawLocation.file
this.currentLine = lineColumnPos.start.line
this.currentLine = lineColumnPos.start.line
}
} else {
this.event.trigger('newSourceLocation', [null])

@ -32,7 +32,7 @@ export class DebuggerSolidityState {
}
if (this.stepManager.currentStepIndex !== index) return
if (!this.storageResolver) {
return
}

@ -77,7 +77,7 @@ export class DebuggerStepManager {
const revertedReason = this.currentCall.outofgas ? 'outofgas' : 'reverted'
this.revertionPoint = this.currentCall.return
this.event.trigger('revertWarning', [revertedReason])
return
return
}
for (let k = callsPath.length - 2; k >= 0; k--) {
const parent = callsPath[k]

@ -1,9 +1,9 @@
'use strict'
import Web3, { Web3PluginBase } from 'web3'
import {toNumber} from 'web3-utils'
import { toNumber } from 'web3-utils'
export function extendWeb3 (web3) {
if(!web3.debug){
if (!web3.debug){
web3.registerPlugin(new Web3DebugPlugin())
}
}

@ -97,7 +97,7 @@ export class InternalCallTree {
})
} catch (e) {
console.log(e)
}
}
}
})
}
@ -214,7 +214,7 @@ export class InternalCallTree {
}
throw new Error('Could not find gas cost per line')
}
getLocalVariableById (id: number) {
return this.variables[id]
}
@ -226,7 +226,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?,
const address = tree.traceManager.getCurrentCalledAddressAt(step)
await registerFunctionParameters(tree, functionDefinition, step, scopeId, contractObj, validSourceLocation, address)
}
function callDepthChange (step, trace) {
if (step + 1 < trace.length) {
return trace[step].depth !== trace[step + 1].depth
@ -252,11 +252,11 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?,
let sourceLocation
let validSourceLocation
let address
try {
address = tree.traceManager.getCurrentCalledAddressAt(step)
sourceLocation = await tree.extractSourceLocation(step, address)
if (!includedSource(sourceLocation, currentSourceLocation)) {
tree.reducedTrace.push(step)
currentSourceLocation = sourceLocation
@ -270,7 +270,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?,
validSourceLocation = previousValidSourceLocation
} else
validSourceLocation = currentSourceLocation
} catch (e) {
return { outStep: step, error: 'InternalCallTree - Error resolving source location. ' + step + ' ' + e }
}
@ -285,7 +285,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?,
} else {
stepDetail.gasCost = parseInt(stepDetail.gasCost as unknown as string)
}
// gas per line
let lineColumnPos
if (tree.offsetToLineColumnConverter) {
@ -299,7 +299,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?,
sources[genSource.name] = { content: genSource.contents }
}
}
lineColumnPos = await tree.offsetToLineColumnConverter.offsetToLineColumn(validSourceLocation, validSourceLocation.file, sources, astSources)
if (!tree.gasCostPerLine[validSourceLocation.file]) tree.gasCostPerLine[validSourceLocation.file] = {}
if (!tree.gasCostPerLine[validSourceLocation.file][lineColumnPos.start.line]) {
@ -391,7 +391,7 @@ function getGeneratedSources (tree, scopeId, contractObj) {
async function registerFunctionParameters (tree, functionDefinition, step, scopeId, contractObj, sourceLocation, address) {
tree.functionCallStack.push(step)
const functionDefinitionAndInputs = { functionDefinition, inputs: [] }
const functionDefinitionAndInputs = { functionDefinition, inputs: []}
// means: the previous location was a function definition && JUMPDEST
// => we are at the beginning of the function and input/output are setup
try {

@ -64,7 +64,7 @@ export class SolidityProxy {
*/
async extractStatesDefinitions (address: string) {
const compilationResult = await this.compilationResult(address)
if (!this.cache.contractDeclarations[address]) {
if (!this.cache.contractDeclarations[address]) {
this.cache.contractDeclarations[address] = extractContractDefinitions(compilationResult.data.sources)
}
if (!this.cache.statesDefinitions[address]) {

@ -1,5 +1,5 @@
'use strict'
import { util } from '@remix-project/remix-lib'
import { util } from '@remix-project/remix-lib'
import { bytesToHex } from '@ethereumjs/util'
const { toHexPaddedString } = util
import * as traceHelper from './traceHelper'

@ -155,7 +155,7 @@ export class TraceManager {
return stack.map(el => toHexPaddedString(el))
} else {
// it's an object coming from the VM.
// for performance reasons,
// for performance reasons,
// we don't turn the stack coming from the VM into an array when the tx is executed
// but now when the app needs it.
const stack = []

@ -37,7 +37,7 @@ const compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(in
console.dir(Object.keys(compilationData))
const compilation = {}
compilation['data'] = compilationData
compilation['source'] = {sources: inputJson.sources}
compilation['source'] = { sources: inputJson.sources }
console.dir(compilation)
console.dir(compilation['data'].errors)

@ -5,7 +5,7 @@ import { CodeManager } from '../src/code/codeManager'
const web3Test = require('./resources/testWeb3.ts')
tape('CodeManager', function (t) {
const traceManager = new TraceManager({web3: web3Test})
const traceManager = new TraceManager({ web3: web3Test })
const codeManager = new CodeManager(traceManager)
const contractCode = web3Test.eth.getCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', contractCode) // so a call to web3 is not necessary

@ -156,7 +156,7 @@ contract Ballot {
output = JSON.parse(output)
const param = '0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000148656c6c6f20576f726c64210000000000000000000000000000000000000000'
const web3 = await vmCall.getWeb3()
vmCall.sendTx(web3, {nonce: 0, privateKey: privateKey}, undefined, 0, output.contracts['test.sol']['Ballot'].evm.bytecode.object + param, (error, hash) => {
vmCall.sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, output.contracts['test.sol']['Ballot'].evm.bytecode.object + param, (error, hash) => {
console.log(error, hash)
if (error) {
throw error
@ -177,7 +177,7 @@ contract Ballot {
}
}
})
debugManager.callTree.event.register('callTreeReady', () => {
testDebugging(debugManager)
})
@ -189,7 +189,7 @@ contract Ballot {
console.error(error)
throw error
})
debugManager.debug(tx)
})
.catch(error => { throw error })
@ -279,10 +279,10 @@ function testDebugging (debugManager) {
tape('breakPointManager', (t) => {
t.plan(2)
const {traceManager, callTree, solidityProxy} = debugManager
const breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy})
const { traceManager, callTree, solidityProxy } = debugManager
const breakPointManager = new BreakpointManager({ traceManager, callTree, solidityProxy })
breakPointManager.add({fileName: 'test.sol', row: 39})
breakPointManager.add({ fileName: 'test.sol', row: 39 })
breakPointManager.event.register('breakpointHit', function (sourceLocation, step) {
t.equal(JSON.stringify(sourceLocation), JSON.stringify({ start: 1146, length: 6, file: 0, jump: '-' }))

@ -11,4 +11,4 @@ module.exports = {
uint p = 45;
}
}
`}
` }

@ -39,4 +39,4 @@ contract intLocal {
uint8 ui81 = asd;
}
}
`}
` }

@ -36,4 +36,4 @@ contract miscLocal {
string memory smallstring = "test_test_test";
}
}
`}
` }

@ -81,4 +81,4 @@ contract structArrayLocal {
arrayStruct.c = enumdef.three;
}
}
`}
` }

@ -31,7 +31,7 @@ async function test (st, privateKey) {
let compilationResults = new CompilerAbstract('json', output, sources)
console.log('intLocalTest')
await intLocalTest(st, privateKey, output.contracts['test.sol']['intLocal'].evm.bytecode.object, compilationResults, intLocal.contract)
output = compiler.compile(compilerInput(miscLocal.contract))
output = JSON.parse(output)
sources = {
@ -41,7 +41,7 @@ async function test (st, privateKey) {
compilationResults = new CompilerAbstract('json', output, sources)
console.log('miscLocalTest')
await miscLocalTest(st, privateKey, output.contracts['test.sol']['miscLocal'].evm.bytecode.object, compilationResults, miscLocal.contract)
output = compiler.compile(compilerInput(miscLocal.contract))
output = JSON.parse(output)
sources = {
@ -51,7 +51,7 @@ async function test (st, privateKey) {
compilationResults = new CompilerAbstract('json', output, sources)
console.log('misc2LocalTest')
await misc2LocalTest(st, privateKey, output.contracts['test.sol']['miscLocal2'].evm.bytecode.object, compilationResults, miscLocal.contract)
output = compiler.compile(compilerInput(structArrayLocal.contract))
output = JSON.parse(output)
sources = {

@ -30,8 +30,8 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe
const traceManager = new TraceManager({ web3 })
const codeManager = new CodeManager(traceManager)
codeManager.clear()
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
getCode: codeManager.getCode.bind(codeManager),
compilationResult: () => compilationResult
})
@ -54,7 +54,7 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe
callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
helper.decodeLocals(st, 140, traceManager, callTree, function (locals) {
try {
const expected = {"p":{"value":"45","type":"uint256"},"foo":{"length":"1","value":[{"value":"3","type":"uint8"}],"type":"uint8[1]"},"boo":{"length":"1","value":[{"length":"2","value":[{"value":"R","type":"string"},{"value":"T","type":"string"}],"type":"string[2]"}],"type":"string[2][1]"}}
const expected = { "p":{ "value":"45","type":"uint256" },"foo":{ "length":"1","value":[{ "value":"3","type":"uint8" }],"type":"uint8[1]" },"boo":{ "length":"1","value":[{ "length":"2","value":[{ "value":"R","type":"string" },{ "value":"T","type":"string" }],"type":"string[2]" }],"type":"string[2][1]" } }
st.deepEqual(locals, expected)
} catch (e) {
st.fail(e.message)
@ -62,7 +62,6 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe
resolve({})
})
})
traceManager.resolveTrace(tx).then(() => {
debuggerEvent.trigger('newTraceLoaded', [traceManager.trace])

@ -12,9 +12,9 @@ import * as helper from './helper'
module.exports = function (st, privateKey, contractBytecode, compilationResult, contractCode) {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve) => {
return new Promise(async (resolve) => {
const web3 = await (vmCall as any).getWeb3();
(vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) {
(vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) {
if (error) {
return st.fail(error)
}
@ -24,10 +24,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
const traceManager = new TraceManager({ web3 })
const codeManager = new CodeManager(traceManager)
codeManager.clear()
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
getCode: codeManager.getCode.bind(codeManager),
compilationResult: () => compilationResult
compilationResult: () => compilationResult
})
const debuggerEvent = new EventManager()
const offsetToLineColumnConverter = {
@ -47,26 +47,26 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
})
callTree.event.register('callTreeReady', async (scopes, scopeStarts) => {
try {
// test gas cost per line
st.equals((await callTree.getGasCostPerLine(0, 16)).gasCost, 11)
st.equals((await callTree.getGasCostPerLine(0, 32)).gasCost, 84)
const functions1 = callTree.retrieveFunctionsStack(103)
const functions2 = callTree.retrieveFunctionsStack(116)
const functions3 = callTree.retrieveFunctionsStack(13)
st.equals(functions1.length, 2)
st.equals(functions2.length, 3)
st.equals(functions3.length, 1)
st.equal(functions1[0].gasCost, 54)
st.equal(functions1[1].gasCost, 436)
st.equal(functions2[0].gasCost, 23)
st.equal(functions2[1].gasCost, 54)
st.equal(functions2[2].gasCost, 436)
st.equals(Object.keys(functions1[0])[0], 'functionDefinition')
st.equals(Object.keys(functions1[0])[1], 'inputs')
st.equals(functions1[0].inputs[0], 'foo')
@ -76,11 +76,11 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
st.equals(Object.keys(functions2[1])[1], 'inputs')
st.equals(functions2[0].inputs[0], 'asd')
st.equals(functions2[1].inputs[0], 'foo')
st.equals(functions1[0].functionDefinition.name, 'level11')
st.equals(functions2[0].functionDefinition.name, 'level12')
st.equals(functions2[1].functionDefinition.name, 'level11')
st.equals(scopeStarts[0], '1')
st.equals(scopeStarts[10], '1.1')
st.equals(scopeStarts[102], '1.1.1')
@ -111,7 +111,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
} catch (e) {
st.fail(e.message)
}
helper.decodeLocals(st, 95, traceManager, callTree, function (locals) {
st.equals(Object.keys(locals).length, 16)
st.equals(locals['ui8'].value, '130')
@ -130,7 +130,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
st.equals(locals['i'].value, '-32432423423')
st.equals(locals['ishrink'].value, '2')
})
helper.decodeLocals(st, 106, traceManager, callTree, function (locals) {
try {
st.equals(locals['ui8'].value, '123')

@ -13,7 +13,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve) => {
const web3 = await (vmCall as any).getWeb3();
(vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) {
(vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) {
if (error) {
return st.fail(error)
}
@ -23,10 +23,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
const traceManager = new TraceManager({ web3 })
const codeManager = new CodeManager(traceManager)
codeManager.clear()
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
getCode: codeManager.getCode.bind(codeManager),
compilationResult: () => compilationResult
compilationResult: () => compilationResult
})
const debuggerEvent = new EventManager()
const offsetToLineColumnConverter = {
@ -65,7 +65,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
st.fail(e.message)
}
})
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
try {
// st.equals(Object.keys(locals).length, 0)
@ -84,5 +84,5 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
})
.catch(error => st.fail(error))
})
})
})
}

@ -23,10 +23,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
const traceManager = new TraceManager({ web3 })
const codeManager = new CodeManager(traceManager)
codeManager.clear()
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
getCode: codeManager.getCode.bind(codeManager),
compilationResult: () => compilationResult
compilationResult: () => compilationResult
})
const debuggerEvent = new EventManager()
const offsetToLineColumnConverter = {
@ -51,7 +51,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
st.fail(e.message)
}
})
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
try {
// st.equals(Object.keys(locals).length, 0)
@ -70,5 +70,5 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,
})
.catch(error => st.fail(error))
})
})
})
}

@ -23,10 +23,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c
const traceManager = new TraceManager({ web3 })
const codeManager = new CodeManager(traceManager)
codeManager.clear()
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
const solidityProxy = new SolidityProxy({
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
getCode: codeManager.getCode.bind(codeManager),
compilationResult: () => compilationResult
compilationResult: () => compilationResult
})
const debuggerEvent = new EventManager()
const offsetToLineColumnConverter = {
@ -59,24 +59,24 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c
st.equals(locals['f'].raw, '0x746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f')
st.equals(locals['f'].value, 'test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_')
st.equals(locals['e'].value['e'].value, true)
st.equals(locals['simpleArray'].value[0].value, '45')
st.equals(locals['simpleArray'].value[1].value, '324324')
st.equals(locals['simpleArray'].value[2].value, '-333')
st.equals(locals['simpleArray'].value[3].value, '5656')
st.equals(locals['simpleArray'].value[4].value, '-1111')
st.equals(locals['stringArray'].value[0].value, 'long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_')
st.equals(locals['stringArray'].value[1].value, 'two')
st.equals(locals['stringArray'].value[2].value, 'three')
st.equals(locals['dynArray'].value[0].value[0].value, '3423423532')
st.equals(locals['dynArray'].value[1].value[0].value, '-342343323532')
st.equals(locals['dynArray'].value[1].value[1].value, '23432')
st.equals(locals['dynArray'].value[2].value[0].value, '-432432')
st.equals(locals['dynArray'].value[2].value[1].value, '3423423532')
st.equals(locals['dynArray'].value[2].value[2].value, '-432432')
st.equals(locals['structArray'].value[0].value['a'].value, 'test')
st.equals(locals['structArray'].value[0].value['a'].length, '0x8')
st.equals(locals['structArray'].value[0].value['a'].raw, '0x74657374')
@ -86,31 +86,31 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c
st.equals(locals['structArray'].value[0].value['c'].value, 'test_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_test')
st.equals(locals['structArray'].value[0].value['d'].value, '3')
st.equals(locals['structArray'].value[0].value['e'].value, true)
st.equals(locals['structArray'].value[1].value['a'].value, 'item1 a')
st.equals(locals['structArray'].value[1].value['b'].value, '20')
st.equals(locals['structArray'].value[1].value['c'].value, 'item1 c')
st.equals(locals['structArray'].value[1].value['d'].value, '-45')
st.equals(locals['structArray'].value[1].value['e'].value, false)
st.equals(locals['structArray'].value[2].value['a'].value, 'item2 a')
st.equals(locals['structArray'].value[2].value['b'].value, '200')
st.equals(locals['structArray'].value[2].value['c'].value, 'item2 c')
st.equals(locals['structArray'].value[2].value['d'].value, '-450')
st.equals(locals['structArray'].value[2].value['e'].value, true)
st.equals(locals['arrayStruct'].value.a.value[0].value, 'string')
st.equals(locals['arrayStruct'].value.b.value[0].value, '34')
st.equals(locals['arrayStruct'].value.b.value[1].value, '-23')
st.equals(locals['arrayStruct'].value.b.value[2].value, '-3')
st.equals(locals['arrayStruct'].value.c.value, 'three')
st.equals(Object.keys(locals).length, 8)
} catch (e) {
st.fail(e.message)
}
})
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
try {
console.log('at 7', locals)
@ -130,5 +130,5 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c
})
.catch(error => st.fail(error))
})
})
})
}

@ -10,7 +10,7 @@ import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree
import * as vmCall from '../../vmCall'
import { StorageResolver } from '../../../src/storage/storageResolver'
import { StorageViewer } from '../../../src/storage/storageViewer'
import { Address, bytesToHex } from '@ethereumjs/util'
import { Address, bytesToHex } from '@ethereumjs/util'
module.exports = async function testMappingStorage (st, cb) {
const mappingStorage = require('../contracts/mappingStorage')
@ -23,7 +23,7 @@ module.exports = async function testMappingStorage (st, cb) {
}
const compilationResults = new CompilerAbstract('json', output, sources)
const web3 = await (vmCall as any).getWeb3();
(vmCall as any).sendTx(web3, {nonce: 0, privateKey: privateKey}, undefined, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, hash) {
(vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, hash) {
if (error) {
console.log(error)
st.end(error)
@ -44,7 +44,7 @@ module.exports = async function testMappingStorage (st, cb) {
}
function testMapping (st, privateKey, contractAddress, output, compilationResults, web3, cb) {
(vmCall as any).sendTx(web3, {nonce: 1, privateKey: privateKey}, contractAddress, 0, '2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000',
(vmCall as any).sendTx(web3, { nonce: 1, privateKey: privateKey }, contractAddress, 0, '2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000',
function (error, hash) {
if (error) {
console.log(error)
@ -74,7 +74,7 @@ function testMapping (st, privateKey, contractAddress, output, compilationResult
stepIndex: 268,
tx: tx,
address: contractAddress
}, new StorageResolver({web3}), traceManager)
}, new StorageResolver({ web3 }), traceManager)
const stateVars = stateDecoder.extractStateVariables('SimpleMappingState', output.sources)
stateDecoder.decodeState(stateVars, storageViewer).then((result) => {
st.equal(result['_num'].value, '1')

@ -13,8 +13,8 @@ export function compilerInput (contracts) {
},
outputSelection: {
'*': {
'': [ 'ast' ],
'*': [ 'abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ]
'': ['ast'],
'*': ['abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates']
}
}
}

@ -1,14 +1,14 @@
const node = {}
node['ast'] = {"legacyAST":{"children":[{"attributes":{"fullyImplemented":true,"isLibrary":false,"linearizedBaseContracts":[5640396],"name":"test"},"children":[{"attributes":{"name":"x","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5657860,"name":"ElementaryTypeName","src":"21:3:11"}],"id":5658100,"name":"VariableDeclaration","src":"21:5:11"},{"attributes":{"name":"y","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658180,"name":"ElementaryTypeName","src":"38:3:11"}],"id":5658268,"name":"VariableDeclaration","src":"38:5:11"},{"attributes":{"constant":false,"name":"set","public":true},"children":[{"children":[{"attributes":{"name":"_x","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658404,"name":"ElementaryTypeName","src":"68:3:11"}],"id":5658492,"name":"VariableDeclaration","src":"68:6:11"}],"id":5658572,"name":"ParameterList","src":"67:8:11"},{"children":[{"attributes":{"name":"_r","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658628,"name":"ElementaryTypeName","src":"85:3:11"}],"id":5658716,"name":"VariableDeclaration","src":"85:6:11"}],"id":5658796,"name":"ParameterList","src":"84:8:11"},{"children":[{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"x"},"id":5658900,"name":"Identifier","src":"108:1:11"},{"attributes":{"type":"int256","value":"_x"},"id":5658980,"name":"Identifier","src":"112:2:11"}],"id":5657492,"name":"Assignment","src":"108:6:11"}],"id":5659028,"name":"ExpressionStatement","src":"108:6:11"},{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"y"},"id":5659116,"name":"Identifier","src":"125:1:11"},{"attributes":{"string":null,"type":"int_const 10","value":"10"},"id":5659196,"name":"Literal","src":"129:2:11"}],"id":5659252,"name":"Assignment","src":"125:6:11"}],"id":5659316,"name":"ExpressionStatement","src":"125:6:11"},{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"_r"},"id":5659428,"name":"Identifier","src":"141:2:11"},{"attributes":{"type":"int256","value":"x"},"id":5639308,"name":"Identifier","src":"146:1:11"}],"id":5639356,"name":"Assignment","src":"141:6:11"}],"id":5639420,"name":"ExpressionStatement","src":"141:6:11"}],"id":5639516,"name":"Block","src":"97:57:11"}],"id":5639612,"name":"FunctionDefinition","src":"55:99:11"},{"attributes":{"constant":false,"name":"get","public":true},"children":[{"children":[],"id":5639764,"name":"ParameterList","src":"179:2:11"},{"children":[{"attributes":{"name":"x","type":"uint256"},"children":[{"attributes":{"name":"uint"},"id":5639820,"name":"ElementaryTypeName","src":"191:4:11"}],"id":5639908,"name":"VariableDeclaration","src":"191:6:11"},{"attributes":{"name":"y","type":"uint256"},"children":[{"attributes":{"name":"uint"},"id":5639988,"name":"ElementaryTypeName","src":"199:4:11"}],"id":5640076,"name":"VariableDeclaration","src":"199:6:11"}],"id":5640156,"name":"ParameterList","src":"190:16:11"},{"children":[],"id":5640212,"name":"Block","src":"212:17:11"}],"id":5640276,"name":"FunctionDefinition","src":"167:62:11"}],"id":5640396,"name":"ContractDefinition","src":"0:231:11"}],"name":"SourceUnit"}}
node['ast'] = { "legacyAST":{ "children":[{ "attributes":{ "fullyImplemented":true,"isLibrary":false,"linearizedBaseContracts":[5640396],"name":"test" },"children":[{ "attributes":{ "name":"x","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5657860,"name":"ElementaryTypeName","src":"21:3:11" }],"id":5658100,"name":"VariableDeclaration","src":"21:5:11" },{ "attributes":{ "name":"y","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658180,"name":"ElementaryTypeName","src":"38:3:11" }],"id":5658268,"name":"VariableDeclaration","src":"38:5:11" },{ "attributes":{ "constant":false,"name":"set","public":true },"children":[{ "children":[{ "attributes":{ "name":"_x","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658404,"name":"ElementaryTypeName","src":"68:3:11" }],"id":5658492,"name":"VariableDeclaration","src":"68:6:11" }],"id":5658572,"name":"ParameterList","src":"67:8:11" },{ "children":[{ "attributes":{ "name":"_r","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658628,"name":"ElementaryTypeName","src":"85:3:11" }],"id":5658716,"name":"VariableDeclaration","src":"85:6:11" }],"id":5658796,"name":"ParameterList","src":"84:8:11" },{ "children":[{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"x" },"id":5658900,"name":"Identifier","src":"108:1:11" },{ "attributes":{ "type":"int256","value":"_x" },"id":5658980,"name":"Identifier","src":"112:2:11" }],"id":5657492,"name":"Assignment","src":"108:6:11" }],"id":5659028,"name":"ExpressionStatement","src":"108:6:11" },{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"y" },"id":5659116,"name":"Identifier","src":"125:1:11" },{ "attributes":{ "string":null,"type":"int_const 10","value":"10" },"id":5659196,"name":"Literal","src":"129:2:11" }],"id":5659252,"name":"Assignment","src":"125:6:11" }],"id":5659316,"name":"ExpressionStatement","src":"125:6:11" },{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"_r" },"id":5659428,"name":"Identifier","src":"141:2:11" },{ "attributes":{ "type":"int256","value":"x" },"id":5639308,"name":"Identifier","src":"146:1:11" }],"id":5639356,"name":"Assignment","src":"141:6:11" }],"id":5639420,"name":"ExpressionStatement","src":"141:6:11" }],"id":5639516,"name":"Block","src":"97:57:11" }],"id":5639612,"name":"FunctionDefinition","src":"55:99:11" },{ "attributes":{ "constant":false,"name":"get","public":true },"children":[{ "children":[],"id":5639764,"name":"ParameterList","src":"179:2:11" },{ "children":[{ "attributes":{ "name":"x","type":"uint256" },"children":[{ "attributes":{ "name":"uint" },"id":5639820,"name":"ElementaryTypeName","src":"191:4:11" }],"id":5639908,"name":"VariableDeclaration","src":"191:6:11" },{ "attributes":{ "name":"y","type":"uint256" },"children":[{ "attributes":{ "name":"uint" },"id":5639988,"name":"ElementaryTypeName","src":"199:4:11" }],"id":5640076,"name":"VariableDeclaration","src":"199:6:11" }],"id":5640156,"name":"ParameterList","src":"190:16:11" },{ "children":[],"id":5640212,"name":"Block","src":"212:17:11" }],"id":5640276,"name":"FunctionDefinition","src":"167:62:11" }],"id":5640396,"name":"ContractDefinition","src":"0:231:11" }],"name":"SourceUnit" } }
node['ast'].ast = {
node['ast'].ast = {
absolutePath: 'sample.sol',
exportedSymbols: { test: [ 33 ] },
exportedSymbols: { test: [33]},
id: 34,
nodeType: 'SourceUnit',
nodes:
[ {
[{
abstract: false,
baseContracts: [],
contractDependencies: [],
@ -16,11 +16,11 @@ node['ast'].ast = {
documentation: null,
fullyImplemented: true,
id: 33,
linearizedBaseContracts: [ 33 ],
linearizedBaseContracts: [33],
name: 'test',
nodeType: 'ContractDefinition',
nodes:
[ { constant: false,
[{ constant: false,
id: 2,
name: 'x',
nodeType: 'VariableDeclaration',
@ -30,12 +30,12 @@ node['ast'].ast = {
stateVariable: true,
storageLocation: 'default',
typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' },
typeName: {
typeName: {
id: 1,
name: 'int',
nodeType: 'ElementaryTypeName',
src: '20:3:0',
typeDescriptions: [Object]
typeDescriptions: [Object]
},
value: null,
visibility: 'internal' },
@ -54,14 +54,14 @@ node['ast'].ast = {
name: 'int',
nodeType: 'ElementaryTypeName',
src: '31:3:0',
typeDescriptions: [Object] },
typeDescriptions: [Object]},
value: null,
visibility: 'internal' },
{ body: { id: 23,
nodeType: 'Block',
src: '96:55:0',
statements:
[ { expression:
[{ expression:
{ argumentTypes: null,
id: 13,
isConstant: false,
@ -69,7 +69,7 @@ node['ast'].ast = {
isPure: false,
lValueRequested: false,
leftHandSide:
{ argumentTypes: null,
{ argumentTypes: null,
id: 11,
name: 'x',
nodeType: 'Identifier',
@ -89,7 +89,7 @@ node['ast'].ast = {
src: '110:2:0',
typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' } },
src: '106:6:0',
typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' }
typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' }
},
id: 14,
nodeType: 'ExpressionStatement',
@ -106,7 +106,7 @@ node['ast'].ast = {
operator: '=',
rightHandSide: [Object],
src: '122:6:0',
typeDescriptions: [Object] },
typeDescriptions: [Object]},
id: 18,
nodeType: 'ExpressionStatement',
src: '122:6:0' },
@ -122,10 +122,10 @@ node['ast'].ast = {
operator: '=',
rightHandSide: [Object],
src: '138:6:0',
typeDescriptions: [Object] },
typeDescriptions: [Object]},
id: 22,
nodeType: 'ExpressionStatement',
src: '138:6:0' } ]
src: '138:6:0' }]
},
documentation: null,
functionSelector: 'e5c19b2d',
@ -149,7 +149,7 @@ node['ast'].ast = {
stateMutability: 'nonpayable',
virtual: false,
visibility: 'public' },
{ body: { id: 31, nodeType: 'Block', src: '214:17:0', statements: [] },
{ body: { id: 31, nodeType: 'Block', src: '214:17:0', statements: []},
documentation: null,
functionSelector: '6d4ce63c',
id: 32,
@ -173,13 +173,12 @@ node['ast'].ast = {
src: '163:68:0',
stateMutability: 'nonpayable',
virtual: false,
visibility: 'public' } ],
visibility: 'public' }],
scope: 34,
src: '0:233:0'
} ],
src: '0:233:0'
src: '0:233:0'
}],
src: '0:233:0'
}
node['source'] = `contract test {
int x;

@ -7,7 +7,7 @@ let data = init.readFile(require('path').resolve(__dirname, 'testWeb3.json'), nu
data = JSON.parse(data)
let traceWithABIEncoder = init.readFile(require('path').resolve(__dirname, 'traceWithABIEncoder.json'), null)
traceWithABIEncoder =
traceWithABIEncoder =
data.testTraces['0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd53'] = JSON.parse(traceWithABIEncoder)
web3Override.eth.getCode = function (address, callback) {
@ -48,7 +48,7 @@ web3Override.eth.setProvider = function (provider) {}
web3Override.eth.providers = { 'HttpProvider': function (url) {} }
web3Override.eth.currentProvider = {'host': 'test provider'}
web3Override.eth.currentProvider = { 'host': 'test provider' }
if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') {
module.exports = web3Override

@ -11,20 +11,20 @@ import { compilerInput } from './helpers/compilerHelper'
tape('SourceLocationTracker', function (t) {
t.test('SourceLocationTracker.getSourceLocationFromVMTraceIndex - simple contract', async function (st) {
const traceManager = new TraceManager({web3: web3Test})
const codeManager = new CodeManager(traceManager)
const traceManager = new TraceManager({ web3: web3Test })
const codeManager = new CodeManager(traceManager)
let output = compiler.compile(compilerInput(contracts))
output = JSON.parse(output)
codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', '0x' + output.contracts['test.sol']['test'].evm.deployedBytecode.object)
const tx = web3Test.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd52')
traceManager.resolveTrace(tx).then(async () => {
traceManager.resolveTrace(tx).then(async () => {
const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: false })
const sourceLocationTracker = new SourceLocationTracker(codeManager, {debugWithGeneratedSources: false})
try {
const map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 0, output.contracts)
st.equal(map['file'], 0)
@ -42,20 +42,18 @@ tape('SourceLocationTracker', function (t) {
t.test('SourceLocationTracker.getSourceLocationFromVMTraceIndex - ABIEncoder V2 contract', async function (st) {
const traceManager = new TraceManager({web3: web3Test})
const codeManager = new CodeManager(traceManager)
const traceManager = new TraceManager({ web3: web3Test })
const codeManager = new CodeManager(traceManager)
let output = compiler.compile(compilerInput(ABIEncoderV2))
output = JSON.parse(output)
codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', '0x' + output.contracts['test.sol']['test'].evm.deployedBytecode.object)
const tx = web3Test.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd53')
traceManager.resolveTrace(tx).then(async () => {
traceManager.resolveTrace(tx).then(async () => {
try {
// with debugWithGeneratedSources: false
const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: false })
@ -67,7 +65,7 @@ tape('SourceLocationTracker', function (t) {
map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 45, output.contracts)
st.equal(map['file'], 1) // 1 refers to the generated source (pragma experimental ABIEncoderV2)
map = await sourceLocationTracker.getValidSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 45, output.contracts)
st.equal(map['file'], 0) // 1 refers to the generated source (pragma experimental ABIEncoderV2)
st.equal(map['start'], 303)
@ -84,7 +82,7 @@ tape('SourceLocationTracker', function (t) {
try {
// with debugWithGeneratedSources: true
const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: true })
let map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 0, output.contracts)
console.log(map)
st.equal(map['file'], 0)

@ -7,7 +7,7 @@ tape('TraceManager', function (t) {
let traceManager
t.test('TraceManager.init', function (st) {
traceManager = new TraceManager({web3: web3Test})
traceManager = new TraceManager({ web3: web3Test })
st.end()
})

@ -1,10 +1,9 @@
'use strict'
import { extendWeb3 } from '../src/init'
import { extendWeb3 } from '../src/init'
import { Address } from '@ethereumjs/util'
import { Web3 } from 'web3';
const { Provider } = require('@remix-project/remix-simulator')
async function getWeb3 () {
const remixSimulatorProvider = new Provider({ fork: 'berlin' })
await remixSimulatorProvider.init()

Loading…
Cancel
Save