ava-labs / teleporter

EVM cross-chain messaging protocol built on top of Avalanche Warp Messaging
Other
47 stars 22 forks source link

[Bug]: EVM Error when deploying ERC20Bridge contract #360

Open vanderheijden86 opened 5 months ago

vanderheijden86 commented 5 months ago

Describe the bug The contract deployment fails with an execution reverted error. The specific reasons for the revert are not provided in the error message, and no relevant logs are generated by the subnet.

forge create ERC20Bridge --rpc-url http://127.0.0.1:9650/ext/bc/aPabi2btNqgqXx3hT7ckwqpaewrJzpsXwH3MGc8dASPk3wJkR/rpc --private-key=0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027 --constructor-args 0x5aa01B3b5877255cE50cc55e8986a7a5fe29C70e 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC --chain 68430
[⠢] Compiling...
No files changed, compilation skipped
Error:
(code: -32000, message: execution reverted, data: None)

To Reproduce Clone repo on Mac

image

MacOS Sonoma 14.2.1

And then run

teleporter/contracts/src/CrossChainApplications/examples/ERC20Bridge git:(main) forge create ERC20Bridge --rpc-url http://127.0.0.1:9650/ext/bc/aPabi2btNqgqXx3hT7ckwqpaewrJzpsXwH3MGc8dASPk3wJkR/rpc --private-key=0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027 --constructor-args 0x5aa01B3b5877255cE50cc55e8986a7a5fe29C70e 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC

Expected behavior The contract would be deployed without issues as I am using the default contract with default parameters. I have verified that the avalanche network runs without issues. I can deploy contracts to the subnetA using hardhat.

Screenshots If applicable, add screenshots to help explain your problem.

Logs SubnetA doesn't put out any logs related to this issue.

Operating System MacOS Sonoma 14.2.1

Additional context Add any other context about the problem here.

To best protect the Avalanche community security bugs should be reported in accordance to our Security Policy

cam-schultz commented 5 months ago

Hi @vanderheijden86, can you please confirm that the Warp precompile is correctly enabled on your Subnet? You can check this by calling getActivePrecompilesAt via RPC.

Your node's version information would also be helpful.

vanderheijden86 commented 5 months ago

Yup that is enabled. I've run the same command inside the local-network-run docker container (exec-ing into it) and then I can run forge create without issues. So it's maybe something with the foundry / forge version or so. Or something else on my Mac OS environment. I tried to install foundry using the shell script included in the repo, but this didn't work on Mac. So I ended up installing it like curl -L https://foundry.paradigm.xyz | bash.

So this is the logs of me running it inside docker.

root@docker-desktop:/code/contracts/src/CrossChainApplications/examples/ERC20Bridge# forge create ERC20Bridge --rpc-url http://127.0.0.1:9650/ext/bc/h5rtJmsfqxvz5rKa2uc2Fmq47oqo6VH5FVzVuHEKhEPyWYcZs/rpc --private-key=0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027 --constructor-args 0x5aa01B3b5877255cE50cc55e8986a7a5fe29C70e 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
[⠑] Compiling...
No files changed, compilation skipped
Deployer: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
Deployed to: 0xe336d36FacA76840407e6836d26119E1EcE0A2b4
Transaction hash: 0xd7731b18975599fa3471781cde08c1e3a60989badb5fccb9f781afcab0e84dde
cam-schultz commented 5 months ago

As one more sanity check, can you try calling getBlockchainID on the contract at address 0x0200000000000000000000000000000000000005? Using cast, the call should look like: blockchainID=$(cast call 0x0200000000000000000000000000000000000005 "getBlockchainID()(bytes32)" --rpc-url $rpc_url)

If that returns cleanly, then it sounds like a difference between the Docker environment and your Mac environment. AFAICT there's no bug in any of the code shipped in this repo, as the supported Docker development environment is working as expected.

The two primary suspects are: 1) A difference in the network running in the container versus on your Mac. Is your node connected to a local network? If so, it would be worth opening an issue in https://github.com/ava-labs/avalanche-cli to find the root cause. If not,

2) A difference between the forge fork used in the Docker container and the source repo you're trying to use to deploy on your Mac.

vanderheijden86 commented 5 months ago

Thanks for the suggestions @cam-schultz. I've checked the blockchainId call:

root@docker-desktop:/code# blockchainID=$(cast call 0x0200000000000000000000000000000000000005 "getBlockchainID()(bytes32)" --rpc-url http://127.0.0.1:9650/ext/bc/2JR1L4JdiwdzjyDmFDBWpSL9tHHF1CNrDMPNb6GtEpkiKbT6cp/rpc)
root@docker-desktop:/code# echo $blockchainID
0xab3c88f1f0333cf8c871285592b38c5041beb1c16ab49ee58af0a83cb5dee770

I'll leave this for now as I can run the commands, contract deployments and go e2e tests within the docker container just fine. I'd like to have run a golang test from my mac so I could set breakpoints etcetera. But also given that host mode for docker on Mac is experimental, it's too cumbersome for now to proceed. When I run the network in host mode with latest docker version and the host ports feature enabled, I still can't access the rpc. As from my host I'll get:

nc -v localhost 9650
nc: connectx to localhost port 9650 (tcp) failed: Connection refused
image

When I look inside the container (local_network_run) I see that it's listening on the 9650 port. So from what I understand I should be able to connect to it from my Mac.

root@docker-desktop:/code# lsof | grep 9650
avalanche  921                root    7u     IPv6  49772       0t0      TCP *:9650 (LISTEN)
avalanche  921                root   22u     IPv6  76199       0t0      TCP localhost:9650->localhost:65440 (ESTABLISHED)
avalanche  921                root   63u     IPv6  74203       0t0      TCP localhost:9650->localhost:61130 (ESTABLISHED)
avalanche  921                root   64u     IPv6  58725       0t0      TCP localhost:9650->localhost:61316 (ESTABLISHED)
avalanche  921                root   67u     IPv6  58726       0t0      TCP localhost:9650->localhost:61330 (ESTABLISHED)
avalanche  921  922 avalanche root    7u     IPv6  49772       0t0      TCP *:9650 (LISTEN)

Completely understand that this is not part of the scope of this repo, and as such is not a bug as far as this repo is concerned. Feel free to close it. If you have some ideas about my Mac host mode issue and why the ports aren't accessible from host I would be happy to hear though :-).