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

The bridge returns a response only one time #79

Open
irimiacosmin opened this issue Jan 27, 2020 · 0 comments
Open

The bridge returns a response only one time #79

irimiacosmin opened this issue Jan 27, 2020 · 0 comments

Comments

@irimiacosmin
Copy link

irimiacosmin commented Jan 27, 2020

Hello,
I want to deploy locally a oracle contract that gives me the current timestamp but it works only one time, after this it does not call the query anymore.
The steps:

  1. ganache-cli -l 800000000 --allowUnlimitedContractSize
  2. ethereum-bridge -H localhost:8545 --broadcast -a 1 --dev --loglevel verbose
  3. I copy the line OAR = OracleAddrResolverI(0xX...X); in the ctor of the TimeMachine contract
  4. truffle migrate --reset

After this, the ganache console prints a infinite number of eth_getFilterChanges and that's a good thing, the call to the exposed public method returns one valid timestamp and the bridge prints this

[2020-01-27T08:41:14.230Z] INFO contract 0xcf903000689f8fd441a2f90ae797a4d4acc14cd0 __callback tx sent, transaction hash: 0x8f5b03fdb3b5c3968ad9f17c7a8aef06d9f18ce6c8ea5fef80fb45507178d668
{
    "myid": "0x5c2db0aca7e507a155675a93f2db0b9d69a1413cc793f80f0c94e6f209bb9cf2",
    "result": "1580114467",
    "proof": null,
    "proof_type": "0x00",
    "contract_address": "0xcf903000689f8fd441a2f90ae797a4d4acc14cd0",
    "gas_limit": 200000,
    "gas_price": null
}

After this, ganache continue to print filter changes but the bridge does not give me another timestamp, it sticks with the current one for the rost of it's life.

For the full context, see the contract bellow:

pragma solidity ^0.5.10;
import "./usingOraclize.sol";

contract TimeMachine is usingProvable {

    uint256 public timestamp;
    event LogConstructorInitiated(string nextStep);
    event LogPriceUpdated(string price);
    event LogNewProvableQuery(string description);

    constructor () public payable {
	OAR = OracleAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
        emit LogConstructorInitiated("Constructor was initiated. Call 'updateTime()' to send the Provable Query.");
	updateTime();
    }

    function pay() public payable {}

    function balance() public view returns(uint256)  {
        return address(this).balance;
    }

    function __callback(bytes32, string memory result) public {
        if (msg.sender != provable_cbAddress()) revert();
        timestamp = parseInt(result);
        emit LogPriceUpdated(result);
        updateTime();
    }

    function updateTime() public payable {
        if (provable_getPrice("URL") > address(this).balance) {
            emit LogNewProvableQuery("Provable query was NOT sent, please add some ETH to cover for the query fee");
        } else {
            emit LogNewProvableQuery("Provable query was sent, standing by for the answer..");
            provable_query("URL", "json(http://worldtimeapi.org/api/timezone/Europe/Bucharest).unixtime");
        }
    }
}

I'm doing something wrong or this is a bug?

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

No branches or pull requests

1 participant