Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Make the oracle work on polygon network (or other network) #15

Closed
foufrix opened this issue Apr 16, 2022 · 10 comments
Closed

Make the oracle work on polygon network (or other network) #15

foufrix opened this issue Apr 16, 2022 · 10 comments

Comments

@foufrix
Copy link
Contributor

foufrix commented Apr 16, 2022

I deployed the Factory Escrow contract here: https://mumbai.polygonscan.com/address/0x2dd72db2bBA65cE663e476bA8b84A1aAF802A8e3
And I deployed it to work with USDC (for easy testing): https://mumbai.polygonscan.com/address/0xe11a86849d99f524cac3e7a0ec1241828e332c62

In constants.js I changed the value to make it work :

export const HMT_ADDRESS = "0xe11A86849d99F524cAC3E7A0Ec1241828e332C62";
export const ESCROW_FACTORY_ADDRESS = "0x2dd72db2bBA65cE663e476bA8b84A1aAF802A8e3";

I started the fortune exchange and launcher docker image locally. Creation of Escrow worked ok. Funding the Escrow (with USDC) and providing manifest.json worked ok.

image

Here is the manifest I provide :

{
"job_title": "Requesting fortunes from the fortunes teller",
"job_type": "fortune",
"fortunes_requested": 2,
"recording_oracle_address": "0x61F9F0B31eacB420553da8BCC59DC617279731Ac",
"reputation_oracle_address": "0xD979105297fB0eee83F7433fC09279cb5B94fFC6",
"echange_oracle_address": "0x6b7E3C31F34cF38d1DFC1D9A8A59482028395809",
"recording_oracle_url": "http://ec2-3-15-230-238.us-east-2.compute.amazonaws.com:3005/job/results",
"reputation_oracle_url": "http://ec2-3-15-230-238.us-east-2.compute.amazonaws.com:3006/job/results",
"exchange_oracle_url": "http://ec2-3-15-230-238.us-east-2.compute.amazonaws.com:3001/"
}

I get the exchange URL, I can go to it, but when I want to send the fortune message from Agent 2 and 3 accounts, I get this error :
image

From my understanding, the oracles are running on this RPC http://ec2-3-15-230-238.us-east-2.compute.amazonaws.com:8545/ hosted on Amazon AWS.

Can the polygon Escrow contract created on Polygon Mumbai interact with the oracles hosted on AWS? If yes, what do I need to change?

Because on the AWS chain, the fortune app works ok.

@foufrix foufrix changed the title Make the oracle work on polygon netwok (or other network) Make the oracle work on polygon network (or other network) Apr 16, 2022
@kaseLunt
Copy link

Having the same issue on Moonbeam

@posix4e
Copy link
Contributor

posix4e commented Apr 17, 2022

@kaseLunt @foufrix Do you see anything in the logs on the oracles?

@vkomodey
Copy link
Contributor

Hey guys! Fortune is not multichain right now and can be configured via environment variables(backends). There are 2 ways of doing this:

  1. You deploy fortune to some free hosting(like heroku) for a particular blockchain(Moonbeam for example)
  2. Or we will add the multichain support and deploy it to some test network
  3. After proper contracts testing we will deploy fortune to the existing setup with some testnet

Personally I don't think that we need a multichain right now. New chain = new instance is the best way right now

@posix4e
Copy link
Contributor

posix4e commented Apr 19, 2022

  1. Agreed, no reason to change the source.
  2. It would be good to see a video and for you to share the environment variables. You can do this by forking the repo, and we will add a link in documentation to your fork
  3. Vlad provides a good example of using a free services like heroku. This will make the environment variables more clear

@posix4e posix4e closed this as completed Apr 19, 2022
@foufrix
Copy link
Contributor Author

foufrix commented Apr 21, 2022

It's a bit complicated to deploy on heroku because they allow only one port, so it's always a different link and instance need to be deployed one by one, I'm not even sure it would work as reputation and recording oracles would not be on the same instance.

Anyway by running everything locally and changing constants.js to use contract on Polygon Mumbai and USDC for the moment, I manage to :

  1. launch app and create escrow interacting with contract on Mumbai
  2. Fund contract with USDC and provide manifest.json using only localhost
  3. Launching the exchange, trying to send Fortune Message over Polygon Mumbai, I get the same error as what I had when interacting with the AWS instance :
    image
    But this time I have the backend logs :
    image

After some search on this error, it can be cause by a wrong ABI.

I launched the exchange without docker to debug, and I see that there is an error when setting up the main escrow here :

  const setMainEscrow = async (address) => {
    setEscrow(address);
    console.log("address: ", address);
    const Escrow = new web3.eth.Contract(EscrowABI, address);
    console.log("1");
    const escrowSt = await Escrow.methods.status().call();
    console.log("2");
    setEscrowStatus(statusesMap[escrowSt]);

    const balance = await Escrow.methods.getBalance().call();
    setBalance(web3.utils.fromWei(balance, "ether"));
    console.log("3");

    const manifestUrl = await Escrow.methods.manifestUrl().call();
    if (manifestUrl) {
      const manifestContent = (await axios.get(manifestUrl)).data;

      setRecordingOracleUrl(manifestContent.recording_oracle_url);
    }
  };

And the logs on the frontend :
image

We see that the function crash directly at Escrow.methods.status().call()

Do you have any idea what need to be changed in /contracts/EscrowAbi.json to work with Polygon contract ?

@vkomodey
Copy link
Contributor

Hey @foufrix . Let's replace the Escrow ABI with this implementation - https://github.com/humanprotocol/hmt-escrow/pull/295/files

It supports the standard ERC20 interface without bulk* methods

@foufrix
Copy link
Contributor Author

foufrix commented Apr 21, 2022

Hi, @vkomodey thanks for the help,

I deployed the contract of your branch polygon-escrow-bulk here: https://mumbai.polygonscan.com/address/0x5D65C42cF4a140863744889BAd07f246C0211754

I tried again, creating an Escrow and redoing everything, I still got the same error on the call of the oracle :
Front
image

Back
image

Is it my guess there may be a mismatch of networks?

Because the from : 0x61f9f0b31eacb420553da8bcc59dc617279731ac it's the oracle on local ganache and to : 0x4f7106aac91ca6d1e6fef1d6f114baeb7643cdf8 is the Escrow created on Polygon Mumbai

Can a local call from the oracle on ganache to the polygon network work? And maybe the code of the oracle is trying to reach the contract 0x4f7106aac91ca6d1e6fef1d6f114baeb7643cdf8 on ganache instead on polygon

@vkomodey
Copy link
Contributor

Because the from : 0x61f9f0b31eacb420553da8bcc59dc617279731ac it's the oracle on local ganache and to : 0x4f7106aac91ca6d1e6fef1d6f114baeb7643cdf8 is the Escrow created on Polygon Mumbai

Are you trying this on the deployed playground? I mean, we definitely can't use current oracles deployed in the ganache setup

Can a local call from the oracle on ganache to the polygon network work?
Definitely not. Let me check this tomorrow

@foufrix
Copy link
Contributor Author

foufrix commented Apr 21, 2022

Are you trying this on the deployed playground? I mean, we definitely can't use current oracles deployed in the ganache setup

It's not on the AWS deployed ganache, but on a local ganache instance on my computer

I thought we could, I asked on the discord about that and it did not seem to be an issue.
So I need to deploy oracle as well on the polygon Mumbai network? But there is no .sol contract in reputation/recording-oracle

@vkomodey
Copy link
Contributor

So I need to deploy oracle as well on the polygon Mumbai network?

Oracle is not a contract. It's EOA. You don't have to deploy anything here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants