Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Problem: etherjs smartcontract cannot change state (fix #257) #264

Closed
wants to merge 1 commit into from

Conversation

leejw51crypto
Copy link
Contributor

Solution: increase base gas to make similar with ethereum

Solution: increase base gas to make similar with ethereum
@thomas-nguy
Copy link
Contributor

I have tried current main and its consistent with infura (no contract call)

I think its better to fix the calculation rather than add a fixed value.

➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0x52d4"}
➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"}],"id":1}'  -H "Content-Type: application/json" https://ropsten.infura.io/v3/<project_id>
{"jsonrpc":"2.0","id":1,"result":"0x52d4"}%


➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "value":"0x16345785d8a00000"}],"id":1}'  -H "Content-Type: application/json" https://ropsten.infura.io/v3/<projectId>
{"jsonrpc":"2.0","id":1,"result":"0x5208"}%
➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "value":"0x16345785d8a00000"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0x5208"}

@leejw51crypto
Copy link
Contributor Author

ok , i'll find a way to compute

@thomas-nguy
Copy link
Contributor

check this method
https://github.com/tharsis/ethermint/blob/main/x/evm/keeper/state_transition.go#L262

(it refund max half consumed, maybe the logic is different with geth)

@yijiasu
Copy link

yijiasu commented Jul 12, 2021

I have tried current main and its consistent with infura (no contract call)

I think its better to fix the calculation rather than add a fixed value.

➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0x52d4"}
➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"}],"id":1}'  -H "Content-Type: application/json" https://ropsten.infura.io/v3/<project_id>
{"jsonrpc":"2.0","id":1,"result":"0x52d4"}%

➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "value":"0x16345785d8a00000"}],"id":1}'  -H "Content-Type: application/json" https://ropsten.infura.io/v3/<projectId>
{"jsonrpc":"2.0","id":1,"result":"0x5208"}%
➜  ethermint git:(thomas/gas_estimate) ✗ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "to":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E", "value":"0x16345785d8a00000"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0x5208"}

If the calculation is equal to the value from infura, then there's no issue at all. It's expected to have the same gas value from any existing Etherum network

what's going wrong here?

Is 0x52d4 (dec. 21204) enough for executing the call? What's the value in its compiled ABI?

@leejw51crypto
Copy link
Contributor Author

leejw51crypto commented Jul 13, 2021

21204 is not enough, it should be equal or above than 41646,
i tried 41645, not working

Ganache: 0xa2ae = 41646
Tharsis: 0x52d4 = 21204

@yihuang
Copy link
Contributor

yihuang commented Jul 13, 2021

21204 is not enough, it should be equal or above than 41646,
i tried 41645, not working

Ganache: 0xa2ae = 41646
Tharsis: 0x52d4 = 21204

Probably this issue: #268

@thomas-nguy
Copy link
Contributor

thomas-nguy commented Jul 13, 2021

Is 0x52d4 (dec. 21204) enough for executing the call? What's the value in its compiled ABI?

I used the example from the rpc doc. I think its just a memo.

@leejw51crypto what is your code to return 0xa2ae = 41646 ?

BTW the gas is a dynamic value, it depends on what you are calling, so you cannot assume we can use the same value for all

@leejw51crypto
Copy link
Contributor Author

leejw51crypto commented Jul 13, 2021

return hexutil.Uint64(data.GasUsed + 40000), nil

i added 40000

@leejw51crypto
Copy link
Contributor Author

leejw51crypto commented Jul 13, 2021

i'll rebase after
#268 is resolved

if EstimateGas returns correct estimation,
then this pr can be closed

@leejw51crypto
Copy link
Contributor Author

closed by
#272

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants