Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of gas when trying to deploy erc20 contract #8

Open
ledanghuy1811 opened this issue Sep 19, 2024 · 1 comment
Open

Out of gas when trying to deploy erc20 contract #8

ledanghuy1811 opened this issue Sep 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ledanghuy1811
Copy link

When we run script test to try deploy erc20 contract:

#!/bin/bash

# This script should be called when there's already a running local network

set -ux

# hard-coded test private key. DO NOT USE!!
PRIVATE_KEY_ETH=${PRIVATE_KEY_ETH:-"021646C7F742C743E60CC460C56242738A3951667E71C803929CB84B6FA4B0D6"}
# run erc20 tests
current_dir=$PWD

# clone repo
rm -rf ../erc20-deploy/ && git clone https://github.com/oraichain/evm-bridge-proxy.git ../erc20-deploy && cd ../erc20-deploy

# prepare env and chain
yarn && yarn compile;
echo "PRIVATE_KEY=$PRIVATE_KEY_ETH" > .env

# run the test
output=$(yarn erc20-deploy)
# collect only the contract address part
contract_addr=$(echo "$output" | grep -oE '0x[0-9a-fA-F]+')
echo "ERC20 contract addr: $contract_addr"

# validate
contract_addr_len=${#contract_addr}
if [ $contract_addr_len -ne 42 ] ; then
   echo "ERC20 Test Failed"; 
   # clean up
   rm -rf ../../erc20-deploy/ && exit 1
fi

echo "ERC20 Test Passed"; rm -rf ../erc20-deploy/ && cd $current_dir

We got error:
Screenshot 2024-09-19 at 11 31 40

@ledanghuy1811
Copy link
Author

After debuging, we found that in module ethermint, we compare if gasWanted larger than blockGasLimit but in our app, we don't set BlockGasMeter and by default BlockGasMeter is nil lead to blockGasLimit is 0.
Screenshot 2024-09-19 at 11 34 43

And in the old version, its seem like we don't check gasWanted with blockGasLimit nor set BlockGasMeter in our app, we just check if blockGasLimit is larger than 0.
Screenshot 2024-09-19 at 11 39 41

So we implement this logic in new version that if blockGasLimit is larger than 0 (meaning BlockGasMeter is set in app) then we will compare it with gasWanted, otherwise the logic continue as normal.
Screenshot 2024-09-19 at 11 44 22

Fixed in #2

@ducphamle2 ducphamle2 added this to the Upgrade Oraichain to 0.50 milestone Oct 30, 2024
@ducphamle2 ducphamle2 added the bug Something isn't working label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants