skalenetwork/skaled

Skaled returns the error if "gas" or "gasPrice" optional fields are presented in eth_call

Closed this issue · 1 comments

https://ethereum.org/developers/docs/apis/json-rpc#eth_call
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth

Version

schain:3.14.15-sync.15-historic
schain:3.18.0

Preconditions
Active schain medium type.
Address with Sfuel and whitelist deployer role
Contract to test

pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    address private owner;
    uint256 private initialBalance;

    event InitialBalance(uint256 balance);
    event AfterInteractionBalance(uint256 balance);
    event BalanceDifference(int256 difference);
    constructor(uint256 _initialSupply) ERC20("MyToken", "MTK") {
        owner = msg.sender;
        _mint(owner, _initialSupply);
        initialBalance = _initialSupply;
        emit InitialBalance(_initialSupply);
    }
    function interact(uint256 _amount) external {
        uint256 balanceBefore = balanceOf(owner);
        transfer(address(0xdeadbeef), _amount);
        uint256 balanceAfter = balanceOf(owner);
        emit AfterInteractionBalance(balanceAfter);
        emit BalanceDifference(int256(balanceAfter) - int256(balanceBefore));
    }
}

To Reproduce

  1. Deploy the contract on the chain and save CONTRACT_ADDRESS (example: 0x4d9a359786d1d314a0f7363263bf0ed1589152d1)
    data field
0x70a08231 << balanceOf
000000000000000000000000
71cbe3fede33905d4d1bf2bd51f9d4a62375e659 <<< deployer's address to check ERC20 balance 
  1. send eth_call to the "interact" function with "gas" or "gasPrice" fields via geth attach

example

eth.call({"data":"0x70a0823100000000000000000000000071cbe3fede33905d4d1bf2bd51f9d4a62375e659", "to":"0x4d9a359786d1d314a0f7363263bf0ed1589152d1","gasPrice":100000,"gas":100000},"latest")
  1. send eth_call to the "interact" function with the "gasPrice" and "gas" fields via JSON-RPC
 http://localhost:10007 -X POST   -H "Content-Type: application/json"   --data '{"method":"eth_call","params":[{"to":"0x4D9a359786d1d314A0f7363263BF0ED1589152D1","data":"0x70a0823100000000000000000000000071cbe3fede33905d4d1bf2bd51f9d4a62375e659","from":"0x71cbe3fede33905d4d1bf2bd51f9d4a62375e659","gasPrice":100000,"gas":100000}, "latest"],"id":1,"jsonrpc":"2.0"}'

Expected behavior
Eth_call should return the balance of the account in both cases
Example:
0x0000000000000000000000000000000000000000000000000000000005f5e0fe

Actual state:
Skaled returns the "Invalid method parameters" error in both cases

Logs:
Response on 2nd step

Error: INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised
   at web3.js:6367:9(39)
   at send (web3.js:5101:62(29))
   at <eval>:1:9(10)

Response on 3rd step

{"error":{"code":-32602,"message":"INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"},"id":1,"jsonrpc":"2.0"}

Hey @oleksandrSydorenkoJ ! You should pass gas and gasPrice fields as strings, not as raw ints. Here is a fixed example of your request:

 http://localhost:10007 -X POST   -H "Content-Type: application/json"   --data '{"method":"eth_call","params":[{"to":"0x4D9a359786d1d314A0f7363263BF0ED1589152D1","data":"0x70a0823100000000000000000000000071cbe3fede33905d4d1bf2bd51f9d4a62375e659","from":"0x71cbe3fede33905d4d1bf2bd51f9d4a62375e659","gasPrice":"100000","gas":"100000"}, "latest"],"id":1,"jsonrpc":"2.0"}'