XY Oracle Network Diviner Node
Implementation of a basic diviner node of the XYO Network. This node is responsible for querying the Archivist net, processing proof of origin data, and relaying responses back to the XYO smart contract as an oracle.
The initial, reference diviner node architecture will consist of the following components:
- A client that creates a JSON-RPC connection to a locally running Geth node
- A server that connects to the XYO Archivist Network through an endpoint for issuing issuing queries
- A simple tool for simulating pending queries sent over to the XY Smart Contract
In a mainnet implementation, an end-to-end example of the XYO Network would entail having the diviner node send answers into the smart contract that can then be extracted by a tool such as https://if-eth.com that listens to event logs from smart contracts using webhooks.
Installing Ganache as a local, Ethereum blockchain node:
- Make sure you have Node.js installed, then run
npm install -g ganache-cli
- Then, run
ganache-cli. It will start a local Ethereum simulation on port 8545.
Now that you have Ganache, you can clone the xyo-solidity repo and deploy the XY core smart contract to the local node as follows:
- Install truffle with
npm i truffle -g
- Clone the xyo-solidity repo
git clone https://github.com/XYOracleNetwork/xyo-solidity
- While ganache is running, compile and deploy the contract:
truffle compile && truffle migrate
- You should see the following in your command line so copy the
XY:contract address somewhere (you'll need it!)
Getting Golang, $GOPATH, and cloning the repository:
- Install the latest version of go for your operating system
- Ensure your
$GOPATHis set. If not, then pick a directory as your
- Create the path
git clone https://github.com/XYOracleNetwork/xyo-diviner
cd ./xyo-diviverand then
- Inside the xyo-diviner folder run,
./main -contract CONTRACT_ADDRESSwhere
CONTRACT_ADDRESSis the address of the deployed XY contract in the running Ethereum node you copied earlier
Then, you'll start seeing some queries being issued to the XY contract and the diviner node constantly polling for pending queries that it will start to process! You'll see in the command line when the diviner node successfully publishes an answer to a query back to the XY smart contract as follows:
How the XYO-Diviner Works
When we start a diviner node instance, it sets up a connection to an Ethereum instance endpoint - in this case the ganache-cli. Then, it sets up a server that connects to the Archivist network, which for now is implemented as a single JSON http endpoint that accepts queries and returns a hardcoded response.
After the server begins listening for requests, 3 concurrent threads are launched:
FetchPendingQueries()interacts with the XY smart contract to fetch the list of pending queries and transmits them over a channel
IssueQuery()listens for pending queries being sent over the previous channel and issues JSON post requests with the query payload to the Archivist server. Once it receives an answer it sends it over to another channel that listens for answers.
ProcessAndPublishSignedAnswers()listens to answers over the previous channel, processes them, and sends signed answers back to the XY smart contract which will eliminate the corresponding pending query in the contract and issue an
AnswerReceivedlog that can then be subscribed to with webhooks from services such as https://if-eth.com.
-[x] Implement fake Archivist network endpoint server
-[ ] Fetch pending queries from the actual XYO contract with ABI bindings
-[ ] Send signed transactions over to the smart contract