raineorshine/solgraph

Solgraph return blank .dot file on large contract

Bunjin opened this issue · 4 comments

Hey there Raine,

A real issue this time.
I have been able (after some trouble with npm install) to install solgraph.

Also for some reason the link has not been made and I have to start it with
sudo node /usr/local/lib/node_modules/solgraph/dist/solgraph.js mycontract.sol > graph.dot

Anyways, no big deal, I have been able to generate the graph from the example contract and it works fine.

But my real issue is that when I turn to a more complex contract, it returns (silently) a blank .dot file.
Any idea as to why and how to proceed ?

(I'm on gitter solidity we can speak there if you prefer)

Thanks again !!

Thanks for reporting! I'm just as excited as you to be able run this on full contracts (like the DAO). It is failing silently because the parser is just missing certain constructs that are being used in complex, real-world constructs that are not used in my simple test contracts. The next step would be to test this on slightly larger contracts, one-step-at-a-time, to identify which specific Solidity constructs are being missed by the parser.

My idea is to run it on a sampling of contracts from dapp-bin. That should give us a good representation of different Solidity contracts.

If you'd like to help, it would be awesome if you could find a small-ish contract that breaks solgraph and isolate what construct is different that it does not support. Then we can add the necessary unit test and implementation to get it to work.

First of all: good work! :)
But I am having similar problems as @Bunjin with large contracts. I get the following parse error

Parse error
{ [SyntaxError: Expected "!=", "!==", "%", "%=", "&", "&&", "&=", "*", "*=", "+", "++", "+=", ",", "-", "--", "-=", "/", "/*", "//", "/=", ";", "<", "<<", "<<=", "<=", "=", "==", "===", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "^", "^=", "in", "instanceof", "|", "|=", "||", comment, end of line or whitespace but "f" found. Line: 26, Column: 21]
  message: 'Expected "!=", "!==", "%", "%=", "&", "&&", "&=", "*", "*=", "+", "++", "+=", ",", "-", "--", "-=", "/", "/*", "//", "/=", ";", "<", "<<", "<<=", "<=", "=", "==", "===", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "^", "^=", "in", "instanceof", "|", "|=", "||", comment, end of line or whitespace but "f" found. Line: 26, Column: 21',
  expected: 
   [ { type: 'literal', value: '!=', description: '"!="' },
     { type: 'literal', value: '!==', description: '"!=="' },
     { type: 'literal', value: '%', description: '"%"' },
     { type: 'literal', value: '%=', description: '"%="' },
     { type: 'literal', value: '&', description: '"&"' },
     { type: 'literal', value: '&&', description: '"&&"' },
     { type: 'literal', value: '&=', description: '"&="' },
     { type: 'literal', value: '*', description: '"*"' },
     { type: 'literal', value: '*=', description: '"*="' },
     { type: 'literal', value: '+', description: '"+"' },
     { type: 'literal', value: '++', description: '"++"' },
     { type: 'literal', value: '+=', description: '"+="' },
     { type: 'literal', value: ',', description: '","' },
     { type: 'literal', value: '-', description: '"-"' },
     { type: 'literal', value: '--', description: '"--"' },
     { type: 'literal', value: '-=', description: '"-="' },
     { type: 'literal', value: '/', description: '"/"' },
     { type: 'literal', value: '/*', description: '"/*"' },
     { type: 'literal', value: '//', description: '"//"' },
     { type: 'literal', value: '/=', description: '"/="' },
     { type: 'literal', value: ';', description: '";"' },
     { type: 'literal', value: '<', description: '"<"' },
     { type: 'literal', value: '<<', description: '"<<"' },
     { type: 'literal', value: '<<=', description: '"<<="' },
     { type: 'literal', value: '<=', description: '"<="' },
     { type: 'literal', value: '=', description: '"="' },
     { type: 'literal', value: '==', description: '"=="' },
     { type: 'literal', value: '===', description: '"==="' },
     { type: 'literal', value: '>', description: '">"' },
     { type: 'literal', value: '>=', description: '">="' },
     { type: 'literal', value: '>>', description: '">>"' },
     { type: 'literal', value: '>>=', description: '">>="' },
     { type: 'literal', value: '>>>', description: '">>>"' },
     { type: 'literal', value: '>>>=', description: '">>>="' },
     { type: 'literal', value: '?', description: '"?"' },
     { type: 'literal', value: '^', description: '"^"' },
     { type: 'literal', value: '^=', description: '"^="' },
     { type: 'literal', value: 'in', description: '"in"' },
     { type: 'literal',
       value: 'instanceof',
       description: '"instanceof"' },
     { type: 'literal', value: '|', description: '"|"' },
     { type: 'literal', value: '|=', description: '"|="' },
     { type: 'literal', value: '||', description: '"||"' },
     { type: 'other', description: 'comment' },
     { type: 'other', description: 'end of line' },
     { type: 'other', description: 'whitespace' } ],
  found: 'f',
  location: 
   { start: { offset: 611, line: 26, column: 21 },
     end: { offset: 612, line: 26, column: 22 } },
  name: 'SyntaxError' }

Thanks for reporting! Can you paste here line 26 of your contract where the error is occurring (with a few lines above and below for context)?

A lot of the parsing errors got fixed with solidity-parser v0.1.0. If the problem persists, feel free to reopen. If there is a rendering issue, please create a new issue. Thanks!