Deploying ganache-local w/brownie: VM Exception while processing transaction: invalid opcode #422
-
Thanks for an amazing class Patrick. I taught myself to code 3 years ago and wish I did it 33 years ago! :) IssueI am going through brownie simple storage part of this course. The initial deploy,.py works properly, but I keeping getting some variation of invalid opcode and the transaction is reverting when I try to deploy to ganache-local. I am able to run the tests in this project to development/ganache-cli, but fail with ganache-local and Rinkeby. I am experiencing the same issues as I am with my own code base. I decided to test with a clone of this repo as 'bss' and replacing .env files with my info and am experiencing the same issues. I'm on MacOS. Steps to reproduce & Troubleshooting
EnvironmentBrownie The only part of the code that has been changed from the repo is adding the gas_limit. Still happy to share the code if request. For the life of me, I can't figure what invalid opcode is causing this to revert . . . Any help would be greatly appreciated! Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 35 replies
-
Hello @GratefulDave first of all thanks for the detailed description of your error, it seems the application is reverting because you are not using Mocks to get the price feed, so if you are requesting the price feed directly to chainlink. your deploy script should deploy mocks also for ganache-local as you can see: def deploy_fund_me():
account = get_account()
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
price_feed_address = config["networks"][network.show_active()][
"eth_usd_price_feed"
]
else:
deploy_mocks()
price_feed_address = MockV3Aggregator[-1].address
fund_me = FundMe.deploy(
price_feed_address,
{"from": account},
publish_source=config["networks"][network.show_active()].get("verify"),
)
print(f"Contract deployed to {fund_me.address}")
return fund_me
Regarding to Rinkeby you must have some eth to pay the transaction, so you must use a faucet to get some eth. Also remember Please let us know if this info was helpful to you. Best regards, Cromewar. |
Beta Was this translation helpful? Give feedback.
-
Hi Vasiliy,
I am using a virtualenv. I’ve tried removing and reinstalling brownie and pipx, but have not tried deleting the .brownie or removing the network from brownie and adding it again.
What’s odd is that everything else works. I’ll try these solutions and let you know how it goes.
Thank you!
@GratefulDave
… On Nov 24, 2021, at 9:37 AM, Vasiliy Gualoto ***@***.***> wrote:
Hello @GratefulDave <https://github.com/GratefulDave> I was trying to do research on your problem but I was unable to reproduce the problem meanwhile @PatrickAlphaC <https://github.com/PatrickAlphaC> give a check to this problem I'll suggest you to try one of this things:
Use a python virtualenv for the project.
Maybe something is messing up with your brownie installation, may be reinstalling it would help (also deleting .brownie folder on your home path before installing again).
Just remove ganache-local from brownie and add it again.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#422 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACTWE76K6AON3DLVVLNCNGTUNT2ELANCNFSM5IP6NPDQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
1. I am using a virtualenv.
2. I removed pipx and brownie.
3. I removed the brownie fold from ~/.local/bin directory.
4. I removed and added the ganache-local network which is for me https://127.0.0.1:7545 and chainid=5777
Still experiencing the same behavior. :/
… On Nov 24, 2021, at 9:37 AM, Vasiliy Gualoto ***@***.***> wrote:
Hello @GratefulDave <https://github.com/GratefulDave> I was trying to do research on your problem but I was unable to reproduce the problem meanwhile @PatrickAlphaC <https://github.com/PatrickAlphaC> give a check to this problem I'll suggest you to try one of this things:
Use a python virtualenv for the project.
Maybe something is messing up with your brownie installation, may be reinstalling it would help (also deleting .brownie folder on your home path before installing again).
Just remove ganache-local from brownie and add it again.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#422 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACTWE76K6AON3DLVVLNCNGTUNT2ELANCNFSM5IP6NPDQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
Hmm... any chance you can upload what you have to a github repo so we can reproduce what you have? Thanks for making this issue, and thanks for the flag @cromewar ! |
Beta Was this translation helpful? Give feedback.
-
I uploaded it to a private repo and sent you an invite. I had a private key in the .env with a small balance - which I cleared. There’s also one worthless NFT. Lol.
… On Nov 24, 2021, at 7:28 PM, Patrick Collins ***@***.***> wrote:
Hmm... any chance you can upload what you have to a github repo so we can reproduce what you have?
Thanks for making this issue, and thanks for the flag @cromewar <https://github.com/cromewar> !
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#422 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACTWE77ZDOOGPF5TQ6HYIBDUNV7MTANCNFSM5IP6NPDQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone, Thank you @GratefulDave for tagging your post on mine, I'll follow how things are evolving. I've spent today trying everything that was suggested in this thread and just like you, keep having the same error showing. |
Beta Was this translation helpful? Give feedback.
-
@PatrickAlphaC here's the repo: https://github.com/GratefulDave/brownie-fund-me.git. |
Beta Was this translation helpful? Give feedback.
-
Hello @GratefulDave I just cloned your repo and tried to reproduce the error, but unfortunately I couldn't as everything worked just fine using ganache-local, so I think something is messing up with your configuration, as you can see bellow it worked just fine: So I have some recommendations for you:
I hope this might help. |
Beta Was this translation helpful? Give feedback.
-
Hi! So, being stuck just like @GratefulDave , I've followed the advice from @cromewar by changing my Ganache network ID. Now my error is different, brownie is somehow not taking the entrance fee. I've tried with Dave's codes, as well as with the original files from Patrick on his repo, and the error comes back the exact same every time:
I've modified once again the ganache network to try to get back to the original error, deleted it from Brownie, re-added it, three times, but the abovementioned error remains the same. |
Beta Was this translation helpful? Give feedback.
-
@GratefulDave I was able to reproduce de error adding this On the terminal type:
def fund():
fund_me = FundMe[-1]
account = get_account()
entrance_fee = fund_me.getEntranceFee()
print(entrance_fee)
print(f"The current entry fee is {entrance_fee}")
print("Funding")
tx = fund_me.fund({"from": account, "value": entrance_fee})
tx.wait(1)
def withdraw():
fund_me = FundMe[-1]
account = get_account()
# fund_me.withdraw({"from": account, 'gas_limit': 6721975})
tx = fund_me.withdraw({"from": account, "gas_limit": 6721975, "allow_revert": True})
tx.wait(1) and try again. Best regards, Cromewar. |
Beta Was this translation helpful? Give feedback.
-
Here you have. aiohttp==3.7.4.post0
asttokens==2.0.4
async-timeout==3.0.1
attrs==21.2.0
base58==2.1.0
bitarray==1.2.2
black==21.9b0
certifi==2021.5.30
chardet==4.0.0
charset-normalizer==2.0.6
click==8.0.1
cytoolz==0.11.0
dataclassy==0.10.4
eip712==0.1.0
eth-abi==2.1.1
eth-account==0.5.5
eth-brownie==1.16.4
eth-event==1.2.3
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
execnet==1.9.0
hexbytes==0.2.2
hypothesis==6.21.6
idna==3.2
inflection==0.5.0
iniconfig==1.1.1
ipfshttpclient==0.8.0a2
jsonschema==3.2.0
lazy-object-proxy==1.6.0
lru-dict==1.1.7
multiaddr==0.0.9
multidict==5.1.0
mypy-extensions==0.4.3
mythx-models==1.9.1
netaddr==0.8.0
packaging==21.0
parsimonious==0.8.1
pathspec==0.9.0
platformdirs==2.3.0
pluggy==1.0.0
prompt-toolkit==3.0.20
protobuf==3.18.0
psutil==5.8.0
py==1.10.0
py-solc-ast==1.2.9
py-solc-x==1.1.0
pycryptodome==3.10.1
Pygments==2.10.0
pygments-lexer-solidity==0.7.0
PyJWT==1.7.1
pyparsing==2.4.7
pyrsistent==0.18.0
pytest==6.2.5
pytest-forked==1.3.0
pytest-xdist==1.34.0
python-dateutil==2.8.1
python-dotenv==0.16.0
pythx==1.6.1
PyYAML==5.4.1
regex==2021.8.28
requests==2.26.0
rlp==1.2.0
semantic-version==2.8.5
six==1.16.0
sortedcontainers==2.4.0
toml==0.10.2
tomli==1.2.1
toolz==0.11.1
tqdm==4.62.3
typing-extensions==3.10.0.2
urllib3==1.26.6
varint==1.0.2
vvm==0.1.0
vyper==0.2.16
wcwidth==0.2.5
web3==5.23.1
websockets==9.1
wrapt==1.12.1
yarl==1.6.3 |
Beta Was this translation helpful? Give feedback.
-
Update, I've run the following commands:
and now the entry fee is grabbing the correct number, the contract is called and shows on my Ganache transaction page, but the withdraw function still doesn't work. So, I fixed the problem I had created when changing the chainID on Ganache, back to the original problem where brownie tells me
@GratefulDave I'll update my post on eth-brownie/brownie. Fingers crossed someone will help us out, I really want to keep learning through this tutorial! (making zombies in the meantime!) |
Beta Was this translation helpful? Give feedback.
-
@GratefulDave I found a solution on my part, change the gas limit on Ganache itself, for which you have to create a new workspace. I've described my process on 1358. |
Beta Was this translation helpful? Give feedback.
-
This is the only answer I am getting from Ethereum.stackexcahnge so far . . .
getPrice() isn't returning a number you want from the mock, somewhere in the vicinity of 2B. Think this is a bug with the Ganache implementation- performing the calculation (minimumUSD * precision) / price in getEntranceFee() gives you a number less than 1- and, since Solidity can't handle floats, Solidity simply sees it as a 0, and the whole thing errors out.
… On Dec 5, 2021, at 9:31 AM, Vasiliy Gualoto ***@***.***> wrote:
@GratefulDave <https://github.com/GratefulDave> if your have any updates on this, let us know.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#422 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACTWE754GLLFGCNAJXWJG53UPNZS5ANCNFSM5IP6NPDQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
Hi. I was able to solve the problems mentioned above in my environment. ResolutionBoth the "ValueError: Gas estimation failed: 'execution reverted: VM Exception while processing transaction: invalid opcode'" error and the getEntranceFee() return value problem was resolved in my local environment by changing the "Hard Fork" property in the Ganache UI app from "Petersburg" to "Muir Glacier". In the Ganachi UI app, go to Settings > Chain > HARDFORK. I do not know why the "Petersburg" hardfork does not work. fund_and_withdraw.py also required "gas_limit" being passed to fund_me.withdraw. If I remember right, that was due to changes in new versions of web.py. It is possible you may not need to pass in the gas_limit. The change...
My/our tests...Before I started troubleshooting I did a diff on Patrick's code vs mine. They were the same in all ways that mattered with the exception of the "fund_me.withdraw()" statement above. A friend and I were able to replicate the problem in both of our local environments: Note that my friend and I both cleaned out our "build > contracts" contract files and "build > deployment" deployment files every time we switched hardforks. This meant redeploying the contracts before running fund_and_withdraw.py again. For what it's worth, my environment and my friend's differed only slightly: Hope this helps :) |
Beta Was this translation helpful? Give feedback.
-
I know this has been closed but none of the above solutions have worked for me :/ Really want to continue on with this amazing tutorial but cannot find a solution |
Beta Was this translation helpful? Give feedback.
Hi.
I was able to solve the problems mentioned above in my environment.
Resolution
Both the "ValueError: Gas estimation failed: 'execution reverted: VM Exception while processing transaction: invalid opcode'" error and the getEntranceFee() return value problem was resolved in my local environment by changing the "Hard Fork" property in the Ganache UI app from "Petersburg" to "Muir Glacier". In the Ganachi UI app, go to Settings > Chain > HARDFORK.
I do not know why the "Petersburg" hardfork does not work.
fund_and_withdraw.py also required "gas_limit" being passed to fund_me.withdraw. If I remember right, that was due to changes in new versions of web.py. It is possible you may not need t…