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

internal/ethapi: EstimateGas and Call handle revert error(#173) #200

Merged
merged 1 commit into from
Oct 27, 2022

Conversation

gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Oct 18, 2022

in current version XDPoSChain, it always return message:

gas required exceeds allowance or always failing transaction

if solidity contract function reverts when metamask or other client calls method eth.estimateGas. So the user and wallet software can not judge if revert will occur, and can not get the revert message when revert. This is the main problem which complained by xcantera in #173. This PR parse and return the revert message/reason for both of eth.call and eth.estimateGas. I have tested this PR in my private network, not in Apothem testnet, since I can not synchronize with Apothem testnet according to current document.

Below is my test contract:

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

contract Test {
    uint256 private val;

    constructor() public {
        val = 1;
    }

    function getVal() public view returns (uint256) {
        return val;
    }

    function testRevert(bool willRevert) public view returns (uint256) {
        if (willRevert) {
            revert("I reverted");
        }

        return block.number;
    }

    function setVal(uint256 newValue) external {
        require(newValue < 10, "newValue >= 10");

        val = newValue;
    }
}

1666089131790

1666090703480

1666089185626

@wjrjerome
Copy link
Collaborator

wjrjerome commented Oct 23, 2022

Hi, is this an urgent fix ? If not, prefer merge against "dev-upgrade" branch. Otherwise we shall be ok with this merge into master as we can cherrypick into development branch

@gzliudan
Copy link
Collaborator Author

gzliudan commented Oct 23, 2022

This is the fix for #173

Hi, is this an urgent fix ? If not, prefer merge against "dev-upgrade" branch. Otherwise we shall be ok with this merge into master as we can cherrypick into development branch

@xcantera
Copy link

Will be amazing if we have this fix asap :) Thank you for the work

internal/ethapi/api.go Show resolved Hide resolved
internal/ethapi/api.go Show resolved Hide resolved
@wgr523
Copy link
Collaborator

wgr523 commented Oct 27, 2022

LGTM.
Pending dev-net test for this PR.

@wgr523 wgr523 merged commit 42379f5 into XinFinOrg:master Oct 27, 2022
@AnilChinchawale
Copy link
Member

PR would get live on the apothem network first...!!!

@gzliudan gzliudan deleted the issue-173 branch October 10, 2023 07:18
@JukLee0ira JukLee0ira mentioned this pull request Sep 10, 2024
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants