Remove the `getblocktemplate-rpcs` Cargo feature (#9401)
* Remove the `getblocktemplate-rpcs` Cargo feature * Keep the feature in `zebrad/Cargo.toml`
This commit is contained in:
parent
0ea5fe076f
commit
4e29b097af
|
@ -430,7 +430,7 @@ jobs:
|
|||
saves_to_disk: false
|
||||
secrets: inherit
|
||||
|
||||
## getblocktemplate-rpcs using cached Zebra state on mainnet
|
||||
## getblocktemplate RPC tests using cached Zebra state on mainnet
|
||||
#
|
||||
# TODO: move these below the rest of the mainnet jobs that just use Zebra cached state
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ The following are general desiderata for Zebra:
|
|||
|
||||
## Service Dependencies
|
||||
|
||||
Note: dotted lines are for "getblocktemplate-rpcs" feature
|
||||
|
||||
<div id="service-dep-diagram">
|
||||
{{#include diagrams/service-dependencies.svg}}
|
||||
</div>
|
||||
|
@ -74,6 +72,8 @@ digraph services {
|
|||
Render here: https://dreampuf.github.io/GraphvizOnline
|
||||
-->
|
||||
|
||||
The dotted lines are for the `getblocktemplate` RPC.
|
||||
|
||||
## Architecture
|
||||
|
||||
Unlike `zcashd`, which originated as a Bitcoin Core fork and inherited its
|
||||
|
|
|
@ -29,10 +29,6 @@ async-error = [
|
|||
"tokio",
|
||||
]
|
||||
|
||||
# Mining RPC support
|
||||
getblocktemplate-rpcs = [
|
||||
]
|
||||
|
||||
# Experimental shielded scanning support
|
||||
shielded-scan = [
|
||||
"zcash_client_backend"
|
||||
|
|
|
@ -14,7 +14,6 @@ mod sighash;
|
|||
mod txid;
|
||||
mod unmined;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub mod builder;
|
||||
|
||||
#[cfg(any(test, feature = "proptest-impl"))]
|
||||
|
|
|
@ -218,7 +218,6 @@ impl Input {
|
|||
/// # Panics
|
||||
///
|
||||
/// If the coinbase data is greater than [`MAX_COINBASE_DATA_LEN`].
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub fn new_coinbase(
|
||||
height: block::Height,
|
||||
data: Option<Vec<u8>>,
|
||||
|
@ -409,7 +408,6 @@ pub struct Output {
|
|||
|
||||
impl Output {
|
||||
/// Returns a new coinbase output that pays `amount` using `lock_script`.
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub fn new_coinbase(amount: Amount<NonNegative>, lock_script: Script) -> Output {
|
||||
Output {
|
||||
value: amount,
|
||||
|
|
|
@ -24,13 +24,6 @@ progress-bar = [
|
|||
"zebra-state/progress-bar",
|
||||
]
|
||||
|
||||
# Mining RPC support
|
||||
getblocktemplate-rpcs = [
|
||||
"zebra-state/getblocktemplate-rpcs",
|
||||
"zebra-node-services/getblocktemplate-rpcs",
|
||||
"zebra-chain/getblocktemplate-rpcs",
|
||||
]
|
||||
|
||||
tx_v6 = ["zebra-chain/tx_v6", "zebra-state/tx_v6"]
|
||||
|
||||
# Test-only features
|
||||
|
|
|
@ -79,7 +79,6 @@ pub enum VerifyBlockError {
|
|||
// TODO: make this into a concrete type, and add it to is_duplicate_request() (#2908)
|
||||
Commit(#[source] BoxError),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[error("unable to validate block proposal: failed semantic verification (proof of work is not checked for proposals): {0}")]
|
||||
// TODO: make this into a concrete type (see #5732)
|
||||
ValidateProposal(#[source] BoxError),
|
||||
|
@ -343,8 +342,7 @@ where
|
|||
deferred_balance: Some(expected_deferred_amount),
|
||||
};
|
||||
|
||||
// Return early for proposal requests when getblocktemplate-rpcs feature is enabled
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
// Return early for proposal requests.
|
||||
if request.is_proposal() {
|
||||
return match state_service
|
||||
.ready()
|
||||
|
|
|
@ -9,8 +9,6 @@ use zebra_chain::block::Block;
|
|||
pub enum Request {
|
||||
/// Performs semantic validation, then asks the state to perform contextual validation and commit the block
|
||||
Commit(Arc<Block>),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Performs semantic validation but skips checking proof of work,
|
||||
/// then asks the state to perform contextual validation.
|
||||
/// Does not commit the block to the state.
|
||||
|
@ -22,8 +20,6 @@ impl Request {
|
|||
pub fn block(&self) -> Arc<Block> {
|
||||
Arc::clone(match self {
|
||||
Request::Commit(block) => block,
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Request::CheckProposal(block) => block,
|
||||
})
|
||||
}
|
||||
|
@ -32,8 +28,6 @@ impl Request {
|
|||
pub fn is_proposal(&self) -> bool {
|
||||
match self {
|
||||
Request::Commit(_) => false,
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Request::CheckProposal(_) => true,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,6 @@ where
|
|||
let block = request.block();
|
||||
|
||||
match block.coinbase_height() {
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
// There's currently no known use case for block proposals below the checkpoint height,
|
||||
// so it's okay to immediately return an error here.
|
||||
Some(height) if height <= self.max_checkpoint_height && request.is_proposal() => {
|
||||
|
|
|
@ -19,11 +19,6 @@ default = []
|
|||
|
||||
# Production features that activate extra dependencies, or extra features in dependencies
|
||||
|
||||
# Mining RPC support
|
||||
getblocktemplate-rpcs = [
|
||||
"zebra-chain/getblocktemplate-rpcs",
|
||||
]
|
||||
|
||||
# Tool and test features
|
||||
|
||||
rpc-client = [
|
||||
|
|
|
@ -65,7 +65,6 @@ pub enum Request {
|
|||
//
|
||||
// TODO: make the Transactions response return VerifiedUnminedTx,
|
||||
// and remove the FullTransactions variant
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
FullTransactions,
|
||||
|
||||
/// Query matching cached rejected transaction IDs in the mempool,
|
||||
|
@ -133,7 +132,6 @@ pub enum Response {
|
|||
//
|
||||
// TODO: make the Transactions response return VerifiedUnminedTx,
|
||||
// and remove the FullTransactions variant
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
FullTransactions {
|
||||
/// All [`VerifiedUnminedTx`]s in the mempool
|
||||
transactions: Vec<VerifiedUnminedTx>,
|
||||
|
|
|
@ -30,16 +30,8 @@ indexer-rpcs = [
|
|||
"zebra-state/indexer"
|
||||
]
|
||||
|
||||
# Production features that activate extra dependencies, or extra features in dependencies
|
||||
|
||||
# Mining RPC support
|
||||
getblocktemplate-rpcs = [
|
||||
"zcash_address",
|
||||
"zebra-consensus/getblocktemplate-rpcs",
|
||||
"zebra-state/getblocktemplate-rpcs",
|
||||
"zebra-node-services/getblocktemplate-rpcs",
|
||||
"zebra-chain/getblocktemplate-rpcs",
|
||||
]
|
||||
# Production features that activate extra dependencies, or extra features in
|
||||
# dependencies
|
||||
|
||||
# Experimental internal miner support
|
||||
internal-miner = []
|
||||
|
@ -93,8 +85,7 @@ nix = { workspace = true, features = ["signal"] }
|
|||
zcash_primitives = { workspace = true, features = ["transparent-inputs"] }
|
||||
zcash_protocol.workspace = true
|
||||
|
||||
# ECC deps used by getblocktemplate-rpcs feature
|
||||
zcash_address = { workspace = true, optional = true}
|
||||
zcash_address = { workspace = true }
|
||||
|
||||
# Test-only feature proptest-impl
|
||||
proptest = { workspace = true, optional = true }
|
||||
|
|
|
@ -80,12 +80,7 @@ impl Default for Config {
|
|||
// Disable indexer RPCs by default.
|
||||
indexer_listen_addr: None,
|
||||
|
||||
// Use a single thread, so we can detect RPC port conflicts.
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
parallel_cpu_threads: 1,
|
||||
|
||||
// Use multiple threads, because we pause requests during getblocktemplate long polling
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
parallel_cpu_threads: 0,
|
||||
|
||||
// Debug options are always off by default.
|
||||
|
|
|
@ -60,14 +60,6 @@ impl Default for Config {
|
|||
}
|
||||
|
||||
impl Config {
|
||||
/// Return true if `getblocktemplate-rpcs` rust feature is not turned on, false otherwise.
|
||||
///
|
||||
/// This is used to ignore the mining section of the configuration if the feature is not
|
||||
/// enabled, allowing us to log a warning when the config found is different from the default.
|
||||
pub fn skip_getblocktemplate(&self) -> bool {
|
||||
!cfg!(feature = "getblocktemplate-rpcs")
|
||||
}
|
||||
|
||||
/// Is the internal miner enabled using at least one thread?
|
||||
#[cfg(feature = "internal-miner")]
|
||||
pub fn is_internal_miner_enabled(&self) -> bool {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
//! Some parts of the `zcashd` RPC documentation are outdated.
|
||||
//! So this implementation follows the `zcashd` server and `lightwalletd` client implementations.
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use std::collections::HashMap;
|
||||
use std::{collections::HashSet, fmt::Debug, sync::Arc};
|
||||
|
||||
|
@ -63,13 +62,10 @@ pub mod trees;
|
|||
pub mod types;
|
||||
|
||||
use types::GetRawMempool;
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use types::MempoolObject;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub mod get_block_template_rpcs;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub use get_block_template_rpcs::{GetBlockTemplateRpcImpl, GetBlockTemplateRpcServer};
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -1140,25 +1136,19 @@ where
|
|||
#[allow(unused)]
|
||||
let verbose = verbose.unwrap_or(false);
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use zebra_chain::block::MAX_BLOCK_BYTES;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
// Determines whether the output of this RPC is sorted like zcashd
|
||||
let should_use_zcashd_order = self.debug_like_zcashd;
|
||||
|
||||
let mut mempool = self.mempool.clone();
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
let request = if should_use_zcashd_order || verbose {
|
||||
mempool::Request::FullTransactions
|
||||
} else {
|
||||
mempool::Request::TransactionIds
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
let request = mempool::Request::TransactionIds;
|
||||
|
||||
// `zcashd` doesn't check if it is synced to the tip here, so we don't either.
|
||||
let response = mempool
|
||||
.ready()
|
||||
|
@ -1167,7 +1157,6 @@ where
|
|||
.map_misc_error()?;
|
||||
|
||||
match response {
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
mempool::Response::FullTransactions {
|
||||
mut transactions,
|
||||
transaction_dependencies,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! RPC methods related to mining only available with `getblocktemplate-rpcs` rust feature.
|
||||
//! Mining-related RPCs.
|
||||
|
||||
use std::{fmt::Debug, sync::Arc, time::Duration};
|
||||
|
||||
|
@ -83,10 +83,6 @@ pub trait GetBlockTemplateRpc {
|
|||
/// zcashd reference: [`getblockcount`](https://zcash.github.io/rpc/getblockcount.html)
|
||||
/// method: post
|
||||
/// tags: blockchain
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
/// This rpc method is available only if zebra is built with `--features getblocktemplate-rpcs`.
|
||||
#[method(name = "getblockcount")]
|
||||
fn get_block_count(&self) -> Result<u32>;
|
||||
|
||||
|
@ -105,7 +101,6 @@ pub trait GetBlockTemplateRpc {
|
|||
///
|
||||
/// - If `index` is positive then index = block height.
|
||||
/// - If `index` is negative then -1 is the last known valid block.
|
||||
/// - This rpc method is available only if zebra is built with `--features getblocktemplate-rpcs`.
|
||||
#[method(name = "getblockhash")]
|
||||
async fn get_block_hash(&self, index: i32) -> Result<GetBlockHash>;
|
||||
|
||||
|
@ -130,8 +125,6 @@ pub trait GetBlockTemplateRpc {
|
|||
///
|
||||
/// Zebra verifies blocks in parallel, and keeps recent chains in parallel,
|
||||
/// so moving between chains and forking chains is very cheap.
|
||||
///
|
||||
/// This rpc method is available only if zebra is built with `--features getblocktemplate-rpcs`.
|
||||
#[method(name = "getblocktemplate")]
|
||||
async fn get_block_template(
|
||||
&self,
|
||||
|
@ -218,10 +211,6 @@ pub trait GetBlockTemplateRpc {
|
|||
/// # Parameters
|
||||
///
|
||||
/// - `address`: (string, required) The zcash address to validate.
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
/// - No notes
|
||||
#[method(name = "validateaddress")]
|
||||
async fn validate_address(&self, address: String) -> Result<validate_address::Response>;
|
||||
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
mod prop;
|
||||
mod snapshot;
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub mod utils;
|
||||
mod vectors;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
//! Randomised property tests for RPC methods.
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use std::collections::HashMap;
|
||||
use std::{collections::HashSet, fmt::Debug, sync::Arc};
|
||||
|
||||
|
@ -30,7 +29,6 @@ use zebra_state::{BoxError, GetBlockTemplateChainInfo};
|
|||
|
||||
use zebra_test::mock_service::MockService;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use crate::methods::types::MempoolObject;
|
||||
use crate::methods::{
|
||||
self,
|
||||
|
@ -246,28 +244,7 @@ proptest! {
|
|||
tokio::time::pause();
|
||||
|
||||
runtime.block_on(async move {
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
let (expected_response, mempool_query) = {
|
||||
let transaction_ids: HashSet<_> = transactions
|
||||
.iter()
|
||||
.map(|tx| tx.transaction.id)
|
||||
.collect();
|
||||
|
||||
let mut expected_response: Vec<String> = transaction_ids
|
||||
.iter()
|
||||
.map(|id| id.mined_id().encode_hex())
|
||||
.collect();
|
||||
expected_response.sort();
|
||||
|
||||
let mempool_query = mempool
|
||||
.expect_request(mempool::Request::TransactionIds)
|
||||
.map_ok(|r|r.respond(mempool::Response::TransactionIds(transaction_ids)));
|
||||
|
||||
(GetRawMempool::TxIds(expected_response), mempool_query)
|
||||
};
|
||||
|
||||
// Note: this depends on `SHOULD_USE_ZCASHD_ORDER` being true.
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
let (expected_response, mempool_query) = {
|
||||
let mut expected_response = transactions.clone();
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ use zebra_test::mock_service::MockService;
|
|||
|
||||
use super::super::*;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
mod get_block_template_rpcs;
|
||||
|
||||
/// The first block height in the state that can never be stored in the database,
|
||||
|
@ -180,8 +179,8 @@ async fn test_rpc_response_data_for_network(network: &Network) {
|
|||
|
||||
let mut mempool: MockService<_, _, _, zebra_node_services::BoxError> =
|
||||
MockService::build().for_unit_tests();
|
||||
|
||||
// Create a populated state service
|
||||
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
|
||||
let (state, read_state, latest_chain_tip, _chain_tip_change) =
|
||||
zebra_state::populated_state(blocks.clone(), network).await;
|
||||
|
||||
|
@ -189,8 +188,7 @@ async fn test_rpc_response_data_for_network(network: &Network) {
|
|||
let mut settings = insta::Settings::clone_current();
|
||||
settings.set_snapshot_suffix(format!("{}_{}", network_string(network), blocks.len() - 1));
|
||||
|
||||
// Test getblocktemplate-rpcs snapshots
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
// Test the `getblocktemplate` RPC snapshots.
|
||||
get_block_template_rpcs::test_responses(
|
||||
network,
|
||||
mempool.clone(),
|
||||
|
@ -388,7 +386,6 @@ async fn test_rpc_response_data_for_network(network: &Network) {
|
|||
// - as we have the mempool mocked we need to expect a request and wait for a response,
|
||||
// which will be an empty mempool in this case.
|
||||
// Note: this depends on `SHOULD_USE_ZCASHD_ORDER` being true.
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
let mempool_req = mempool
|
||||
.expect_request_that(|request| matches!(request, mempool::Request::FullTransactions))
|
||||
.map(|responder| {
|
||||
|
@ -399,15 +396,6 @@ async fn test_rpc_response_data_for_network(network: &Network) {
|
|||
});
|
||||
});
|
||||
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
let mempool_req = mempool
|
||||
.expect_request_that(|request| matches!(request, mempool::Request::TransactionIds))
|
||||
.map(|responder| {
|
||||
responder.respond(mempool::Response::TransactionIds(
|
||||
std::collections::HashSet::new(),
|
||||
));
|
||||
});
|
||||
|
||||
// make the api call
|
||||
let get_raw_mempool = rpc.get_raw_mempool(None);
|
||||
let (response, _) = futures::join!(get_raw_mempool, mempool_req);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! To update these snapshots, run:
|
||||
//! ```sh
|
||||
//! cargo insta test --review --features getblocktemplate-rpcs --delete-unreferenced-snapshots
|
||||
//! cargo insta test --review --delete-unreferenced-snapshots
|
||||
//! ```
|
||||
|
||||
use std::{
|
||||
|
|
|
@ -1255,7 +1255,6 @@ async fn rpc_getaddressutxos_response() {
|
|||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn rpc_getblockcount() {
|
||||
use zebra_chain::chain_sync_status::MockSyncStatus;
|
||||
use zebra_network::address_book_peers::MockAddressBookPeers;
|
||||
|
@ -1315,7 +1314,6 @@ async fn rpc_getblockcount() {
|
|||
mempool.expect_no_requests().await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_getblockcount_empty_state() {
|
||||
use zebra_chain::chain_sync_status::MockSyncStatus;
|
||||
|
@ -1369,7 +1367,6 @@ async fn rpc_getblockcount_empty_state() {
|
|||
mempool.expect_no_requests().await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_getpeerinfo() {
|
||||
use zebra_chain::chain_sync_status::MockSyncStatus;
|
||||
|
@ -1487,7 +1484,6 @@ async fn rpc_getpeerinfo() {
|
|||
mempool.expect_no_requests().await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_getblockhash() {
|
||||
use zebra_chain::chain_sync_status::MockSyncStatus;
|
||||
|
@ -1557,7 +1553,6 @@ async fn rpc_getblockhash() {
|
|||
mempool.expect_no_requests().await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_getmininginfo() {
|
||||
use zebra_chain::chain_sync_status::MockSyncStatus;
|
||||
|
@ -1594,7 +1589,6 @@ async fn rpc_getmininginfo() {
|
|||
.expect("get_mining_info call should succeed");
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_getnetworksolps() {
|
||||
use zebra_chain::chain_sync_status::MockSyncStatus;
|
||||
|
@ -1663,7 +1657,6 @@ async fn rpc_getnetworksolps() {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_getblocktemplate() {
|
||||
// test getblocktemplate with a miner P2SH address
|
||||
|
@ -1672,7 +1665,6 @@ async fn rpc_getblocktemplate() {
|
|||
rpc_getblocktemplate_mining_address(false).await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn rpc_getblocktemplate_mining_address(use_p2pkh: bool) {
|
||||
use zebra_chain::{
|
||||
amount::NonNegative,
|
||||
|
@ -2006,7 +1998,6 @@ async fn rpc_getblocktemplate_mining_address(use_p2pkh: bool) {
|
|||
mempool.expect_no_requests().await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_submitblock_errors() {
|
||||
use zebra_chain::chain_sync_status::MockSyncStatus;
|
||||
|
@ -2082,7 +2073,6 @@ async fn rpc_submitblock_errors() {
|
|||
// See zebrad::tests::acceptance::submit_block for success case.
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_validateaddress() {
|
||||
use get_block_template_rpcs::types::validate_address;
|
||||
|
@ -2128,7 +2118,6 @@ async fn rpc_validateaddress() {
|
|||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_z_validateaddress() {
|
||||
use get_block_template_rpcs::types::z_validate_address;
|
||||
|
@ -2174,7 +2163,6 @@ async fn rpc_z_validateaddress() {
|
|||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_getdifficulty() {
|
||||
use zebra_chain::{
|
||||
|
@ -2338,7 +2326,6 @@ async fn rpc_getdifficulty() {
|
|||
assert_eq!(format!("{:.2}", get_difficulty.unwrap()), "4096.00");
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn rpc_z_listunifiedreceivers() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
//! Types used in `getrawmempool` RPC method.
|
||||
|
||||
use std::collections::HashMap;
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use hex::ToHex as _;
|
||||
|
||||
use super::Zec;
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use zebra_chain::transaction::VerifiedUnminedTx;
|
||||
use zebra_chain::{amount::NonNegative, block::Height};
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use zebra_node_services::mempool::TransactionDependencies;
|
||||
|
||||
/// Response to a `getrawmempool` RPC request.
|
||||
|
@ -55,7 +51,6 @@ pub struct MempoolObject {
|
|||
}
|
||||
|
||||
impl MempoolObject {
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub(crate) fn from_verified_unmined_tx(
|
||||
unmined_tx: &VerifiedUnminedTx,
|
||||
transactions: &[VerifiedUnminedTx],
|
||||
|
|
|
@ -31,7 +31,6 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use crate::methods::{GetBlockTemplateRpcImpl, GetBlockTemplateRpcServer};
|
||||
|
||||
pub mod cookie;
|
||||
|
@ -106,21 +105,16 @@ impl RpcServer {
|
|||
AddressBook,
|
||||
>(
|
||||
config: Config,
|
||||
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
|
||||
mining_config: crate::config::mining::Config,
|
||||
build_version: VersionString,
|
||||
user_agent: UserAgentString,
|
||||
mempool: Mempool,
|
||||
state: State,
|
||||
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
|
||||
block_verifier_router: BlockVerifierRouter,
|
||||
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
|
||||
sync_status: SyncStatus,
|
||||
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
|
||||
address_book: AddressBook,
|
||||
latest_chain_tip: Tip,
|
||||
network: Network,
|
||||
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
|
||||
mined_block_sender: Option<watch::Sender<(block::Hash, block::Height)>>,
|
||||
last_event: LoggedLastEvent,
|
||||
) -> Result<(ServerTask, JoinHandle<()>), tower::BoxError>
|
||||
|
@ -162,7 +156,6 @@ impl RpcServer {
|
|||
.listen_addr
|
||||
.expect("caller should make sure listen_addr is set");
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
// Initialize the getblocktemplate rpc method handler
|
||||
let get_block_template_rpc_impl = GetBlockTemplateRpcImpl::new(
|
||||
&network,
|
||||
|
@ -182,10 +175,7 @@ impl RpcServer {
|
|||
user_agent,
|
||||
network.clone(),
|
||||
config.debug_force_finished_sync,
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
mining_config.debug_like_zcashd,
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
true,
|
||||
mempool,
|
||||
state,
|
||||
latest_chain_tip,
|
||||
|
@ -220,11 +210,7 @@ impl RpcServer {
|
|||
.expect("Unable to get local address");
|
||||
info!("{OPENED_RPC_ENDPOINT_MSG}{}", addr);
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
let mut rpc_module = rpc_impl.into_rpc();
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
let rpc_module = rpc_impl.into_rpc();
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
rpc_module
|
||||
.merge(get_block_template_rpc_impl.into_rpc())
|
||||
.unwrap();
|
||||
|
|
|
@ -70,7 +70,6 @@ pub(crate) trait MapError<T>: Sized {
|
|||
fn map_error(self, code: impl Into<ErrorCode>) -> std::result::Result<T, ErrorObjectOwned>;
|
||||
|
||||
/// Maps errors to [`jsonrpsee_types::ErrorObjectOwned`] with a prefixed message and a specific error code.
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
fn map_error_with_prefix(
|
||||
self,
|
||||
code: impl Into<ErrorCode>,
|
||||
|
@ -107,7 +106,6 @@ where
|
|||
self.map_err(|error| ErrorObject::owned(code.into().code(), error.to_string(), None::<()>))
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
fn map_error_with_prefix(
|
||||
self,
|
||||
code: impl Into<ErrorCode>,
|
||||
|
|
|
@ -22,11 +22,6 @@ progress-bar = [
|
|||
"howudoin",
|
||||
]
|
||||
|
||||
# Mining RPC support
|
||||
getblocktemplate-rpcs = [
|
||||
"zebra-chain/getblocktemplate-rpcs",
|
||||
]
|
||||
|
||||
# Indexes spending transaction ids by spent outpoints and revealed nullifiers
|
||||
indexer = []
|
||||
|
||||
|
|
|
@ -860,7 +860,6 @@ pub enum Request {
|
|||
/// Returns [`Response::KnownBlock(None)`](Response::KnownBlock) otherwise.
|
||||
KnownBlock(block::Hash),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Performs contextual validation of the given block, but does not commit it to the state.
|
||||
///
|
||||
/// Returns [`Response::ValidBlockProposal`] when successful.
|
||||
|
@ -891,7 +890,6 @@ impl Request {
|
|||
Request::BestChainNextMedianTimePast => "best_chain_next_median_time_past",
|
||||
Request::BestChainBlockHash(_) => "best_chain_block_hash",
|
||||
Request::KnownBlock(_) => "known_block",
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Request::CheckBlockProposalValidity(_) => "check_block_proposal_validity",
|
||||
}
|
||||
}
|
||||
|
@ -1160,7 +1158,6 @@ pub enum ReadRequest {
|
|||
/// best chain state information.
|
||||
ChainInfo,
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Get the average solution rate in the best chain.
|
||||
///
|
||||
/// Returns [`ReadResponse::SolutionRate`]
|
||||
|
@ -1172,7 +1169,6 @@ pub enum ReadRequest {
|
|||
height: Option<block::Height>,
|
||||
},
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Performs contextual validation of the given block, but does not commit it to the state.
|
||||
///
|
||||
/// It is the caller's responsibility to perform semantic validation.
|
||||
|
@ -1182,7 +1178,6 @@ pub enum ReadRequest {
|
|||
/// the block fails contextual validation.
|
||||
CheckBlockProposalValidity(SemanticallyVerifiedBlock),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Returns [`ReadResponse::TipBlockSize(usize)`](ReadResponse::TipBlockSize)
|
||||
/// with the current best chain tip block size in bytes.
|
||||
TipBlockSize,
|
||||
|
@ -1220,11 +1215,8 @@ impl ReadRequest {
|
|||
#[cfg(feature = "indexer")]
|
||||
ReadRequest::SpendingTransactionId(_) => "spending_transaction_id",
|
||||
ReadRequest::ChainInfo => "chain_info",
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadRequest::SolutionRate { .. } => "solution_rate",
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadRequest::CheckBlockProposalValidity(_) => "check_block_proposal_validity",
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadRequest::TipBlockSize => "tip_block_size",
|
||||
}
|
||||
}
|
||||
|
@ -1282,7 +1274,6 @@ impl TryFrom<Request> for ReadRequest {
|
|||
|
||||
Request::KnownBlock(_) => Err("ReadService does not track queued blocks"),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Request::CheckBlockProposalValidity(semantically_verified) => Ok(
|
||||
ReadRequest::CheckBlockProposalValidity(semantically_verified),
|
||||
),
|
||||
|
|
|
@ -90,7 +90,6 @@ pub enum Response {
|
|||
/// Response to [`Request::KnownBlock`].
|
||||
KnownBlock(Option<KnownBlock>),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Response to [`Request::CheckBlockProposalValidity`]
|
||||
ValidBlockProposal,
|
||||
}
|
||||
|
@ -254,15 +253,12 @@ pub enum ReadResponse {
|
|||
/// information needed by the `getblocktemplate` RPC method.
|
||||
ChainInfo(GetBlockTemplateChainInfo),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Response to [`ReadRequest::SolutionRate`]
|
||||
SolutionRate(Option<u128>),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Response to [`ReadRequest::CheckBlockProposalValidity`]
|
||||
ValidBlockProposal,
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
/// Response to [`ReadRequest::TipBlockSize`]
|
||||
TipBlockSize(Option<usize>),
|
||||
}
|
||||
|
@ -362,10 +358,8 @@ impl TryFrom<ReadResponse> for Response {
|
|||
#[cfg(feature = "indexer")]
|
||||
ReadResponse::TransactionId(_) => Err("there is no corresponding Response for this ReadResponse"),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadResponse::ValidBlockProposal => Ok(Response::ValidBlockProposal),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadResponse::SolutionRate(_) | ReadResponse::TipBlockSize(_) => {
|
||||
Err("there is no corresponding Response for this ReadResponse")
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ use zebra_chain::{
|
|||
subtree::NoteCommitmentSubtreeIndex,
|
||||
};
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use zebra_chain::{block::Height, serialization::ZcashSerialize};
|
||||
|
||||
use crate::{
|
||||
|
@ -1113,7 +1112,6 @@ impl Service<Request> for StateService {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Request::CheckBlockProposalValidity(_) => {
|
||||
// Redirect the request to the concurrent ReadStateService
|
||||
let read_service = self.read_service.clone();
|
||||
|
@ -1894,7 +1892,6 @@ impl Service<ReadRequest> for ReadStateService {
|
|||
}
|
||||
|
||||
// Used by getmininginfo, getnetworksolps, and getnetworkhashps RPCs.
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadRequest::SolutionRate { num_blocks, height } => {
|
||||
let state = self.clone();
|
||||
|
||||
|
@ -1946,7 +1943,6 @@ impl Service<ReadRequest> for ReadStateService {
|
|||
.wait_for_panics()
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadRequest::CheckBlockProposalValidity(semantically_verified) => {
|
||||
let state = self.clone();
|
||||
|
||||
|
@ -1994,7 +1990,6 @@ impl Service<ReadRequest> for ReadStateService {
|
|||
.wait_for_panics()
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
ReadRequest::TipBlockSize => {
|
||||
let state = self.clone();
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ pub struct NonFinalizedState {
|
|||
/// with a commit to a cloned non-finalized state.
|
||||
//
|
||||
// TODO: make this field private and set it via an argument to NonFinalizedState::new()
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
should_count_metrics: bool,
|
||||
|
||||
/// Number of chain forks transmitter.
|
||||
|
@ -87,7 +86,6 @@ impl std::fmt::Debug for NonFinalizedState {
|
|||
f.field("chain_set", &self.chain_set)
|
||||
.field("network", &self.network);
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
f.field("should_count_metrics", &self.should_count_metrics);
|
||||
|
||||
f.finish()
|
||||
|
@ -100,14 +98,10 @@ impl Clone for NonFinalizedState {
|
|||
chain_set: self.chain_set.clone(),
|
||||
network: self.network.clone(),
|
||||
invalidated_blocks: self.invalidated_blocks.clone(),
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
should_count_metrics: self.should_count_metrics,
|
||||
|
||||
// Don't track progress in clones.
|
||||
#[cfg(feature = "progress-bar")]
|
||||
chain_count_bar: None,
|
||||
|
||||
#[cfg(feature = "progress-bar")]
|
||||
chain_fork_length_bars: Vec::new(),
|
||||
}
|
||||
|
@ -121,7 +115,6 @@ impl NonFinalizedState {
|
|||
chain_set: Default::default(),
|
||||
network: network.clone(),
|
||||
invalidated_blocks: Default::default(),
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
should_count_metrics: true,
|
||||
#[cfg(feature = "progress-bar")]
|
||||
chain_count_bar: None,
|
||||
|
@ -753,13 +746,8 @@ impl NonFinalizedState {
|
|||
}
|
||||
|
||||
/// Should this `NonFinalizedState` instance track metrics and progress bars?
|
||||
#[allow(dead_code)]
|
||||
fn should_count_metrics(&self) -> bool {
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
return self.should_count_metrics;
|
||||
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
return true;
|
||||
self.should_count_metrics
|
||||
}
|
||||
|
||||
/// Update the metrics after `block` is committed
|
||||
|
@ -901,10 +889,7 @@ impl NonFinalizedState {
|
|||
|
||||
/// Stop tracking metrics for this non-finalized state and all its chains.
|
||||
pub fn disable_metrics(&mut self) {
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
{
|
||||
self.should_count_metrics = false;
|
||||
}
|
||||
self.should_count_metrics = false;
|
||||
|
||||
#[cfg(feature = "progress-bar")]
|
||||
{
|
||||
|
|
|
@ -34,7 +34,6 @@ required-features = ["search-issue-refs"]
|
|||
name = "block-template-to-proposal"
|
||||
# this setting is required for Zebra's Docker build caches
|
||||
path = "src/bin/block-template-to-proposal/main.rs"
|
||||
required-features = ["getblocktemplate-rpcs"]
|
||||
|
||||
[[bin]]
|
||||
name = "openapi-generator"
|
||||
|
@ -59,13 +58,6 @@ search-issue-refs = [
|
|||
"tokio"
|
||||
]
|
||||
|
||||
# block-template-to-proposal uses the experimental mining RPC support feature name
|
||||
getblocktemplate-rpcs = [
|
||||
"zebra-rpc/getblocktemplate-rpcs",
|
||||
"zebra-node-services/getblocktemplate-rpcs",
|
||||
"zebra-chain/getblocktemplate-rpcs",
|
||||
]
|
||||
|
||||
shielded-scan = [
|
||||
"itertools",
|
||||
"jsonrpc",
|
||||
|
@ -74,7 +66,6 @@ shielded-scan = [
|
|||
]
|
||||
|
||||
openapi-generator = [
|
||||
"zebra-rpc",
|
||||
"syn",
|
||||
"quote",
|
||||
"serde_yml",
|
||||
|
@ -98,7 +89,7 @@ zebra-node-services = { path = "../zebra-node-services", version = "1.0.0-beta.4
|
|||
zebra-chain = { path = "../zebra-chain", version = "1.0.0-beta.45" }
|
||||
|
||||
# These crates are needed for the block-template-to-proposal binary
|
||||
zebra-rpc = { path = "../zebra-rpc", version = "1.0.0-beta.45", optional = true }
|
||||
zebra-rpc = { path = "../zebra-rpc", version = "1.0.0-beta.45" }
|
||||
|
||||
# These crates are needed for the zebra-checkpoints binary
|
||||
itertools = { workspace = true, optional = true }
|
||||
|
|
|
@ -49,12 +49,11 @@ features = [
|
|||
"prometheus",
|
||||
"sentry",
|
||||
"indexer",
|
||||
"getblocktemplate-rpcs"
|
||||
]
|
||||
|
||||
[features]
|
||||
# In release builds, don't compile debug logging code, to improve performance.
|
||||
default = ["release_max_level_info", "progress-bar", "getblocktemplate-rpcs"]
|
||||
default = ["release_max_level_info", "progress-bar"]
|
||||
|
||||
# Default features for official ZF binary release builds
|
||||
default-release-binaries = ["default", "sentry"]
|
||||
|
@ -64,14 +63,8 @@ default-release-binaries = ["default", "sentry"]
|
|||
# Indexer support
|
||||
indexer = ["zebra-rpc/indexer-rpcs", "zebra-state/indexer"]
|
||||
|
||||
# Mining RPC support
|
||||
getblocktemplate-rpcs = [
|
||||
"zebra-rpc/getblocktemplate-rpcs",
|
||||
"zebra-consensus/getblocktemplate-rpcs",
|
||||
"zebra-state/getblocktemplate-rpcs",
|
||||
"zebra-node-services/getblocktemplate-rpcs",
|
||||
"zebra-chain/getblocktemplate-rpcs",
|
||||
]
|
||||
# TODO: Remove this feature when releasing Zebra 3.0 (#9412).
|
||||
getblocktemplate-rpcs = []
|
||||
|
||||
# Experimental internal miner support
|
||||
internal-miner = [
|
||||
|
@ -79,7 +72,6 @@ internal-miner = [
|
|||
"zebra-chain/internal-miner",
|
||||
# TODO: move common code into zebra-chain or zebra-node-services and remove the RPC dependency
|
||||
"zebra-rpc/internal-miner",
|
||||
"zebra-rpc/getblocktemplate-rpcs",
|
||||
]
|
||||
|
||||
# Experimental elasticsearch indexing
|
||||
|
|
|
@ -86,7 +86,6 @@ use zebra_chain::block::genesis::regtest_genesis_block;
|
|||
use zebra_consensus::{router::BackgroundTaskHandles, ParameterCheckpoint};
|
||||
use zebra_rpc::server::RpcServer;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use zebra_rpc::methods::get_block_template_rpcs::types::submit_block::SubmitBlockChannel;
|
||||
|
||||
use crate::{
|
||||
|
@ -240,15 +239,6 @@ impl StartCmd {
|
|||
// And give it time to clear its queue
|
||||
tokio::task::yield_now().await;
|
||||
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
if config.mining != zebra_rpc::config::mining::Config::default() {
|
||||
warn!(
|
||||
"Unused mining section in config,\
|
||||
compile with 'getblocktemplate-rpcs' feature to use mining RPCs"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
// Create a channel to send mined blocks to the gossip task
|
||||
let submit_block_channel = SubmitBlockChannel::new();
|
||||
|
||||
|
@ -269,10 +259,7 @@ impl StartCmd {
|
|||
address_book.clone(),
|
||||
latest_chain_tip.clone(),
|
||||
config.network.network.clone(),
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Some(submit_block_channel.sender()),
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
None,
|
||||
LAST_WARN_ERROR_LOG_SENDER.subscribe(),
|
||||
);
|
||||
rpc_task_handle.await.unwrap()
|
||||
|
@ -316,10 +303,7 @@ impl StartCmd {
|
|||
sync_status.clone(),
|
||||
chain_tip_change.clone(),
|
||||
peer_set.clone(),
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Some(submit_block_channel.receiver()),
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
None,
|
||||
)
|
||||
.in_current_span(),
|
||||
);
|
||||
|
|
|
@ -24,7 +24,6 @@ use zebra_network::{
|
|||
AddressBook, InventoryResponse, Request, Response,
|
||||
};
|
||||
use zebra_node_services::mempool;
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use zebra_rpc::methods::get_block_template_rpcs::types::submit_block::SubmitBlockChannel;
|
||||
use zebra_state::{ChainTipChange, Config as StateConfig, CHAIN_TIP_UPDATE_WAIT_LIMIT};
|
||||
use zebra_test::mock_service::{MockService, PanicAssertion};
|
||||
|
@ -983,17 +982,13 @@ async fn setup(
|
|||
// Pretend we're close to tip
|
||||
SyncStatus::sync_close_to_tip(&mut recent_syncs);
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
let submitblock_channel = SubmitBlockChannel::new();
|
||||
let sync_gossip_task_handle = tokio::spawn(
|
||||
sync::gossip_best_tip_block_hashes(
|
||||
sync_status.clone(),
|
||||
chain_tip_change.clone(),
|
||||
peer_set.clone(),
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Some(submitblock_channel.receiver()),
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
None,
|
||||
)
|
||||
.in_current_span(),
|
||||
);
|
||||
|
|
|
@ -21,7 +21,6 @@ use zebra_network::{
|
|||
Config as NetworkConfig, InventoryResponse, PeerError, Request, Response, SharedPeerError,
|
||||
};
|
||||
use zebra_node_services::mempool;
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
use zebra_rpc::methods::get_block_template_rpcs::types::submit_block::SubmitBlockChannel;
|
||||
use zebra_state::Config as StateConfig;
|
||||
use zebra_test::mock_service::{MockService, PanicAssertion};
|
||||
|
@ -733,17 +732,13 @@ async fn setup(
|
|||
// We can't expect or unwrap because the returned Result does not implement Debug
|
||||
assert!(r.is_ok(), "unexpected setup channel send failure");
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
let submitblock_channel = SubmitBlockChannel::new();
|
||||
|
||||
let block_gossip_task_handle = tokio::spawn(sync::gossip_best_tip_block_hashes(
|
||||
sync_status.clone(),
|
||||
chain_tip_change,
|
||||
peer_set.clone(),
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Some(submitblock_channel.receiver()),
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
None,
|
||||
));
|
||||
|
||||
let tx_gossip_task_handle = tokio::spawn(gossip_mempool_transaction_id(
|
||||
|
@ -798,7 +793,6 @@ async fn setup(
|
|||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
mod submitblock_test {
|
||||
use std::io;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
|
|
@ -717,10 +717,7 @@ impl Service<Request> for Mempool {
|
|||
ActiveState::Enabled {
|
||||
storage,
|
||||
tx_downloads,
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
last_seen_tip_hash,
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
last_seen_tip_hash: _,
|
||||
} => match req {
|
||||
// Queries
|
||||
Request::TransactionIds => {
|
||||
|
@ -791,7 +788,6 @@ impl Service<Request> for Mempool {
|
|||
response_fut.boxed()
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Request::FullTransactions => {
|
||||
trace!(?req, "got mempool request");
|
||||
|
||||
|
@ -878,7 +874,6 @@ impl Service<Request> for Mempool {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
Request::FullTransactions => {
|
||||
return async move {
|
||||
Err("mempool is not active: wait for Zebra to sync to the tip".into())
|
||||
|
|
|
@ -51,7 +51,6 @@ pub struct ZebradConfig {
|
|||
/// RPC configuration
|
||||
pub rpc: zebra_rpc::config::Config,
|
||||
|
||||
#[serde(skip_serializing_if = "zebra_rpc::config::mining::Config::skip_getblocktemplate")]
|
||||
/// Mining configuration
|
||||
pub mining: zebra_rpc::config::mining::Config,
|
||||
}
|
||||
|
|
|
@ -61,10 +61,6 @@
|
|||
//! features](https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options)
|
||||
//! are available at compile time:
|
||||
//!
|
||||
//! ### JSON-RPC
|
||||
//!
|
||||
//! * `getblocktemplate-rpcs`: Mining pool RPC support, enabled by default in production builds.
|
||||
//!
|
||||
//! ### Metrics
|
||||
//!
|
||||
//! * configuring a `tracing.progress_bar`: shows key metrics in the terminal using progress bars,
|
||||
|
|
|
@ -113,13 +113,13 @@
|
|||
//! Example of how to run the get_block_template test:
|
||||
//!
|
||||
//! ```console
|
||||
//! ZEBRA_CACHE_DIR=/path/to/zebra/state cargo test get_block_template --features getblocktemplate-rpcs --release -- --ignored --nocapture
|
||||
//! ZEBRA_CACHE_DIR=/path/to/zebra/state cargo test get_block_template --release -- --ignored --nocapture
|
||||
//! ```
|
||||
//!
|
||||
//! Example of how to run the submit_block test:
|
||||
//!
|
||||
//! ```console
|
||||
//! ZEBRA_CACHE_DIR=/path/to/zebra/state cargo test submit_block --features getblocktemplate-rpcs --release -- --ignored --nocapture
|
||||
//! ZEBRA_CACHE_DIR=/path/to/zebra/state cargo test submit_block --release -- --ignored --nocapture
|
||||
//! ```
|
||||
//!
|
||||
//! Example of how to run the has_spending_transaction_ids test:
|
||||
|
@ -219,9 +219,6 @@ use crate::common::cached_state::{
|
|||
/// This limit only applies to some tests.
|
||||
pub const MAX_ASYNC_BLOCKING_TIME: Duration = zebra_test::mock_service::DEFAULT_MAX_REQUEST_DELAY;
|
||||
|
||||
/// The test config file prefix for `--feature getblocktemplate-rpcs` configs.
|
||||
pub const GET_BLOCK_TEMPLATE_CONFIG_PREFIX: &str = "getblocktemplate-";
|
||||
|
||||
/// The test config file prefix for `--feature shielded-scan` configs.
|
||||
pub const SHIELDED_SCAN_CONFIG_PREFIX: &str = "shieldedscan-";
|
||||
|
||||
|
@ -949,17 +946,6 @@ fn stored_configs_parsed_correctly() -> Result<()> {
|
|||
continue;
|
||||
}
|
||||
|
||||
// ignore files starting with getblocktemplate prefix
|
||||
// if we were not built with the getblocktemplate-rpcs feature.
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
if config_file_name.starts_with(GET_BLOCK_TEMPLATE_CONFIG_PREFIX) {
|
||||
tracing::info!(
|
||||
?config_file_path,
|
||||
"skipping getblocktemplate-rpcs config file path"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignore files starting with shieldedscan prefix
|
||||
// if we were not built with the shielded-scan feature.
|
||||
if config_file_name.starts_with(SHIELDED_SCAN_CONFIG_PREFIX) {
|
||||
|
@ -1008,17 +994,6 @@ fn stored_configs_work() -> Result<()> {
|
|||
continue;
|
||||
}
|
||||
|
||||
// ignore files starting with getblocktemplate prefix
|
||||
// if we were not built with the getblocktemplate-rpcs feature.
|
||||
#[cfg(not(feature = "getblocktemplate-rpcs"))]
|
||||
if config_file_name.starts_with(GET_BLOCK_TEMPLATE_CONFIG_PREFIX) {
|
||||
tracing::info!(
|
||||
?config_file_path,
|
||||
"skipping getblocktemplate-rpcs config file path"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
let run_dir = testdir()?;
|
||||
let stored_config_path = config_file_full_path(config_file.path());
|
||||
|
||||
|
@ -2552,7 +2527,6 @@ async fn lightwalletd_wallet_grpc_tests() -> Result<()> {
|
|||
///
|
||||
/// See [`common::get_block_template_rpcs::get_peer_info`] for more information.
|
||||
#[tokio::test]
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn get_peer_info() -> Result<()> {
|
||||
common::get_block_template_rpcs::get_peer_info::run().await
|
||||
}
|
||||
|
@ -2561,8 +2535,6 @@ async fn get_peer_info() -> Result<()> {
|
|||
///
|
||||
/// See [`common::get_block_template_rpcs::get_block_template`] for more information.
|
||||
#[tokio::test]
|
||||
#[ignore]
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn get_block_template() -> Result<()> {
|
||||
common::get_block_template_rpcs::get_block_template::run().await
|
||||
}
|
||||
|
@ -2571,8 +2543,6 @@ async fn get_block_template() -> Result<()> {
|
|||
///
|
||||
/// See [`common::get_block_template_rpcs::submit_block`] for more information.
|
||||
#[tokio::test]
|
||||
#[ignore]
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn submit_block() -> Result<()> {
|
||||
common::get_block_template_rpcs::submit_block::run().await
|
||||
}
|
||||
|
@ -2983,14 +2953,12 @@ fn external_address() -> Result<()> {
|
|||
/// See [`common::regtest::submit_blocks`] for more information.
|
||||
// TODO: Test this with an NU5 activation height too once config can be serialized.
|
||||
#[tokio::test]
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn regtest_block_templates_are_valid_block_submissions() -> Result<()> {
|
||||
common::regtest::submit_blocks_test().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn trusted_chain_sync_handles_forks_correctly() -> Result<()> {
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -3263,9 +3231,8 @@ async fn trusted_chain_sync_handles_forks_correctly() -> Result<()> {
|
|||
/// Test successful block template submission as a block proposal or submission on a custom Testnet.
|
||||
///
|
||||
/// This test can be run locally with:
|
||||
/// `cargo test --package zebrad --test acceptance --features getblocktemplate-rpcs -- nu6_funding_streams_and_coinbase_balance --exact --show-output`
|
||||
/// `cargo test --package zebrad --test acceptance -- nu6_funding_streams_and_coinbase_balance --exact --show-output`
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
async fn nu6_funding_streams_and_coinbase_balance() -> Result<()> {
|
||||
use zebra_chain::{
|
||||
chain_sync_status::MockSyncStatus,
|
||||
|
@ -3736,7 +3703,7 @@ fn check_no_git_refs_in_cargo_lock() {
|
|||
|
||||
// /// Check that Zebra will disconnect from misbehaving peers.
|
||||
// #[tokio::test]
|
||||
// #[cfg(all(feature = "getblocktemplate-rpcs", not(target_os = "windows")))]
|
||||
// #[cfg(not(target_os = "windows"))]
|
||||
// async fn disconnects_from_misbehaving_peers() -> Result<()> {
|
||||
// use std::sync::{atomic::AtomicBool, Arc};
|
||||
|
||||
|
|
|
@ -68,17 +68,14 @@ pub fn default_test_config(net: &Network) -> Result<ZebradConfig> {
|
|||
#[allow(unused_mut)]
|
||||
let mut mining = zebra_rpc::config::mining::Config::default();
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
{
|
||||
let miner_address = if network.network.is_a_test_network() {
|
||||
// Assume test networks all use the same address prefix and format
|
||||
"t27eWDgjFYJGVXmzrXeVjnb5J3uXDM9xH9v"
|
||||
} else {
|
||||
"t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1"
|
||||
};
|
||||
let miner_address = if network.network.is_a_test_network() {
|
||||
// Assume test networks all use the same address prefix and format
|
||||
"t27eWDgjFYJGVXmzrXeVjnb5J3uXDM9xH9v"
|
||||
} else {
|
||||
"t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1"
|
||||
};
|
||||
|
||||
mining.miner_address = Some(miner_address.parse().expect("hard-coded address is valid"));
|
||||
}
|
||||
mining.miner_address = Some(miner_address.parse().expect("hard-coded address is valid"));
|
||||
|
||||
Ok(ZebradConfig {
|
||||
network,
|
||||
|
|
|
@ -11,18 +11,13 @@
|
|||
|
||||
pub mod cached_state;
|
||||
pub mod check;
|
||||
pub mod config;
|
||||
pub mod failure_messages;
|
||||
pub mod launch;
|
||||
pub mod lightwalletd;
|
||||
pub mod sync;
|
||||
pub mod test_type;
|
||||
|
||||
#[cfg(feature = "zebra-checkpoints")]
|
||||
pub mod checkpoints;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub mod config;
|
||||
pub mod failure_messages;
|
||||
pub mod get_block_template_rpcs;
|
||||
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
pub mod launch;
|
||||
pub mod lightwalletd;
|
||||
pub mod regtest;
|
||||
pub mod sync;
|
||||
pub mod test_type;
|
||||
|
|
Loading…
Reference in New Issue