Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1eb5720
Add transaction downloader
conradoplg Aug 26, 2021
5f2e744
Changed mempool downloader to be like inbound
conradoplg Aug 27, 2021
8cc6eef
Verifier working (logs result)
conradoplg Aug 27, 2021
345c86d
Apply suggestions from code review
conradoplg Aug 30, 2021
033bb28
Apply suggestions from code review
conradoplg Aug 30, 2021
37ddeb0
Fix coinbase check for mempool, improve is_coinbase() docs
conradoplg Aug 30, 2021
8da4f40
Change other downloads.rs docs to reflect the mempool downloads.rs ch…
conradoplg Aug 30, 2021
a68bf1c
Change TIMEOUTs to downloads.rs; add docs
conradoplg Aug 30, 2021
91e8cfe
Merge remote-tracking branch 'origin/main' into transaction-sync-veri…
conradoplg Aug 30, 2021
5e4488a
Merge branch 'main' into transaction-sync-verifier
conradoplg Aug 30, 2021
315eaf5
Renamed is_coinbase() to has_valid_coinbase_transaction_inputs() and …
conradoplg Aug 31, 2021
bc5fc1f
Merge remote-tracking branch 'origin/main' into transaction-sync-veri…
conradoplg Aug 31, 2021
d90463c
Validate network upgrade for V4 transactions; check before computing …
conradoplg Aug 31, 2021
a3b73f5
Add block_ prefix to downloads and verifier
conradoplg Aug 31, 2021
930ea62
Merge remote-tracking branch 'origin/main' into transaction-sync-veri…
conradoplg Aug 31, 2021
1b01f3c
Update zebra-consensus/src/transaction.rs
conradoplg Sep 1, 2021
6969c31
Add consensus doc; add more Block prefixes
conradoplg Sep 1, 2021
647bcd8
Merge remote-tracking branch 'origin/main' into transaction-sync-veri…
conradoplg Sep 1, 2021
8b06f6d
Merge branch 'main' into transaction-sync-verifier
teor2345 Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
11 changes: 10 additions & 1 deletion zebra-chain/src/transaction/unmined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! unmined transactions. They can be used to handle transactions regardless of version,
//! and get the [`WtxId`] or [`Hash`] when required.

use std::sync::Arc;
use std::{fmt, sync::Arc};

#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
Expand Down Expand Up @@ -93,6 +93,15 @@ impl From<&WtxId> for UnminedTxId {
}
}

impl fmt::Display for UnminedTxId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Legacy(hash) => hash.fmt(f),
Witnessed(id) => id.fmt(f),
}
}
}

impl UnminedTxId {
/// Create a new `UnminedTxId` using a v1-v4 legacy transaction ID.
///
Expand Down
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
2 changes: 1 addition & 1 deletion zebra-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod config;
mod parameters;
mod primitives;
mod script;
mod transaction;
pub mod transaction;

pub mod chain;
#[allow(missing_docs)]
Expand Down
14 changes: 8 additions & 6 deletions zebra-consensus/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Asynchronous verification of transactions.
//!
use std::{
collections::HashMap,
future::Future,
Expand Down Expand Up @@ -50,6 +52,7 @@ where
ZS: Service<zs::Request, Response = zs::Response, Error = BoxError> + Send + Clone + 'static,
ZS::Future: Send + 'static,
{
/// Create a new transaction verifier.
pub fn new(network: Network, script_verifier: script::Verifier<ZS>) -> Self {
Self {
network,
Expand Down Expand Up @@ -165,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 @@ -184,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
3 changes: 2 additions & 1 deletion zebrad/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl StartCmd {

info!("initializing verifiers");
// TODO: use the transaction verifier to verify mempool transactions (#2637, #2606)
let (chain_verifier, _tx_verifier) = zebra_consensus::chain::init(
let (chain_verifier, tx_verifier) = zebra_consensus::chain::init(
config.consensus.clone(),
config.network.network,
state.clone(),
Expand All @@ -75,6 +75,7 @@ impl StartCmd {
setup_rx,
state.clone(),
chain_verifier.clone(),
tx_verifier.clone(),
));

let (peer_set, address_book) =
Expand Down
Loading