Skip to content

Commit

Permalink
Verifier working (logs result)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg committed Aug 27, 2021
1 parent 5f2e744 commit 8cc6eef
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 27 deletions.
207 changes: 207 additions & 0 deletions grafana/transaction_verification.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
{
"__inputs": [
{
"name": "DS_PROMETHEUS-ZEBRA",
"label": "Prometheus-Zebra",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "8.1.2"
},
{
"type": "panel",
"id": "graph",
"name": "Graph (old)",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"iteration": 1630092146360,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 0
},
"hiddenSeries": false,
"id": 6,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.1.2",
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatDirection": "h",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"exemplar": true,
"expr": "rate(gossip_downloaded_transaction_count{job=\"$job\"}[1m]) * 60",
"interval": "",
"legendFormat": "gossip_downloaded_transaction_count per min",
"refId": "C"
},
{
"exemplar": true,
"expr": "rate(gossip_verified_transaction_count{job=\"$job\"}[1m]) * 60",
"interval": "",
"legendFormat": "gossip_verified_transaction_count per min",
"refId": "D"
},
{
"exemplar": true,
"expr": "gossip_queued_transaction_count{job=\"$job\"}",
"interval": "",
"legendFormat": "gossip_queued_transaction_count",
"refId": "E"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Transaction Verifier Gossip Count - $job",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"refresh": "5s",
"schemaVersion": 30,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"allValue": null,
"current": {},
"datasource": "${DS_PROMETHEUS-ZEBRA}",
"definition": "label_values(zcash_chain_verified_block_height, job)",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": null,
"multi": true,
"name": "job",
"options": [],
"query": {
"query": "label_values(zcash_chain_verified_block_height, job)",
"refId": "StandardVariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "transaction verification",
"uid": "oBEHvS4nz",
"version": 2
}
3 changes: 3 additions & 0 deletions zebra-consensus/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub enum TransactionError {
#[error("coinbase transaction MUST NOT have the EnableSpendsOrchard flag set")]
CoinbaseHasEnableSpendsOrchard,

#[error("coinbase transaction MUST NOT exist in mempool")]
CoinbaseInMempool,

#[error("coinbase transaction failed subsidy validation")]
Subsidy(#[from] SubsidyError),

Expand Down
11 changes: 5 additions & 6 deletions zebra-consensus/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ where

// TODO: break up each chunk into its own method
fn call(&mut self, req: Request) -> Self::Future {
if req.is_mempool() {
// XXX determine exactly which rules apply to mempool transactions
unimplemented!("Zebra does not yet have a mempool (#2309)");
}

let script_verifier = self.script_verifier.clone();
let network = self.network;

Expand All @@ -187,7 +182,11 @@ where
check::has_inputs_and_outputs(&tx)?;

if tx.is_coinbase() {
check::coinbase_tx_no_prevout_joinsplit_spend(&tx)?;
if req.is_mempool() {
return Err(TransactionError::CoinbaseInMempool);
} else {
check::coinbase_tx_no_prevout_joinsplit_spend(&tx)?;
}
}

// [Canopy onward]: `vpub_old` MUST be zero.
Expand Down
24 changes: 18 additions & 6 deletions zebrad/src/components/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use zebra_consensus::transaction;
use zebra_consensus::{chain::VerifyChainError, error::TransactionError};
use zebra_network::AddressBook;

use crate::components::sync::{TRANSACTION_DOWNLOAD_TIMEOUT, TRANSACTION_VERIFY_TIMEOUT};

// Re-use the syncer timeouts for consistency.
use super::mempool::downloads::Downloads as TxDownloads;
use super::sync::{BLOCK_DOWNLOAD_TIMEOUT, BLOCK_VERIFY_TIMEOUT};
Expand All @@ -36,7 +38,7 @@ type TxVerifier = Buffer<
transaction::Request,
>;
type InboundDownloads = Downloads<Timeout<Outbound>, Timeout<Verifier>, State>;
type InboundTxDownloads = TxDownloads<Timeout<Outbound>, Timeout<TxVerifier>>;
type InboundTxDownloads = TxDownloads<Timeout<Outbound>, Timeout<TxVerifier>, State>;

pub type NetworkSetupData = (Outbound, Arc<std::sync::Mutex<AddressBook>>);

Expand Down Expand Up @@ -179,8 +181,9 @@ impl Service<zn::Request> for Inbound {
self.state.clone(),
));
let tx_downloads = Box::pin(TxDownloads::new(
Timeout::new(outbound, BLOCK_DOWNLOAD_TIMEOUT),
Timeout::new(tx_verifier, BLOCK_VERIFY_TIMEOUT),
Timeout::new(outbound, TRANSACTION_DOWNLOAD_TIMEOUT),
Timeout::new(tx_verifier, TRANSACTION_VERIFY_TIMEOUT),
self.state.clone(),
));
result = Ok(());
Setup::Initialized {
Expand Down Expand Up @@ -340,9 +343,18 @@ impl Service<zn::Request> for Inbound {
// TODO: send to Tx Download & Verify Stream
async { Ok(zn::Response::Nil) }.boxed()
}
zn::Request::AdvertiseTransactionIds(_transactions) => {
debug!("ignoring unimplemented request");
// TODO: send to Tx Download & Verify Stream
zn::Request::AdvertiseTransactionIds(transactions) => {
if let Setup::Initialized { tx_downloads, .. } = &mut self.network_setup {
// TODO: check if we're close to the tip before proceeding?
// what do we do if it's not?
for txid in transactions {
tx_downloads.download_and_verify(txid);
}
} else {
info!(
"ignoring `AdvertiseTransactionIds` request from remote peer during network setup"
);
}
async { Ok(zn::Response::Nil) }.boxed()
}
zn::Request::AdvertiseBlock(hash) => {
Expand Down
2 changes: 1 addition & 1 deletion zebrad/src/components/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use zebra_chain::{
use crate::BoxError;

mod crawler;
pub mod downloads;
mod error;
mod storage;
pub mod downloads;

#[cfg(test)]
mod tests;
Expand Down
Loading

0 comments on commit 8cc6eef

Please sign in to comment.