Rename cchost interval options (#1534)

This commit is contained in:
Julien Maffre 2020-08-27 08:17:42 +01:00 коммит произвёл GitHub
Родитель 3203203eb9
Коммит 136f64e598
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 83 добавлений и 78 удалений

Просмотреть файл

@ -577,7 +577,7 @@ if(BUILD_TESTS)
NAME reconfiguration_snapshot_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/reconfiguration.py
CONSENSUS raft
ADDITIONAL_ARGS --snapshot-max-tx 10
ADDITIONAL_ARGS --snapshot-tx-interval 10
)
add_e2e_test(

Просмотреть файл

@ -15,15 +15,14 @@ Nodes can be configured to store their ledger under a particular directory with
File layout
-----------
The ledger directory contains a series of files. File size is controlled by the ``--ledger-chunk-min-bytes`` command line option.
The ledger directory contains a series of files. File size is controlled by the ``--ledger-chunk-bytes`` command line option.
Files containing only committed entries are named ``ledger_$STARTSEQNO-$ENDSEQNO.committed``. These files are closed and immutable,
it is safe to replicate them to backup storage. They are identical across nodes, provided ``--ledger-chunk-min-bytes`` has been set to the same value.
Files containing only committed entries are named ``ledger_$STARTSEQNO-$ENDSEQNO.committed``. These files are closed and immutable, it is safe to replicate them to backup storage. They are identical across nodes, provided ``--ledger-chunk-bytes`` has been set to the same value.
.. warning:: Removing files from a ledger directory may cause a node to crash.
Files that still contain some uncommitted entries will be named ``ledger_$STARTSEQNO-$ENDSEQNO`` or ``ledger_$STARTSEQNO`` for the last one.
These files are typically held open by the cchost process, which may modify their content, or even erase them completely. They may differ arbitrarily across nodes.
These files are typically held open by the ``cchost`` process, which may modify their content, or even erase them completely. They may differ arbitrarily across nodes.
It is important to note that while all entries stored in files ending in ``.committed`` are committed, not all committed entries
are stored in such a file at any given time. A number of them are typically in the in-progress files, waiting to be flushed to
@ -35,7 +34,7 @@ The listing below is an example of what a ledger directory may look like.
$ ./cchost --ledger-dir $LEDGER_DIR ...
$ cd $LEDGER_DIR
$ ls
$ ls -la
-rw-rw-r-- 1 user user 1.6M Jun 16 14:08 ledger_1-7501.committed
...
-rw-rw-r-- 1 user user 1.1M Jun 16 14:08 ledger_92502-97501.committed

Просмотреть файл

@ -21,8 +21,8 @@ To create a new CCF network, the first node of the network should be invoked wit
[--domain domain]
--ledger-dir /path/to/ledger/dir
--node-cert-file /path/to/node_certificate
[--sig-max-tx number_of_transactions]
[--sig-max-ms number_of_milliseconds]
[--sig-tx-interval number_of_transactions]
[--sig-ms-interval number_of_milliseconds]
start
--network-cert-file /path/to/network_certificate
--network-enc-pubk-file /path/to/network_encryption_pubk
@ -62,14 +62,14 @@ To use the PBFT consensus protocol, pass ``--consensus pbft``. Please see :ref:`
Signature Interval
~~~~~~~~~~~~~~~~~~
Transaction commit latency in a CCF network is primarily a function of signature frequency. A network emitting signatures more frequently will be able to commit transactions faster,
but will spend a larger proportion of its execution resources creating and verifying signatures. Setting signature frequency is a trade-off between transaction
latency and throughput.
Transaction commit latency in a CCF network is primarily a function of signature frequency. A network emitting signatures more frequently will be able to commit transactions faster, but will spend a larger proportion of its execution resources creating and verifying signatures. Setting signature frequency is a trade-off between transaction latency and throughput.
Two options are provided to that end:
- ``--sig-max-tx``: maximum number of transactions between two signatures
- ``--sig-max-ms``: maximum time in milliseconds between two signatures.
- ``--sig-tx-interval``: number of transactions between two signatures
- ``--sig-ms-interval``: time in milliseconds between two signatures
.. note:: These options specify the intervals at which the generation of signature transactions is `triggered`. However, because of the parallel execution of transactions, it is possible that signature transactions are recorded in the ledger at a slightly higher interval than the specified values.
Adding a New Node to the Network
--------------------------------

Просмотреть файл

@ -359,7 +359,7 @@ namespace pbft
std::unique_ptr<pbft::PbftStore> store_,
std::shared_ptr<ChannelProxy> channels_,
NodeId id,
size_t sig_max_tx,
size_t sig_tx_interval,
std::unique_ptr<consensus::LedgerEnclave> ledger_,
std::shared_ptr<enclave::RPCMap> rpc_map,
std::shared_ptr<enclave::RPCSessions> rpcsessions_,
@ -390,7 +390,7 @@ namespace pbft
general_info.status_timeout = consensus_config.pbft_status_interval;
general_info.recovery_timeout = 9999250000;
general_info.max_requests_between_signatures =
sig_max_tx / Max_requests_in_batch;
sig_tx_interval / Max_requests_in_batch;
general_info.support_threading = true;
// Adding myself

Просмотреть файл

@ -109,7 +109,8 @@ namespace enclave
for (auto& [actor, fe] : rpc_map->get_map())
{
fe->set_sig_intervals(
signature_intervals.sig_max_tx, signature_intervals.sig_max_ms);
signature_intervals.sig_tx_interval,
signature_intervals.sig_ms_interval);
fe->set_cmd_forwarder(cmd_forwarder);
}

Просмотреть файл

@ -37,13 +37,13 @@ struct CCFConfig
consensus::Config consensus_config = {};
ccf::NodeInfoNetwork node_info_network = {};
std::string domain;
size_t snapshot_interval;
size_t snapshot_tx_interval;
struct SignatureIntervals
{
size_t sig_max_tx;
size_t sig_max_ms;
MSGPACK_DEFINE(sig_max_tx, sig_max_ms);
size_t sig_tx_interval;
size_t sig_ms_interval;
MSGPACK_DEFINE(sig_tx_interval, sig_ms_interval);
};
SignatureIntervals signature_intervals = {};
@ -70,7 +70,7 @@ struct CCFConfig
consensus_config,
node_info_network,
domain,
snapshot_interval,
snapshot_tx_interval,
signature_intervals,
genesis,
joining);

Просмотреть файл

@ -17,7 +17,8 @@ namespace enclave
virtual ~RpcHandler() {}
// Used by enclave to initialise and tick frontends
virtual void set_sig_intervals(size_t sig_max_tx_, size_t sig_max_ms_) = 0;
virtual void set_sig_intervals(
size_t sig_tx_interval, size_t sig_ms_interval) = 0;
virtual void set_cmd_forwarder(
std::shared_ptr<AbstractForwarder> cmd_forwarder_) = 0;
virtual void tick(std::chrono::milliseconds) {}

Просмотреть файл

@ -137,21 +137,21 @@ int main(int argc, char** argv)
app.add_option("--ledger-dir", ledger_dir, "Ledger and snapshots directory")
->capture_default_str();
size_t ledger_min_bytes = 5'000'000;
size_t ledger_chunk_bytes = 5'000'000;
app
.add_option(
"--ledger-chunk-min-bytes",
ledger_min_bytes,
"Minimum size (bytes) at which a new ledger chunk is created.")
"--ledger-chunk-bytes",
ledger_chunk_bytes,
"Size (bytes) at which a new ledger chunk is created")
->capture_default_str()
->transform(CLI::AsSizeValue(true)); // 1000 is kb
size_t snapshot_max_tx = std::numeric_limits<std::size_t>::max();
size_t snapshot_tx_interval = std::numeric_limits<std::size_t>::max();
app
.add_option(
"--snapshot-max-tx",
snapshot_max_tx,
"Maximum number of transactions between snapshots (experimental). "
"--snapshot-tx-interval",
snapshot_tx_interval,
"Number of transactions between snapshots (experimental). "
"Defaults to no snapshot.")
->capture_default_str();
@ -190,18 +190,18 @@ int main(int argc, char** argv)
"Path to which the node PID will be written")
->capture_default_str();
size_t sig_max_tx = 5000;
size_t sig_tx_interval = 5000;
app
.add_option(
"--sig-max-tx",
sig_max_tx,
"Maximum number of transactions between signatures")
"--sig-tx-interval",
sig_tx_interval,
"Number of transactions between signatures")
->capture_default_str();
size_t sig_max_ms = 1000;
size_t sig_ms_interval = 1000;
app
.add_option(
"--sig-max-ms", sig_max_ms, "Maximum milliseconds between signatures")
"--sig-ms-interval", sig_ms_interval, "Milliseconds between signatures")
->capture_default_str();
size_t circuit_size_shift = 22;
@ -541,7 +541,7 @@ int main(int argc, char** argv)
// graceful shutdown on sigterm
asynchost::Sigterm sigterm(writer_factory);
asynchost::Ledger ledger(ledger_dir, writer_factory, ledger_min_bytes);
asynchost::Ledger ledger(ledger_dir, writer_factory, ledger_chunk_bytes);
ledger.register_message_handlers(bp.get_dispatcher());
asynchost::SnapshotManager snapshot(ledger_dir);
@ -596,14 +596,14 @@ int main(int argc, char** argv)
raft_election_timeout,
pbft_view_change_timeout,
pbft_status_interval};
ccf_config.signature_intervals = {sig_max_tx, sig_max_ms};
ccf_config.signature_intervals = {sig_tx_interval, sig_ms_interval};
ccf_config.node_info_network = {rpc_address.hostname,
public_rpc_address.hostname,
node_address.hostname,
node_address.port,
rpc_address.port};
ccf_config.domain = domain;
ccf_config.snapshot_interval = snapshot_max_tx;
ccf_config.snapshot_tx_interval = snapshot_tx_interval;
if (*start)
{

Просмотреть файл

@ -237,7 +237,7 @@ namespace ccf
open_node_frontend();
snapshotter = std::make_shared<Snapshotter>(
writer_factory, network, args.config.snapshot_interval);
writer_factory, network, args.config.snapshot_tx_interval);
#ifdef GET_QUOTE
if (network.consensus_type != ConsensusType::PBFT)

Просмотреть файл

@ -51,9 +51,9 @@ namespace ccf
std::shared_ptr<enclave::AbstractForwarder> cmd_forwarder;
kv::TxHistory* history;
size_t sig_max_tx = 1000;
size_t sig_tx_interval = 5000;
std::atomic<size_t> tx_count = 0;
std::chrono::milliseconds sig_max_ms = std::chrono::milliseconds(1000);
std::chrono::milliseconds sig_ms_interval = std::chrono::milliseconds(1000);
std::chrono::milliseconds ms_to_sig = std::chrono::milliseconds(1000);
bool request_storing_disabled = false;
@ -403,7 +403,7 @@ namespace ccf
if (
history && consensus->is_primary() &&
(cv % sig_max_tx == sig_max_tx / 2))
(cv % sig_tx_interval == sig_tx_interval / 2))
{
if (consensus->type() == ConsensusType::RAFT)
{
@ -483,11 +483,12 @@ namespace ccf
history(nullptr)
{}
void set_sig_intervals(size_t sig_max_tx_, size_t sig_max_ms_) override
void set_sig_intervals(
size_t sig_tx_interval_, size_t sig_ms_interval_) override
{
sig_max_tx = sig_max_tx_;
sig_max_ms = std::chrono::milliseconds(sig_max_ms_);
ms_to_sig = sig_max_ms;
sig_tx_interval = sig_tx_interval_;
sig_ms_interval = std::chrono::milliseconds(sig_ms_interval_);
ms_to_sig = sig_ms_interval;
}
void set_cmd_forwarder(
@ -688,7 +689,7 @@ namespace ccf
return;
}
ms_to_sig = sig_max_ms;
ms_to_sig = sig_ms_interval;
if (history && tables.commit_gap() > 0)
{
if (consensus->type() == ConsensusType::RAFT)

Просмотреть файл

@ -23,7 +23,7 @@ namespace ccf
NetworkState& network;
size_t snapshot_interval;
size_t snapshot_tx_interval;
// Index at which the lastest snapshot was generated
consensus::Index last_snapshot_idx = 0;
@ -100,10 +100,10 @@ namespace ccf
Snapshotter(
ringbuffer::AbstractWriterFactory& writer_factory,
NetworkState& network_,
size_t snapshot_interval_) :
size_t snapshot_tx_interval_) :
to_host(writer_factory.create_writer_to_outside()),
network(network_),
snapshot_interval(snapshot_interval_)
snapshot_tx_interval(snapshot_tx_interval_)
{
next_snapshot_indices.push_back(last_snapshot_idx);
}
@ -119,7 +119,7 @@ namespace ccf
idx,
last_snapshot_idx);
if (idx - last_snapshot_idx > snapshot_interval)
if (idx - last_snapshot_idx > snapshot_tx_interval)
{
auto msg = std::make_unique<threading::Tmsg<SnapshotMsg>>(&snapshot_cb);
msg->data.self = shared_from_this();
@ -147,7 +147,7 @@ namespace ccf
std::lock_guard<SpinLock> guard(lock);
// Returns true if the idx will require the generation of a snapshot
if ((idx - next_snapshot_indices.back()) >= snapshot_interval)
if ((idx - next_snapshot_indices.back()) >= snapshot_tx_interval)
{
next_snapshot_indices.push_back(idx);
return true;

Просмотреть файл

@ -21,5 +21,5 @@ CURL_CLIENT=ON \
python "${PATH_HERE}"/tests/start_network.py \
--gov-script "${PATH_HERE}"/src/runtime_config/gov.lua \
--label test_network \
--ledger-chunk-min-bytes 5MB \
--ledger-chunk-bytes 5MB \
"$@"

Просмотреть файл

@ -74,13 +74,16 @@ def cli_args(add=lambda x: None, parser=None, accept_unknown=False):
action="store_true",
)
parser.add_argument(
"--sig-max-tx", help="Max transactions between signatures", type=int
"--sig-tx-interval",
help="Number of transactions between signatures",
type=int,
default=5000,
)
parser.add_argument(
"--sig-max-ms",
help="Max milliseconds between signatures",
"--sig-ms-interval",
help="Milliseconds between signatures",
type=int,
default=100,
default=1000,
)
parser.add_argument(
"--memory-reserve-startup",
@ -169,13 +172,13 @@ def cli_args(add=lambda x: None, parser=None, accept_unknown=False):
default=30,
)
parser.add_argument(
"--ledger-chunk-min-bytes",
help="Minimum size (bytes) at which a new ledger chunk is created",
"--ledger-chunk-bytes",
help="Size (bytes) at which a new ledger chunk is created",
default="20KB",
)
parser.add_argument(
"--snapshot-max-tx",
help="Maximum number of transactions between two snapshots",
"--snapshot-tx-interval",
help="Number of transactions between two snapshots",
default=None,
)

Просмотреть файл

@ -62,8 +62,8 @@ class Network:
node_args_to_forward = [
"enclave_type",
"host_log_level",
"sig_max_tx",
"sig_max_ms",
"sig_tx_interval",
"sig_ms_interval",
"raft_election_timeout",
"pbft_view_change_timeout",
"consensus",
@ -73,9 +73,9 @@ class Network:
"gov_script",
"join_timer",
"worker_threads",
"ledger_chunk_min_bytes",
"ledger_chunk_bytes",
"domain",
"snapshot_max_tx",
"snapshot_tx_interval",
]
# Maximum delay (seconds) for updates to propagate from the primary to backups

Просмотреть файл

@ -553,8 +553,8 @@ class CCFRemote(object):
members_info=None,
join_timer=None,
host_log_level="info",
sig_max_tx=1000,
sig_max_ms=1000,
sig_tx_interval=5000,
sig_ms_interval=1000,
raft_election_timeout=1000,
pbft_view_change_timeout=5000,
consensus="raft",
@ -565,9 +565,9 @@ class CCFRemote(object):
ledger_dir=None,
log_format_json=None,
binary_dir=".",
ledger_chunk_min_bytes=(5 * 1024 * 1024),
ledger_chunk_bytes=(5 * 1000 * 1000),
domain=None,
snapshot_max_tx=None,
snapshot_tx_interval=None,
):
"""
Run a ccf binary on a remote host.
@ -624,17 +624,17 @@ class CCFRemote(object):
if log_format_json:
cmd += ["--log-format-json"]
if sig_max_tx:
cmd += [f"--sig-max-tx={sig_max_tx}"]
if sig_tx_interval:
cmd += [f"--sig-tx-interval={sig_tx_interval}"]
if sig_max_ms:
cmd += [f"--sig-max-ms={sig_max_ms}"]
if sig_ms_interval:
cmd += [f"--sig-ms-interval={sig_ms_interval}"]
if memory_reserve_startup:
cmd += [f"--memory-reserve-startup={memory_reserve_startup}"]
if ledger_chunk_min_bytes:
cmd += [f"--ledger-chunk-min-bytes={ledger_chunk_min_bytes}"]
if ledger_chunk_bytes:
cmd += [f"--ledger-chunk-bytes={ledger_chunk_bytes}"]
if notify_server:
notify_server_host, *notify_server_port = notify_server.split(":")
@ -653,8 +653,8 @@ class CCFRemote(object):
if domain:
cmd += [f"--domain={domain}"]
if snapshot_max_tx:
cmd += [f"--snapshot-max-tx={snapshot_max_tx}"]
if snapshot_tx_interval:
cmd += [f"--snapshot-tx-interval={snapshot_tx_interval}"]
if start_type == StartType.new:
cmd += [