Skip to content

Commit 6b3c7ae

Browse files
author
Garand Tyson
committed
Send transactions to the upcoming round leaders only, with an admission check (prototype)
A node that accepts a transaction from a client checks it against its last closed ledger, keeps it, and has its overlay send the body straight to the leaders that will build the next ledgers instead of advertising it to every peer. Overlays prove which validator they belong to with a binding signed by the node key. A target that is not a directly connected, identified peer makes the node fall back to the advert flood. The targets (HerderImpl::computeTxFloodTargets) are the leaders of the node's round of the next slot and of the round after it. With leader terms the node that closes a ledger leads the next one too; one slot before a new term starts, that term's expected first leader is a target as well, so that it holds the transactions when it validates and builds its first set. Options for measurements: TX_FLOOD_TARGET_LEADERS (0 = every validator), TX_FLOOD_LEGACY_ADVERTS, BATCH_EXECUTOR_TASKS.
1 parent 6716b4e commit 6b3c7ae

27 files changed

Lines changed: 3833 additions & 49 deletions

‎docs/metrics.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ crypto.verify.miss | meter | number of signature cach
6262
crypto.verify.total | meter | sum of both hits and misses
6363
crypto.verify.tx-valid-hit | meter | signature cache hits that occurred while validating transactions (outside of background signature validation)
6464
crypto.verify.tx-valid-total | meter | sum of both hits and misses during transaction validation (outside of background signature validation)
65+
herder.tx-admission.account-busy | meter | submitted transactions refused because their source account already has a pending transaction accepted by this node
66+
herder.tx-admission.check | timer | time spent checking a submitted transaction against the last closed ledger before it is sent on
67+
herder.tx-admission.invalid | meter | submitted transactions refused because they are invalid against the last closed ledger
6568
herder.txset.build | timer | time spent building the tx set proposed at nomination from the transaction queues
6669
herder.txset.validate | timer | time spent turning a received tx set into an applicable tx set and validating it on a validity-cache miss
6770
herder.txset.validate-sig-cache-hit | meter | signature cache hits while validating a received tx set (herder.txset.validate)
@@ -166,6 +169,10 @@ overlay.flood.broadcast | meter | message sent as broadcas
166169
overlay.flood.duplicate_recv | meter | number of bytes of flooded messages that have already been received
167170
overlay.flood.unique_recv | meter | number of bytes of flooded messages that have not yet been received
168171
overlay.flood.tx-batch-size | histogram | number of transactions in a batch
172+
overlay.flood.tx-direct-recv | meter | transaction bodies received without a demand (sent directly by a peer), kept and not relayed
173+
overlay.flood.tx-direct-sent | meter | transaction bodies sent straight to a target leader, without an advert
174+
overlay.flood.tx-direct-sent-bytes | meter | bytes of those bodies
175+
overlay.flood.tx-local-flooded | meter | own transactions advertised to every peer because no target list was set or a target was not directly connected
169176
overlay.inbound.attempt | meter | inbound connection attempted (accepted on socket)
170177
overlay.inbound.drop | meter | inbound connection dropped
171178
overlay.inbound.establish | meter | inbound connection established (added to pending)
@@ -179,6 +186,8 @@ overlay.message.broadcast | meter | message broadcasted
179186
overlay.message.read | meter | message received
180187
overlay.message.write | meter | message sent
181188
overlay.message.drop | meter | message dropped due to load-shedding
189+
overlay.node-id.identified | counter | connected peers that proved which validator they belong to
190+
overlay.node-id.rejected | meter | validator identity claims from peers with a signature that does not bind them to the connection
182191
overlay.outbound.attempt | meter | outbound connection attempted (socket opened)
183192
overlay.outbound.cancel | meter | outbound connection cancelled
184193
overlay.outbound.drop | meter | outbound connection dropped

‎docs/stellar-core_example.cfg‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,30 @@ EXPERIMENTAL_PARALLEL_TX_SET_DOWNLOAD = false
291291
# also enabled.
292292
BACKGROUND_TX_SIG_VERIFICATION = true
293293

294+
# TX_FLOOD_TARGET_LEADERS (integer) default 2
295+
# Experimental. How many upcoming round leaders get the transactions this
296+
# node accepts (the leader of the node's current round of the next ledger and
297+
# the ones after it; one ledger before a new leader term starts, also that
298+
# term's expected first leader). The node sends them the transactions
299+
# directly instead of advertising them to every peer. 0 = every validator of
300+
# the leader schedule (no adverts either, but every validator holds every
301+
# transaction before the leader's set arrives).
302+
TX_FLOOD_TARGET_LEADERS = 2
303+
304+
# TX_FLOOD_LEGACY_ADVERTS (boolean) default false
305+
# Experimental. If true, no target list is used: transactions are advertised
306+
# to every peer and fetched on demand (the behaviour before
307+
# TX_FLOOD_TARGET_LEADERS existed).
308+
TX_FLOOD_LEGACY_ADVERTS = false
309+
310+
# BATCH_EXECUTOR_TASKS (integer) default 0
311+
# Experimental. Number of tasks (worker threads) used for CPU-bound batch
312+
# work: transaction validation when building and when applying a transaction
313+
# set, and the background signature verification. 0 = one per physical core
314+
# minus one. A larger value uses hyper-thread siblings once the physical
315+
# cores are taken.
316+
BATCH_EXECUTOR_TASKS = 0
317+
294318
# NTP_DRIFT_CHECK_SERVER (string) default "pool.ntp.org"
295319
# Hostname of an NTP server that the node periodically queries (about every ten
296320
# minutes) to detect and warn about drift of the local clock. This is detection

‎overlay/src/flood/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod inv_tracker;
88
mod mempool;
99
mod pending_requests;
1010
mod tx_buffer;
11+
pub(crate) mod tx_router;
1112
mod txset;
1213
pub(crate) mod txset_encoding;
1314
pub(crate) mod txset_push;
@@ -19,6 +20,7 @@ pub use inv_tracker::InvTracker;
1920
pub use mempool::Mempool;
2021
pub use pending_requests::PendingRequests;
2122
pub use tx_buffer::TxBuffer;
23+
pub use tx_router::{NodeId, SendPlan, TxRouter};
2224
pub use txset::{CachedTxSet, Hash256, TxSetCache};
2325
pub use txset_encoding::TxSetData;
2426
pub use txset_push::{PushRateLimiter, PushRecord, UnclaimedSetBudget};

0 commit comments

Comments
 (0)