Compare commits

...

14 Commits

Author SHA1 Message Date
36398bc3f3 Only check TRIGGERED_BUILDKITE_TAG 2019-01-07 19:53:52 -08:00
fa0e1ad356 Don't turn the build red if channel cannot be figured (eg, building a tag) 2019-01-07 19:53:39 -08:00
f56c5dacca Remove some metrics datapoint, as it was causing excessive logging (#2287) (#2291)
- 100 nodes test was bringing down the influx DB server
2019-01-03 10:42:13 -08:00
80e0da132a Rename getConfirmation -> getConfirmationTime 2018-12-22 13:11:10 -08:00
f89debdfa6 Document getConfirmationTime 2018-12-22 13:11:10 -08:00
16f7e46fce Ignore error while enabling nvidia persistence mode (#2265) 2018-12-21 12:47:45 -08:00
3a039c8007 Load nvidia drivers on node startup (#2263) (#2264)
* Load nvidia drivers on node startup

* added new script to enable nvidia driver persistent mode

* remove set -ex
2018-12-21 11:58:06 -08:00
56d5324837 Use CUDA for testnet automation performance calculations (#2259) (#2261) 2018-12-21 05:14:08 -08:00
d3bf0fc707 Use SSD for testnet automation (#2257) (#2258) 2018-12-21 04:52:00 -08:00
f9d8a1d6c0 Rename finality to confirmation (#2250)
* Rename finality to confirmation

* fix cargo fmt errors
2018-12-20 16:03:56 -08:00
70559253ee Use newer votes to calculate confirmation time (#2247) 2018-12-20 16:03:56 -08:00
9c61abe468 Reduce ticks per block to increase voting frequency (#2242) 2018-12-20 16:03:56 -08:00
970954ac3b Stable dashboard can now actually come from the stable channel 2018-12-20 08:06:02 -08:00
39d821ead8 Select correct branch for {testnet,-perf} when using a stable channel tag 2018-12-19 17:47:18 -08:00
20 changed files with 165 additions and 140 deletions

View File

@ -22,8 +22,9 @@ Methods
--- ---
* [confirmTransaction](#confirmtransaction) * [confirmTransaction](#confirmtransaction)
* [getBalance](#getbalance)
* [getAccountInfo](#getaccountinfo) * [getAccountInfo](#getaccountinfo)
* [getBalance](#getbalance)
* [getConfirmationTime](#getconfirmationTime)
* [getLastId](#getlastid) * [getLastId](#getlastid)
* [getSignatureStatus](#getsignaturestatus) * [getSignatureStatus](#getsignaturestatus)
* [getTransactionCount](#gettransactioncount) * [getTransactionCount](#gettransactioncount)
@ -201,6 +202,25 @@ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "m
{"jsonrpc":"2.0","result":268,"id":1} {"jsonrpc":"2.0","result":268,"id":1}
``` ```
---
### getConfirmationTime
Returns the current cluster confirmation time in milliseconds
##### Parameters:
None
##### Results:
* `integer` - confirmation time in milliseconds, as unsigned 64-bit integer
##### Example:
```bash
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getConfirmationTime"}' http://localhost:8899
// Result
{"jsonrpc":"2.0","result":500,"id":1}
```
--- ---
### requestAirdrop ### requestAirdrop

View File

@ -30,7 +30,7 @@ maybePackage="echo Package skipped"
maybePublish="echo Publish skipped" maybePublish="echo Publish skipped"
# Only package/publish if this is a tagged release # Only package/publish if this is a tagged release
if [[ -n $BUILDKITE_TAG && -n $TRIGGERED_BUILDKITE_TAG ]]; then if [[ -n $TRIGGERED_BUILDKITE_TAG ]]; then
maybePackage="cargo package" maybePackage="cargo package"
# Only publish if there's no human around # Only publish if there's no human around

View File

@ -45,7 +45,7 @@ beta)
CHANNEL_BRANCH=$BETA_CHANNEL CHANNEL_BRANCH=$BETA_CHANNEL
;; ;;
stable) stable)
CHANNEL_BRANCH=$BETA_CHANNEL CHANNEL_BRANCH=$STABLE_CHANNEL
;; ;;
*) *)
echo "Error: Invalid CHANNEL=$CHANNEL" echo "Error: Invalid CHANNEL=$CHANNEL"

View File

@ -25,6 +25,7 @@ launchTestnet() {
echo --- setup "$nodeCount" node test echo --- setup "$nodeCount" node test
net/gce.sh create \ net/gce.sh create \
-b \ -b \
-d pd-ssd \
-n "$nodeCount" -c "$CLIENT_COUNT" \ -n "$nodeCount" -c "$CLIENT_COUNT" \
-G "$LEADER_CPU_MACHINE_TYPE" \ -G "$LEADER_CPU_MACHINE_TYPE" \
-p "$TESTNET_TAG" -z "$TESTNET_ZONE" -p "$TESTNET_TAG" -z "$TESTNET_ZONE"
@ -34,9 +35,9 @@ launchTestnet() {
echo --- start "$nodeCount" node test echo --- start "$nodeCount" node test
if [[ -n $USE_PREBUILT_CHANNEL_TARBALL ]]; then if [[ -n $USE_PREBUILT_CHANNEL_TARBALL ]]; then
net/net.sh start -o noValidatorSanity -t "$CHANNEL" net/net.sh start -f "cuda" -o noValidatorSanity -t "$CHANNEL"
else else
net/net.sh start -o noValidatorSanity -T solana*.tar.bz2 net/net.sh start -f "cuda" -o noValidatorSanity -T solana*.tar.bz2
fi fi
echo --- wait "$ITERATION_WAIT" seconds to complete test echo --- wait "$ITERATION_WAIT" seconds to complete test
@ -56,24 +57,24 @@ launchTestnet() {
WHERE time > now() - 300s GROUP BY time(1s) WHERE time > now() - 300s GROUP BY time(1s)
)' )'
declare q_mean_finality=' declare q_mean_confirmation='
SELECT round(mean("duration_ms")) as "mean_finality" SELECT round(mean("duration_ms")) as "mean_confirmation"
FROM "testnet-automation"."autogen"."leader-finality" FROM "testnet-automation"."autogen"."leader-confirmation"
WHERE time > now() - 300s' WHERE time > now() - 300s'
declare q_max_finality=' declare q_max_confirmation='
SELECT round(max("duration_ms")) as "max_finality" SELECT round(max("duration_ms")) as "max_confirmation"
FROM "testnet-automation"."autogen"."leader-finality" FROM "testnet-automation"."autogen"."leader-confirmation"
WHERE time > now() - 300s' WHERE time > now() - 300s'
declare q_99th_finality=' declare q_99th_confirmation='
SELECT round(percentile("duration_ms", 99)) as "99th_finality" SELECT round(percentile("duration_ms", 99)) as "99th_confirmation"
FROM "testnet-automation"."autogen"."leader-finality" FROM "testnet-automation"."autogen"."leader-confirmation"
WHERE time > now() - 300s' WHERE time > now() - 300s'
curl -G "https://metrics.solana.com:8086/query?u=${INFLUX_USERNAME}&p=${INFLUX_PASSWORD}" \ curl -G "https://metrics.solana.com:8086/query?u=${INFLUX_USERNAME}&p=${INFLUX_PASSWORD}" \
--data-urlencode "db=$INFLUX_DATABASE" \ --data-urlencode "db=$INFLUX_DATABASE" \
--data-urlencode "q=$q_mean_tps;$q_max_tps;$q_mean_finality;$q_max_finality;$q_99th_finality" | --data-urlencode "q=$q_mean_tps;$q_max_tps;$q_mean_confirmation;$q_max_confirmation;$q_99th_confirmation" |
python ci/testnet-automation-json-parser.py >>TPS"$nodeCount".log python ci/testnet-automation-json-parser.py >>TPS"$nodeCount".log
upload-ci-artifact TPS"$nodeCount".log upload-ci-artifact TPS"$nodeCount".log

View File

@ -80,10 +80,11 @@ testnet-beta|testnet-beta-perf)
testnet|testnet-perf) testnet|testnet-perf)
if [[ -n $BETA_CHANNEL_LATEST_TAG ]]; then if [[ -n $BETA_CHANNEL_LATEST_TAG ]]; then
CHANNEL_OR_TAG=$BETA_CHANNEL_LATEST_TAG CHANNEL_OR_TAG=$BETA_CHANNEL_LATEST_TAG
CHANNEL_BRANCH=$BETA_CHANNEL
else else
CHANNEL_OR_TAG=$STABLE_CHANNEL_LATEST_TAG CHANNEL_OR_TAG=$STABLE_CHANNEL_LATEST_TAG
CHANNEL_BRANCH=$STABLE_CHANNEL
fi fi
CHANNEL_BRANCH=$BETA_CHANNEL
;; ;;
*) *)
echo "Error: Invalid TESTNET=$TESTNET" echo "Error: Invalid TESTNET=$TESTNET"

View File

@ -722,7 +722,7 @@
], ],
"orderByTime": "ASC", "orderByTime": "ASC",
"policy": "default", "policy": "default",
"query": "SELECT mean(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-finality\" WHERE $timeFilter \n\n\n", "query": "SELECT mean(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-confirmation\" WHERE $timeFilter \n\n\n",
"rawQuery": true, "rawQuery": true,
"refId": "A", "refId": "A",
"resultFormat": "time_series", "resultFormat": "time_series",
@ -744,7 +744,7 @@
} }
], ],
"thresholds": "", "thresholds": "",
"title": "Mean Finality", "title": "Mean Confirmation",
"type": "singlestat", "type": "singlestat",
"valueFontSize": "70%", "valueFontSize": "70%",
"valueMaps": [ "valueMaps": [
@ -833,7 +833,7 @@
], ],
"orderByTime": "ASC", "orderByTime": "ASC",
"policy": "default", "policy": "default",
"query": "SELECT median(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-finality\" WHERE $timeFilter \n\n\n", "query": "SELECT median(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-confirmation\" WHERE $timeFilter \n\n\n",
"rawQuery": true, "rawQuery": true,
"refId": "A", "refId": "A",
"resultFormat": "time_series", "resultFormat": "time_series",
@ -855,7 +855,7 @@
} }
], ],
"thresholds": "", "thresholds": "",
"title": "Median Finality", "title": "Median Confirmation",
"type": "singlestat", "type": "singlestat",
"valueFontSize": "70%", "valueFontSize": "70%",
"valueMaps": [ "valueMaps": [
@ -944,7 +944,7 @@
], ],
"orderByTime": "ASC", "orderByTime": "ASC",
"policy": "default", "policy": "default",
"query": "SELECT min(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-finality\" WHERE $timeFilter \n\n\n", "query": "SELECT min(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-confirmation\" WHERE $timeFilter \n\n\n",
"rawQuery": true, "rawQuery": true,
"refId": "A", "refId": "A",
"resultFormat": "time_series", "resultFormat": "time_series",
@ -966,7 +966,7 @@
} }
], ],
"thresholds": "", "thresholds": "",
"title": "Min Finality", "title": "Min Confirmation",
"type": "singlestat", "type": "singlestat",
"valueFontSize": "70%", "valueFontSize": "70%",
"valueMaps": [ "valueMaps": [
@ -1055,7 +1055,7 @@
], ],
"orderByTime": "ASC", "orderByTime": "ASC",
"policy": "default", "policy": "default",
"query": "SELECT max(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-finality\" WHERE $timeFilter \n\n\n", "query": "SELECT max(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-confirmation\" WHERE $timeFilter \n\n\n",
"rawQuery": true, "rawQuery": true,
"refId": "A", "refId": "A",
"resultFormat": "time_series", "resultFormat": "time_series",
@ -1077,7 +1077,7 @@
} }
], ],
"thresholds": "", "thresholds": "",
"title": "Max Finality", "title": "Max Confirmation",
"type": "singlestat", "type": "singlestat",
"valueFontSize": "70%", "valueFontSize": "70%",
"valueMaps": [ "valueMaps": [
@ -1166,7 +1166,7 @@
], ],
"orderByTime": "ASC", "orderByTime": "ASC",
"policy": "default", "policy": "default",
"query": "SELECT percentile(\"duration_ms\", 99) FROM \"$testnet\".\"autogen\".\"leader-finality\" WHERE $timeFilter \n\n\n", "query": "SELECT percentile(\"duration_ms\", 99) FROM \"$testnet\".\"autogen\".\"leader-confirmation\" WHERE $timeFilter \n\n\n",
"rawQuery": true, "rawQuery": true,
"refId": "A", "refId": "A",
"resultFormat": "time_series", "resultFormat": "time_series",
@ -1188,7 +1188,7 @@
} }
], ],
"thresholds": "", "thresholds": "",
"title": "Finality (99th percentile)", "title": "Confirmation (99th percentile)",
"type": "singlestat", "type": "singlestat",
"valueFontSize": "70%", "valueFontSize": "70%",
"valueMaps": [ "valueMaps": [
@ -1651,7 +1651,7 @@
"measurement": "counter-cluster_info-vote-count", "measurement": "counter-cluster_info-vote-count",
"orderByTime": "ASC", "orderByTime": "ASC",
"policy": "autogen", "policy": "autogen",
"query": "SELECT mean(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-finality\" WHERE $timeFilter GROUP BY time(1s) FILL(0)\n", "query": "SELECT mean(\"duration_ms\") FROM \"$testnet\".\"autogen\".\"leader-confirmation\" WHERE $timeFilter GROUP BY time(1s) FILL(0)\n",
"rawQuery": true, "rawQuery": true,
"refId": "A", "refId": "A",
"resultFormat": "time_series", "resultFormat": "time_series",
@ -1675,7 +1675,7 @@
"thresholds": [], "thresholds": [],
"timeFrom": null, "timeFrom": null,
"timeShift": null, "timeShift": null,
"title": "Finality", "title": "Time since last Confirmation",
"tooltip": { "tooltip": {
"shared": true, "shared": true,
"sort": 0, "sort": 0,

View File

@ -430,6 +430,10 @@ $(
network-config.sh \ network-config.sh \
remove-docker-interface.sh \ remove-docker-interface.sh \
if "$enableGpu"; then
cat enable-nvidia-persistence-mode.sh
fi
) )
cat > /etc/motd <<EOM cat > /etc/motd <<EOM

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
nvidia-smi -pm ENABLED || true

View File

@ -14,7 +14,8 @@ fi
if [[ -z $CHANNEL ]]; then if [[ -z $CHANNEL ]]; then
echo Unable to determine channel to publish into, exiting. echo Unable to determine channel to publish into, exiting.
exit 1 echo "^^^ +++"
exit 0
fi fi
rm -rf usr/ rm -rf usr/

View File

@ -94,8 +94,8 @@ pub struct Bank {
/// FIFO queue of `last_id` items /// FIFO queue of `last_id` items
last_ids: RwLock<StatusDeque<Result<()>>>, last_ids: RwLock<StatusDeque<Result<()>>>,
// The latest finality time for the network // The latest confirmation time for the network
finality_time: AtomicUsize, confirmation_time: AtomicUsize,
// Mapping of account ids to Subscriber ids and sinks to notify on userdata update // Mapping of account ids to Subscriber ids and sinks to notify on userdata update
account_subscriptions: RwLock<HashMap<Pubkey, HashMap<Pubkey, Sink<Account>>>>, account_subscriptions: RwLock<HashMap<Pubkey, HashMap<Pubkey, Sink<Account>>>>,
@ -115,7 +115,7 @@ impl Default for Bank {
Bank { Bank {
accounts: Accounts::default(), accounts: Accounts::default(),
last_ids: RwLock::new(StatusDeque::default()), last_ids: RwLock::new(StatusDeque::default()),
finality_time: AtomicUsize::new(std::usize::MAX), confirmation_time: AtomicUsize::new(std::usize::MAX),
account_subscriptions: RwLock::new(HashMap::new()), account_subscriptions: RwLock::new(HashMap::new()),
signature_subscriptions: RwLock::new(HashMap::new()), signature_subscriptions: RwLock::new(HashMap::new()),
leader_scheduler: Arc::new(RwLock::new(LeaderScheduler::default())), leader_scheduler: Arc::new(RwLock::new(LeaderScheduler::default())),
@ -316,14 +316,14 @@ impl Bank {
} }
/// Looks through a list of tick heights and stakes, and finds the latest /// Looks through a list of tick heights and stakes, and finds the latest
/// tick that has achieved finality /// tick that has achieved confirmation
pub fn get_finality_timestamp( pub fn get_confirmation_timestamp(
&self, &self,
ticks_and_stakes: &mut [(u64, u64)], ticks_and_stakes: &mut [(u64, u64)],
supermajority_stake: u64, supermajority_stake: u64,
) -> Option<u64> { ) -> Option<u64> {
let last_ids = self.last_ids.read().unwrap(); let last_ids = self.last_ids.read().unwrap();
last_ids.get_finality_timestamp(ticks_and_stakes, supermajority_stake) last_ids.get_confirmation_timestamp(ticks_and_stakes, supermajority_stake)
} }
/// Tell the bank which Entry IDs exist on the ledger. This function /// Tell the bank which Entry IDs exist on the ledger. This function
@ -871,12 +871,13 @@ impl Bank {
self.accounts.hash_internal_state() self.accounts.hash_internal_state()
} }
pub fn finality(&self) -> usize { pub fn confirmation_time(&self) -> usize {
self.finality_time.load(Ordering::Relaxed) self.confirmation_time.load(Ordering::Relaxed)
} }
pub fn set_finality(&self, finality: usize) { pub fn set_confirmation_time(&self, confirmation: usize) {
self.finality_time.store(finality, Ordering::Relaxed); self.confirmation_time
.store(confirmation, Ordering::Relaxed);
} }
fn send_account_notifications( fn send_account_notifications(
@ -1403,11 +1404,11 @@ mod tests {
assert_eq!(bank0.hash_internal_state(), bank1.hash_internal_state()); assert_eq!(bank0.hash_internal_state(), bank1.hash_internal_state());
} }
#[test] #[test]
fn test_finality() { fn test_confirmation_time() {
let def_bank = Bank::default(); let def_bank = Bank::default();
assert_eq!(def_bank.finality(), std::usize::MAX); assert_eq!(def_bank.confirmation_time(), std::usize::MAX);
def_bank.set_finality(90); def_bank.set_confirmation_time(90);
assert_eq!(def_bank.finality(), 90); assert_eq!(def_bank.confirmation_time(), 90);
} }
#[test] #[test]
fn test_interleaving_locks() { fn test_interleaving_locks() {

View File

@ -3,7 +3,7 @@
//! can do its processing in parallel with signature verification on the GPU. //! can do its processing in parallel with signature verification on the GPU.
use crate::bank::Bank; use crate::bank::Bank;
use crate::compute_leader_finality_service::ComputeLeaderFinalityService; use crate::compute_leader_confirmation_service::ComputeLeaderConfirmationService;
use crate::counter::Counter; use crate::counter::Counter;
use crate::entry::Entry; use crate::entry::Entry;
use crate::packet::Packets; use crate::packet::Packets;
@ -40,7 +40,7 @@ pub struct BankingStage {
/// Handle to the stage's thread. /// Handle to the stage's thread.
bank_thread_hdls: Vec<JoinHandle<Option<BankingStageReturnType>>>, bank_thread_hdls: Vec<JoinHandle<Option<BankingStageReturnType>>>,
poh_service: PohService, poh_service: PohService,
compute_finality_service: ComputeLeaderFinalityService, compute_confirmation_service: ComputeLeaderConfirmationService,
} }
impl BankingStage { impl BankingStage {
@ -64,8 +64,8 @@ impl BankingStage {
// Once an entry has been recorded, its last_id is registered with the bank. // Once an entry has been recorded, its last_id is registered with the bank.
let poh_service = PohService::new(poh_recorder.clone(), config); let poh_service = PohService::new(poh_recorder.clone(), config);
// Single thread to compute finality // Single thread to compute confirmation
let compute_finality_service = ComputeLeaderFinalityService::new( let compute_confirmation_service = ComputeLeaderConfirmationService::new(
bank.clone(), bank.clone(),
leader_id, leader_id,
poh_service.poh_exit.clone(), poh_service.poh_exit.clone(),
@ -120,7 +120,7 @@ impl BankingStage {
Self { Self {
bank_thread_hdls, bank_thread_hdls,
poh_service, poh_service,
compute_finality_service, compute_confirmation_service,
}, },
entry_receiver, entry_receiver,
) )
@ -239,7 +239,7 @@ impl Service for BankingStage {
} }
} }
self.compute_finality_service.join()?; self.compute_confirmation_service.join()?;
let poh_return_value = self.poh_service.join()?; let poh_return_value = self.poh_service.join()?;
match poh_return_value { match poh_return_value {

View File

@ -1,5 +1,5 @@
//! The `compute_leader_finality_service` module implements the tools necessary //! The `compute_leader_confirmation_service` module implements the tools necessary
//! to generate a thread which regularly calculates the last finality times //! to generate a thread which regularly calculates the last confirmation times
//! observed by the leader //! observed by the leader
use crate::bank::Bank; use crate::bank::Bank;
@ -17,23 +17,23 @@ use std::thread::{self, Builder, JoinHandle};
use std::time::Duration; use std::time::Duration;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum FinalityError { pub enum ConfirmationError {
NoValidSupermajority, NoValidSupermajority,
} }
pub const COMPUTE_FINALITY_MS: u64 = 100; pub const COMPUTE_CONFIRMATION_MS: u64 = 100;
pub struct ComputeLeaderFinalityService { pub struct ComputeLeaderConfirmationService {
compute_finality_thread: JoinHandle<()>, compute_confirmation_thread: JoinHandle<()>,
} }
impl ComputeLeaderFinalityService { impl ComputeLeaderConfirmationService {
fn get_last_supermajority_timestamp( fn get_last_supermajority_timestamp(
bank: &Arc<Bank>, bank: &Arc<Bank>,
leader_id: Pubkey, leader_id: Pubkey,
now: u64, now: u64,
last_valid_validator_timestamp: u64, last_valid_validator_timestamp: u64,
) -> result::Result<u64, FinalityError> { ) -> result::Result<u64, ConfirmationError> {
let mut total_stake = 0; let mut total_stake = 0;
let mut ticks_and_stakes: Vec<(u64, u64)> = { let mut ticks_and_stakes: Vec<(u64, u64)> = {
@ -72,14 +72,14 @@ impl ComputeLeaderFinalityService {
let super_majority_stake = (2 * total_stake) / 3; let super_majority_stake = (2 * total_stake) / 3;
if let Some(last_valid_validator_timestamp) = if let Some(last_valid_validator_timestamp) =
bank.get_finality_timestamp(&mut ticks_and_stakes, super_majority_stake) bank.get_confirmation_timestamp(&mut ticks_and_stakes, super_majority_stake)
{ {
return Ok(last_valid_validator_timestamp); return Ok(last_valid_validator_timestamp);
} }
if last_valid_validator_timestamp != 0 { if last_valid_validator_timestamp != 0 {
submit( submit(
influxdb::Point::new(&"leader-finality") influxdb::Point::new(&"leader-confirmation")
.add_field( .add_field(
"duration_ms", "duration_ms",
influxdb::Value::Integer((now - last_valid_validator_timestamp) as i64), influxdb::Value::Integer((now - last_valid_validator_timestamp) as i64),
@ -88,10 +88,10 @@ impl ComputeLeaderFinalityService {
); );
} }
Err(FinalityError::NoValidSupermajority) Err(ConfirmationError::NoValidSupermajority)
} }
pub fn compute_finality( pub fn compute_confirmation(
bank: &Arc<Bank>, bank: &Arc<Bank>,
leader_id: Pubkey, leader_id: Pubkey,
last_valid_validator_timestamp: &mut u64, last_valid_validator_timestamp: &mut u64,
@ -103,53 +103,60 @@ impl ComputeLeaderFinalityService {
now, now,
*last_valid_validator_timestamp, *last_valid_validator_timestamp,
) { ) {
let finality_ms = now - super_majority_timestamp; let confirmation_ms = now - super_majority_timestamp;
*last_valid_validator_timestamp = super_majority_timestamp; *last_valid_validator_timestamp = super_majority_timestamp;
bank.set_finality((now - *last_valid_validator_timestamp) as usize); bank.set_confirmation_time((now - *last_valid_validator_timestamp) as usize);
submit( submit(
influxdb::Point::new(&"leader-finality") influxdb::Point::new(&"leader-confirmation")
.add_field("duration_ms", influxdb::Value::Integer(finality_ms as i64)) .add_field(
"duration_ms",
influxdb::Value::Integer(confirmation_ms as i64),
)
.to_owned(), .to_owned(),
); );
} }
} }
/// Create a new ComputeLeaderFinalityService for computing finality. /// Create a new ComputeLeaderConfirmationService for computing confirmation.
pub fn new(bank: Arc<Bank>, leader_id: Pubkey, exit: Arc<AtomicBool>) -> Self { pub fn new(bank: Arc<Bank>, leader_id: Pubkey, exit: Arc<AtomicBool>) -> Self {
let compute_finality_thread = Builder::new() let compute_confirmation_thread = Builder::new()
.name("solana-leader-finality-stage".to_string()) .name("solana-leader-confirmation-stage".to_string())
.spawn(move || { .spawn(move || {
let mut last_valid_validator_timestamp = 0; let mut last_valid_validator_timestamp = 0;
loop { loop {
if exit.load(Ordering::Relaxed) { if exit.load(Ordering::Relaxed) {
break; break;
} }
Self::compute_finality(&bank, leader_id, &mut last_valid_validator_timestamp); Self::compute_confirmation(
sleep(Duration::from_millis(COMPUTE_FINALITY_MS)); &bank,
leader_id,
&mut last_valid_validator_timestamp,
);
sleep(Duration::from_millis(COMPUTE_CONFIRMATION_MS));
} }
}) })
.unwrap(); .unwrap();
(ComputeLeaderFinalityService { (ComputeLeaderConfirmationService {
compute_finality_thread, compute_confirmation_thread,
}) })
} }
} }
impl Service for ComputeLeaderFinalityService { impl Service for ComputeLeaderConfirmationService {
type JoinReturnType = (); type JoinReturnType = ();
fn join(self) -> thread::Result<()> { fn join(self) -> thread::Result<()> {
self.compute_finality_thread.join() self.compute_confirmation_thread.join()
} }
} }
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use crate::bank::Bank; use crate::bank::Bank;
use crate::compute_leader_finality_service::ComputeLeaderFinalityService; use crate::compute_leader_confirmation_service::ComputeLeaderConfirmationService;
use crate::create_vote_account::*; use crate::create_vote_account::*;
use crate::mint::Mint; use crate::mint::Mint;
@ -164,7 +171,7 @@ pub mod tests {
use std::time::Duration; use std::time::Duration;
#[test] #[test]
fn test_compute_finality() { fn test_compute_confirmation() {
solana_logger::setup(); solana_logger::setup();
let mint = Mint::new(1234); let mint = Mint::new(1234);
@ -206,14 +213,14 @@ pub mod tests {
}) })
.collect(); .collect();
// There isn't 2/3 consensus, so the bank's finality value should be the default // There isn't 2/3 consensus, so the bank's confirmation value should be the default
let mut last_finality_time = 0; let mut last_confirmation_time = 0;
ComputeLeaderFinalityService::compute_finality( ComputeLeaderConfirmationService::compute_confirmation(
&bank, &bank,
dummy_leader_id, dummy_leader_id,
&mut last_finality_time, &mut last_confirmation_time,
); );
assert_eq!(bank.finality(), std::usize::MAX); assert_eq!(bank.confirmation_time(), std::usize::MAX);
// Get another validator to vote, so we now have 2/3 consensus // Get another validator to vote, so we now have 2/3 consensus
let vote_account = &vote_accounts[7]; let vote_account = &vote_accounts[7];
@ -221,12 +228,12 @@ pub mod tests {
let vote_tx = Transaction::vote_new(&vote_account, vote, ids[6], 0); let vote_tx = Transaction::vote_new(&vote_account, vote, ids[6], 0);
bank.process_transaction(&vote_tx).unwrap(); bank.process_transaction(&vote_tx).unwrap();
ComputeLeaderFinalityService::compute_finality( ComputeLeaderConfirmationService::compute_confirmation(
&bank, &bank,
dummy_leader_id, dummy_leader_id,
&mut last_finality_time, &mut last_confirmation_time,
); );
assert!(bank.finality() != std::usize::MAX); assert!(bank.confirmation_time() != std::usize::MAX);
assert!(last_finality_time > 0); assert!(last_confirmation_time > 0);
} }
} }

View File

@ -32,7 +32,7 @@ pub mod create_vote_account;
#[macro_use] #[macro_use]
pub mod contact_info; pub mod contact_info;
pub mod cluster_info; pub mod cluster_info;
pub mod compute_leader_finality_service; pub mod compute_leader_confirmation_service;
pub mod db_ledger; pub mod db_ledger;
pub mod db_window; pub mod db_window;
pub mod entry; pub mod entry;

View File

@ -25,7 +25,7 @@ use std::thread::{self, Builder, JoinHandle};
use std::time::Duration; use std::time::Duration;
use std::time::Instant; use std::time::Instant;
pub const BLOCK_TICK_COUNT: u64 = 8; pub const BLOCK_TICK_COUNT: u64 = 4;
pub const MAX_ENTRY_RECV_PER_ITER: usize = 512; pub const MAX_ENTRY_RECV_PER_ITER: usize = 512;
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]

View File

@ -135,8 +135,8 @@ build_rpc_trait! {
#[rpc(meta, name = "getBalance")] #[rpc(meta, name = "getBalance")]
fn get_balance(&self, Self::Metadata, String) -> Result<u64>; fn get_balance(&self, Self::Metadata, String) -> Result<u64>;
#[rpc(meta, name = "getFinality")] #[rpc(meta, name = "getConfirmationTime")]
fn get_finality(&self, Self::Metadata) -> Result<usize>; fn get_confirmation_time(&self, Self::Metadata) -> Result<usize>;
#[rpc(meta, name = "getLastId")] #[rpc(meta, name = "getLastId")]
fn get_last_id(&self, Self::Metadata) -> Result<String>; fn get_last_id(&self, Self::Metadata) -> Result<String>;
@ -184,9 +184,9 @@ impl RpcSol for RpcSolImpl {
let pubkey = verify_pubkey(id)?; let pubkey = verify_pubkey(id)?;
meta.request_processor.get_balance(pubkey) meta.request_processor.get_balance(pubkey)
} }
fn get_finality(&self, meta: Self::Metadata) -> Result<usize> { fn get_confirmation_time(&self, meta: Self::Metadata) -> Result<usize> {
info!("get_finality rpc request received"); info!("get_confirmation_time rpc request received");
meta.request_processor.get_finality() meta.request_processor.get_confirmation_time()
} }
fn get_last_id(&self, meta: Self::Metadata) -> Result<String> { fn get_last_id(&self, meta: Self::Metadata) -> Result<String> {
info!("get_last_id rpc request received"); info!("get_last_id rpc request received");
@ -329,8 +329,8 @@ impl JsonRpcRequestProcessor {
let val = self.bank.get_balance(&pubkey); let val = self.bank.get_balance(&pubkey);
Ok(val) Ok(val)
} }
fn get_finality(&self) -> Result<usize> { fn get_confirmation_time(&self) -> Result<usize> {
Ok(self.bank.finality()) Ok(self.bank.confirmation_time())
} }
fn get_last_id(&self) -> Result<String> { fn get_last_id(&self) -> Result<String> {
let id = self.bank.last_id(); let id = self.bank.last_id();
@ -612,11 +612,11 @@ mod tests {
} }
#[test] #[test]
fn test_rpc_get_finality() { fn test_rpc_get_confirmation() {
let bob_pubkey = Keypair::new().pubkey(); let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _last_id, _alice_keypair) = start_rpc_handler_with_tx(bob_pubkey); let (io, meta, _last_id, _alice_keypair) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getFinality"}}"#); let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmationTime"}}"#);
let res = io.handle_request_sync(&req, meta); let res = io.handle_request_sync(&req, meta);
let expected = format!(r#"{{"jsonrpc":"2.0","result":18446744073709551615,"id":1}}"#); let expected = format!(r#"{{"jsonrpc":"2.0","result":18446744073709551615,"id":1}}"#);
let expected: Response = let expected: Response =

View File

@ -44,7 +44,7 @@ pub enum RpcRequest {
ConfirmTransaction, ConfirmTransaction,
GetAccountInfo, GetAccountInfo,
GetBalance, GetBalance,
GetFinality, GetConfirmationTime,
GetLastId, GetLastId,
GetSignatureStatus, GetSignatureStatus,
GetTransactionCount, GetTransactionCount,
@ -89,7 +89,7 @@ impl RpcRequest {
RpcRequest::ConfirmTransaction => "confirmTransaction", RpcRequest::ConfirmTransaction => "confirmTransaction",
RpcRequest::GetAccountInfo => "getAccountInfo", RpcRequest::GetAccountInfo => "getAccountInfo",
RpcRequest::GetBalance => "getBalance", RpcRequest::GetBalance => "getBalance",
RpcRequest::GetFinality => "getFinality", RpcRequest::GetConfirmationTime => "getConfirmationTime",
RpcRequest::GetLastId => "getLastId", RpcRequest::GetLastId => "getLastId",
RpcRequest::GetSignatureStatus => "getSignatureStatus", RpcRequest::GetSignatureStatus => "getSignatureStatus",
RpcRequest::GetTransactionCount => "getTransactionCount", RpcRequest::GetTransactionCount => "getTransactionCount",
@ -166,9 +166,9 @@ mod tests {
); );
assert_eq!(request["method"], "getBalance"); assert_eq!(request["method"], "getBalance");
let test_request = RpcRequest::GetFinality; let test_request = RpcRequest::GetConfirmationTime;
let request = test_request.build_request_json(1, None); let request = test_request.build_request_json(1, None);
assert_eq!(request["method"], "getFinality"); assert_eq!(request["method"], "getConfirmationTime");
assert_eq!(request["params"], json!(null)); assert_eq!(request["params"], json!(null));
let test_request = RpcRequest::GetLastId; let test_request = RpcRequest::GetLastId;

View File

@ -44,7 +44,7 @@ struct StatusEntry<T> {
/// when the id was registered, according to network time /// when the id was registered, according to network time
tick_height: u64, tick_height: u64,
/// timestamp when this id was registered, used for stats/finality /// timestamp when this id was registered, used for stats/confirmation
timestamp: u64, timestamp: u64,
/// a map of signature status, used for duplicate detection /// a map of signature status, used for duplicate detection
@ -183,14 +183,14 @@ impl<T: Clone> StatusDeque<T> {
} }
/// Looks through a list of tick heights and stakes, and finds the latest /// Looks through a list of tick heights and stakes, and finds the latest
/// tick that has achieved finality /// tick that has achieved confirmation
pub fn get_finality_timestamp( pub fn get_confirmation_timestamp(
&self, &self,
ticks_and_stakes: &mut [(u64, u64)], ticks_and_stakes: &mut [(u64, u64)],
supermajority_stake: u64, supermajority_stake: u64,
) -> Option<u64> { ) -> Option<u64> {
// Sort by tick height // Sort by tick height
ticks_and_stakes.sort_by(|a, b| a.0.cmp(&b.0)); ticks_and_stakes.sort_by(|a, b| b.0.cmp(&a.0));
let current_tick_height = self.tick_height; let current_tick_height = self.tick_height;
let mut total = 0; let mut total = 0;
for (tick_height, stake) in ticks_and_stakes.iter() { for (tick_height, stake) in ticks_and_stakes.iter() {

View File

@ -41,7 +41,7 @@ pub struct ThinClient {
transaction_count: u64, transaction_count: u64,
balances: HashMap<Pubkey, Account>, balances: HashMap<Pubkey, Account>,
signature_status: bool, signature_status: bool,
finality: Option<usize>, confirmation: Option<usize>,
rpc_client: RpcClient, rpc_client: RpcClient,
} }
@ -87,7 +87,7 @@ impl ThinClient {
transaction_count: 0, transaction_count: 0,
balances: HashMap::new(), balances: HashMap::new(),
signature_status: false, signature_status: false,
finality: None, confirmation: None,
} }
} }
@ -187,23 +187,23 @@ impl ThinClient {
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "AccountNotFound")) .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "AccountNotFound"))
} }
/// Request the finality from the leader node /// Request the confirmation time from the leader node
pub fn get_finality(&mut self) -> usize { pub fn get_confirmation_time(&mut self) -> usize {
trace!("get_finality"); trace!("get_confirmation_time");
let mut done = false; let mut done = false;
while !done { while !done {
debug!("get_finality send_to {}", &self.rpc_addr); debug!("get_confirmation_time send_to {}", &self.rpc_addr);
let resp = RpcRequest::GetFinality.make_rpc_request(&self.rpc_client, 1, None); let resp = RpcRequest::GetConfirmationTime.make_rpc_request(&self.rpc_client, 1, None);
if let Ok(value) = resp { if let Ok(value) = resp {
done = true; done = true;
let finality = value.as_u64().unwrap() as usize; let confirmation = value.as_u64().unwrap() as usize;
self.finality = Some(finality); self.confirmation = Some(confirmation);
} else { } else {
debug!("thin_client get_finality error: {:?}", resp); debug!("thin_client get_confirmation_time error: {:?}", resp);
} }
} }
self.finality.expect("some finality") self.confirmation.expect("some confirmation")
} }
/// Request the transaction count. If the response packet is dropped by the network, /// Request the transaction count. If the response packet is dropped by the network,
@ -477,8 +477,8 @@ mod tests {
let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket); let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket);
let transaction_count = client.transaction_count(); let transaction_count = client.transaction_count();
assert_eq!(transaction_count, 0); assert_eq!(transaction_count, 0);
let finality = client.get_finality(); let confirmation = client.get_confirmation_time();
assert_eq!(finality, 18446744073709551615); assert_eq!(confirmation, 18446744073709551615);
let last_id = client.get_last_id(); let last_id = client.get_last_id();
let signature = client let signature = client
.transfer(500, &alice.keypair(), bob_pubkey, &last_id) .transfer(500, &alice.keypair(), bob_pubkey, &last_id)

12
src/window_service.rs Normal file → Executable file
View File

@ -89,12 +89,6 @@ fn recv_window(
(p.index()?, p.meta.size) (p.index()?, p.meta.size)
}; };
submit(
influxdb::Point::new("window-service")
.add_field("last-recv", influxdb::Value::Integer(pix as i64))
.to_owned(),
);
trace!("{} window pix: {} size: {}", id, pix, meta_size); trace!("{} window pix: {} size: {}", id, pix, meta_size);
let _ = process_blob( let _ = process_blob(
@ -172,12 +166,6 @@ pub fn window_service(
let received = meta.received; let received = meta.received;
let consumed = meta.consumed; let consumed = meta.consumed;
submit(
influxdb::Point::new("window-stage")
.add_field("consumed", influxdb::Value::Integer(consumed as i64))
.to_owned(),
);
// Consumed should never be bigger than received // Consumed should never be bigger than received
assert!(consumed <= received); assert!(consumed <= received);
if received == consumed { if received == consumed {

View File

@ -714,8 +714,8 @@ fn test_multi_node_dynamic_network() {
let mut validators: Vec<_> = t2.into_iter().map(|t| t.join().unwrap()).collect(); let mut validators: Vec<_> = t2.into_iter().map(|t| t.join().unwrap()).collect();
let mut client = mk_client(&leader_data); let mut client = mk_client(&leader_data);
let mut last_finality = client.get_finality(); let mut last_confirmation = client.get_confirmation_time();
info!("Last finality {}", last_finality); info!("Last confirmation {}", last_confirmation);
let start = Instant::now(); let start = Instant::now();
let mut consecutive_success = 0; let mut consecutive_success = 0;
let mut expected_balance = leader_balance; let mut expected_balance = leader_balance;
@ -738,28 +738,28 @@ fn test_multi_node_dynamic_network() {
assert!(e.is_ok(), "err: {:?}", e); assert!(e.is_ok(), "err: {:?}", e);
let now = Instant::now(); let now = Instant::now();
let mut finality = client.get_finality(); let mut confirmation = client.get_confirmation_time();
// Need this to make sure the finality is updated // Need this to make sure the confirmation is updated
// (i.e. the node is not returning stale value) // (i.e. the node is not returning stale value)
while last_finality == finality { while last_confirmation == confirmation {
finality = client.get_finality(); confirmation = client.get_confirmation_time();
} }
while duration_as_ms(&now.elapsed()) < finality as u64 { while duration_as_ms(&now.elapsed()) < confirmation as u64 {
sleep(Duration::from_millis(100)); sleep(Duration::from_millis(100));
finality = client.get_finality() confirmation = client.get_confirmation_time()
} }
last_finality = finality; last_confirmation = confirmation;
let balance = retry_get_balance(&mut client, &bob_pubkey, Some(expected_balance)); let balance = retry_get_balance(&mut client, &bob_pubkey, Some(expected_balance));
assert_eq!(balance, Some(expected_balance)); assert_eq!(balance, Some(expected_balance));
consecutive_success += 1; consecutive_success += 1;
info!( info!(
"SUCCESS[{}] balance: {}, finality: {} ms", "SUCCESS[{}] balance: {}, confirmation: {} ms",
i, expected_balance, last_finality, i, expected_balance, last_confirmation,
); );
if consecutive_success == 10 { if consecutive_success == 10 {