trufflesuite / truffle-debugger

Core functionality for debugging Solidity files built with Truffle
67 stars 12 forks source link

Invocation example steps potentially out of date? #72

Open makoto opened 6 years ago

makoto commented 6 years ago

Hi, I tried to follow Invocation example

import Debugger from "truffle-debugger";

let session = Debugger
  .forTx(txHash, { contracts, provider })
  .connect();

But getting the TypeError: Debugger.forTx(...).connect is not a function error.

$ truffle unbox metacoin
$ truffle develop
Connected to existing Truffle Develop session at http://127.0.0.1:9545/
truffle(develop)> var m, trx;
var m = MetaCoin.deployed().then((i)=>{m = i})
truffle(develop)> undefined
truffle(develop)> m.sendCoin(web3.eth.accounts[2], 1, {from:web3.eth.accounts[1]}).then((_trx)=>{trx = _trx})
undefined
truffle(develop)> trx.tx
'0xcb294be238d306d0b1df4757c60461c310ede7aabb47bdd347c93fbe812acba2'
truffle(develop)> var Debugger = require("truffle-debugger");
truffle(develop)> var provider = MetaCoin.web3.currentProvider;
truffle(develop)> contracts = [MetaCoin];
truffle(develop)> txHash = trx.tx
truffle(develop)> Debugger.forTx(txHash, { contracts, provider }).connect()
TypeError: Debugger.forTx(...).connect is not a function

By looking at some of the tests, it has different input arguments

      let bugger = await Debugger.forTx(txHash, {
        provider,
        files,
        contracts: artifacts
      });

      let session = bugger.connect();

I wasn't quite sure who I can set files variable so could not proceed any more. Would be great if you can update doc to try out the invocation using simple Metacoin example so I don't have to second guess how to set variables like contracts , providers or files

gnidan commented 6 years ago

Good catch @makoto!

files comes from truffle-compile, when you do compile(..., callback), callback is called with callback(contracts, files).

But that's not the issue you're having with that exception - Debugger.forTx() returns a promise, so you'll have to do Debugger.forTx(...).then(function(bugger) { return bugger.connect(); }). The files argument is optional and the debugger attempts to deduce the values if it's not provided, so I'd be curious if that works for you.

Regardless, I'll update the README when I get the chance, or feel free to open a PR. Thanks for bringing this up!

makoto commented 6 years ago

Ummm, not working

truffle(develop)> Debugger.forTx(trx.tx, { contracts, provider }).then((s)=>{session = s})
undefined
truffle(develop)> await session.connect()
SyntaxError: Unexpected identifier
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.emit (events.js:211:7)
    at emitOne (events.js:116:13)
    at REPLServer.onLine (repl.js:468:10)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at bound (domain.js:301:14)
    at ReplManager.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-core/lib/repl.js:119:1)
    at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-core/lib/console.js:164:1)
    at Object.runInContext (vm.js:119:10)
    at createScript (vm.js:80:10)

Having said that. Now even debug trxHash stopped working so may be related to something else.

truffle(develop)> debug trx.tx
Compiling ./contracts/Compare.sol...
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/GetCode.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/SumVector.sol...

Compilation warnings encountered:

/Users/makoto/work/tmp/assembly/contracts/MetaCoin.sol:15:2: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
    function MetaCoin() public {
 ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/Migrations.sol:11:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
  function Migrations() public {
  ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/MetaCoin.sol:23:3: Warning: Invoking events without "emit" prefix is deprecated.
        Transfer(msg.sender, receiver, amount);
        ^------------------------------------^
,/Users/makoto/work/tmp/assembly/contracts/GetCode.sol:3:5: Warning: No visibility specified. Defaulting to "public". 
    function at(address _codeAddr) returns (bytes o_codeArray) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/SumVector.sol:5:5: Warning: No visibility specified. Defaulting to "public". 
    function SoliditySum(uint[] _sumData) returns (uint o_dataSum) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/SumVector.sol:12:5: Warning: No visibility specified. Defaulting to "public". 
    function asmSum(uint[] _sumData) returns (uint o_dataSum) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/SumVector.sol:20:5: Warning: No visibility specified. Defaulting to "public". 
    function asmPureSum(uint[] _sumData) returns (uint o_dataSum) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/Compare.sol:10:5: Warning: Function state mutability can be restricted to pure
    function compare(bytes self, bytes other) public returns (int) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/GetCode.sol:3:5: Warning: Function state mutability can be restricted to view
    function at(address _codeAddr) returns (bytes o_codeArray) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/SumVector.sol:5:5: Warning: Function state mutability can be restricted to pure
    function SoliditySum(uint[] _sumData) returns (uint o_dataSum) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/SumVector.sol:12:5: Warning: Function state mutability can be restricted to pure
    function asmSum(uint[] _sumData) returns (uint o_dataSum) {
    ^ (Relevant source part starts here and spans across multiple lines).
,/Users/makoto/work/tmp/assembly/contracts/SumVector.sol:20:5: Warning: Function state mutability can be restricted to pure
    function asmPureSum(uint[] _sumData) returns (uint o_dataSum) {
    ^ (Relevant source part starts here and spans across multiple lines).

Gathering transaction data...

Error: Unknown transaction 0x30e033
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-core/~/truffle-debugger/dist/debugger.js:6148:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
gnidan commented 6 years ago

truffle(develop)> await session.connect()
SyntaxError: Unexpected identifier```

Truffle's console doesn't yet support the await syntax, unfortunately. But! You don't need it for that method; just do session.connect(). Check out the public methods in the Debugger API Docs, that should help. Take note which methods are labeled async, so you know which ones return Promises.


truffle(develop)> debug trx.tx```

I'm not sure what's going on there, but I am guessing that trx.tx is getting interpreted as a string literal, not looked up as a variable. Truffle's console isn't smart about that sort of thing, AFAIK.

makoto commented 6 years ago

Ok, it's working...ish

truffle(develop)> Debugger.forTx(trx.tx, { contracts, provider }).then((s)=>{session = s.connect()})
undefined
truffle(develop)> session.ready()

undefined
truffle(develop)> session.stepNext();
undefined
truffle(develop)> true
truffle(develop)> session.stepOver();
false

stepInfo may be typo to stepInto.

truffle(develop)> session.stepInfo();
TypeError: session.stepInfo is not a function
truffle(develop)> session.stepInto();
false

And I cannot reproduce step 4 either

truffle(develop)> variables = session.view(data.identifiers.native.current);
TypeError: Cannot read property 'native' of undefined
truffle(develop)> sourceRange = session.view(solidity.current.sourceRange);
TypeError: Cannot read property 'match' of undefined
    at Session.view (/Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/session/index.js:116:1)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:90:33
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:76:25
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/evm/selectors/index.js:206:1
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/evm/selectors/index.js:167:1
    at Array.filter (<anonymous>)
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/evm/selectors/index.js:168:1

About debug trx.tx, you were right. When I copy&paste transaction hash directly then it's working.

gnidan commented 6 years ago

@makoto ok, I just fixed the README a bit.

Couple notes:

Thanks for your continued feedback on this! Sorry for the bad usage docs, I'll plan to rewrite them to be clearer soon.

makoto commented 6 years ago

session.view(solidity.current.source) returned empty hash {}

truffle(develop)> trx.tx
'0x4427dac949d34f0e13bce6b6a08fa06c8c5e1f1241fe45355bf920f957ff8319'
truffle(develop)> Debugger.forTx(trx.tx, { contracts, provider }).then((s)=>{session = s.connect()})
undefined
truffle(develop)> session
Session {
  _store: 
   { dispatch: [Function],
     subscribe: [Function: subscribe],
     getState: [Function: getState],
     replaceReducer: [Function: replaceReducer],
     [Symbol(observable)]: [Function: observable] } }
truffle(develop)> session.ready()

undefined
truffle(develop)> let { ast, data, evm, solidity, trace } = Debugger.selectors;
undefined
truffle(develop)> session.view(solidity.current.source)
{}
truffle(develop)> session.view(data.current.identifiers.native);
TypeError: Cannot read property 'id' of undefined
    at Session.view (/Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/session/index.js:116:1)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function._ (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:90:33
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:76:25
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/data/selectors/index.js:153:1
truffle(develop)> session.view(solidity.current.sourceRange);
{ start: 316,
  length: 675,
  lines: 
   { start: { line: null, column: null },
     end: { line: null, column: null } } }
truffle(develop)>  session.stepNext()
undefined
truffle(develop)> true
truffle(develop)> session.view(solidity.current.sourceRange);
TypeError: Cannot read property 'match' of undefined
    at Session.view (/Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/session/index.js:116:1)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:90:33
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:76:25
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/evm/selectors/index.js:206:1
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/evm/selectors/index.js:167:1
    at Array.filter (<anonymous>)
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/evm/selectors/index.js:168:1
truffle(develop)> session.view(data.current.identifiers.native);
TypeError: Cannot read property 'stack' of undefined
    at Session.view (/Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/session/index.js:116:1)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at args (/Users/makoto/work/tmp/assembly/node_modules/reselect-tree/lib/index.js:79:1)
    at Function.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25)
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:86:37
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:90:33
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:36:25
    at /Users/makoto/work/tmp/assembly/node_modules/reselect/lib/index.js:76:25
    at /Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/evm/selectors/index.js:232:1

Well, debugging in solidity is such a painful process at this moment so I will be patiently trying out anything which may potentially improve the process. truffle-debugger has such a great potential so keen to pork around the gut of it.

gnidan commented 6 years ago

@makoto can you show me contracts that you've passed in? I'm starting to suspect files isn't as optional as I thought.

I'm glad to hear that you're interested in this! I think you might be the first person to try this stuff out, so thank you for your patience as the first guinea pig :)

makoto commented 6 years ago

@gnidan contracts is just [MetaCoin]

truffle(develop)> contracts
[ { [Function: TruffleContract]
    _static_methods: 
     { setProvider: [Function: setProvider],
       new: [Function: new],
       at: [Function: at],
       deployed: [Function: deployed],
       defaults: [Function: defaults],
       hasNetwork: [Function: hasNetwork],
       isDeployed: [Function: isDeployed],
       detectNetwork: [Function: detectNetwork],
       setNetwork: [Function: setNetwork],
       resetAddress: [Function: resetAddress],
       link: [Function: link],
       clone: [Function: clone],
       addProp: [Function: addProp],
       toJSON: [Function: toJSON] },
    _properties: 
     { contract_name: [Object],
       contractName: [Object],
       abi: [Object],
       network: [Function: network],
       networks: [Function: networks],
       address: [Object],
       transactionHash: [Object],
       links: [Function: links],
       events: [Function: events],
       binary: [Function: binary],
       deployedBinary: [Function: deployedBinary],
       unlinked_binary: [Object],
       bytecode: [Object],
       deployedBytecode: [Object],
       sourceMap: [Object],
       deployedSourceMap: [Object],
       source: [Object],
       sourcePath: [Object],
       legacyAST: [Object],
       ast: [Object],
       compiler: [Object],
       schema_version: [Function: schema_version],
       schemaVersion: [Function: schemaVersion],
       updated_at: [Function: updated_at],
       updatedAt: [Function: updatedAt] },
    _property_values: {},
    _json: 
     { contractName: 'MetaCoin',
       abi: [Array],
       bytecode: '0x608060405234801561001057600080fd5b506127106000803273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506103fc806100656000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680637bd703e81461005c57806390b98a11146100b3578063f8b2cb4f14610118575b600080fd5b34801561006857600080fd5b5061009d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061016f565b6040518082815260200191505060405180910390f35b3480156100bf57600080fd5b506100fe600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061022f565b604051808215151515815260200191505060405180910390f35b34801561012457600080fd5b50610159600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610388565b6040518082815260200191505060405180910390f35b600073__ConvertLib____________________________6396e4ee3d61019484610388565b60026040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018281526020019250505060206040518083038186803b1580156101ed57600080fd5b505af4158015610201573d6000803e3d6000fd5b505050506040513d602081101561021757600080fd5b81019080805190602001909291905050509050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156102805760009050610382565b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b92915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490509190505600a165627a7a723058202fe509a54f8047a1bd8776871a2b16c93a0566ed3b002d3804a9afc5df0486660029',
       deployedBytecode: '0x608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680637bd703e81461005c57806390b98a11146100b3578063f8b2cb4f14610118575b600080fd5b34801561006857600080fd5b5061009d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061016f565b6040518082815260200191505060405180910390f35b3480156100bf57600080fd5b506100fe600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061022f565b604051808215151515815260200191505060405180910390f35b34801561012457600080fd5b50610159600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610388565b6040518082815260200191505060405180910390f35b600073__ConvertLib____________________________6396e4ee3d61019484610388565b60026040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018281526020019250505060206040518083038186803b1580156101ed57600080fd5b505af4158015610201573d6000803e3d6000fd5b505050506040513d602081101561021757600080fd5b81019080805190602001909291905050509050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156102805760009050610382565b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b92915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490509190505600a165627a7a723058202fe509a54f8047a1bd8776871a2b16c93a0566ed3b002d3804a9afc5df0486660029',
       sourceMap: '316:675:3:-;;;453:62;8:9:-1;5:2;;;30:1;27;20:12;5:2;453:62:3;506:5;484:8;:19;493:9;484:19;;;;;;;;;;;;;;;:27;;;;316:675;;;;;;',
       deployedSourceMap: '316:675:3:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;780:117;;8:9:-1;5:2;;;30:1;27;20:12;5:2;780:117:3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;518:259;;8:9:-1;5:2;;;30:1;27;20:12;5:2;518:259:3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;900:89;;8:9:-1;5:2;;;30:1;27;20:12;5:2;900:89:3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;780:117;839:4;855:10;:18;874:16;885:4;874:10;:16::i;:::-;891:1;855:38;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;855:38:3;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;855:38:3;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;855:38:3;;;;;;;;;;;;;;;;848:45;;780:117;;;:::o;518:259::-;582:15;630:6;607:8;:20;616:10;607:20;;;;;;;;;;;;;;;;:29;603:47;;;645:5;638:12;;;;603:47;678:6;654:8;:20;663:10;654:20;;;;;;;;;;;;;;;;:30;;;;;;;;;;;710:6;688:8;:18;697:8;688:18;;;;;;;;;;;;;;;;:28;;;;;;;;;;;741:8;720:38;;729:10;720:38;;;751:6;720:38;;;;;;;;;;;;;;;;;;769:4;762:11;;518:259;;;;;:::o;900:89::-;954:4;971:8;:14;980:4;971:14;;;;;;;;;;;;;;;;964:21;;900:89;;;:::o',
       source: 'pragma solidity ^0.4.18;\n\nimport "./ConvertLib.sol";\n\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\n\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tfunction MetaCoin() public {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) public returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\tTransfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) public view returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) public view returns(uint) {\n\t\treturn balances[addr];\n\t}\n}\n',
       sourcePath: '/Users/makoto/work/tmp/assembly/contracts/MetaCoin.sol',
       ast: [Object],
       legacyAST: [Object],
       compiler: [Object],
       networks: [Object],
       schemaVersion: '2.0.0',
       updatedAt: '2018-05-10T21:35:37.738Z' },
    setProvider: [Function: bound setProvider],
    new: [Function: bound new],
    at: [Function: bound at],
    deployed: [Function: bound deployed],
    defaults: [Function: bound defaults],
    hasNetwork: [Function: bound hasNetwork],
    isDeployed: [Function: bound isDeployed],
    detectNetwork: [Function: bound detectNetwork],
    setNetwork: [Function: bound setNetwork],
    resetAddress: [Function: bound resetAddress],
    link: [Function: bound link],
    clone: [Function: bound clone],
    addProp: [Function: bound addProp],
    toJSON: [Function: bound toJSON],
    web3: 
     Web3 {
       _requestManager: [Object],
       currentProvider: [Object],
       eth: [Object],
       db: [Object],
       shh: [Object],
       net: [Object],
       personal: [Object],
       bzz: [Object],
       settings: [Object],
       version: [Object],
       providers: [Object],
       _extend: [Object] },
    class_defaults: 
     { from: '0x627306090abab3a6e1400e9345bc60c78a8bef57',
       gas: 6721975,
       gasPrice: 100000000000 },
    currentProvider: 
     HttpProvider {
       host: 'http://127.0.0.1:9545/',
       timeout: 0,
       user: undefined,
       password: undefined,
       headers: undefined,
       send: [Function],
       sendAsync: [Function],
       _alreadyWrapped: true },
    network_id: '4447' } ]
gnidan commented 6 years ago

@makoto sweet, that's very helpful.

Try passing this as the files argument (making sure to fix the path string):

[undefined, undefined, undefined, "/path/to/contracts/MetaCoin.sol"]

The reason for this is that the files array is used for interpreting solc's output. Here's what I mean, looking at one of the source maps:

{
  /* ... */
  deployedSourceMap: "316:675:3:-;;;;;;;;;;;;;;;;;;;; ..."
  /* ... */
}

The source-map is a list of ;-separated {2,4}-tuples, values byte:length:file:jump. The debugger needs the information to link file index to source, so thus the files argument. It's filled in with undefined because it looks like you only need to worry about files[3].

Hope that gets you further along, thank you!

makoto commented 6 years ago

Ummm, I am getting this.

truffle(develop)> var files = [undefined, undefined, undefined, "/Users/makoto/work/tmp/assembly/contracts/MetaCoin.sol"];
undefined
truffle(develop)> var session;
undefined
truffle(develop)> Debugger.forTx(trx.tx, { contracts, files, provider }).then((s)=>{session = s.connect()})
redux-saga error: uncaught at session.saga
at session.saga 
 TypeError: Cannot read property 'sourcePath' of undefined
    at recordSources$ (/Users/makoto/work/tmp/assembly/node_modules/truffle-debugger/dist/lib/session/sagas/index.js:110:1)
    at tryCatch (/Users/makoto/work/tmp/assembly/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/makoto/work/tmp/assembly/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/makoto/work/tmp/assembly/node_modules/regenerator-runtime/runtime.js:114:21)
    at tryCatch (/Users/makoto/work/tmp/assembly/node_modules/regenerator-runtime/runtime.js:62:40)
    at maybeInvokeDelegate (/Users/makoto/work/tmp/assembly/node_modules/regenerator-runtime/runtime.js:358:18)
    at Generator.invoke [as _invoke] (/Users/makoto/work/tmp/assembly/node_modules/regenerator-runtime/runtime.js:270:32)
    at Generator.prototype.(anonymous function) [as next] (/Users/makoto/work/tmp/assembly/node_modules/regenerator-runtime/runtime.js:114:21)
    at next (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/proc.js:322:27)
    at currCb (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/proc.js:399:7)
    at /Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/proc.js:510:16
    at exec (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/scheduler.js:25:5)
    at flush (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/scheduler.js:66:5)
    at asap (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/scheduler.js:39:5)
    at Array.<anonymous> (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/channel.js:197:27)
    at Object.emit (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/channel.js:38:13)
    at Object.dispatch (/Users/makoto/work/tmp/assembly/node_modules/redux-saga/lib/internal/middleware.js:73:21)
gnidan commented 6 years ago

@makoto hm, try null instead of undefined. Or maybe empty strings. Or maybe mess with the indexes, in case there's an off-by-one? I'll sort this out on Monday or sooner if I get the chance.

makoto commented 6 years ago

Ok, I will wait until you sort it out...

gnidan commented 6 years ago

@makoto sorry to keep you waiting, I will try to get to this this week.

mbican commented 6 years ago

I was getting this error when one of the *.sol files has been compiled twice because it has been accessible from two different paths because I have had a symlink in my contracts/ directory