Plugin,a Decentralized Oracle built on XDC Network
  • Migrating from Plugin Node V2 to V2.4 Without Changing the Node Address
    • 1 - Backup on Plugin Node V2.0
    • 2 - Installation and Configuration of Plugin Node V2.4
    • 3 - Importing PluginV2 Node Address into PluginV2.4
    • 4. Backup After Plugin V2.4 Upgrade
  • Plugin 2.0 - Node Operators
    • Introduction
    • Unstake PLI Tokens from Plugin 1.0 Node
    • Plugin 2.0 Set Up Requirements
    • Node Installation
      • Node Fulfillment
      • Job Setup
        • Steps to Setup Direct Request Job
      • Process of Approval
    • How to Update Your Plugin Node for the Latest XDC Gas Fee
  • PLUGIN 2.0 - Validators
    • Introduction
    • Set-up Requirements
    • Job Setup
      • Steps to Setup Direct Request Job
      • Flux Monitor Job
        • Idle Timer
        • Drum Beat
        • Poll Timer
        • POLL TIMER + IDLE TIMER (Recommended)
      • Process Of Approval
      • Rewards Information
    • OCR Set-up
    • How to Update Your Plugin Node for the Latest XDC Gas Fee
  • WALLET
    • XDCPay - Apothem
    • XDCPay - Mainnet
  • PLUGIN VRF SUBSCRIPTION
    • Introduction
    • Guidance on Utilizing Random Values
    • Creation and Deployment of VRF-Consumer Contract
    • Requesting Random Values
  • Multichain
    • PLISwap - How to instructions
  • Plugin Data Feeds platform
    • Introduction
    • End data consumers - Mainnet
    • End data consumers - Apothem
    • Benefits
  • Restaking Model
    • Introduction
      • Scenarios in Re-staking Model
      • Benefits To Node Members
      • Steps for Restaking
  • Tips and tricks
    • Known-Issues
    • Open-Issues
  • Plugin 1.0 Installations - Deprecated
    • How to install Plugin 1.0 Node
      • Modular Method Deployment (Recommended Approach)
      • Script Method (Legacy)
        • Script - Phase 1
        • Script - Phase 2
      • Docker Method
        • Docker - Phase 1
        • Docker - Phase 2
    • Core Adapters
    • Fund your Node
  • External Initiators - Deprecated
    • Introduction
    • Installation
    • Setup & Build
  • Oracle Plugin 1.0 - Deprecated
    • Deployment
    • Fulfillment Request
    • Job-Setup
    • Testing
  • Job-Tasks Plugin 1.0 Deprecated
    • Sleep
    • Get > Bytes32
    • HttpGet
    • CRON
    • Web
  • External Adapters Plugin 1.0 - Deprecated
    • Introduction
    • Implement External -Adapters
    • Define Bridge
    • Add Bridge to Job Spec
  • Deprecated
    • How to use
  • Use Cases
    • Plugin WFN Use Case
      • Plugin WFN Data Review
      • Plugin WFN Use Case - FAQ
      • Plugin WFN - Ambient Weather Unit Onboarding Instructions
      • Plugin WFN - Acurite Weather Unit Onboarding Instructions - LEGACY
      • Unlock WFN Node
    • Crypto Compare - Pricing Index
  • Node Operators
    • How to Register / Sign-up
    • How to enable 2FA
    • How to update profile
    • How to add XDC Wallet Address
    • How to Navigate Dashboards
    • How to submit Node Details
    • How to stake PLI token for Plugin Node
    • How to add Job to your node
    • View the node details
    • De-Activate / Re-activate my nodes
    • Withdraw staked PLI
    • Withdraw PLI from Plugin Node
    • Withdraw PLI from Oracle contract
    • How to add more stake in Node?
    • How to Migrate my Plugin Node to New Server?
    • How to Un-Stake the node.
    • How a Reputation is calculated?
    • Node Maintenance Instructions for node operators
  • FEATURES
    • PLI Yield Farming
      • Steps for Staking in Plugin Yield Farming (PLIYF)
      • PLIYF - FAQ
  • Support
    • FAQ
  • RESOURCES
    • Node Setup Video Tutorials
    • Community Supports
    • How to Submit your node details - Video Tutorial
  • CHANGELOG
    • v1.0.1
    • V1.0.2
    • V1.0.3
    • V1.0.4
    • V1.05
  • Terms and Conditions
Powered by GitBook
On this page
  1. PLUGIN 2.0 - Validators

OCR Set-up

PreviousRewards InformationNextHow to Update Your Plugin Node for the Latest XDC Gas Fee

Last updated 4 months ago

OCR configuration, currently is specific for validators involved in participating in the Oracle price feeds. We will send an announcement to validators while changing the current price feeds to OCR protocol based price feeds.

Here are the detailed steps to enable Offchain reporting onto the Plugin Node for Peer.

  1. To enable OCR in the Plugin environment, set the parameters in the config.toml file as shown below. Once the changes are made, restart the plugin using pm2 restart 0.

// OCR parameters in config.toml in addition to Plugin parameters

[P2P]
PeerID = '<peer_ID_as shown in the image>'

[P2P.V1]
Enabled = true

[P2P.V2]
Enabled = true
AnnounceAddresses = ['<Public_IP_address_of_the_server>:5001']
DefaultBootstrappers = ['<bootStrapper_peer_ID>@<bootStrapper_node_IP>:5001']
ListenAddresses = ['<Public_IP_address_of_the_server>:5001']

[OCR]
Enabled = true
KeyBundleID = '<key_bundle_ID_as shown in the image>'

[OCR2]
Enabled = true
KeyBundleID =  '<key_bundle_ID_as shown in the image>'
  1. Now move into the foundry contracts directory

  2. Invoke remix to deploy Offchainaggregator contract

    • "remixd -s . -u https://remix.xinfin.network"

  3. Now select Offchainaggregator.sol contract as given below.

  4. Parameters for deploying Offchainaggregator.sol

    i) Constructor params: ii) Decimal: 18

    iii) Billing Access Controller: <wallet_address>

    iv) Request Access Controller: <wallet_address>

    v) Min Ans : 0

    vi) Max Ans : 99999999999999999999

    vii) Validator : 0x0000000000000000000000000000000000000000 viii) PLI : 0x33f4212b027E22aF7e6BA21Fc572843C0D701CD1 ix) Max gas price : 3000

    x) Reasonable Gas Price: 75

    xi) MicroPliPerEth: 305186108

    xii) PliWeiPerObservation : 151513582

    xiii) PliWeiPerTransmission : 9090766

  5. To get the OS instruction set of server, execute the command "uname -m" in CLI.

  6. Now execute the command in foundry directory as given below.

external/OCRHelper/ocrhelper-linux-<command_7_output> NODE_ADDRESSES="<node_address_peer1>","<node_address_peer2>","<node_address_peer3>","<node_address_peer4>" OFFCHAIN_PUBLIC_KEYS="<peer1_offchain_public_key>,<peer2_offchain_public_key>,<peer3_offchain_public_key>,<peer4_offchain_public_key>" CONFIG_PUBLIC_KEYS="<peer1_config_public_key>,<peer2_config_public_key>,<peer3_config_public_key>,<peer4_config_public_key>" ONCHAIN_SIGNING_ADDRESSES="<peer1_onchain_sign_addr>,<peer2_onchain_sign_addr>,<peer3_onchain_sign_addr>,<peer4_onchain_sign_addr>" PEER_IDS="<Peer1_ID>,<Peer2_ID>,<Peer3_ID>,<Peer4_ID>"
// SAMPLE OUTPUT of the above command execution
[0x4bEDDe1B6464aC385C32E06Db3E3cD7486636BA7,0x336acE60B9247CC39996f15B2788AD7C9df7b2A1,0xeF53A8245De8169c40a2325Bab7D7369a92Fb4bC,0xae51BD92635FCbD683975aEcB778f2CE7d013FA5] 
[0xe2B935C17089b31c457B80A577338AbeDD5e6206,0xF73A7CD3908700F18e424C327c0301583bcEf41d,0x3CE7D10187eFf99DEbDC0923B2d4F447A5b42eB9,0x20A3beCE1147e33F1932AA12245E50858b261fFB] 
1 
1 
00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000826299e0000000000000000000000000000000000000000000000000000000003f5476a0000000000000000000000000000000000000000000000000000000006fc23ac0000000000000000000000000000000000000000000000000000000002cb4178000000000000000000000000000000000000000000000000000000034630b8a00000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000df847580000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004315e5b0930b10e51c9149013ed68fa88c6bc230048212ccb7066cb02f4525e282d1fb82f0b3b1fa7a32531bac38c5cb53b030711165038b1185f5259d3db678317af622227ec7bf7f4e32c5a2b4161d86147c299750b236043622a83af6901719a829bf2db49f3e215c948b8108e4da83cb61ed5c53483e237175fb57d9ec2a700000000000000000000000000000000000000000000000000000000000000e37032705f313244334b6f6f5748596e694c6b76376f7a32726a3374564c4156657231384b373546356b4e736142506277576d6a6d686158432c7032705f313244334b6f6f57506f716a36486d7a6e5738553657436e4a46486a516774486442594a3352425a4770624b46473662316461652c7032705f313244334b6f6f57536165344b624835374d446e48504b476a656739354e444d593435347273334739376e51474d6335356f396a2c7032705f313244334b6f6f57535756386a74774b363666347a435a4237597179595238734a64674b316e547743354c5347313347353472640000000000000000000000000000000000000000000000000000000000d91977e6e91d96dc1577706e4d6b4232bfdd4cdb5a26e3de7c6ba5ecade1c224bc052e956da259990fa5364def4eb76fcee1374aa863d7244db0fc39dee675870000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000467df5168d0cd9e03571d5afeb312e7df00000000000000000000000000000000a278a323a7bcc33f6dcc64fe7ec960c100000000000000000000000000000000fa7aca070b44c477a2eb93f4f17f134a000000000000000000000000000000005b1e4c4b5cd02a4861b707e23ff2c6b900000000000000000000000000000000
  1. Get the [5th] parameter field from the above output as the value of hexString

  2. Deploy the cast.sol contract in remix to convert the hexString value to solidity bytes

```remix-solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract HexToBytesConverter {
    // Function to convert hexadecimal string to bytes
    function hexStringToBytes(string memory hexa) public pure returns (bytes memory) {
        bytes memory b = bytes(hexa);
        require(b.length % 2 == 0, "Hex string has odd length");

        bytes memory result = new bytes(b.length / 2);

        for (uint256 i = 0; i < bytes(hexa).length / 2; i++) {
            result[i] = bytes1(_fromHexChar(uint8(bytes(hexa)[2 * i])) * 16 + _fromHexChar(uint8(bytes(hexa)[2 * i + 1])));
        }

        return result;
    }

    // Helper function to convert a hex character to its value
    function _fromHexChar(uint8 c) internal pure returns (uint8) {
        if (bytes1(c) >= bytes1('0') && bytes1(c) <= bytes1('9')) {
            return c - uint8(bytes1('0'));
        } else if (bytes1(c) >= bytes1('a') && bytes1(c) <= bytes1('f')) {
            return 10 + c - uint8(bytes1('a'));
        } else if (bytes1(c) >= bytes1('A') && bytes1(c) <= bytes1('F')) {
            return 10 + c - uint8(bytes1('A'));
        } else {
            revert("Invalid hex character");
        }
    }
    
    // Function to simulate the usage of envBytes
    function getEnvBytes() public view returns (bytes memory) {
        // In a real scenario, this would retrieve the environment variable
        // Using the provided long hexadecimal string as an example
        string memory hexStr = "";
        return hexStringToBytes(hexStr);
    }
}
```
  1. In the 'hexStringToBytes' option pass the hexString value and click to get the solidity converted bytes.

  1. Set the payee in Offchainaggregator.sol contract using the below-mentioned values, and click on transact, transmitters: ["<node_address_peer1>","<node_address_peer2>","<node_address_peer3>","<node_address_peer4>"] payees: ["<node_address_peer1_walletaddress>","<node_address_peer2_walletaddress>","<node_address_peer3_walletaddress>","<node_address_peer4_walletaddress>"]

  1. Now set Offchainaggregator config using setConfig option

signers: [1] value from step 9 output 
transmitters: [2] value from step 9 output (Node address)
threshold: [3] value from step 9 output 
_encodedConfigVersion: [4] value from step 9 output 
encoded: bytes value from step 12
  1. It is time to submit Job for OCR. Job spec template for Peer nodes is available in foundry directory @ ./src/sandbox/clroot/jobs/ocr_job.toml. Kindly, make the required changes in the ocr_job.toml (mentioned in between '<>')and submit the job in your node, so that it will communicate with the bootstrapper node and participate in generating the off chain report.

type = "offchainreporting"
schemaVersion = 1
name = "Get > Uint256 <Offchainaggregator_contract_address> (ocr)"
forwardingAllowed = false
maxTaskDuration = "0s"
blockchainTimeout = "20s"
contractAddress = "<Offchainaggregator_contract_address>"
contractConfigConfirmations = 3
contractConfigTrackerPollInterval = "2m0s"
contractConfigTrackerSubscribeInterval = "5m0s"
evmChainID = "51"
isBootstrapPeer = false
keyBundleID = "<key_bundle_ID_as mentioned in step 1>"
observationTimeout = "20s"
p2pBootstrapPeers = [
  "/dns4/<bootStrapper_node_IP>/tcp/6689/p2p/<bootStrapper_peer_ID>"
]
p2pv2Bootstrappers = [
  "<bootStrapper_peer_ID>@<bootStrapper_node_IP>:6689"
]
transmitterAddress = "<your_node_address>"
observationSource = """
   fetch        [type="http" method=GET url="https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd" allowUnrestrictedNetworkAccess="true"]
   parse        [type="jsonparse" path="ethereum,usd" data="$(fetch)"]
   multiply     [type="multiply" input="$(parse)" times=100]

   fetch -> parse -> multiply
"""
  1. Job submission output Once the job is submitted you can see the job is running in Plugin UI @ "Jobs" option.

To set up the foundry repository pull the code base to your local environment git clone

"cd foundry/contracts/v0.7.6"

Once the remix is invoked, open the remix in the browser "" URL.

https://github.com/GoPlugin/foundry.git
https://remix.xinfin.network