Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,15 @@ serial = [
"snarkos-node-sync/serial",
"snarkvm/serial"
]
tokio_console = [ "snarkos-cli/tokio_console" ]
# Set low puzzle targets for easier testing.
test_targets = [ "snarkos-cli/test_targets" ]
# Set custom consensus heights for easier testing.
test_consensus_heights = [ "snarkos-cli/test_consensus_heights" ]
# Set low puzzle targets and custom consensus heights for easier testing.
test_network = [ "snarkos-cli/test_network" ]
tokio_console = [ "snarkos-cli/tokio_console" ]
# Track duration of consensus stages.
test_consensus_tracking = [ "snarkos-node/test_consensus_tracking" ]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to start documenting these new features. Either here or in the README similar to what I did in this PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


[dependencies.clap]
workspace = true
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ serial = [
"snarkvm/serial",
"snarkos-node-bft/serial"
]
test_consensus_tracking = [ "snarkos-node-bft/test_consensus_tracking", "snarkos-node-consensus/test_consensus_tracking" ]
test = []

[dependencies.aleo-std]
Expand Down
11 changes: 11 additions & 0 deletions node/bft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test = [
"snarkos-node-bft-ledger-service/test",
"snarkos-node-bft-storage-service/test"
]
test_consensus_tracking = [ ]
serial = [
"snarkos-node-metrics/serial",
"snarkos-node-bft-ledger-service/serial"
Expand Down Expand Up @@ -97,6 +98,16 @@ workspace = true
[dependencies.rayon]
workspace = true

[dependencies.serde]
workspace = true
features = [ "derive" ]

[dependencies.serde_json]
workspace = true

[dependencies.once_cell]
version = "1.0"

[dependencies.sha2]
version = "0.10"
default-features = false
Expand Down
8 changes: 8 additions & 0 deletions node/bft/src/bft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "test_consensus_tracking")]
use crate::helpers::{ConsensusStage, SubdagStage, record_event, start_subdag_stage};
use crate::{
MAX_LEADER_CERTIFICATE_DELAY_IN_SECS,
Primary,
Expand Down Expand Up @@ -506,6 +508,9 @@ impl<N: Network> BFT<N> {
// Insert the certificate into the DAG.
self.dag.write().insert(certificate);

#[cfg(feature = "test_consensus_tracking")]
record_event(certificate_round, ConsensusStage::CertificateAdded);

// ### Second, determine if a new leader certificate can be committed. ###
let commit_round = certificate_round.saturating_sub(1);

Expand Down Expand Up @@ -596,6 +601,9 @@ impl<N: Network> BFT<N> {

// Fetch the leader round.
let latest_leader_round = leader_certificate.round();

#[cfg(feature = "test_consensus_tracking")]
start_subdag_stage(latest_leader_round.saturating_sub(2), latest_leader_round, SubdagStage::SubdagProcessing);
// Determine the list of all previous leader certificates since the last committed round.
// The order of the leader certificates is from **newest** to **oldest**.
let mut leader_certificates = vec![leader_certificate.clone()];
Expand Down
5 changes: 5 additions & 0 deletions node/bft/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ pub use telemetry::*;
pub mod timestamp;
pub use timestamp::*;

#[cfg(feature = "test_consensus_tracking")]
pub mod timing;
#[cfg(feature = "test_consensus_tracking")]
pub use timing::*;

/// Formats an ID into a truncated identifier (for logging purposes).
pub fn fmt_id(id: impl ToString) -> String {
let id = id.to_string();
Expand Down
Loading