{"action":"created","issue":{"url":"https://api.github.com/repos/trufflesuite/ganache-cli/issues/600","repository_url":"https://api.github.com/repos/trufflesuite/ganache-cli","labels_url":"https://api.github.com/repos/trufflesuite/ganache-cli/issues/600/labels{/name}","comments_url":"https://api.github.com/repos/trufflesuite/ganache-cli/issues/600/comments","events_url":"https://api.github.com/repos/trufflesuite/ganache-cli/issues/600/events","html_url":"https://github.com/trufflesuite/ganache-cli/issues/600","id":384408417,"node_id":"MDU6SXNzdWUzODQ0MDg0MTc=","number":600,"title":"TypeError: Cannot read property 'pop' of undefined when restarting from existing `--db`","user":{"login":"tsuberim","id":33967618,"node_id":"MDQ6VXNlcjMzOTY3NjE4","avatar_url":"https://avatars2.githubusercontent.com/u/33967618?v=4","gravatar_id":"","url":"https://api.github.com/users/tsuberim","html_url":"https://github.com/tsuberim","followers_url":"https://api.github.com/users/tsuberim/followers","following_url":"https://api.github.com/users/tsuberim/following{/other_user}","gists_url":"https://api.github.com/users/tsuberim/gists{/gist_id}","starred_url":"https://api.github.com/users/tsuberim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsuberim/subscriptions","organizations_url":"https://api.github.com/users/tsuberim/orgs","repos_url":"https://api.github.com/users/tsuberim/repos","events_url":"https://api.github.com/users/tsuberim/events{/privacy}","received_events_url":"https://api.github.com/users/tsuberim/received_events","type":"User","site_admin":false},"labels":[{"id":308742739,"node_id":"MDU6TGFiZWwzMDg3NDI3Mzk=","url":"https://api.github.com/repos/trufflesuite/ganache-cli/labels/bug","name":"bug","color":"fc2929","default":true},{"id":1023238532,"node_id":"MDU6TGFiZWwxMDIzMjM4NTMy","url":"https://api.github.com/repos/trufflesuite/ganache-cli/labels/priority-high","name":"priority-high","color":"ff0000","default":false}],"state":"open","locked":false,"assignee":{"login":"benjamincburns","id":803016,"node_id":"MDQ6VXNlcjgwMzAxNg==","avatar_url":"https://avatars1.githubusercontent.com/u/803016?v=4","gravatar_id":"","url":"https://api.github.com/users/benjamincburns","html_url":"https://github.com/benjamincburns","followers_url":"https://api.github.com/users/benjamincburns/followers","following_url":"https://api.github.com/users/benjamincburns/following{/other_user}","gists_url":"https://api.github.com/users/benjamincburns/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamincburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamincburns/subscriptions","organizations_url":"https://api.github.com/users/benjamincburns/orgs","repos_url":"https://api.github.com/users/benjamincburns/repos","events_url":"https://api.github.com/users/benjamincburns/events{/privacy}","received_events_url":"https://api.github.com/users/benjamincburns/received_events","type":"User","site_admin":false},"assignees":[{"login":"benjamincburns","id":803016,"node_id":"MDQ6VXNlcjgwMzAxNg==","avatar_url":"https://avatars1.githubusercontent.com/u/803016?v=4","gravatar_id":"","url":"https://api.github.com/users/benjamincburns","html_url":"https://github.com/benjamincburns","followers_url":"https://api.github.com/users/benjamincburns/followers","following_url":"https://api.github.com/users/benjamincburns/following{/other_user}","gists_url":"https://api.github.com/users/benjamincburns/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamincburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamincburns/subscriptions","organizations_url":"https://api.github.com/users/benjamincburns/orgs","repos_url":"https://api.github.com/users/benjamincburns/repos","events_url":"https://api.github.com/users/benjamincburns/events{/privacy}","received_events_url":"https://api.github.com/users/benjamincburns/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2018-11-26T16:25:51Z","updated_at":"2018-12-06T00:57:41Z","closed_at":null,"author_association":"NONE","body":"<!--- \r\n\r\nTO INSURE THE FASTEST RESPONSE POSSIBLE, PLEASE READ THESE INSTRUCTIONS\r\nCAREFULLY.\r\n\r\n-->\r\n\r\n<!--- Please provide a short summary of the issue in the Title above -->\r\n\r\n<!--- When you see empty square brackets below, that's a checkbox. Replace with\r\n[x] to check the box -->\r\n\r\n\r\n<!---\r\n\r\nYou can get a link to your gitter question by rt-clicking the timestamp of your\r\npost and hitting \"Copy Link\", or by clicking the timestamp and copying the URL\r\nfrom your browser's address bar.\r\n\r\nTruffle gitter: https://gitter.im/ConsenSys/truffle\r\n\r\n-->\r\n\r\n\r\n## Expected Behavior\r\n\r\n<!---\r\n\r\nIf you're describing a bug, tell us what should happen.\r\n\r\nIf you're suggesting a change/improvement, tell us how it should work.\r\n\r\n-->\r\n\r\nGanache should behave exactly the same after restarting from an existing `db` as if it were not restarted at all.\r\n\r\n## Current Behavior\r\n\r\n<!---\r\n\r\nIf describing a bug, tell us what happens instead of the expected behavior.\r\n\r\nIf suggesting a change/improvement, explain the difference from current\r\nbehavior.\r\n\r\n-->\r\n\r\n`ganache-cli` does not behave the same when starting from an existing `db` directory. It wrongly rejects a transaction with correct `nonce` and crashes when given the `nonce` it (wrongly) expects.\r\n\r\n## Steps to Reproduce (for bugs)\r\n\r\n1. `git clone https://github.com/tsuberim/ganache-bug.git`\r\n2. `npm install`\r\n3. `npm run ganache` - start ganache command in one terminal tab for the first time (creating db directory `./asdf`)\r\n4. `node crash.js` - run a simple script in another tab sending 1 ether to an account.\r\n5. Stop ganache.\r\n6. `npm run ganache` - start ganache again (now using existing db).\r\n7. `node crash.js` - run simple script again.\r\n8. The script fails with:\r\n   ```\r\n   Error: Returned error: the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 1\r\n   at Object.ErrorResponse (/home/tsuberim/projects/ganache-test/node_modules/web3-core-helpers/src/errors.js:29:16)\r\n   at /home/tsuberim/projects/ganache-test/node_modules/web3-core-requestmanager/src/index.js:140:36\r\n   at XMLHttpRequest.request.onreadystatechange (/home/tsuberim/projects/ganache-test/node_modules/web3-providers-http/src/index.js:91:13)\r\n   at XMLHttpRequestEventTarget.dispatchEvent (/home/tsuberim/projects/ganache-test/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)\r\n   at XMLHttpRequest._setReadyState (/home/tsuberim/projects/ganache-test/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)\r\n   at XMLHttpRequest._onHttpResponseEnd (/home/tsuberim/projects/ganache-test/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)\r\n   at IncomingMessage.<anonymous> (/home/tsuberim/projects/ganache-test/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)\r\n   at IncomingMessage.emit (events.js:187:15)\r\n   at endReadableNT (_stream_readable.js:1094:12)\r\n   at process._tickCallback (internal/process/next_tick.js:63:19)\r\n   ```\r\n9. If using `nonce: 0`, ganache fails with:\r\n   ```\r\n   TypeError: Cannot read property 'pop' of undefined\r\n   at CheckpointTrie.Trie._updateNode (/home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:360:24)\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:107:16\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:461:14\r\n   at processNode (/home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:471:23)\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:457:5\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:180:7\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/util.js:75:7\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:52:16\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:269:32\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:44:16\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/util.js:71:7\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:157:9\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/lib/database/levelupobjectadapter.js:41:16\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/level-sublevel/shell.js:101:15\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/level-sublevel/nut.js:121:19\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/encoding-down/index.js:51:21\r\n   at /home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/node_modules/cachedown/index.js:58:21\r\n   at ReadFileContext.callback (/home/tsuberim/projects/ganache-test/node_modules/ganache-cli/node_modules/ganache-core/lib/database/filedown.js:26:14)\r\n   at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:235:13)\r\n   ```\r\n\r\n**Note: The script succeeds when not restarting ganache midway.**\r\n\r\n<!--\r\nHow has this issue affected you? What are you trying to accomplish? Is this\r\nissue likely to block you or others from getting your work done?\r\n\r\nThis is the best place to try to convince us that this issue needs to be solved\r\nASAP (if necessary), and to help us to understand what our code must stand up to\r\nin the real world.\r\n\r\n-->\r\n\r\n## Your Environment\r\n* Version used: `Ganache CLI v6.2.3 (ganache-core: 2.3.1)`\r\n* Version of Truffle/Remix/Other tools used: `web3@1.0.0-beta.36`\r\n* NodeJS Version: `v10.13.0`\r\n* Operating System and version (include distro if Linux): \r\n```\r\nDistributor ID: Ubuntu\r\nDescription:    Ubuntu 18.04.1 LTS\r\nRelease:        18.04\r\nCodename:       bionic\r\n```\r\n* Link to your project or repro gist: https://github.com/tsuberim/ganache-bug\r\n* Commit hash to use with above link for reproduction: `606cccd494479e88f25cfbb22cd683d842e61b27`\r\n* I intend to submit a pull request to fix this issue: [ ] \r\n\r\n<!--- When you're finished with the above, please delete these comments to avoid\r\nwhitespace formatting issues -->\r\n"},"comment":{"url":"https://api.github.com/repos/trufflesuite/ganache-cli/issues/comments/444708589","html_url":"https://github.com/trufflesuite/ganache-cli/issues/600#issuecomment-444708589","issue_url":"https://api.github.com/repos/trufflesuite/ganache-cli/issues/600","id":444708589,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDcwODU4OQ==","user":{"login":"benjamincburns","id":803016,"node_id":"MDQ6VXNlcjgwMzAxNg==","avatar_url":"https://avatars1.githubusercontent.com/u/803016?v=4","gravatar_id":"","url":"https://api.github.com/users/benjamincburns","html_url":"https://github.com/benjamincburns","followers_url":"https://api.github.com/users/benjamincburns/followers","following_url":"https://api.github.com/users/benjamincburns/following{/other_user}","gists_url":"https://api.github.com/users/benjamincburns/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamincburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamincburns/subscriptions","organizations_url":"https://api.github.com/users/benjamincburns/orgs","repos_url":"https://api.github.com/users/benjamincburns/repos","events_url":"https://api.github.com/users/benjamincburns/events{/privacy}","received_events_url":"https://api.github.com/users/benjamincburns/received_events","type":"User","site_admin":false},"created_at":"2018-12-06T00:57:41Z","updated_at":"2018-12-06T00:57:41Z","author_association":"COLLABORATOR","body":"Leaving this issue open until we have a fix, but we've reverted the change which causes this problem."}}
{"actor":{"display_login":"benjamincburns"}}