provable-things / ethereum-api

Provable API for Ethereum smart contracts
https://docs.provable.xyz/#ethereum
MIT License
801 stars 427 forks source link

Mismatching queryId and myid in Remix JavascriptVM. #65

Closed rrubo closed 5 years ago

rrubo commented 5 years ago

Wasn't sure where to open this issue, but I'm having troubles in mapping values from the query and then getting them in the __callback(). I.e. senderAddress[queryId] is different than senderAddress[myid] (the latter is 0x0 instead of showing the query msg.sender address).

In the testnets, everything is working fine. I wish you guys could fix this in the Remix JavascriptVM as well.

D-Nice commented 5 years ago

@rrubo Thanks for reporting, we have a few iterations of the remix IDE, could you include the link of the IDE you are using? The newest and our recommended one currently is the official remix.ethereum.org IDE and then launching the Oraclize plugin from the settings tab, in case you are using something else, it'd be appreciated if you can try with that one and let us know if the issue persists.

rrubo commented 5 years ago

It is the official remix IDE, and I am using the Oraclize Plugin as well.

D-Nice commented 5 years ago

Thanks, we'll investigate, I'm assuming at this point the plugin is likely passing an internal id instead of the EVM-side generated one.

Fi3 commented 5 years ago

@rrubo could you please test again against remix-ide and in case provide the code of the contract that is not working? Ty

rrubo commented 5 years ago

@Fi3 I tested, still there's a mismatch. Below's the code:

 import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

  contract ContractTest is usingOraclize {
    using strings for *;

    bytes32 public query;

    function makeQuery()
        public
        payable {

            string memory queryStringOne = "[URL] ['json(https://api.random.org/json-rpc/1/invoke).result.random[\"serialNumber\",\"data\"]', '\\n{\"jsonrpc\":\"2.0\",\"method\":\"generateSignedIntegers\",\"params\":{\"apiKey\":\"a59c50a4-1424-4a38-b066-fa8447ee3658\",\"n\":2,\"min\":1,\"max\":4,\"replacement\":false,\"base\":10${[identity] \"}\"},\"id\":";
            string memory queryStringTwo = uint2str(77);
            string memory queryStringThree = "${[identity] \"}\"}']";

            string memory queryStringOne_Two = queryStringOne.toSlice().concat(queryStringTwo.toSlice());
            string memory queryStringOne_Two_Three = queryStringOne_Two.toSlice().concat(queryStringThree.toSlice());

            bytes32 queryId = oraclize_query("nested", queryStringOne_Two_Three, 235000);

            query = queryId;

        }   

    bytes32 public myId;
    string public res;

    function __callback(
        bytes32 myid, 
        string result,
        bytes proof)
        public {

            res = result;
            myId = myid;
        }
     }
gskapka commented 5 years ago

Compiling & simpler version which exhibits the same behaviour:

import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

 contract ContractTest is usingOraclize {

   bytes32 public queryIDBefore;
   bytes32 public queryIDAfter;

   constructor() public {
       makeQuery();
   }

   function makeQuery() public payable {
        bytes32 qID = oraclize_query("URL", "xml(https://www.fueleconomy.gov/ws/rest/fuelprices).fuelPrices.diesel");
        queryIDBefore = qID;
   }   

   function __callback(bytes32 myid, string result, bytes proof) public {
        queryIDAfter = myid;
    }
 }
Fi3 commented 5 years ago

Fixed in https://github.com/oraclize/remix-oraclize-plugin/commit/8c0b043eae9053fd094393ad9e18568dd698347f