1

I'm using Geth evm version 1.8.4-stable to run private network and I see different behavior on CALL between the Remix environment of Javascript VM and Web3 Provider.

On this example, using callHi() makes difference. It works fine with JavaScript VM, but Web3 Provider fails. Web3 Provider needs gas specification to avoid this failure.

According to 0.4.21 release, CALL does not automatically send the remaining gas. Therefore we need to specify the gas amount when using CALL otherwise it fails to run after 0.4.21.

I understand gas specification is needed to avoid reentrancy issue, but why JavaScript VM still allows CALL without gas specification? Is it a bug or evm version difference?

pragma solidity ^0.4.21;
contract Hi {
    event SayHi(string);
    function hi() public { emit SayHi("Hi!");}
    function callHi() public {
        // OK with JavaScript VM, 
        // OK with Web3 Provider, compiled with ^0.4.20
        // Not OK with Web3 Provider, compiled with ^0.4.21 and later
        require(address(this).call(bytes4(keccak256("hi()"))));  

        // Web3 Provider needs gas specification to fix Error
        // require(address(this).call.gas(2000)(bytes4(keccak256("hi()"))));
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.