This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #404 (again).
This fixes the following issues:
Web3 treats block numbers stored as hex as block hashes: https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-4874586eb254ab1351e089bbba5b8aecR113 and https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-cc3132bd8158377c2dc590dd722b5d0aL33
When tracing a transaction we need to make sure the forked trie is block-number aware: https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-8f55aa0c345972c969bb69ce03983e2dR900 https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-4874586eb254ab1351e089bbba5b8aecR91 https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-4874586eb254ab1351e089bbba5b8aecR341
Ensure addresses and keys are encoded properly before sending to the main node, or we may get an error back if the hex representation needs to be padded with a 0. https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-cc3132bd8158377c2dc590dd722b5d0aR61
When tracing a transaction the VM may ask for block by passing in a Buffer of the number instead of a hex string. Handle both: https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-4874586eb254ab1351e089bbba5b8aecR195
Don't even let the vm try to flush the a traced transaction's block's internal
_cache
to the stateTrie. When forking, some of the data that the traced function may request will exist only on the main chain. Because we pretty much lie to the VM by telling it we DO have data in our Trie, when we really don't, it gets lost during the commit phase when it traverses the "borrowed" data's trie (as it may not have a valid root). Because this is a trace, and we don't need to commit the data, duck punching theflush
method (the simplest method I could find) is fine. Remove this and you may see the infamousUncaught TypeError: Cannot read property 'pop' of undefined
error!https://github.com/trufflesuite/ganache-core/compare/fix/forking?expand=1#diff-8f55aa0c345972c969bb69ce03983e2dR956