From 3c9834877464219ea53caf64444d3cee844e689a Mon Sep 17 00:00:00 2001 From: Kristijan Rebernisak Date: Thu, 30 Dec 2021 11:56:42 +0100 Subject: [PATCH 1/2] Improve job spec examples --- examples/spec/ocr2-oracle-simple.spec.toml | 47 ++++++++++++++++ examples/spec/ocr2-oracle.spec.toml | 64 +++++++++++++++++----- 2 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 examples/spec/ocr2-oracle-simple.spec.toml diff --git a/examples/spec/ocr2-oracle-simple.spec.toml b/examples/spec/ocr2-oracle-simple.spec.toml new file mode 100644 index 000000000..ef8f356a6 --- /dev/null +++ b/examples/spec/ocr2-oracle-simple.spec.toml @@ -0,0 +1,47 @@ +type = "offchainreporting2" +schemaVersion = 1 +blockchainTimeout = "20s" +contractConfigConfirmations = 3 +contractConfigTrackerPollInterval = "1m" +contractConfigTrackerSubscribeInterval = "2m" +name = "" +relay = "solana" +contractID = "" +p2pBootstrapPeers = ["somep2pkey@localhost-tcp:port"] +isBootstrapPeer = false +p2pPeerID = "" +ocrKeyBundleID = "" +monitoringEndpoint = "" +transmitterID = "" +observationSource = """ + // data source 1 + ds1 [type="bridge" name="bridge-coingecko" requestData="<{"data": {"from":"LINK","to":"USD"}}>"] + ds1_parse [type="jsonparse" path="result"] + ds1_multiply [type="multiply" times=100000000] + ds1 -> ds1_parse -> ds1_multiply +""" +juelsPerFeeCoinSource = """ + // Fetch the LINK price from a data source + // data source 1 + ds1_link [type="bridge" name="bridge-coingecko" requestData="<{"data": {"from":"LINK","to":"USD"}}>"] + ds1_link_parse [type="jsonparse" path="result"] + ds1_link -> ds1_link_parse -> divide + + // Fetch the SOL price from a data source + // data source 1 + ds1_coin [type="bridge" name="bridge-coingecko" requestData="<{"data": {"from":"SOL","to":"USD"}}."] + ds1_coin_parse [type="jsonparse" path="result"] + ds1_coin -> ds1_coin_parse -> divide + + divide [type="divide" input="$(ds1_link_parse)" divisor="$(ds1_coin_parse)" precision="9"] + scale [type="multiply" times=1000000000] + + divide -> scale +""" + +[relayConfig] +nodeEndpointHTTP = "http:..." +nodeEndpointWS = "ws:..." +stateID = "" +transmissionsID = "" +validatorProgramID = "" diff --git a/examples/spec/ocr2-oracle.spec.toml b/examples/spec/ocr2-oracle.spec.toml index 10ae8a1f2..d74eb5b75 100644 --- a/examples/spec/ocr2-oracle.spec.toml +++ b/examples/spec/ocr2-oracle.spec.toml @@ -14,25 +14,63 @@ ocrKeyBundleID = "" monitoringEndpoint = "" transmitterID = "" observationSource = """ - ea [type=bridge name=coingecko requestData=<{"data":{"from":"LINK", "to":"USD"}}>] - parse [type="jsonparse" path="result"] - multiply [type="multiply" times=100000000] - - ea -> parse -> multiply + // data source 1 + ds1 [type="bridge" name="bridge-tiingo" requestData="<{"data": {"from":"BTC","to":"USD"}}>"] + ds1_parse [type="jsonparse" path="result"] + ds1_multiply [type="multiply" times=100000000] + ds1 -> ds1_parse -> ds1_multiply -> answer + // data source 2 + ds2 [type="bridge" name="bridge-nomics" requestData="<{"data": {"from":"BTC","to":"USD"}}>"] + ds2_parse [type="jsonparse" path="result"] + ds2_multiply [type="multiply" times=100000000] + ds2 -> ds2_parse -> ds2_multiply -> answer + // data source 3 + ds3 [type="bridge" name="bridge-coinmarketcap" requestData="<{"data": {"from":"BTC","to":"USD"}}>"] + ds3_parse [type="jsonparse" path="result"] + ds3_multiply [type="multiply" times=100000000] + ds3 -> ds3_parse -> ds3_multiply -> answer + answer [type="median" index=0] """ juelsPerFeeCoinSource = """ - link2usd [type=bridge name=coingecko requestData=<{"data":{"from":"LINK", "to":"USD"}}>] - parseL [type="jsonparse" path="result"] + // Fetch the LINK price from three data sources + // data source 1 + ds1_link [type="bridge" name="bridge-tiingo" requestData="<{"data": {"from":"LINK","to":"USD"}}>"] + ds1_link_parse [type="jsonparse" path="result"] + ds1_link -> ds1_link_parse -> median_link + // data source 2 + ds2_link [type="bridge" name="bridge-nomics" requestData="<{"data": {"from":"LINK","to":"USD"}}>"] + ds2_link_parse [type="jsonparse" path="result"] + ds2_link -> ds2_link_parse -> median_link + // data source 3 + ds3_link [type="bridge" name="bridge-coinmarketcap" requestData="<{"data": {"from":"LINK","to":"USD"}}>"] + ds3_link_parse [type="jsonparse" path="result"] + ds3_link -> ds3_link_parse -> median_link + + // Fetch the SOL price from three data sources + // data source 1 + ds1_coin [type="bridge" name="bridge-tiingo" requestData="<{"data": {"from":"SOL","to":"USD"}}."] + ds1_coin_parse [type="jsonparse" path="result"] + ds1_coin -> ds1_coin_parse -> median_coin + // data source 2 + ds2_coin [type="bridge" name="bridge-nomics" requestData="<{"data": {"from":"SOL","to":"USD"}}>"] + ds2_coin_parse [type="jsonparse" path="result"] + ds2_coin -> ds2_coin_parse -> median_coin + // data source 3 + ds3_coin [type="bridge" name="bridge-coinmarketcap" requestData="<{"data": {"from":"SOL","to":"USD"}}>"] + ds3_coin_parse [type="jsonparse" path="result"] + ds3_coin -> ds3_coin_parse -> median_coin - sol2usd [type=bridge name=coingecko requestData=<{"data":{"from":"SOL", "to":"USD"}}>] - parseT [type="jsonparse" path="result"] + // Compute the medians from all data sources + median_link [type="median" values=<[ $(ds1_link_parse), $(ds2_link_parse), $(ds3_link_parse) ]> allowedFaults=1] + median_coin [type="median" values=<[ $(ds1_coin_parse), $(ds2_coin_parse), $(ds3_coin_parse) ]> allowedFaults=1] - divide [type="divide" input="$(parseL)" divisor="$(parseT)" precision="9"] + // Divide and scale appropriately + divide [type="divide" input="$(median_link)" divisor="$(median_coin)" precision="9"] scale [type="multiply" times=1000000000] - link2usd -> parseL -> divide - sol2usd -> parseT -> divide - divide -> scale + median_link -> divide + median_coin -> divide + divide -> scale """ [relayConfig] From 023efc9de54e5f8a33cf864109d446646c75ae02 Mon Sep 17 00:00:00 2001 From: Kristijan Rebernisak Date: Tue, 11 Jan 2022 20:21:29 +0100 Subject: [PATCH 2/2] Update example job specs to latest version --- examples/spec/ocr2-bootstrap.spec.toml | 6 +++--- examples/spec/ocr2-oracle-simple.spec.toml | 9 ++++----- examples/spec/ocr2-oracle.spec.toml | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/spec/ocr2-bootstrap.spec.toml b/examples/spec/ocr2-bootstrap.spec.toml index 6927d914a..ce18b2815 100644 --- a/examples/spec/ocr2-bootstrap.spec.toml +++ b/examples/spec/ocr2-bootstrap.spec.toml @@ -16,6 +16,6 @@ transmitterID = "" [relayConfig] nodeEndpointHTTP = "http:..." -ocr2ProgramID = "" -transmissionsID = "" -storeProgramID = "" +ocr2ProgramID = "" +transmissionsID = "" +storeProgramID = "" diff --git a/examples/spec/ocr2-oracle-simple.spec.toml b/examples/spec/ocr2-oracle-simple.spec.toml index ef8f356a6..8ab2b8f3c 100644 --- a/examples/spec/ocr2-oracle-simple.spec.toml +++ b/examples/spec/ocr2-oracle-simple.spec.toml @@ -6,7 +6,7 @@ contractConfigTrackerPollInterval = "1m" contractConfigTrackerSubscribeInterval = "2m" name = "" relay = "solana" -contractID = "" +contractID = "" p2pBootstrapPeers = ["somep2pkey@localhost-tcp:port"] isBootstrapPeer = false p2pPeerID = "" @@ -41,7 +41,6 @@ juelsPerFeeCoinSource = """ [relayConfig] nodeEndpointHTTP = "http:..." -nodeEndpointWS = "ws:..." -stateID = "" -transmissionsID = "" -validatorProgramID = "" +ocr2ProgramID = "" +transmissionsID = "" +storeProgramID = "" diff --git a/examples/spec/ocr2-oracle.spec.toml b/examples/spec/ocr2-oracle.spec.toml index d74eb5b75..4c8923a0c 100644 --- a/examples/spec/ocr2-oracle.spec.toml +++ b/examples/spec/ocr2-oracle.spec.toml @@ -75,6 +75,6 @@ juelsPerFeeCoinSource = """ [relayConfig] nodeEndpointHTTP = "http:..." -ocr2ProgramID = "" -transmissionsID = "" -storeProgramID = "" +ocr2ProgramID = "" +transmissionsID = "" +storeProgramID = ""