rpc(config): Add a `mining` section with miner address to config (#5491)

* add mining section to zebra config

* fix features in zebrad `Cargo.toml`

* change field name

* add docs

Co-authored-by: teor <teor@riseup.net>

* add getblocktemplate-rpcs config

* fix commit

Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
Alfredo Garcia 2022-10-31 21:43:45 -03:00 committed by GitHub
parent b66d81a9e4
commit 19cb670614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 1 deletions

View File

@ -35,7 +35,7 @@ use zebra_state::{OutputIndex, OutputLocation, TransactionLocation};
use crate::queue::Queue;
#[cfg(feature = "getblocktemplate-rpcs")]
mod get_block_template_rpcs;
pub mod get_block_template_rpcs;
#[cfg(feature = "getblocktemplate-rpcs")]
pub use get_block_template_rpcs::{GetBlockTemplateRpc, GetBlockTemplateRpcImpl};

View File

@ -15,6 +15,7 @@ use crate::methods::{
GetBlockHash, MISSING_BLOCK_ERROR_CODE,
};
pub mod config;
pub(crate) mod types;
/// getblocktemplate RPC method signatures.

View File

@ -0,0 +1,17 @@
//! Mining config
use serde::{Deserialize, Serialize};
use zebra_chain::transparent::Address;
/// Mining configuration section.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(deny_unknown_fields, default)]
pub struct Config {
/// The address used for miner payouts.
/// Currently, Zebra only supports transparent addresses.
///
/// Zebra sends mining fees and miner rewards to this address in the
/// `getblocktemplate` RPC coinbase transaction.
pub miner_address: Option<Address>,
}

View File

@ -15,6 +15,7 @@ default-run = "zebrad"
[features]
# In release builds, don't compile debug logging code, to improve performance.
default = ["release_max_level_info"]
getblocktemplate-rpcs = ["zebra-rpc/getblocktemplate-rpcs"]
# Production features that activate extra dependencies

View File

@ -37,4 +37,8 @@ pub struct ZebradConfig {
/// RPC configuration
pub rpc: zebra_rpc::config::Config,
#[cfg(feature = "getblocktemplate-rpcs")]
/// Mining configuration
pub mining: zebra_rpc::methods::get_block_template_rpcs::config::Config,
}

View File

@ -784,6 +784,18 @@ fn stored_configs_works() -> Result<()> {
.expect("read_dir call failed")
.flatten()
{
// ignore files starting with getblocktemplate prefix
// if we were not built with the getblocktemplate-rpcs feature.
#[cfg(not(feature = "getblocktemplate-rpcs"))]
if config_file
.file_name()
.into_string()
.expect("all files names should be string convertible")
.starts_with("getblocktemplate-")
{
continue;
}
let run_dir = testdir()?;
let stored_config_path = config_file_full_path(config_file.path());

View File

@ -0,0 +1,72 @@
# Default configuration for zebrad.
#
# This file can be used as a skeleton for custom configs.
#
# Unspecified fields use default values. Optional fields are Some(field) if the
# field is present and None if it is absent.
#
# This file is generated as an example using zebrad's current defaults.
# You should set only the config options you want to keep, and delete the rest.
# Only a subset of fields are present in the skeleton, since optional values
# whose default is None are omitted.
#
# The config format (including a complete list of sections and fields) is
# documented here:
# https://doc.zebra.zfnd.org/zebrad/config/struct.ZebradConfig.html
#
# zebrad attempts to load configs in the following order:
#
# 1. The -c flag on the command line, e.g., `zebrad -c myconfig.toml start`;
# 2. The file `zebrad.toml` in the users's preference directory (platform-dependent);
# 3. The default config.
[consensus]
checkpoint_sync = true
debug_skip_parameter_preload = false
[mempool]
eviction_memory_time = '1h'
tx_cost_limit = 80000000
[metrics]
[mining]
[network]
crawl_new_peer_interval = '1m 1s'
initial_mainnet_peers = [
'dnsseed.z.cash:8233',
'dnsseed.str4d.xyz:8233',
'mainnet.seeder.zfnd.org:8233',
'mainnet.is.yolo.money:8233',
]
initial_testnet_peers = [
'dnsseed.testnet.z.cash:18233',
'testnet.seeder.zfnd.org:18233',
'testnet.is.yolo.money:18233',
]
listen_addr = '0.0.0.0:8233'
network = 'Mainnet'
peerset_initial_target_size = 25
[rpc]
debug_force_finished_sync = false
parallel_cpu_threads = 1
[state]
cache_dir = 'cache_dir'
delete_old_database = true
ephemeral = false
[sync]
checkpoint_verify_concurrency_limit = 800
download_concurrency_limit = 50
full_verify_concurrency_limit = 20
parallel_cpu_threads = 0
[tracing]
buffer_limit = 128000
force_use_color = false
use_color = true
use_journald = false