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
1 change: 1 addition & 0 deletions aptos-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ tokio = { workspace = true }
ureq = { workspace = true }
url = { workspace = true }
rapture = { git="https://github.com/aptos-labs/rapture/", branch="rapture-clean", optional = true }
#rapture = { path = "/root/aptos-core-rapture-test-0627/rapture", optional = true }

[target.'cfg(unix)'.dependencies]
jemallocator = { version = "0.5.0", features = [
Expand Down
4 changes: 2 additions & 2 deletions aptos-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ use clap::Parser;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
fn init_fuzzing_hooks() {
rapture::init_state_model(); // register StateModel
rapture::init_fuzzer_hook(); // register FuzzHook
}

fn main() {
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
init_fuzzing_hooks();
// Check that we are not including any Move test natives
aptos_vm::natives::assert_no_test_natives(ERROR_MSG_BAD_FEATURE_FLAGS);
Expand Down
23 changes: 11 additions & 12 deletions consensus/src/epoch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ use std::{
time::Duration,
};

#[cfg(feature = "consensus_fuzzer")]
use crate::rapture_hook::{StateModelLike, run_fuzzer};
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
use crate::rapture_hook::rapture_hook::{StateModelLike, run_fuzzer};
#[cfg(feature = "consensus-fuzzer")]
use std::sync::OnceLock;
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
static GLOBAL_STATE_MODEL: OnceLock<Arc<Mutex<Box<dyn StateModelLike>>>> = OnceLock::new();

/// Range of rounds (window) that we might be calling proposer election
Expand Down Expand Up @@ -957,11 +957,10 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
.config
.max_blocks_per_receiving_request(onchain_consensus_config.quorum_store_enabled());

#[cfg(feature = "consensus_fuzzer")]
{
let epoch_state_copy = epoch_state.clone();
let safety_rules_container_new = safety_rules_container.clone();
}
#[cfg(feature = "consensus-fuzzer")]
let epoch_state_copy = epoch_state.clone();
#[cfg(feature = "consensus-fuzzer")]
let safety_rules_container_new = safety_rules_container.clone();
let mut round_manager = RoundManager::new(
epoch_state,
block_store.clone(),
Expand Down Expand Up @@ -994,7 +993,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> {

self.spawn_block_retrieval_task(epoch, block_store, max_blocks_allowed);

#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
{
let mut rapture_network_sender = NetworkSender::new(
self.author,
Expand All @@ -1003,7 +1002,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
epoch_state_copy.verifier.clone(),
);
let mut copy_network = rapture_network_sender.clone();
if let Some(state_model) = crate::rapture_hook::get_state_model_arc() {
if let Some(state_model) = crate::rapture_hook::rapture_hook::get_state_model_arc() {
run_fuzzer(copy_network, state_model.clone(), safety_rules_container_new, self.author);
}
}
Expand Down Expand Up @@ -1524,7 +1523,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
fail_point!("consensus::process::any", |_| {
Err(anyhow::anyhow!("Injected error in process_message"))
});
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
if let Some(model) = GLOBAL_STATE_MODEL.get() {
let mut model_guard = model.lock();
model_guard.on_new_msg(&consensus_msg);
Expand Down
16 changes: 8 additions & 8 deletions consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

#![cfg_attr(not(feature = "consensus_fuzzer"), forbid(unsafe_code))]
#![cfg_attr(not(feature = "consensus-fuzzer"), forbid(unsafe_code))]

//! Consensus for the Aptos Core blockchain
//!
Expand All @@ -24,13 +24,13 @@ mod epoch_manager;
mod error;
mod liveness;
mod logging;
#[cfg(not(feature = "consensus_fuzzer"))]
#[cfg(not(feature = "consensus-fuzzer"))]
mod metrics_safety_rules;
#[cfg(not(feature = "consensus_fuzzer"))]
#[cfg(not(feature = "consensus-fuzzer"))]
mod network;
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
pub mod metrics_safety_rules;
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
pub mod network;
#[cfg(test)]
mod network_tests;
Expand All @@ -42,11 +42,11 @@ mod pending_votes_test;
pub mod persistent_liveness_storage;
mod pipeline;
pub mod quorum_store;
#[cfg(not(feature = "consensus_fuzzer"))]
#[cfg(not(feature = "consensus-fuzzer"))]
mod rand;
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
pub mod rand;
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
pub mod rapture_hook;
mod recovery_manager;
mod round_manager;
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ use std::{
use tokio::time::timeout;
use cfg_if::cfg_if;

#[cfg(feature = "consensus_fuzzer")]
use crate::rapture_hook::consensus_msg_mutate;
#[cfg(feature = "consensus-fuzzer")]
use crate::rapture_hook::rapture_hook::consensus_msg_mutate;

pub trait TConsensusMsg: Sized + Serialize + DeserializeOwned {
fn epoch(&self) -> u64;
Expand Down Expand Up @@ -372,7 +372,7 @@ impl NetworkSender {
.with_label_values(&[msg.name()])
.inc_by(other_validators.len() as u64);
cfg_if! {
if #[cfg(feature = "consensus_fuzzer")] {
if #[cfg(feature = "consensus-fuzzer")] {
let mut fuzzing_msg = consensus_msg_mutate(msg.clone());
if let Err(err) = self
.consensus_network_client
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/rapture_hook/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[cfg(feature = "consensus_fuzzer")]
#[cfg(feature = "consensus-fuzzer")]
pub mod rapture_hook;
Loading