From 8cac706133833c3f29bfb769fbecd7c7185e143f Mon Sep 17 00:00:00 2001 From: Gorka Irazoqui Date: Wed, 25 Mar 2020 17:11:17 +0100 Subject: [PATCH] feat: make the bridge compatible with latest naming and new abis --- bridges/ethereum/README.md | 24 +- bridges/ethereum/block_relay_abi.json | 201 ++++--- .../src/actors/block_relay_and_poi.rs | 38 +- bridges/ethereum/src/actors/claim_and_post.rs | 62 +- .../ethereum/src/actors/eth_event_stream.rs | 38 +- bridges/ethereum/src/actors/mod.rs | 6 +- bridges/ethereum/src/actors/tally_finder.rs | 6 +- ...l_sync.rs => wrb_requests_initial_sync.rs} | 38 +- bridges/ethereum/src/config.rs | 4 +- bridges/ethereum/src/eth.rs | 56 +- bridges/ethereum/src/main.rs | 22 +- .../ethereum/{wbi_abi.json => wrb_abi.json} | 538 ++++++++++-------- witnet_ethereum_bridge.toml | 4 +- 13 files changed, 567 insertions(+), 470 deletions(-) rename bridges/ethereum/src/actors/{wbi_requests_initial_sync.rs => wrb_requests_initial_sync.rs} (84%) rename bridges/ethereum/{wbi_abi.json => wrb_abi.json} (82%) diff --git a/bridges/ethereum/README.md b/bridges/ethereum/README.md index daee10b93..96ec16699 100644 --- a/bridges/ethereum/README.md +++ b/bridges/ethereum/README.md @@ -32,7 +32,7 @@ If the command results in an error complaining about "network local does not exi Copy BlockRelay contract address to witnet-rust/witnet_ethereum_bridge.toml -Copy WBI contract address to witnet-rust/witnet_ethereum_bridge.toml +Copy WRB contract address to witnet-rust/witnet_ethereum_bridge.toml If the api of the contracts was modified recently, you have to manually copy the ABI from @@ -45,13 +45,13 @@ the ABI from (the contents of block_relay_abi.json should be a JSON array) -Same for the WBI: copy +Same for the WRB: copy witnet-ethereum-bridge/build/contracts/WitnetBridgeInterface.json to - witnet-rust/bridges/ethereum/wbi_abi.json + witnet-rust/bridges/ethereum/wrb_abi.json ## Ethereum (Ropsten) @@ -89,7 +89,7 @@ If the command results in an error complaining about "network local does not exi Copy BlockRelay contract address to witnet-rust/witnet_ethereum_bridge.toml -Copy WBI contract address to witnet-rust/witnet_ethereum_bridge.toml +Copy wrb contract address to witnet-rust/witnet_ethereum_bridge.toml If the api of the contracts was modified recently, you have to manually copy the ABI from @@ -102,13 +102,13 @@ the ABI from (the contents of block_relay_abi.json should be a JSON array) -Same for the WBI: copy +Same for the WRB: copy witnet-ethereum-bridge/build/contracts/WitnetBridgeInterface.json to - witnet-rust/bridges/ethereum/wbi_abi.json + witnet-rust/bridges/ethereum/wrb_abi.json ## Witnet Run the node: @@ -127,28 +127,28 @@ Start the bridge: RUST_LOG=witnet_ethereum_bridge=debug cargo run -p witnet-ethereum-bridge -It will try to subscribe to blocks from Witnet and WBI events from Ethereum. +It will try to subscribe to blocks from Witnet and WRB events from Ethereum. -If that's successful, we can post a data request to the WBI: +If that's successful, we can post a data request to the WRB: cargo run -p witnet-ethereum-bridge -- --post-dr This will send a data request querying the price of bitcoin. -* The bridge will be listening to events from the WBI, so when the transaction -gets accepted into a block, the WBI contract will emit a `PostDataRequest` event. +* The bridge will be listening to events from the WRB, so when the transaction +gets accepted into a block, the WRB contract will emit a `PostDataRequest` event. * The bridge will call `claimDataRequests` in order to claim the data request, and when that transaction is accepted, the bridge will post the data request to Witnet. * When this data request is included in a Witnet block, the bridge will send the -proof of inclusion to the WBI contract. This will emit an `InclusionDataRequest` +proof of inclusion to the WRB contract. This will emit an `InclusionDataRequest` event, which indicates to all the bridge nodes that they should start checking all the new Witnet blocks for a tally which resolves that data request. * Once a tally has been included in a block, any bridge node can sent the proof -of inclusion. If that proof is valid, the WBI contract will emit a `PostResult` +of inclusion. If that proof is valid, the WRB contract will emit a `PostResult` event indicating that the data request has been resolved. ## Block Relay diff --git a/bridges/ethereum/block_relay_abi.json b/bridges/ethereum/block_relay_abi.json index 5ec805ca9..7a4947d08 100644 --- a/bridges/ethereum/block_relay_abi.json +++ b/bridges/ethereum/block_relay_abi.json @@ -3,7 +3,8 @@ "inputs": [], "payable": false, "stateMutability": "nonpayable", - "type": "constructor" + "type": "constructor", + "signature": "constructor" }, { "anonymous": false, @@ -22,7 +23,8 @@ } ], "name": "NewBlock", - "type": "event" + "type": "event", + "signature": "0xe1c9ac156359e117ba0744ca389de158e27192cd006ad58e099f4beb0b568e17" }, { "constant": true, @@ -48,7 +50,29 @@ ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0xf25b3f99" + }, + { + "constant": true, + "inputs": [], + "name": "lastBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "blockHash", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "epoch", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x806b984f" }, { "constant": true, @@ -63,129 +87,140 @@ ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0xe987ed58" }, { "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "isUpgradable", + "inputs": [], + "name": "getLastEpoch", "outputs": [ { - "internalType": "bool", + "internalType": "uint256", "name": "", - "type": "bool" + "type": "uint256" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0x398bac63" }, { "constant": true, "inputs": [], - "name": "lastBlock", + "name": "getLastHash", "outputs": [ { "internalType": "uint256", - "name": "blockHash", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", + "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0x4a910046" }, { - "constant": false, + "constant": true, "inputs": [ { - "internalType": "uint256", - "name": "_blockHash", - "type": "uint256" + "internalType": "uint256[]", + "name": "_poi", + "type": "uint256[]" }, { "internalType": "uint256", - "name": "_epoch", + "name": "_blockHash", "type": "uint256" }, { "internalType": "uint256", - "name": "_drMerkleRoot", + "name": "_index", "type": "uint256" }, { "internalType": "uint256", - "name": "_tallyMerkleRoot", + "name": "_element", "type": "uint256" } ], - "name": "postNewBlock", - "outputs": [], + "name": "verifyDrPoi", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], "payable": false, - "stateMutability": "nonpayable", - "type": "function" + "stateMutability": "view", + "type": "function", + "signature": "0x1b58f9c7" }, { "constant": true, "inputs": [ + { + "internalType": "uint256[]", + "name": "_poi", + "type": "uint256[]" + }, { "internalType": "uint256", "name": "_blockHash", "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_element", + "type": "uint256" } ], - "name": "readDrMerkleRoot", + "name": "verifyTallyPoi", "outputs": [ { - "internalType": "uint256", - "name": "drMerkleRoot", - "type": "uint256" + "internalType": "bool", + "name": "", + "type": "bool" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0x9806e62b" }, { "constant": true, "inputs": [ { - "internalType": "uint256", - "name": "_blockHash", - "type": "uint256" + "internalType": "address", + "name": "_address", + "type": "address" } ], - "name": "readTallyMerkleRoot", + "name": "isUpgradable", "outputs": [ { - "internalType": "uint256", - "name": "tallyMerkleRoot", - "type": "uint256" + "internalType": "bool", + "name": "", + "type": "bool" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0xbe2adb35" }, { - "constant": true, + "constant": false, "inputs": [ - { - "internalType": "uint256[]", - "name": "_poi", - "type": "uint256[]" - }, { "internalType": "uint256", "name": "_blockHash", @@ -193,61 +228,69 @@ }, { "internalType": "uint256", - "name": "_index", + "name": "_epoch", "type": "uint256" }, { "internalType": "uint256", - "name": "_element", + "name": "_drMerkleRoot", "type": "uint256" - } - ], - "name": "verifyDrPoi", - "outputs": [ + }, { - "internalType": "bool", - "name": "", - "type": "bool" + "internalType": "uint256", + "name": "_tallyMerkleRoot", + "type": "uint256" } ], + "name": "postNewBlock", + "outputs": [], "payable": false, - "stateMutability": "view", - "type": "function" + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xd2afe01a" }, { "constant": true, "inputs": [ - { - "internalType": "uint256[]", - "name": "_poi", - "type": "uint256[]" - }, { "internalType": "uint256", "name": "_blockHash", "type": "uint256" - }, + } + ], + "name": "readDrMerkleRoot", + "outputs": [ { "internalType": "uint256", - "name": "_index", + "name": "drMerkleRoot", "type": "uint256" - }, + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x98276535" + }, + { + "constant": true, + "inputs": [ { "internalType": "uint256", - "name": "_element", + "name": "_blockHash", "type": "uint256" } ], - "name": "verifyTallyPoi", + "name": "readTallyMerkleRoot", "outputs": [ { - "internalType": "bool", - "name": "", - "type": "bool" + "internalType": "uint256", + "name": "tallyMerkleRoot", + "type": "uint256" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0xfcc770ee" } -] +] \ No newline at end of file diff --git a/bridges/ethereum/src/actors/block_relay_and_poi.rs b/bridges/ethereum/src/actors/block_relay_and_poi.rs index 8659626a2..9276f4e6e 100644 --- a/bridges/ethereum/src/actors/block_relay_and_poi.rs +++ b/bridges/ethereum/src/actors/block_relay_and_poi.rs @@ -30,7 +30,7 @@ pub fn block_relay_and_poi( let eth_account = config.eth_account; let enable_claim_and_inclusion = config.enable_claim_and_inclusion; let enable_result_reporting = config.enable_result_reporting; - let wbi_contract = eth_state.wbi_contract.clone(); + let wrb_contract = eth_state.wrb_contract.clone(); let block_relay_contract = eth_state.block_relay_contract.clone(); let config2 = config.clone(); @@ -66,7 +66,7 @@ pub fn block_relay_and_poi( let block_relay_contract2 = block_relay_contract.clone(); let config2 = config.clone(); - // Post witnet block to BlockRelay wbi_contract + // Post witnet block to BlockRelay wrb_contract tokio::spawn( block_relay_contract .query( @@ -120,9 +120,9 @@ pub fn block_relay_and_poi( }) }) .and_then(move |()| { - eth_state.wbi_requests.read() + eth_state.wrb_requests.read() }) - .and_then(move |wbi_requests| { + .and_then(move |wrb_requests| { let block_hash: U256 = match block.hash() { Hash::SHA256(x) => x.into(), }; @@ -131,8 +131,8 @@ pub fn block_relay_and_poi( let mut including = vec![]; let mut resolving = vec![]; - let claimed_drs = wbi_requests.claimed(); - let waiting_for_tally = wbi_requests.included(); + let claimed_drs = wrb_requests.claimed(); + let waiting_for_tally = wrb_requests.included(); if enable_claim_and_inclusion { for dr in &block.txns.data_request_txns { @@ -163,7 +163,7 @@ pub fn block_relay_and_poi( poi_index, ); info!("[{}] Claimed dr got included in witnet block!", dr_id); - info!("[{}] Sending proof of inclusion to WBI wbi_contract", dr_id); + info!("[{}] Sending proof of inclusion to WRB wrb_contract", dr_id); including.push((*dr_id, poi.clone(), poi_index, block_hash, block_epoch)); } @@ -175,7 +175,7 @@ pub fn block_relay_and_poi( if let Some(dr_id) = waiting_for_tally.get_by_right(&tally.dr_pointer) { let Hash::SHA256(dr_pointer_bytes) = tally.dr_pointer; - info!("[{}] Found tally for data request, posting to WBI", dr_id); + info!("[{}] Found tally for data request, posting to WRB", dr_id); let tally_inclusion_proof = match tally.data_proof_of_inclusion(&block) { Some(x) => x, None => { @@ -207,16 +207,16 @@ pub fn block_relay_and_poi( // Check if we need to acquire a write lock if !including.is_empty() || !resolving.is_empty() { - Either::A(eth_state2.wbi_requests.write().map(move |mut wbi_requests| { + Either::A(eth_state2.wrb_requests.write().map(move |mut wrb_requests| { let config3 = config2.clone(); for (dr_id, poi, poi_index, block_hash, block_epoch) in including { - if wbi_requests.claimed().contains_left(&dr_id) { - wbi_requests.set_including(dr_id, poi.clone(), poi_index, block_hash, block_epoch); - let wbi_requests = eth_state2.wbi_requests.clone(); + if wrb_requests.claimed().contains_left(&dr_id) { + wrb_requests.set_including(dr_id, poi.clone(), poi_index, block_hash, block_epoch); + let wrb_requests = eth_state2.wrb_requests.clone(); let config4 = config3.clone(); let params_str = format!("{:?}", (dr_id, poi.clone(), poi_index, block_hash, block_epoch)); tokio::spawn( - wbi_contract + wrb_contract .call_with_confirmations( "reportDataRequestInclusion", (dr_id, poi, poi_index, block_hash, block_epoch), @@ -235,7 +235,7 @@ pub fn block_relay_and_poi( } Err(e) => { error!("reportDataRequestInclusion{}: {:?}", params_str, e); - Either::B(wbi_requests.write().map(move |mut wbi_requests| wbi_requests.undo_including(dr_id))) + Either::B(wrb_requests.write().map(move |mut wrb_requests| wrb_requests.undo_including(dr_id))) } } }), @@ -243,13 +243,13 @@ pub fn block_relay_and_poi( } } for (dr_id, poi, poi_index, block_hash, block_epoch, result) in resolving { - if wbi_requests.included().contains_left(&dr_id) { - wbi_requests.set_resolving(dr_id, poi.clone(), poi_index, block_hash, block_epoch, result.clone()); - let wbi_requests = eth_state2.wbi_requests.clone(); + if wrb_requests.included().contains_left(&dr_id) { + wrb_requests.set_resolving(dr_id, poi.clone(), poi_index, block_hash, block_epoch, result.clone()); + let wrb_requests = eth_state2.wrb_requests.clone(); let config4 = config3.clone(); let params_str = format!("{:?}", &(dr_id, poi.clone(), poi_index, block_hash, block_epoch, result.clone())); tokio::spawn( - wbi_contract + wrb_contract .call_with_confirmations( "reportResult", (dr_id, poi, poi_index, block_hash, block_epoch, result), @@ -267,7 +267,7 @@ pub fn block_relay_and_poi( } Err(e) => { error!("reportResult{}: {:?}", params_str, e); - Either::B(wbi_requests.write().map(move |mut wbi_requests| wbi_requests.undo_resolving(dr_id))) + Either::B(wrb_requests.write().map(move |mut wrb_requests| wrb_requests.undo_resolving(dr_id))) } } }), diff --git a/bridges/ethereum/src/actors/claim_and_post.rs b/bridges/ethereum/src/actors/claim_and_post.rs index 851e4235d..7b7445b36 100644 --- a/bridges/ethereum/src/actors/claim_and_post.rs +++ b/bridges/ethereum/src/actors/claim_and_post.rs @@ -1,4 +1,4 @@ -//! Actor which tries to claim data requests from WBI and posts them to Witnet +//! Actor which tries to claim data requests from WRB and posts them to Witnet use crate::{actors::handle_receipt, actors::ClaimMsg, config::Config, eth::EthState}; use async_jsonrpc_client::{futures::Stream, transports::tcp::TcpSocket, Transport}; @@ -27,7 +27,7 @@ fn convert_json_array_to_eth_bytes(value: Value) -> Result, [U256; 4], [U256; 2], [U256; 2], [U256; 4], Bytes); -/// Check if we can claim a DR from the WBI locally, +/// Check if we can claim a DR from the WRB locally, /// without sending any transactions to Ethereum, /// and return all the parameters needed for the real transaction fn try_to_claim_local_query( @@ -38,18 +38,18 @@ fn try_to_claim_local_query( ) -> impl Future { let eth_account = config.eth_account; - let wbi_contract = eth_state.wbi_contract.clone(); - let wbi_contract2 = wbi_contract.clone(); - let wbi_contract3 = wbi_contract.clone(); - let wbi_contract5 = wbi_contract.clone(); - let wbi_contract6 = wbi_contract.clone(); - let wbi_contract7 = wbi_contract.clone(); + let wrb_contract = eth_state.wrb_contract.clone(); + let wrb_contract2 = wrb_contract.clone(); + let wrb_contract3 = wrb_contract.clone(); + let wrb_contract5 = wrb_contract.clone(); + let wrb_contract6 = wrb_contract.clone(); + let wrb_contract7 = wrb_contract.clone(); let witnet_client = Arc::clone(&witnet_client); let witnet_client2 = Arc::clone(&witnet_client); let witnet_client3 = Arc::clone(&witnet_client); let witnet_client4 = Arc::clone(&witnet_client); - wbi_contract + wrb_contract .query( "checkDataRequestsClaimability", (vec![dr_id],), @@ -61,7 +61,7 @@ fn try_to_claim_local_query( .and_then(move |claimable: Vec| { match claimable.get(0) { Some(true) => { - Either::A(wbi_contract + Either::A(wrb_contract .query( "readDataRequest", (dr_id,), @@ -126,7 +126,7 @@ fn try_to_claim_local_query( }; Either::A( - wbi_contract2 + wrb_contract2 .query( "getLastBeacon", (), @@ -206,7 +206,7 @@ fn try_to_claim_local_query( info!("[{}] Checking eligibility for claiming dr", dr_id); Box::new( - wbi_contract5 + wrb_contract5 .query( "decodePoint", witnet_pk, @@ -229,7 +229,7 @@ fn try_to_claim_local_query( .and_then(move |(poe, sign_addr, witnet_pk, dr_output, last_beacon)| { Box::new( - wbi_contract6 + wrb_contract6 .query( "decodeProof", poe, @@ -252,7 +252,7 @@ fn try_to_claim_local_query( .and_then(move |(poe, sign_addr, witnet_pk, dr_output, last_beacon)| { Box::new( - wbi_contract7 + wrb_contract7 .query( "computeFastVerifyParams", (witnet_pk, poe, last_beacon), @@ -279,7 +279,7 @@ fn try_to_claim_local_query( // we can bruteforce the v value by setting it to 0, and if it // fails, setting it to 1. sign_addr2.push(0); - let fut1 = wbi_contract3 + let fut1 = wrb_contract3 .query( "claimDataRequests", (vec![dr_id], poe, witnet_pk, u_point, v_point, sign_addr.clone()), @@ -290,7 +290,7 @@ fn try_to_claim_local_query( .map(|_: Token| sign_addr); // If the query fails, we want to retry it with the signature "v" value flipped. *sign_addr2.last_mut().unwrap() ^= 0x01; - let fut2 = wbi_contract3 + let fut2 = wrb_contract3 .query( "claimDataRequests", (vec![dr_id], poe, witnet_pk, u_point, v_point, sign_addr2.clone()), @@ -322,7 +322,7 @@ fn try_to_claim_local_query( }) } -/// Try to claim DR in WBI and post it to Witnet +/// Try to claim DR in WRB and post it to Witnet fn claim_and_post_dr( config: Arc, eth_state: Arc, @@ -333,7 +333,7 @@ fn claim_and_post_dr( let eth_account = config.eth_account; let post_to_witnet_more_than_once = config.post_to_witnet_more_than_once; - let wbi_contract = eth_state.wbi_contract.clone(); + let wrb_contract = eth_state.wrb_contract.clone(); let witnet_client = Arc::clone(&witnet_client); try_to_claim_local_query(config, Arc::clone(ð_state), Arc::clone(&witnet_client), dr_id) @@ -346,12 +346,12 @@ fn claim_and_post_dr( let witnet_client2 = witnet_client.clone(); // Mark the data request as claimed to prevent double claims by other threads - eth_state.wbi_requests.write() - .and_then(move |mut wbi_requests| { - if wbi_requests.posted().contains(&dr_id) { - wbi_requests.set_claiming(dr_id); + eth_state.wrb_requests.write() + .and_then(move |mut wrb_requests| { + if wrb_requests.posted().contains(&dr_id) { + wrb_requests.set_claiming(dr_id); Either::A(futures::finished(())) - } else if post_to_witnet_more_than_once && wbi_requests.claimed().contains_left(&dr_id) { + } else if post_to_witnet_more_than_once && wrb_requests.claimed().contains_left(&dr_id) { // Post dr in witnet again. // This may lead to double spending wits. // This can be useful in the following scenarios: @@ -378,7 +378,7 @@ fn claim_and_post_dr( .and_then(move |()| { let eth_state2 = eth_state.clone(); - wbi_contract + wrb_contract .call_with_confirmations( "claimDataRequests", claim_data_requests_params, @@ -404,14 +404,14 @@ fn claim_and_post_dr( }) }) .and_then(move |()| { - eth_state.wbi_requests.write().map(move |mut wbi_requests| { - wbi_requests.confirm_claim(dr_id, dr_output_hash); + eth_state.wrb_requests.write().map(move |mut wrb_requests| { + wrb_requests.confirm_claim(dr_id, dr_output_hash); }) }) .or_else(move |()| { // Undo the claim - eth_state2.wbi_requests.write().map(move |mut wbi_requests| { - wbi_requests.undo_claim(dr_id); + eth_state2.wrb_requests.write().map(move |mut wrb_requests| { + wrb_requests.undo_claim(dr_id); }).then(|_| { // Short-circuit the and_then cascade Err(()) @@ -435,7 +435,7 @@ fn claim_and_post_dr( }) } -/// Actor which tries to claim data requests from WBI and posts them to Witnet +/// Actor which tries to claim data requests from WRB and posts them to Witnet pub fn claim_and_post( config: Arc, eth_state: Arc, @@ -473,11 +473,11 @@ pub fn claim_and_post( dr_id, )), ClaimMsg::Tick => { - Either::B(eth_state.wbi_requests.read().and_then(move |known_dr_ids| { + Either::B(eth_state.wrb_requests.read().and_then(move |known_dr_ids| { let known_dr_ids_posted = known_dr_ids.posted(); let known_dr_ids_claimed = known_dr_ids.claimed(); debug!( - "Known data requests in WBI: {:?}{:?}", + "Known data requests in WRB: {:?}{:?}", known_dr_ids_posted, known_dr_ids_claimed ); diff --git a/bridges/ethereum/src/actors/eth_event_stream.rs b/bridges/ethereum/src/actors/eth_event_stream.rs index 672de96a5..abe4917eb 100644 --- a/bridges/ethereum/src/actors/eth_event_stream.rs +++ b/bridges/ethereum/src/actors/eth_event_stream.rs @@ -3,7 +3,7 @@ use crate::{ actors::ClaimMsg, config::Config, - eth::{read_u256_from_event_log, EthState, WbiEvent}, + eth::{read_u256_from_event_log, EthState, WrbEvent}, }; use async_jsonrpc_client::futures::Stream; use futures::{future::Either, sink::Sink}; @@ -39,7 +39,7 @@ pub fn eth_event_stream( ))); } - let contract_address = config.wbi_contract_addr; + let contract_address = config.wrb_contract_addr; let eth_event_polling_rate_ms = config.eth_event_polling_rate_ms; let eth_account = config.eth_account; let interval_ms = config.read_dr_hash_interval_ms; @@ -67,17 +67,17 @@ pub fn eth_event_stream( ) .build(); - // Helper function to parse an ethereum event log as one of the possible WBI events - let parse_as_wbi_event = move |value: &web3::types::Log| -> Result { + // Helper function to parse an ethereum event log as one of the possible WRB events + let parse_as_wrb_event = move |value: &web3::types::Log| -> Result { match &value.topics[0] { x if x == &post_dr_event_sig => { - Ok(WbiEvent::PostedRequest(read_u256_from_event_log(&value)?)) + Ok(WrbEvent::PostedRequest(read_u256_from_event_log(&value)?)) } x if x == &inclusion_dr_event_sig => { - Ok(WbiEvent::IncludedRequest(read_u256_from_event_log(&value)?)) + Ok(WrbEvent::IncludedRequest(read_u256_from_event_log(&value)?)) } x if x == &post_tally_event_sig => { - Ok(WbiEvent::PostedResult(read_u256_from_event_log(&value)?)) + Ok(WrbEvent::PostedResult(read_u256_from_event_log(&value)?)) } _ => Err(()), } @@ -99,7 +99,7 @@ pub fn eth_event_stream( Ok(value) => { debug!("Got ethereum event: {:?}", value); - Ok(parse_as_wbi_event(&value)) + Ok(parse_as_wrb_event(&value)) } Err(e) => { error!("ethereum event error = {:?}", e); @@ -112,12 +112,12 @@ pub fn eth_event_stream( let eth_state2 = eth_state.clone(); let fut: Box + Send> = match value { - Ok(WbiEvent::PostedRequest(dr_id)) => { - info!("[{}] New data request posted to WBI", dr_id); + Ok(WrbEvent::PostedRequest(dr_id)) => { + info!("[{}] New data request posted to WRB", dr_id); Box::new( - eth_state.wbi_requests.write().map(move |mut wbi_requests| { - wbi_requests.insert_posted(dr_id); + eth_state.wrb_requests.write().map(move |mut wrb_requests| { + wrb_requests.insert_posted(dr_id); }).and_then(move |()| { tx4.send(ClaimMsg::NewDr(dr_id)) .map(|_| ()) @@ -125,7 +125,7 @@ pub fn eth_event_stream( }) ) } - Ok(WbiEvent::IncludedRequest(dr_id)) => { + Ok(WrbEvent::IncludedRequest(dr_id)) => { let mut retries = 0; Box::new( Interval::new(Instant::now(), Duration::from_millis(interval_ms)) @@ -135,7 +135,7 @@ pub fn eth_event_stream( debug!("[{}] Reading dr_tx_hash for id, try {}", dr_id, retries); retries += 1; - eth_state2.wbi_contract + eth_state2.wrb_contract .query( "readDrHash", (dr_id, ), @@ -155,8 +155,8 @@ pub fn eth_event_stream( "[{}] Data request included in witnet with dr_tx_hash: {}", dr_id, dr_tx_hash ); - Either::B(eth_state2.wbi_requests.write().map(move |mut wbi_requests| { - wbi_requests.insert_included(dr_id, dr_tx_hash); + Either::B(eth_state2.wrb_requests.write().map(move |mut wrb_requests| { + wrb_requests.insert_included(dr_id, dr_tx_hash); }).then(|_| { // Exit interval loop futures::failed(()) @@ -174,13 +174,13 @@ pub fn eth_event_stream( }) ) } - Ok(WbiEvent::PostedResult(dr_id)) => { + Ok(WrbEvent::PostedResult(dr_id)) => { info!("[{}] Data request has been resolved!", dr_id); // TODO: actually get result? let result = vec![]; - Box::new(eth_state.wbi_requests.write().map(move |mut wbi_requests| { - wbi_requests.insert_result(dr_id, result); + Box::new(eth_state.wrb_requests.write().map(move |mut wrb_requests| { + wrb_requests.insert_result(dr_id, result); })) } _ => { diff --git a/bridges/ethereum/src/actors/mod.rs b/bridges/ethereum/src/actors/mod.rs index 47ebc04f2..e91fb7651 100644 --- a/bridges/ethereum/src/actors/mod.rs +++ b/bridges/ethereum/src/actors/mod.rs @@ -8,11 +8,11 @@ pub mod block_relay_check; pub mod claim_and_post; pub mod eth_event_stream; pub mod tally_finder; -pub mod wbi_requests_initial_sync; pub mod witnet_block_stream; +pub mod wrb_requests_initial_sync; /// Message to the claim_and_post actor, which will try to claim data requests from the -/// WBI and post them on Witnet on success +/// WRB and post them on Witnet on success #[derive(Debug)] pub enum ClaimMsg { /// A new data request was just posted, try to claim it @@ -28,7 +28,7 @@ pub enum WitnetBlock { /// Post it to the block relay, and process data requests and tallies. New(Block), /// This old block may have tallies for data requests whose inclusion can - /// be reported to the WBI. + /// be reported to the WRB. /// Process data requests and tallies. Replay(Block), } diff --git a/bridges/ethereum/src/actors/tally_finder.rs b/bridges/ethereum/src/actors/tally_finder.rs index ef0f8358d..9475c7819 100644 --- a/bridges/ethereum/src/actors/tally_finder.rs +++ b/bridges/ethereum/src/actors/tally_finder.rs @@ -32,11 +32,11 @@ pub fn tally_finder( (handle, Interval::new(Instant::now(), Duration::from_millis(config.witnet_dr_report_polling_rate_ms)) .map_err(|e| error!("Error creating interval: {:?}", e)) - .and_then(move |x| eth_state.wbi_requests.read().map(move |wbi_requests| (wbi_requests, x))) - .and_then(move |(wbi_requests, _instant)| { + .and_then(move |x| eth_state.wrb_requests.read().map(move |wrb_requests| (wrb_requests, x))) + .and_then(move |(wrb_requests, _instant)| { debug!("Report tick"); // Try to get the report of a random data request, maybe it already was resolved - let included = wbi_requests.included(); + let included = wrb_requests.included(); debug!("Included data requests: {:?}", included); if included.is_empty() { return Either::A(futures::failed(())); diff --git a/bridges/ethereum/src/actors/wbi_requests_initial_sync.rs b/bridges/ethereum/src/actors/wrb_requests_initial_sync.rs similarity index 84% rename from bridges/ethereum/src/actors/wbi_requests_initial_sync.rs rename to bridges/ethereum/src/actors/wrb_requests_initial_sync.rs index 822f7ee58..e76a8f27b 100644 --- a/bridges/ethereum/src/actors/wbi_requests_initial_sync.rs +++ b/bridges/ethereum/src/actors/wrb_requests_initial_sync.rs @@ -1,4 +1,4 @@ -//! Read all the existing data requests from the WBI +//! Read all the existing data requests from the WRB use crate::{config::Config, eth::EthState}; use async_jsonrpc_client::futures::Stream; @@ -9,16 +9,16 @@ use std::sync::Arc; use web3::{contract, futures::Future, types::U256}; use witnet_data_structures::chain::Hash; -/// Read all the existing data requests from the WBI -pub fn wbi_requests_initial_sync( +/// Read all the existing data requests from the WRB +pub fn wrb_requests_initial_sync( config: Arc, eth_state: Arc, ) -> impl Future { - // On startup, read all the existing data requests in the wbi in order to + // On startup, read all the existing data requests in the wrb in order to // build a local copy and use it for faster queries. // This should be able to run in parallel with the other actors. - let wbi_contract = eth_state.wbi_contract.clone(); - wbi_contract + let wrb_contract = eth_state.wrb_contract.clone(); + wrb_contract .query( "requestsCount", (), @@ -28,7 +28,7 @@ pub fn wbi_requests_initial_sync( ) .map_err(|e| error!("requestsCount: {:?}", e)) .and_then(move |num_requests: U256| { - debug!("{} requests in WBI", num_requests); + debug!("{} requests in WRB", num_requests); let eth_account = config.eth_account; futures::stream::unfold(U256::from(0), move |dr_id| { if dr_id >= num_requests { @@ -38,7 +38,7 @@ pub fn wbi_requests_initial_sync( let eth_state = eth_state.clone(); Some( eth_state - .wbi_contract + .wrb_contract .query( "readResult", (dr_id,), @@ -52,16 +52,16 @@ pub fn wbi_requests_initial_sync( if !result.is_empty() { // In resolved state debug!("[{}] Request has already been resolved", dr_id); - Either::A(eth_state.wbi_requests.write().map( - move |mut wbi_requests| { - wbi_requests.insert_result(dr_id, result); + Either::A(eth_state.wrb_requests.write().map( + move |mut wrb_requests| { + wrb_requests.insert_result(dr_id, result); }, )) } else { // Not in Resolved state Either::B( eth_state - .wbi_contract + .wrb_contract .query( "readDrHash", (dr_id,), @@ -78,11 +78,11 @@ pub fn wbi_requests_initial_sync( "[{}] Request has already been included", dr_id ); - Either::A(eth_state.wbi_requests.write().map( - move |mut wbi_requests| { + Either::A(eth_state.wrb_requests.write().map( + move |mut wrb_requests| { let dr_tx_hash = Hash::SHA256(dr_tx_hash.into()); - wbi_requests + wrb_requests .insert_included(dr_id, dr_tx_hash); }, )) @@ -92,9 +92,9 @@ pub fn wbi_requests_initial_sync( dr_id ); // Not in included state, must be in posted state - Either::B(eth_state.wbi_requests.write().map( - move |mut wbi_requests| { - wbi_requests.insert_posted(dr_id); + Either::B(eth_state.wrb_requests.write().map( + move |mut wrb_requests| { + wrb_requests.insert_posted(dr_id); }, )) } @@ -113,7 +113,7 @@ pub fn wbi_requests_initial_sync( .for_each(|_| Ok(())) }) .then(|_| { - info!("Initial WBI Requests synchronization finished!"); + info!("Initial WRB Requests synchronization finished!"); Ok(()) }) } diff --git a/bridges/ethereum/src/config.rs b/bridges/ethereum/src/config.rs index c64d29c6c..7e02bc6fc 100644 --- a/bridges/ethereum/src/config.rs +++ b/bridges/ethereum/src/config.rs @@ -15,8 +15,8 @@ pub struct Config { pub witnet_jsonrpc_addr: SocketAddr, /// Url of the ethereum client pub eth_client_url: String, - /// Address of the WitnetBridgeInterface deployed contract - pub wbi_contract_addr: H160, + /// Address of the WitnetRequestsBoard deployed contract + pub wrb_contract_addr: H160, /// Address of the BlockRelay deployed contract pub block_relay_contract_addr: H160, /// Ethereum account used to create the transactions diff --git a/bridges/ethereum/src/eth.rs b/bridges/ethereum/src/eth.rs index 9031465fa..ce29b1c77 100644 --- a/bridges/ethereum/src/eth.rs +++ b/bridges/ethereum/src/eth.rs @@ -11,7 +11,7 @@ use web3::{ }; use witnet_data_structures::chain::Hash; -/// State of a data request in the WBI contract, including local intermediate states +/// State of a data request in the WRB contract, including local intermediate states #[derive(Debug)] pub enum DrState { /// The data request was just posted, and may be available for claiming @@ -62,10 +62,10 @@ pub enum DrState { }, } -/// List of all the data requests posted to the WBI, categorized by state. +/// List of all the data requests posted to the WRB, categorized by state. /// This allows for an efficient functionality of the bridge. #[derive(Debug, Default)] -pub struct WbiRequests { +pub struct WrbRequests { requests: HashMap, posted: HashSet, claiming: HashSet, @@ -79,7 +79,7 @@ pub struct WbiRequests { resolved: HashSet, } -impl WbiRequests { +impl WrbRequests { fn remove_from_all_helper_maps(&mut self, dr_id: U256) { self.posted.remove(&dr_id); self.claiming.remove(&dr_id); @@ -99,11 +99,11 @@ impl WbiRequests { self.posted.insert(dr_id); } Some(DrState::Posted) => { - debug!("Invalid state in WbiRequests: [{}] was being set to Posted, but it is already Posted", dr_id); + debug!("Invalid state in WrbRequests: [{}] was being set to Posted, but it is already Posted", dr_id); } _ => { warn!( - "Invalid state in WbiRequests: [{}] was being set to Posted, but it is: {:?}", + "Invalid state in WrbRequests: [{}] was being set to Posted, but it is: {:?}", dr_id, self.requests[&dr_id] ); } @@ -111,7 +111,7 @@ impl WbiRequests { } /// Insert a data request in `Included` state, with the data request /// transaction hash from Witnet stored to allow a map - /// from WBI_dr_id to Witnet_dr_tx_hash + /// from WRB_dr_id to Witnet_dr_tx_hash pub fn insert_included(&mut self, dr_id: U256, dr_tx_hash: Hash) { // This is only safe if the data request was // in a state "before" Included @@ -126,11 +126,11 @@ impl WbiRequests { self.included.insert(dr_id, dr_tx_hash); } Some(DrState::Included) => { - debug!("Invalid state in WbiRequests: [{}] was being set to Included, but it is already Included", dr_id); + debug!("Invalid state in WrbRequests: [{}] was being set to Included, but it is already Included", dr_id); } _ => { warn!( - "Invalid state in WbiRequests: [{}] was being set to Included, but it is: {:?}", + "Invalid state in WrbRequests: [{}] was being set to Included, but it is: {:?}", dr_id, self.requests[&dr_id] ); } @@ -267,8 +267,8 @@ pub struct EthState { pub web3: web3::Web3, /// Accounts pub accounts: Vec, - /// WBI contract - pub wbi_contract: Contract, + /// WRB contract + pub wrb_contract: Contract, /// PostDataRequest event signature pub post_dr_event_sig: H256, /// InclusionDataRequest event signature @@ -277,8 +277,8 @@ pub struct EthState { pub post_tally_event_sig: H256, /// BlockRelay contract pub block_relay_contract: Contract, - /// Internal state of the WBI - pub wbi_requests: RwLock, + /// Internal state of the WRB + pub wrb_requests: RwLock, } impl EthState { @@ -299,12 +299,12 @@ impl EthState { debug!("Web3 accounts: {:?}", accounts); // Why read files at runtime when you can read files at compile time - let wbi_contract_abi_json: &[u8] = include_bytes!("../wbi_abi.json"); - let wbi_contract_abi = ethabi::Contract::load(wbi_contract_abi_json) - .map_err(|e| format!("Unable to load WBI contract from ABI: {:?}", e))?; - let wbi_contract_address = config.wbi_contract_addr; - let wbi_contract = - Contract::new(web3.eth(), wbi_contract_address, wbi_contract_abi.clone()); + let wrb_contract_abi_json: &[u8] = include_bytes!("../wrb_abi.json"); + let wrb_contract_abi = ethabi::Contract::load(wrb_contract_abi_json) + .map_err(|e| format!("Unable to load WRB contract from ABI: {:?}", e))?; + let wrb_contract_address = config.wrb_contract_addr; + let wrb_contract = + Contract::new(web3.eth(), wrb_contract_address, wrb_contract_abi.clone()); let block_relay_contract_abi_json: &[u8] = include_bytes!("../block_relay_abi.json"); let block_relay_contract_abi = ethabi::Contract::load(block_relay_contract_abi_json) @@ -316,16 +316,16 @@ impl EthState { block_relay_contract_abi, ); - debug!("WBI events: {:?}", wbi_contract_abi.events); - let post_dr_event = wbi_contract_abi + debug!("WRB events: {:?}", wrb_contract_abi.events); + let post_dr_event = wrb_contract_abi .event("PostedRequest") .map_err(|e| format!("Unable to get PostedRequest event: {:?}", e))? .clone(); - let inclusion_dr_event = wbi_contract_abi + let inclusion_dr_event = wrb_contract_abi .event("IncludedRequest") .map_err(|e| format!("Unable to get IncludedRequest event: {:?}", e))? .clone(); - let post_tally_event = wbi_contract_abi + let post_tally_event = wrb_contract_abi .event("PostedResult") .map_err(|e| format!("Unable to get PostedResult event: {:?}", e))? .clone(); @@ -334,18 +334,18 @@ impl EthState { let inclusion_dr_event_sig = inclusion_dr_event.signature(); let post_tally_event_sig = post_tally_event.signature(); - let wbi_requests = RwLock::new(Default::default()); + let wrb_requests = RwLock::new(Default::default()); Ok(Self { eloop, web3, accounts, - wbi_contract, + wrb_contract, block_relay_contract, post_dr_event_sig, inclusion_dr_event_sig, post_tally_event_sig, - wbi_requests, + wrb_requests, }) } } @@ -363,8 +363,8 @@ pub fn read_u256_from_event_log(value: &web3::types::Log) -> Result { } } -/// Possible ethereum events emited by the WBI ethereum contract -pub enum WbiEvent { +/// Possible ethereum events emited by the WRB ethereum contract +pub enum WrbEvent { /// A new data request has been posted to ethereum PostedRequest(U256), /// A data request from ethereum has been posted to witnet with a proof of diff --git a/bridges/ethereum/src/main.rs b/bridges/ethereum/src/main.rs index bd1eedafc..2f197ed00 100644 --- a/bridges/ethereum/src/main.rs +++ b/bridges/ethereum/src/main.rs @@ -19,8 +19,8 @@ use witnet_ethereum_bridge::{ claim_and_post::{claim_and_post, claim_ticker}, eth_event_stream::eth_event_stream, tally_finder::tally_finder, - wbi_requests_initial_sync::wbi_requests_initial_sync, witnet_block_stream::witnet_block_stream, + wrb_requests_initial_sync::wrb_requests_initial_sync, }, config::Config, eth::EthState, @@ -59,14 +59,14 @@ fn post_example_dr( config: Arc, eth_state: Arc, ) -> impl Future { - let wbi_contract = eth_state.wbi_contract.clone(); + let wrb_contract = eth_state.wrb_contract.clone(); let data_request_output = data_request_example(); let tally_value = U256::from_dec_str("500000000000000").unwrap(); let data_request_bytes = data_request_output.to_pb_bytes().unwrap(); - wbi_contract + wrb_contract .call( "postDataRequest", (data_request_bytes, tally_value), @@ -79,9 +79,9 @@ fn post_example_dr( }), ) .map(|tx| { - info!("posted dr to wbi: {:?}", tx); + info!("posted dr to wrb: {:?}", tx); }) - .map_err(|e| error!("Error posting dr to wbi: {}", e)) + .map_err(|e| error!("Error posting dr to wrb: {}", e)) } /// Command line usage and flags @@ -120,18 +120,18 @@ fn run() -> Result<(), String> { let eth_state = EthState::create(&config).map(Arc::new)?; if app.post_dr { - // Post example data request to WBI and exit + // Post example data request to WRB and exit let fut = post_example_dr(Arc::clone(&config), Arc::clone(ð_state)); tokio::run(future::ok(()).map(move |_| { tokio::spawn(fut); })); } else { - let wbi_requests_initial_sync_fut = - wbi_requests_initial_sync(Arc::clone(&config), Arc::clone(ð_state)); + let wrb_requests_initial_sync_fut = + wrb_requests_initial_sync(Arc::clone(&config), Arc::clone(ð_state)); if app.read_requests { - // Read all the requests from WBI and exit + // Read all the requests from WRB and exit tokio::run(future::ok(()).map(move |_| { - tokio::spawn(wbi_requests_initial_sync_fut); + tokio::spawn(wrb_requests_initial_sync_fut); })); } else { let (block_relay_check_tx, block_relay_check_fut) = @@ -176,7 +176,7 @@ fn run() -> Result<(), String> { } }; - tokio::spawn(wbi_requests_initial_sync_fut); + tokio::spawn(wrb_requests_initial_sync_fut); if config.subscribe_to_witnet_blocks { tokio::spawn(witnet_event_fut); } diff --git a/bridges/ethereum/wbi_abi.json b/bridges/ethereum/wrb_abi.json similarity index 82% rename from bridges/ethereum/wbi_abi.json rename to bridges/ethereum/wrb_abi.json index 3ce276afc..4f37cba15 100644 --- a/bridges/ethereum/wbi_abi.json +++ b/bridges/ethereum/wrb_abi.json @@ -14,7 +14,8 @@ ], "payable": false, "stateMutability": "nonpayable", - "type": "constructor" + "type": "constructor", + "signature": "constructor" }, { "anonymous": false, @@ -33,7 +34,8 @@ } ], "name": "IncludedRequest", - "type": "event" + "type": "event", + "signature": "0x606da8983234a575e6a11bdee69d011116464a48c9fcaa18f1523046ac6b421e" }, { "anonymous": false, @@ -52,7 +54,8 @@ } ], "name": "PostedRequest", - "type": "event" + "type": "event", + "signature": "0x512c720a10f3b0e3dcf2b8c1eee461d5e2d0ec63f32ec487d83ea4632c5e9913" }, { "anonymous": false, @@ -71,22 +74,108 @@ } ], "name": "PostedResult", - "type": "event" + "type": "event", + "signature": "0x8d8b0475cd196102cef21d842139689bd3544d1bfd4065c8c9ca33e3de5f4a34" }, { "constant": true, - "inputs": [], - "name": "absCount", - "outputs": [ + "inputs": [ { - "internalType": "uint32", + "internalType": "uint256", "name": "", - "type": "uint32" + "type": "uint256" + } + ], + "name": "requests", + "outputs": [ + { + "internalType": "bytes", + "name": "dr", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "inclusionReward", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tallyReward", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "drHash", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "pkhClaim", + "type": "address" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0x81d12c58" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bytes", + "name": "_dr", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "_tallyReward", + "type": "uint256" + } + ], + "name": "postDataRequest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": true, + "stateMutability": "payable", + "type": "function", + "signature": "0xec32e3db" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_tallyReward", + "type": "uint256" + } + ], + "name": "upgradeDataRequest", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function", + "signature": "0x48ab5b65" }, { "constant": true, @@ -107,136 +196,118 @@ ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0x5fb84347" }, { "constant": false, "inputs": [ { - "internalType": "uint256[]", - "name": "_ids", - "type": "uint256[]" - }, - { - "internalType": "uint256[4]", - "name": "_poe", - "type": "uint256[4]" + "internalType": "uint256", + "name": "_id", + "type": "uint256" }, { - "internalType": "uint256[2]", - "name": "_publicKey", - "type": "uint256[2]" + "internalType": "uint256[]", + "name": "_poi", + "type": "uint256[]" }, { - "internalType": "uint256[2]", - "name": "_uPoint", - "type": "uint256[2]" + "internalType": "uint256", + "name": "_index", + "type": "uint256" }, { - "internalType": "uint256[4]", - "name": "_vPointHelpers", - "type": "uint256[4]" + "internalType": "uint256", + "name": "_blockHash", + "type": "uint256" }, { - "internalType": "bytes", - "name": "addrSignature", - "type": "bytes" - } - ], - "name": "claimDataRequests", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" + "internalType": "uint256", + "name": "_epoch", + "type": "uint256" } ], + "name": "reportDataRequestInclusion", + "outputs": [], "payable": false, "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "signature": "0xcbfc2a7c" }, { - "constant": true, + "constant": false, "inputs": [ { - "internalType": "uint256[2]", - "name": "_publicKey", - "type": "uint256[2]" + "internalType": "uint256", + "name": "_id", + "type": "uint256" }, { - "internalType": "uint256[4]", - "name": "_proof", - "type": "uint256[4]" + "internalType": "uint256[]", + "name": "_poi", + "type": "uint256[]" }, { - "internalType": "bytes", - "name": "_message", - "type": "bytes" - } - ], - "name": "computeFastVerifyParams", - "outputs": [ + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, { - "internalType": "uint256[2]", - "name": "", - "type": "uint256[2]" + "internalType": "uint256", + "name": "_blockHash", + "type": "uint256" }, { - "internalType": "uint256[4]", - "name": "", - "type": "uint256[4]" + "internalType": "uint256", + "name": "_epoch", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_result", + "type": "bytes" } ], + "name": "reportResult", + "outputs": [], "payable": false, - "stateMutability": "pure", - "type": "function" + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x8a68f33e" }, { "constant": true, "inputs": [ { - "internalType": "bytes", - "name": "_point", - "type": "bytes" + "internalType": "uint256", + "name": "_id", + "type": "uint256" } ], - "name": "decodePoint", + "name": "readDataRequest", "outputs": [ { - "internalType": "uint256[2]", + "internalType": "bytes", "name": "", - "type": "uint256[2]" + "type": "bytes" } ], "payable": false, - "stateMutability": "pure", - "type": "function" + "stateMutability": "view", + "type": "function", + "signature": "0xc6de1d55" }, { "constant": true, "inputs": [ { - "internalType": "bytes", - "name": "_proof", - "type": "bytes" - } - ], - "name": "decodeProof", - "outputs": [ - { - "internalType": "uint256[4]", - "name": "", - "type": "uint256[4]" + "internalType": "uint256", + "name": "_id", + "type": "uint256" } ], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getLastBeacon", + "name": "readResult", "outputs": [ { "internalType": "bytes", @@ -246,282 +317,265 @@ ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0x45b3d782" }, { "constant": true, "inputs": [ { - "internalType": "address", - "name": "_address", - "type": "address" + "internalType": "uint256", + "name": "_id", + "type": "uint256" } ], - "name": "isABSMember", + "name": "readDrHash", "outputs": [ { - "internalType": "bool", + "internalType": "uint256", "name": "", - "type": "bool" + "type": "uint256" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0x08ba7342" }, { - "constant": false, - "inputs": [ - { - "internalType": "bytes", - "name": "_dr", - "type": "bytes" - }, + "constant": true, + "inputs": [], + "name": "requestsCount", + "outputs": [ { "internalType": "uint256", - "name": "_tallyReward", + "name": "", "type": "uint256" } ], - "name": "postDataRequest", + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xfbfa4b7f" + }, + { + "constant": true, + "inputs": [], + "name": "absCount", "outputs": [ { - "internalType": "uint256", + "internalType": "uint32", "name": "", - "type": "uint256" + "type": "uint32" } ], - "payable": true, - "stateMutability": "payable", - "type": "function" + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xd81b563b" }, { "constant": true, "inputs": [ { - "internalType": "uint256", - "name": "_id", - "type": "uint256" + "internalType": "address", + "name": "_address", + "type": "address" } ], - "name": "readDataRequest", + "name": "isABSMember", "outputs": [ { - "internalType": "bytes", + "internalType": "bool", "name": "", - "type": "bytes" + "type": "bool" } ], "payable": false, "stateMutability": "view", - "type": "function" + "type": "function", + "signature": "0xfdd09acc" }, { "constant": true, "inputs": [ { - "internalType": "uint256", - "name": "_id", - "type": "uint256" + "internalType": "bytes", + "name": "_proof", + "type": "bytes" } ], - "name": "readDrHash", + "name": "decodeProof", "outputs": [ { - "internalType": "uint256", + "internalType": "uint256[4]", "name": "", - "type": "uint256" + "type": "uint256[4]" } ], "payable": false, - "stateMutability": "view", - "type": "function" + "stateMutability": "pure", + "type": "function", + "signature": "0xc9d4ef1f" }, { "constant": true, "inputs": [ { - "internalType": "uint256", - "name": "_id", - "type": "uint256" + "internalType": "bytes", + "name": "_point", + "type": "bytes" } ], - "name": "readResult", + "name": "decodePoint", "outputs": [ { - "internalType": "bytes", + "internalType": "uint256[2]", "name": "", - "type": "bytes" + "type": "uint256[2]" } ], "payable": false, - "stateMutability": "view", - "type": "function" + "stateMutability": "pure", + "type": "function", + "signature": "0x51cdea5f" }, { - "constant": false, + "constant": true, "inputs": [ { - "internalType": "uint256", - "name": "_id", - "type": "uint256" + "internalType": "uint256[2]", + "name": "_publicKey", + "type": "uint256[2]" }, { - "internalType": "uint256[]", - "name": "_poi", - "type": "uint256[]" + "internalType": "uint256[4]", + "name": "_proof", + "type": "uint256[4]" }, { - "internalType": "uint256", - "name": "_index", - "type": "uint256" + "internalType": "bytes", + "name": "_message", + "type": "bytes" + } + ], + "name": "computeFastVerifyParams", + "outputs": [ + { + "internalType": "uint256[2]", + "name": "", + "type": "uint256[2]" }, { - "internalType": "uint256", - "name": "_blockHash", - "type": "uint256" + "internalType": "uint256[4]", + "name": "", + "type": "uint256[4]" } ], - "name": "reportDataRequestInclusion", - "outputs": [], "payable": false, - "stateMutability": "nonpayable", - "type": "function" + "stateMutability": "pure", + "type": "function", + "signature": "0xc95ac47a" }, { "constant": false, "inputs": [ { "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "uint256[]", - "name": "_poi", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "_index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_blockHash", + "name": "_blockNumber", "type": "uint256" - }, - { - "internalType": "bytes", - "name": "_result", - "type": "bytes" } ], - "name": "reportResult", + "name": "updateAbsActivity", "outputs": [], "payable": false, "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "signature": "0xa6e7ad2d" }, { "constant": true, "inputs": [ { - "internalType": "uint256", - "name": "", - "type": "uint256" + "internalType": "address", + "name": "_address", + "type": "address" } ], - "name": "requests", + "name": "isUpgradable", "outputs": [ { - "internalType": "bytes", - "name": "dr", - "type": "bytes" - }, + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xbe2adb35" + }, + { + "constant": false, + "inputs": [ { - "internalType": "uint256", - "name": "inclusionReward", - "type": "uint256" + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" }, { - "internalType": "uint256", - "name": "tallyReward", - "type": "uint256" + "internalType": "uint256[4]", + "name": "_poe", + "type": "uint256[4]" }, { - "internalType": "bytes", - "name": "result", - "type": "bytes" + "internalType": "uint256[2]", + "name": "_publicKey", + "type": "uint256[2]" }, { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" + "internalType": "uint256[2]", + "name": "_uPoint", + "type": "uint256[2]" }, { - "internalType": "uint256", - "name": "drHash", - "type": "uint256" + "internalType": "uint256[4]", + "name": "_vPointHelpers", + "type": "uint256[4]" }, { - "internalType": "address payable", - "name": "pkhClaim", - "type": "address" + "internalType": "bytes", + "name": "addrSignature", + "type": "bytes" } ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "requestsCount", + "name": "claimDataRequests", "outputs": [ { - "internalType": "uint256", + "internalType": "bool", "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "_blockNumber", - "type": "uint256" + "type": "bool" } ], - "name": "updateAbsActivity", - "outputs": [], "payable": false, "stateMutability": "nonpayable", - "type": "function" + "type": "function", + "signature": "0xc9bcae14" }, { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, + "constant": true, + "inputs": [], + "name": "getLastBeacon", + "outputs": [ { - "internalType": "uint256", - "name": "_tallyReward", - "type": "uint256" + "internalType": "bytes", + "name": "", + "type": "bytes" } ], - "name": "upgradeDataRequest", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xe987ed58" } -] +] \ No newline at end of file diff --git a/witnet_ethereum_bridge.toml b/witnet_ethereum_bridge.toml index 2d25869f5..9ccc88ce6 100644 --- a/witnet_ethereum_bridge.toml +++ b/witnet_ethereum_bridge.toml @@ -2,8 +2,8 @@ witnet_jsonrpc_addr = "127.0.0.1:1234" # Url of the ethereum client eth_client_url = "http://127.0.0.1:8545" -# Address of the WitnetBridgeInterface deployed contract -wbi_contract_addr = "0x49824bd89338C26Ea204F20AcbAd404CFeAB3301" +# Address of the WitnetRequestsBoard deployed contract +wrb_contract_addr = "0x49824bd89338C26Ea204F20AcbAd404CFeAB3301" # Address of the BlockRelay deployed contract block_relay_contract_addr = "0x1D774D4D7EC51B111EFE48EB5D53022C3e9CC4Af" # Ethereum account used to create the transactions