diff --git a/config/extra/with-handholding.mk b/config/extra/with-handholding.mk index c0c89ffcc6..1635899958 100644 --- a/config/extra/with-handholding.mk +++ b/config/extra/with-handholding.mk @@ -6,7 +6,6 @@ CPPFLAGS+=-DFD_SPAD_USE_HANDHOLDING=1 CPPFLAGS+=-DFD_TOWER_USE_HANDHOLDING=1 CPPFLAGS+=-DFD_TMPL_USE_HANDHOLDING=1 CPPFLAGS+=-DFD_TXN_HANDHOLDING=1 -CPPFLAGS+=-DFD_FUNK_HANDHOLDING=1 CPPFLAGS+=-DFD_RUNTIME_ERR_HANDHOLDING=1 CPPFLAGS+=-DFD_FOREST_USE_HANDHOLDING=1 CPPFLAGS+=-DFD_STAKES_USE_HANDHOLDING=1 diff --git a/contrib/bundle-test-server/Cargo.toml b/contrib/bundle-test-server/Cargo.toml index c79849c254..7446959512 100644 --- a/contrib/bundle-test-server/Cargo.toml +++ b/contrib/bundle-test-server/Cargo.toml @@ -4,24 +4,26 @@ version = "0.1.0" edition = "2021" [dependencies] -tonic = { version = "0.12.2", features = ["tls-roots", "tls", "tls-webpki-roots"] } -prost = "0.13.3" -prost-types = "0.13.3" +tonic = { version = "0.14", features = ["tls-webpki-roots"] } +tonic-prost = "0.14" +prost = "0.14" +prost-types = "0.14" log = "0.4.22" -tokio = { version = "1.40.0", features = ["rt-multi-thread"] } +tokio = "1.47" tokio-stream = "0.1" -futures = "0.3.30" -chrono = "0.4.38" -thiserror = "1.0.64" +futures = "0.3" +chrono = "0.4" +thiserror = "1.0" bs58 = "0.5.1" -futures-util = "0.3.31" -env_logger = "0.11.5" -base64="0.22.1" +futures-util = "0.3" +env_logger = "0.11" +base64 = "0.22" +rustyline = "17.0" [build-dependencies] -tonic-build = "0.12.2" -protobuf-src = "2.1.0" -prost-types = "0.13.3" +tonic-prost-build = "0.14" +protobuf-src = "2.1" +prost-types = "0.14" [dev-dependencies] ed25519-dalek = "2.1.1" diff --git a/contrib/bundle-test-server/build.rs b/contrib/bundle-test-server/build.rs index e71498c768..9dce0e3a60 100644 --- a/contrib/bundle-test-server/build.rs +++ b/contrib/bundle-test-server/build.rs @@ -1,5 +1,3 @@ -use tonic_build::configure; - fn main() -> Result<(), std::io::Error> { const PROTOC_ENVAR: &str = "PROTOC"; if std::env::var(PROTOC_ENVAR).is_err() { @@ -23,7 +21,7 @@ fn main() -> Result<(), std::io::Error> { protos.push(proto); } - configure() + tonic_prost_build::configure() .build_client(false) .build_server(true) .type_attribute( diff --git a/contrib/bundle-test-server/src/main.rs b/contrib/bundle-test-server/src/main.rs index c5dbff908e..7369ac60c8 100644 --- a/contrib/bundle-test-server/src/main.rs +++ b/contrib/bundle-test-server/src/main.rs @@ -1,49 +1,65 @@ use std::pin::Pin; -use crate::proto::auth::{self, Token}; use crate::proto::auth::auth_service_server::{AuthService, AuthServiceServer}; +use crate::proto::auth::{self, Token}; use crate::proto::bundle::{Bundle, BundleUuid}; use crate::proto::packet::{Packet, PacketBatch}; +use base64::prelude::*; use chrono::{Duration, Utc}; +use futures::select; +use futures::FutureExt; +use futures_util::stream::Stream; use log::info; use prost_types::Timestamp; +use rustyline::{error::ReadlineError, DefaultEditor}; +use std::net::SocketAddr; +use std::sync::Arc; +use tokio::sync::{broadcast, mpsc}; use tonic::{transport::Server, Request, Response, Status}; -use futures_util::stream::Stream; -use base64::prelude::*; -use tokio::sync::mpsc; -use crate::proto::block_engine::block_engine_validator_server::{BlockEngineValidator, BlockEngineValidatorServer}; -use crate::proto::block_engine::{SubscribePacketsRequest, SubscribePacketsResponse, SubscribeBundlesRequest, SubscribeBundlesResponse, BlockBuilderFeeInfoRequest, BlockBuilderFeeInfoResponse}; +use crate::proto::block_engine::block_engine_validator_server::{ + BlockEngineValidator, BlockEngineValidatorServer, +}; +use crate::proto::block_engine::{ + BlockBuilderFeeInfoRequest, BlockBuilderFeeInfoResponse, SubscribeBundlesRequest, + SubscribeBundlesResponse, SubscribePacketsRequest, SubscribePacketsResponse, +}; -#[derive(Debug, Default)] -pub struct BlockEngineValidatorService; +pub struct Service { + kill_streams: broadcast::Receiver<()>, +} + +#[derive(Clone)] +pub struct ServiceHandle(Arc); -type PacketResponseStream = Pin> + Send>>; -type BundleResponseStream = Pin> + Send>>; +type PacketResponseStream = + Pin> + Send>>; +type BundleResponseStream = + Pin> + Send>>; -pub mod proto { - pub mod auth { +pub(crate) mod proto { + pub(crate) mod auth { tonic::include_proto!("auth"); } - pub mod block_engine { + pub(crate) mod block_engine { tonic::include_proto!("block_engine"); } - pub mod bundle { + pub(crate) mod bundle { tonic::include_proto!("bundle"); } - pub mod packet { + pub(crate) mod packet { tonic::include_proto!("packet"); } - pub mod relayer { + pub(crate) mod relayer { tonic::include_proto!("relayer"); } - pub mod shared { + pub(crate) mod shared { tonic::include_proto!("shared"); } } #[tonic::async_trait] -impl BlockEngineValidator for BlockEngineValidatorService { +impl BlockEngineValidator for ServiceHandle { type SubscribePacketsStream = PacketResponseStream; type SubscribeBundlesStream = BundleResponseStream; @@ -51,6 +67,7 @@ impl BlockEngineValidator for BlockEngineValidatorService { &self, _request: Request, ) -> Result, Status> { + let mut kill_streams = self.0.kill_streams.resubscribe(); let (tx, rx) = mpsc::channel(16); tokio::spawn(async move { info!("Packet stream start"); @@ -70,19 +87,23 @@ impl BlockEngineValidator for BlockEngineValidatorService { }), }; loop { - if tx.send(Ok(msg.clone())).await.is_err() { - info!("Packet stream stop"); - break; + select! { + _ = kill_streams.recv().fuse() => break, + res = tx.send(Ok(msg.clone())).fuse() => if res.is_err() { break } } } + info!("Packet stream stop"); }); - Ok(Response::new(Box::pin(tokio_stream::wrappers::ReceiverStream::new(rx)))) + Ok(Response::new(Box::pin( + tokio_stream::wrappers::ReceiverStream::new(rx), + ))) } async fn subscribe_bundles( &self, _request: Request, ) -> Result, Status> { + let mut kill_streams = self.0.kill_streams.resubscribe(); let (tx, rx) = mpsc::channel(16); tokio::spawn(async move { info!("Bundle stream start"); @@ -111,13 +132,16 @@ impl BlockEngineValidator for BlockEngineValidatorService { ] }; loop { - if tx.send(Ok(msg.clone())).await.is_err() { - info!("Bundle stream stop"); - break; + select! { + _ = kill_streams.recv().fuse() => break, + res = tx.send(Ok(msg.clone())).fuse() => if res.is_err() { break } } } + info!("Bundle stream stop"); }); - Ok(Response::new(Box::pin(tokio_stream::wrappers::ReceiverStream::new(rx)))) + Ok(Response::new(Box::pin( + tokio_stream::wrappers::ReceiverStream::new(rx), + ))) } async fn get_block_builder_fee_info( @@ -133,17 +157,17 @@ impl BlockEngineValidator for BlockEngineValidatorService { } } -#[derive(Debug, Default)] -pub struct Auth; - #[tonic::async_trait] -impl AuthService for Auth { +impl AuthService for ServiceHandle { async fn generate_auth_challenge( &self, request: Request, ) -> Result, Status> { let req_data = request.into_inner(); - info!("Received auth challenge request from {}", bs58::encode(&req_data.pubkey).into_string()); + info!( + "Received auth challenge request from {}", + bs58::encode(&req_data.pubkey).into_string() + ); Ok(Response::new(auth::GenerateAuthChallengeResponse { challenge: "012345678".to_string(), })) @@ -187,18 +211,100 @@ impl AuthService for Auth { } } -#[tokio::main] -async fn main() -> Result<(), Box> { - env_logger::init(); +struct Cnc { + kill_streams_tx: broadcast::Sender<()>, + kill_server_tx: broadcast::Sender<()>, +} - let addr = "127.0.0.1:50051".parse()?; - info!("Block Engine Validator Server listening on {}", addr); +fn handle_line(cnc: &mut Cnc, line: &str) -> bool { + match line { + "" => return false, + "help" => { + println!("Available commands:"); + println!(" help - Show this help message"); + println!(" exit - Exit the server"); + println!(" kill-streams - Kill all active streams"); + println!(" kill-server - Kill and restart the server"); + } + "exit" | "quit" => { + println!("Exiting..."); + std::process::exit(0); + } + "kill-streams" => { + let _ = cnc.kill_streams_tx.send(()); + } + "kill-server" => { + let _ = cnc.kill_server_tx.send(()); + } + cmd => { + println!("Unknown command: {}", cmd); + return false; + } + } + true +} - Server::builder() - .add_service(BlockEngineValidatorServer::new(BlockEngineValidatorService::default())) - .add_service(AuthServiceServer::new(Auth::default())) - .serve(addr) - .await?; +async fn run_server( + service: ServiceHandle, + listen_addr: SocketAddr, + mut kill_signal: broadcast::Receiver<()>, +) { + loop { + let server = Server::builder() + .add_service(BlockEngineValidatorServer::new(service.clone())) + .add_service(AuthServiceServer::new(service.clone())) + .serve_with_shutdown(listen_addr.clone(), kill_signal.recv().map(|_| ())); + server.await.unwrap(); + info!("Restarting server"); + } +} + +fn main() { + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); + + let (kill_streams_tx, kill_streams_rx) = broadcast::channel(2); + let (kill_server_tx, kill_server_rx) = broadcast::channel(2); + + let mut cnc = Cnc { + kill_streams_tx, + kill_server_tx, + }; + + // Spawn a thread handling all gRPC I/O + let addr: SocketAddr = "127.0.0.1:50051".parse().unwrap(); + let handle = std::thread::spawn(move || { + let rt = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); - Ok(()) + let service = ServiceHandle(Arc::new(Service { + kill_streams: kill_streams_rx, + })); + rt.block_on(run_server(service, addr, kill_server_rx)); + }); + + // Run a REPL on the current thread + let mut rl = match DefaultEditor::new() { + Ok(rl) => rl, + Err(_) => { + handle.join().unwrap(); + std::process::exit(1); + } + }; + println!("Block Engine Validator Server listening on {}", addr); + loop { + let readline = rl.readline(""); + match readline { + Ok(line) => { + if handle_line(&mut cnc, &line) { + let _ = rl.add_history_entry(&line); + } + } + Err(ReadlineError::Interrupted) | Err(ReadlineError::Eof) => { + std::process::exit(0); + } + Err(err) => panic!("Unexpected error: {}", err), + } + } } diff --git a/src/discof/restore/fd_snapin_tile.c b/src/discof/restore/fd_snapin_tile.c index 85c2747030..a8f0deb382 100644 --- a/src/discof/restore/fd_snapin_tile.c +++ b/src/discof/restore/fd_snapin_tile.c @@ -241,6 +241,7 @@ handle_control_frag( fd_snapin_tile_t * ctx, fd_funk_txn_xid_t incremental_xid = fd_funk_generate_xid(); ctx->funk_txn = fd_funk_txn_prepare( ctx->funk, ctx->funk_txn, &incremental_xid, 0 ); + if( FD_UNLIKELY( !ctx->funk_txn ) ) FD_LOG_ERR(( "fd_funk_txn_prepare failed" )); ctx->full = 0; ctx->state = FD_SNAPIN_STATE_LOADING; break; diff --git a/src/flamenco/runtime/fd_runtime.c b/src/flamenco/runtime/fd_runtime.c index 801501e932..302562e2ce 100644 --- a/src/flamenco/runtime/fd_runtime.c +++ b/src/flamenco/runtime/fd_runtime.c @@ -1954,6 +1954,7 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx, fd_funk_txn_xid_t migration_xid = fd_funk_generate_xid(); fd_funk_txn_start_write( slot_ctx->funk ); slot_ctx->funk_txn = fd_funk_txn_prepare( slot_ctx->funk, slot_ctx->funk_txn, &migration_xid, 0UL ); + if( FD_UNLIKELY( !slot_ctx->funk_txn ) ) FD_LOG_ERR(( "fd_funk_txn_prepare failed" )); fd_funk_txn_end_write( slot_ctx->funk ); /* Attempt serialization of program account. If the program is @@ -2804,6 +2805,7 @@ fd_runtime_read_genesis( fd_exec_slot_ctx_t * slot_ctx, xid.ul[1] = 0UL; xid.ul[0] = 0UL; slot_ctx->funk_txn = fd_funk_txn_prepare( slot_ctx->funk, NULL, &xid, 1 ); + if( FD_UNLIKELY( !slot_ctx->funk_txn ) ) FD_LOG_ERR(( "fd_funk_txn_prepare failed" )); fd_funk_txn_end_write( slot_ctx->funk ); fd_runtime_init_bank_from_genesis( slot_ctx, diff --git a/src/funk/fd_funk_rec.c b/src/funk/fd_funk_rec.c index 690b353cc4..a07a9e2848 100644 --- a/src/funk/fd_funk_rec.c +++ b/src/funk/fd_funk_rec.c @@ -57,14 +57,12 @@ fd_funk_rec_query_try( fd_funk_t * funk, fd_funk_txn_t const * txn, fd_funk_rec_key_t const * key, fd_funk_rec_query_t * query ) { -#ifdef FD_FUNK_HANDHOLDING if( FD_UNLIKELY( funk==NULL || key==NULL || query==NULL ) ) { return NULL; } if( FD_UNLIKELY( txn && !fd_funk_txn_valid( funk, txn ) ) ) { return NULL; } -#endif fd_funk_xid_key_pair_t pair[1]; fd_funk_rec_key_set_pair( pair, txn, key ); @@ -108,14 +106,12 @@ fd_funk_rec_query_try_global( fd_funk_t const * funk, fd_funk_rec_key_t const * key, fd_funk_txn_t const ** txn_out, fd_funk_rec_query_t * query ) { -#ifdef FD_FUNK_HANDHOLDING if( FD_UNLIKELY( funk==NULL || key==NULL || query==NULL ) ) { return NULL; } if( FD_UNLIKELY( txn && !fd_funk_txn_valid( funk, txn ) ) ) { return NULL; } -#endif /* Look for the first element in the hash chain with the right record key. This takes advantage of the fact that elements with @@ -213,7 +209,6 @@ fd_funk_rec_prepare( fd_funk_t * funk, fd_funk_rec_key_t const * key, fd_funk_rec_prepare_t * prepare, int * opt_err ) { -#ifdef FD_FUNK_HANDHOLDING if( FD_UNLIKELY( funk==NULL || key==NULL || prepare==NULL ) ) { fd_int_store_if( !!opt_err, opt_err, FD_FUNK_ERR_INVAL ); return NULL; @@ -222,7 +217,6 @@ fd_funk_rec_prepare( fd_funk_t * funk, fd_int_store_if( !!opt_err, opt_err, FD_FUNK_ERR_INVAL ); return NULL; } -#endif memset( prepare, 0, sizeof(fd_funk_rec_prepare_t) ); if( !txn ) { /* Modifying last published */ @@ -472,14 +466,12 @@ fd_funk_rec_remove( fd_funk_t * funk, fd_funk_txn_t * txn, fd_funk_rec_key_t const * key, fd_funk_rec_t ** rec_out ) { -#ifdef FD_FUNK_HANDHOLDING if( FD_UNLIKELY( funk==NULL || key==NULL ) ) { return FD_FUNK_ERR_INVAL; } if( FD_UNLIKELY( txn && !fd_funk_txn_valid( funk, txn ) ) ) { return FD_FUNK_ERR_INVAL; } -#endif if( !txn ) { /* Modifying last published */ if( FD_UNLIKELY( fd_funk_last_publish_is_frozen( funk ) ) ) { diff --git a/src/funk/fd_funk_txn.c b/src/funk/fd_funk_txn.c index 023736f193..a1a12c2653 100644 --- a/src/funk/fd_funk_txn.c +++ b/src/funk/fd_funk_txn.c @@ -51,17 +51,13 @@ fd_funk_txn_prepare( fd_funk_t * funk, fd_funk_txn_xid_t const * xid, int verbose ) { -#ifdef FD_FUNK_HANDHOLDING - if( FD_UNLIKELY( !funk ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "NULL funk" )); - return NULL; - } + if( FD_UNLIKELY( !funk ) ) FD_LOG_CRIT(( "NULL funk" )); if( FD_UNLIKELY( !xid ) ) { if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "NULL xid" )); return NULL; } if( FD_UNLIKELY( parent && !fd_funk_txn_valid( funk, parent ) ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "bad txn" )); + if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "invalid parent txn" )); return NULL; } if( FD_UNLIKELY( fd_funk_txn_xid_eq_root( xid ) ) ) { @@ -72,7 +68,6 @@ fd_funk_txn_prepare( fd_funk_t * funk, if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "xid is the last published" )); return NULL; } -#endif fd_funk_txn_map_query_t query[1]; if( FD_UNLIKELY( fd_funk_txn_map_query_try( funk->txn_map, xid, NULL, query, 0 ) != FD_MAP_ERR_KEY ) ) { @@ -273,18 +268,12 @@ fd_funk_txn_cancel( fd_funk_t * funk, fd_funk_txn_t * txn, int verbose ) { -#ifdef FD_FUNK_HANDHOLDING - if( FD_UNLIKELY( !funk ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "NULL funk" )); - return 0UL; - } + if( FD_UNLIKELY( !funk ) ) FD_LOG_CRIT(( "NULL funk" )); + if( FD_UNLIKELY( !txn ) ) FD_LOG_CRIT(( "NULL txn" )); if( FD_UNLIKELY( !fd_funk_txn_valid( funk, txn ) ) ) { if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "bad txn" )); return 0UL; } -#else - (void)verbose; -#endif ulong txn_idx = (ulong)(txn - funk->txn_pool->ele); return fd_funk_txn_cancel_family( funk, funk->shmem->cycle_tag++, txn_idx ); @@ -362,18 +351,12 @@ fd_funk_txn_cancel_siblings( fd_funk_t * funk, fd_funk_txn_t * txn, int verbose ) { -#ifdef FD_FUNK_HANDHOLDING - if( FD_UNLIKELY( !funk ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "NULL funk" )); - return 0UL; - } + if( FD_UNLIKELY( !funk ) ) FD_LOG_CRIT(( "NULL funk" )); + if( FD_UNLIKELY( !txn ) ) FD_LOG_CRIT(( "NULL txn" )); if( FD_UNLIKELY( !fd_funk_txn_valid( funk, txn ) ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "bad txn" )); + if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "invalid txn" )); return 0UL; } -#else - (void)verbose; -#endif ulong txn_idx = (ulong)(txn - funk->txn_pool->ele); @@ -387,18 +370,12 @@ fd_funk_txn_cancel_children( fd_funk_t * funk, fd_funk_txn_t * txn, int verbose ) { -#ifdef FD_FUNK_HANDHOLDING - if( FD_UNLIKELY( !funk ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "NULL funk" )); - return 0UL; - } + if( FD_UNLIKELY( !funk ) ) FD_LOG_CRIT(( "NULL funk" )); + if( FD_UNLIKELY( !txn ) ) FD_LOG_CRIT(( "NULL txn" )); if( FD_UNLIKELY( !fd_funk_txn_valid( funk, txn ) ) ) { if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "bad txn" )); return 0UL; } -#else - (void)verbose; -#endif ulong oldest_idx; @@ -620,19 +597,12 @@ ulong fd_funk_txn_publish( fd_funk_t * funk, fd_funk_txn_t * txn, int verbose ) { - -#ifdef FD_FUNK_HANDHOLDING - if( FD_UNLIKELY( !funk ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "NULL funk" )); - return 0UL; - } + if( FD_UNLIKELY( !funk ) ) FD_LOG_CRIT(( "NULL funk" )); + if( FD_UNLIKELY( !txn ) ) FD_LOG_CRIT(( "NULL txn" )); if( FD_UNLIKELY( !fd_funk_txn_valid( funk, txn ) ) ) { if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "bad txn" )); return 0UL; } -#else - (void)verbose; -#endif ulong txn_idx = (ulong)(txn - funk->txn_pool->ele); @@ -685,18 +655,12 @@ int fd_funk_txn_publish_into_parent( fd_funk_t * funk, fd_funk_txn_t * txn, int verbose ) { -#ifdef FD_FUNK_HANDHOLDING - if( FD_UNLIKELY( !funk ) ) { - if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "NULL funk" )); - return FD_FUNK_ERR_INVAL; - } + if( FD_UNLIKELY( !funk ) ) FD_LOG_CRIT(( "NULL funk" )); + if( FD_UNLIKELY( !txn ) ) FD_LOG_CRIT(( "NULL txn" )); if( FD_UNLIKELY( !fd_funk_txn_valid( funk, txn ) ) ) { if( FD_UNLIKELY( verbose ) ) FD_LOG_WARNING(( "bad txn" )); return 0UL; } -#else - (void)verbose; -#endif fd_funk_txn_map_t * txn_map = funk->txn_map; fd_funk_txn_pool_t * txn_pool = funk->txn_pool; diff --git a/src/funk/fd_funk_val.c b/src/funk/fd_funk_val.c index 21ee33f54b..4cad34e455 100644 --- a/src/funk/fd_funk_val.c +++ b/src/funk/fd_funk_val.c @@ -10,14 +10,12 @@ fd_funk_val_truncate( fd_funk_rec_t * rec, /* Check input args */ -#ifdef FD_FUNK_HANDHOLDING if( FD_UNLIKELY( (!rec) | (sz>FD_FUNK_REC_VAL_MAX) | (!alloc) | (!wksp) ) || /* NULL rec,too big,NULL alloc,NULL wksp */ FD_UNLIKELY( rec->flags & FD_FUNK_REC_FLAG_ERASE ) || /* Marked erase */ FD_UNLIKELY( !fd_ulong_is_pow2( align ) & (align != 0UL) ) ) { /* Align is not a power of 2 or == 0 */ fd_int_store_if( !!opt_err, opt_err, FD_FUNK_ERR_INVAL ); return NULL; } -#endif ulong val_sz = (ulong)rec->val_sz; ulong val_max = (ulong)rec->val_max; diff --git a/src/funk/test_funk_common.hpp b/src/funk/test_funk_common.hpp index 71077924d3..1d14be290b 100644 --- a/src/funk/test_funk_common.hpp +++ b/src/funk/test_funk_common.hpp @@ -338,9 +338,7 @@ struct fake_funk { } void verify() { -#ifdef FD_FUNK_HANDHOLDING assert(fd_funk_verify(_real) == FD_FUNK_SUCCESS); -#endif for (auto i : _txns) { assert(i.first == i.second->_key); diff --git a/src/funk/test_funk_concur.cxx b/src/funk/test_funk_concur.cxx index e42412dc9b..e9f8a5ca95 100644 --- a/src/funk/test_funk_concur.cxx +++ b/src/funk/test_funk_concur.cxx @@ -144,9 +144,7 @@ int main(int argc, char** argv) { while( runcnt ) continue; FD_LOG_NOTICE(( "paused (%u inserts)", insertcnt )); -#ifdef FD_FUNK_HANDHOLDING FD_TEST( !fd_funk_verify( funk ) ); -#endif } diff --git a/src/funk/test_funk_rec.c b/src/funk/test_funk_rec.c index f85cb884e4..47c54cc893 100644 --- a/src/funk/test_funk_rec.c +++ b/src/funk/test_funk_rec.c @@ -63,9 +63,7 @@ main( int argc, // for( rec_t * rrec=ref->rec_head; rrec; rrec=rrec->next ) FD_LOG_NOTICE(( "has %lu", rrec->key )); //} -#ifdef FD_FUNK_HANDHOLDING FD_TEST( !fd_funk_verify( tst ) ); -#endif fd_funk_txn_xid_t txid[1]; fd_funk_rec_key_t tkey[1]; @@ -96,17 +94,15 @@ main( int argc, key_set( tkey, rkey ); fd_funk_rec_query_t rec_query[1]; -#ifdef FD_FUNK_HANDHOLDING - FD_TEST( !fd_funk_rec_query_try ( NULL, NULL, NULL, NULL ) ); - FD_TEST( !fd_funk_rec_query_try ( NULL, NULL, tkey, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try ( tst, NULL, NULL, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try ( tst, NULL, tkey, NULL ) ); - - FD_TEST( !fd_funk_rec_query_try_global ( NULL, NULL, NULL, NULL, NULL ) ); - FD_TEST( !fd_funk_rec_query_try_global ( NULL, NULL, tkey, NULL, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try_global ( tst, NULL, NULL, NULL, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try_global ( tst, NULL, tkey, NULL, NULL ) ); -#endif + FD_TEST( !fd_funk_rec_query_try( NULL, NULL, NULL, NULL ) ); + FD_TEST( !fd_funk_rec_query_try( NULL, NULL, tkey, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try( tst, NULL, NULL, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try( tst, NULL, tkey, NULL ) ); + + FD_TEST( !fd_funk_rec_query_try_global( NULL, NULL, NULL, NULL, NULL ) ); + FD_TEST( !fd_funk_rec_query_try_global( NULL, NULL, tkey, NULL, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try_global( tst, NULL, NULL, NULL, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try_global( tst, NULL, tkey, NULL, NULL ) ); rec_t * rrec = rec_query_global( ref, NULL, rkey ); fd_funk_rec_t const * trec = fd_funk_rec_query_try_global( tst, NULL, tkey, NULL, rec_query ); @@ -114,11 +110,9 @@ main( int argc, else FD_TEST( trec && xid_eq( fd_funk_rec_xid( trec ), rrec->txn ? rrec->txn->xid : 0UL ) ); FD_TEST( !fd_funk_rec_query_test( rec_query ) ); -#ifdef FD_FUNK_HANDHOLDING FD_TEST( fd_funk_rec_remove( NULL, NULL, NULL, NULL )==FD_FUNK_ERR_INVAL ); FD_TEST( fd_funk_rec_remove( NULL, NULL, tkey, NULL )==FD_FUNK_ERR_INVAL ); - FD_TEST( fd_funk_rec_remove( tst, NULL, NULL, NULL )==FD_FUNK_ERR_INVAL ); -#endif + FD_TEST( fd_funk_rec_remove( tst, NULL, NULL, NULL )==FD_FUNK_ERR_INVAL ); if( trec ) { if( is_frozen ) { @@ -128,10 +122,8 @@ main( int argc, fd_funk_rec_prepare_t rec_prepare[1]; int err; -#ifdef FD_FUNK_HANDHOLDING FD_TEST( !fd_funk_rec_prepare( NULL, NULL, NULL, NULL, NULL ) ); FD_TEST( !fd_funk_rec_prepare( NULL, NULL, NULL, NULL, &err ) ); FD_TEST( err==FD_FUNK_ERR_INVAL ); -#endif if( is_frozen ) { FD_TEST( !fd_funk_rec_prepare( tst, NULL, tkey, rec_prepare, NULL ) ); @@ -183,17 +175,15 @@ main( int argc, key_set( tkey, rkey ); fd_funk_rec_query_t rec_query[1]; -#ifdef FD_FUNK_HANDHOLDING - FD_TEST( !fd_funk_rec_query_try ( NULL, ttxn, NULL, NULL ) ); - FD_TEST( !fd_funk_rec_query_try ( NULL, ttxn, tkey, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try ( tst, ttxn, NULL, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try ( tst, ttxn, tkey, NULL ) ); - - FD_TEST( !fd_funk_rec_query_try_global ( NULL, ttxn, NULL, NULL, NULL ) ); - FD_TEST( !fd_funk_rec_query_try_global ( NULL, ttxn, tkey, NULL, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try_global ( tst, ttxn, NULL, NULL, rec_query ) ); - FD_TEST( !fd_funk_rec_query_try_global ( tst, ttxn, tkey, NULL, NULL ) ); -#endif + FD_TEST( !fd_funk_rec_query_try( NULL, ttxn, NULL, NULL ) ); + FD_TEST( !fd_funk_rec_query_try( NULL, ttxn, tkey, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try( tst, ttxn, NULL, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try( tst, ttxn, tkey, NULL ) ); + + FD_TEST( !fd_funk_rec_query_try_global( NULL, ttxn, NULL, NULL, NULL ) ); + FD_TEST( !fd_funk_rec_query_try_global( NULL, ttxn, tkey, NULL, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try_global( tst, ttxn, NULL, NULL, rec_query ) ); + FD_TEST( !fd_funk_rec_query_try_global( tst, ttxn, tkey, NULL, NULL ) ); rec_t * rrec = rec_query_global( ref, rtxn, rkey ); fd_funk_rec_t const * trec = fd_funk_rec_query_try_global( tst, ttxn, tkey, NULL, rec_query ); @@ -203,11 +193,9 @@ main( int argc, } FD_TEST( !fd_funk_rec_query_test( rec_query ) ); -#ifdef FD_FUNK_HANDHOLDING FD_TEST( fd_funk_rec_remove( NULL, ttxn, NULL, NULL )==FD_FUNK_ERR_INVAL ); FD_TEST( fd_funk_rec_remove( NULL, ttxn, tkey, NULL )==FD_FUNK_ERR_INVAL ); FD_TEST( fd_funk_rec_remove( tst, ttxn, NULL, NULL )==FD_FUNK_ERR_INVAL ); -#endif if( trec && ttxn_is_frozen ) { FD_TEST( fd_funk_rec_remove( tst, ttxn, tkey, NULL )==FD_FUNK_ERR_FROZEN ); @@ -215,10 +203,8 @@ main( int argc, fd_funk_rec_prepare_t rec_prepare[1]; int err; -#ifdef FD_FUNK_HANDHOLDING FD_TEST( !fd_funk_rec_prepare( NULL, ttxn, NULL, NULL, NULL ) ); FD_TEST( !fd_funk_rec_prepare( NULL, ttxn, NULL, NULL, &err ) ); FD_TEST( err==FD_FUNK_ERR_INVAL ); -#endif if( ttxn_is_frozen ) { FD_TEST( !fd_funk_rec_prepare( tst, ttxn, tkey, rec_prepare, NULL ) ); diff --git a/src/funk/test_funk_txn.c b/src/funk/test_funk_txn.c index 4f1032bf5c..4805eb22a5 100644 --- a/src/funk/test_funk_txn.c +++ b/src/funk/test_funk_txn.c @@ -191,9 +191,7 @@ main( int argc, uint idx; RANDOM_SET_BIT_IDX( ~live_pmap ); fd_funk_txn_t * txn = fd_funk_txn_query( &recent_xid[idx], map ); FD_TEST( !txn ); -#ifdef FD_FUNK_HANDHOLDING FD_TEST( fd_funk_txn_cancel( funk, txn, verbose )==0UL ); -#endif break; } @@ -202,9 +200,7 @@ main( int argc, xid[0] = fd_funk_generate_xid(); fd_funk_txn_t * txn = fd_funk_txn_query( xid, map ); FD_TEST( !txn ); -#ifdef FD_FUNK_HANDHOLDING FD_TEST( fd_funk_txn_cancel( funk, txn, verbose )==0UL ); -#endif break; } @@ -223,9 +219,7 @@ main( int argc, uint idx; RANDOM_SET_BIT_IDX( ~live_pmap ); fd_funk_txn_t * txn = fd_funk_txn_query( &recent_xid[idx], map ); FD_TEST( !txn ); -#ifdef FD_FUNK_HANDHOLDING FD_TEST( fd_funk_txn_publish( funk, txn, verbose )==0UL ); -#endif break; } @@ -234,16 +228,13 @@ main( int argc, xid[0] = fd_funk_generate_xid(); fd_funk_txn_t * txn = fd_funk_txn_query( xid, map ); FD_TEST( !txn ); -#ifdef FD_FUNK_HANDHOLDING FD_TEST( fd_funk_txn_publish( funk, txn, verbose )==0UL ); -#endif break; } default: { /* various sanity checks */ uint idx = r & 63U; r >>= 6; fd_funk_txn_t * txn = fd_funk_txn_query( &recent_xid[idx], map ); -#ifdef FD_FUNK_HANDHOLDING fd_funk_txn_xid_t xid[1]; xid[0] = fd_funk_generate_xid(); @@ -270,7 +261,6 @@ main( int argc, FD_TEST( !fd_funk_txn_publish( funk, NULL, verbose ) ); /* NULL txn */ FD_TEST( !fd_funk_txn_publish( funk, bad, verbose ) ); /* tx not in map */ if( dead ) FD_TEST( !fd_funk_txn_publish( funk, dead, verbose ) ); /* tx not in prep */ -#endif if( txn ) { FD_TEST( fd_funk_txn_xid_eq( fd_funk_txn_xid( txn ), &recent_xid[idx] ) ); @@ -316,9 +306,7 @@ main( int argc, } } -#ifdef FD_FUNK_HANDHOLDING FD_TEST( !fd_funk_verify( funk ) ); -#endif } fd_funk_leave( funk, NULL ); diff --git a/src/funk/test_funk_val.c b/src/funk/test_funk_val.c index 4c30129d8b..547f3c7326 100644 --- a/src/funk/test_funk_val.c +++ b/src/funk/test_funk_val.c @@ -67,9 +67,7 @@ main( int argc, FD_TEST( !tmp ); \ } while(0) -#ifdef FD_FUNK_HANDHOLDING FD_TEST( !fd_funk_verify( tst ) ); -#endif fd_funk_txn_xid_t txid[1]; fd_funk_rec_key_t tkey[1];