provable-things / ethereum-examples

Code examples showing how to use the Provable API on Ethereum
https://docs.provable.xyz/#ethereum
450 stars 163 forks source link

No callback on Ropsten for query random source #28

Closed HSY229 closed 5 years ago

HSY229 commented 5 years ago

Description

I write the contract and deploy it to Ropsten. My contract is base on random example.

I invoke my update() function 17 times to query the random source, but my callback function only invoke 15 times.

Has this happened in the MainNet?

Expected

It should invoke the callback of my contract for all query.

Actual

It does not invoke the callback of my contract for some query.

Detail

Crime scene

Contract address is 0x57d03068d25bb1d313b23cdf219fd68d9dd88f0f TxHash is 0x1a64a68a40c57236db6728a974a9d81a21cf794484d3f52170009127e8c427d9 Query Id is 88d3d9873808e15514c6ac23e551bd407bf3a7b26282f96ce701afaf0d5e676e

Enviroment

Code

Contract code on EtehrScan

pragma solidity 0.4.24;

import "../installed_contracts/oraclize-api/contracts/usingOraclize.sol";

contract RandomExample is usingOraclize {

    event Callback(bytes32 queryId, string result, uint256 number);
    event Update(bytes32 queryId);

    // _oracal is '0x0' on Ropsten and MainNet
    constructor(address _oracal) public payable {
        OAR = OraclizeAddrResolverI(_oracal);
        oraclize_setProof(proofType_Ledger);
        oraclize_setCustomGasPrice(0.02 szabo);
    }

    function __callback(bytes32 _queryId, string _result, bytes _proof) public { 
        require(msg.sender == oraclize_cbAddress(), "only oracal can generate random number");
        require(oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) == 0, "the proof verification has failed");

        uint256 maxRange = 2 ** (8 * 7);
        uint256 randomNumber = uint256(keccak256(abi.encodePacked(_result))) % maxRange;

        emit Callback(_queryId, _result, randomNumber);
    }

    function update() external {
        uint N = 1;
        uint delay = 0;
        uint callbackGas = 200000;
        bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);
        emit Update(queryId);
    }

    function withdraw(uint256 _ammount) external {
        msg.sender.transfer(_ammount);
    }

    function() external payable {}
}

Reference

issue 9

D-Nice commented 5 years ago

Thanks for the detailed report!

Currently on Rinkeby we are running an experimental bridge, these queries could very well be missed because of that and we'll be diagnosing, but even in previous versions we have seen this, which could be arising from the ethereum node itself that's being used, not reporting all events.

Our testnet service is not setup to be super reliable, while on mainnet we do guarantee every query, and have additional services in place to watch out for cases of missed queries. Regarding testnet reliability, currently our most reliable testnet is on Kovan, which runs services similar to mainnet, and you should have more success there. If you provide feedback on that it'll be appreciated, and help us in keeping at least one testnet that is more stable. Again, we use the other public testnets ourselves to test the development versions of some of our tools.

HSY229 commented 5 years ago

@D-Nice Thanks for your response. And I am happy to get your guarantee.

I have no enough ether on Kovan, so I only query 21 times. And I got callback for evey query.

Contract on Kovan Contract address is 0x57d03068d25bb1d313b23cdf219fd68d9dd88f0f

D-Nice commented 5 years ago

@HSY229 If you need some more ETH to test Oraclize with on Kovan, you can let us know here or on gitter, and we can provision you a sufficient amount. We are also in progress of migrating our Rinkeby service to some better servers, which should hopefully increase it's reliability.