diff --git a/.clang-tidy b/.clang-tidy index 648a044ac4..8e579db32e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -100,6 +100,8 @@ CheckOptions: readability-identifier-naming.GlobalConstantPrefix: k readability-identifier-naming.LocalVariableCase: lower_case readability-identifier-naming.MacroDefinitionCase: UPPER_CASE + readability-identifier-naming.NamespaceCase: lower_case + readability-identifier-naming.ParameterCase: lower_case readability-identifier-naming.PrivateMemberCase: lower_case readability-identifier-naming.PrivateMemberSuffix: _ readability-identifier-naming.ProtectedMemberCase: lower_case @@ -108,4 +110,5 @@ CheckOptions: readability-identifier-naming.PublicMemberSuffix: '' readability-identifier-naming.StaticConstantCase: CamelCase readability-identifier-naming.StaticConstantPrefix: k + readability-identifier-naming.StaticVariableCase: lower_case readability-simplify-boolean-expr.SimplifyDeMorgan: false diff --git a/silkworm/db/datastore/snapshots/rec_split/rec_split_seq.hpp b/silkworm/db/datastore/snapshots/rec_split/rec_split_seq.hpp index b65f5feb55..93b4af2934 100644 --- a/silkworm/db/datastore/snapshots/rec_split/rec_split_seq.hpp +++ b/silkworm/db/datastore/snapshots/rec_split/rec_split_seq.hpp @@ -119,7 +119,7 @@ struct RecSplit::SequentialBuildingStrategy : public BuildingStrategy // We use an exception for collision error condition because ETL currently does not support loading errors // TODO(canepat) refactor ETL to support errors in LoadFunc and propagate them to caller to get rid of CollisionError struct CollisionError : public std::runtime_error { - explicit CollisionError(uint64_t _bucket_id) : runtime_error("collision"), bucket_id(_bucket_id) {} + explicit CollisionError(uint64_t bucket_id) : runtime_error("collision"), bucket_id(bucket_id) {} uint64_t bucket_id; }; try { diff --git a/silkworm/db/datastore/snapshots/segment/seg/compressor/pattern_covering_test.cpp b/silkworm/db/datastore/snapshots/segment/seg/compressor/pattern_covering_test.cpp index 791fe83d7b..b363fd51b5 100644 --- a/silkworm/db/datastore/snapshots/segment/seg/compressor/pattern_covering_test.cpp +++ b/silkworm/db/datastore/snapshots/segment/seg/compressor/pattern_covering_test.cpp @@ -151,7 +151,7 @@ TEST_CASE("PatternCoveringSearch1") { PatternCoveringSearch search{ patterns_tree, - [](void* patternScore) { return *reinterpret_cast(patternScore); }}; + [](void* pattern_score) { return *reinterpret_cast(pattern_score); }}; { auto& result = search.cover_word("0x6c6f6e67"_hex); diff --git a/silkworm/infra/common/ensure.hpp b/silkworm/infra/common/ensure.hpp index fc8985f042..6916bdaadb 100644 --- a/silkworm/infra/common/ensure.hpp +++ b/silkworm/infra/common/ensure.hpp @@ -32,9 +32,9 @@ inline void ensure(bool condition, const char (&message)[N]) { //! Ensure that condition is met, otherwise raise a logic error with dynamically built message //! Usage: `ensure(condition, [&]() { return "Message: " + get_str(); });` -inline void ensure(bool condition, const std::function& messageBuilder) { +inline void ensure(bool condition, const std::function& message_builder) { if (!condition) [[unlikely]] { - throw std::logic_error(messageBuilder()); + throw std::logic_error(message_builder()); } } @@ -47,23 +47,23 @@ inline void ensure_invariant(bool condition, const char (&message)[N]) { } //! Similar to \code ensure with emphasis on invariant violation -inline void ensure_invariant(bool condition, const std::function& messageBuilder) { +inline void ensure_invariant(bool condition, const std::function& message_builder) { if (!condition) [[unlikely]] { - throw std::logic_error("Invariant violation: " + messageBuilder()); + throw std::logic_error("Invariant violation: " + message_builder()); } } //! Similar to \code ensure with emphasis on pre-condition violation -inline void ensure_pre_condition(bool condition, const std::function& messageBuilder) { +inline void ensure_pre_condition(bool condition, const std::function& message_builder) { if (!condition) [[unlikely]] { - throw std::invalid_argument("Pre-condition violation: " + messageBuilder()); + throw std::invalid_argument("Pre-condition violation: " + message_builder()); } } //! Similar to \code ensure with emphasis on post-condition violation -inline void ensure_post_condition(bool condition, const std::function& messageBuilder) { +inline void ensure_post_condition(bool condition, const std::function& message_builder) { if (!condition) [[unlikely]] { - throw std::logic_error("Post-condition violation: " + messageBuilder()); + throw std::logic_error("Post-condition violation: " + message_builder()); } } diff --git a/silkworm/node/stagedsync/forks/fork.cpp b/silkworm/node/stagedsync/forks/fork.cpp index a097c0e021..6e66b08b80 100644 --- a/silkworm/node/stagedsync/forks/fork.cpp +++ b/silkworm/node/stagedsync/forks/fork.cpp @@ -78,8 +78,8 @@ void Fork::close() { memory_tx_.abort(); } -void Fork::flush(db::RWTxn& main_chain_tx_) { - memory_tx_.flush(main_chain_tx_); +void Fork::flush(db::RWTxn& main_chain_tx) { + memory_tx_.flush(main_chain_tx); } BlockId Fork::current_head() const { diff --git a/silkworm/node/stagedsync/forks/fork.hpp b/silkworm/node/stagedsync/forks/fork.hpp index 61bb45ec53..7a4924e4b1 100644 --- a/silkworm/node/stagedsync/forks/fork.hpp +++ b/silkworm/node/stagedsync/forks/fork.hpp @@ -48,7 +48,7 @@ class Fork { Fork(const Fork&) = delete; void close(); - void flush(db::RWTxn& main_chain_tx_); + void flush(db::RWTxn& main_chain_tx); // extension & contraction void extend_with(const std::list>&); diff --git a/silkworm/rpc/commands/ots_api.cpp b/silkworm/rpc/commands/ots_api.cpp index 2e89a754d3..80e22ec81f 100644 --- a/silkworm/rpc/commands/ots_api.cpp +++ b/silkworm/rpc/commands/ots_api.cpp @@ -1374,10 +1374,10 @@ Task FromToBlockProvider::get() { co_return BlockProviderResponse{block_num, has_more_from_ || has_more_to_, false}; } -FromToBlockProvider::FromToBlockProvider(bool is_backwards, BlockProvider* callFromProvider, BlockProvider* callToProvider) +FromToBlockProvider::FromToBlockProvider(bool is_backwards, BlockProvider* call_from_provider, BlockProvider* call_to_provider) : is_backwards_{is_backwards}, - call_from_provider_{callFromProvider}, - call_to_provider_{callToProvider} { + call_from_provider_{call_from_provider}, + call_to_provider_{call_to_provider} { } } // namespace silkworm::rpc::commands diff --git a/silkworm/rpc/commands/ots_api.hpp b/silkworm/rpc/commands/ots_api.hpp index 3188fb123b..ff6eb65512 100644 --- a/silkworm/rpc/commands/ots_api.hpp +++ b/silkworm/rpc/commands/ots_api.hpp @@ -183,7 +183,7 @@ class FromToBlockProvider : public BlockProvider { bool initialized_{false}; public: - FromToBlockProvider(bool is_backwards, BlockProvider* callFromProvider, BlockProvider* callToProvider); + FromToBlockProvider(bool is_backwards, BlockProvider* call_from_provider, BlockProvider* call_to_provider); Task get() override; }; diff --git a/silkworm/rpc/commands/rpc_api_test.cpp b/silkworm/rpc/commands/rpc_api_test.cpp index 26564565ea..cf23c830d6 100644 --- a/silkworm/rpc/commands/rpc_api_test.cpp +++ b/silkworm/rpc/commands/rpc_api_test.cpp @@ -30,19 +30,19 @@ using test_util::RpcApiTestBase; #endif // Function to recursively sort JSON arrays -void sort_array(nlohmann::json& jsonObj) { // NOLINT(*-no-recursion) - if (jsonObj.is_array()) { +void sort_array(nlohmann::json& json_obj) { // NOLINT(*-no-recursion) + if (json_obj.is_array()) { // Sort the elements within the array - std::sort(jsonObj.begin(), jsonObj.end(), [](const nlohmann::json& a, const nlohmann::json& b) { + std::sort(json_obj.begin(), json_obj.end(), [](const nlohmann::json& a, const nlohmann::json& b) { return a.dump() < b.dump(); }); // Recursively sort nested arrays - for (auto& item : jsonObj) { + for (auto& item : json_obj) { sort_array(item); } - } else if (jsonObj.is_object()) { - for (auto& item : jsonObj.items()) { + } else if (json_obj.is_object()) { + for (auto& item : json_obj.items()) { sort_array(item.value()); } } diff --git a/silkworm/rpc/core/estimate_gas_oracle.hpp b/silkworm/rpc/core/estimate_gas_oracle.hpp index f77d99dfdd..8cdf115d07 100644 --- a/silkworm/rpc/core/estimate_gas_oracle.hpp +++ b/silkworm/rpc/core/estimate_gas_oracle.hpp @@ -93,7 +93,7 @@ class EstimateGasOracle { Task estimate_gas(const Call& call, const silkworm::Block& latest_block, TxnId txn_id, std::optional block_num_for_gas_limit = {}); protected: - virtual ExecutionResult try_execution(EVMExecutor& executor, const silkworm::Block& _block, const silkworm::Transaction& transaction); + virtual ExecutionResult try_execution(EVMExecutor& executor, const silkworm::Block& block, const silkworm::Transaction& transaction); private: void throw_exception(ExecutionResult& result); diff --git a/silkworm/rpc/engine/execution_engine.hpp b/silkworm/rpc/engine/execution_engine.hpp index 89eeeb753a..80bf351e1a 100644 --- a/silkworm/rpc/engine/execution_engine.hpp +++ b/silkworm/rpc/engine/execution_engine.hpp @@ -35,7 +35,7 @@ class ExecutionEngine { virtual Task new_payload(const NewPayloadRequest& request, Msec timeout) = 0; virtual Task fork_choice_updated(const ForkChoiceUpdatedRequest& request, Msec timeout) = 0; - virtual Task get_payload(uint64_t payloadId, Msec timeout) = 0; + virtual Task get_payload(uint64_t payload_id, Msec timeout) = 0; virtual Task get_payload_bodies_by_hash(const std::vector& block_hashes, Msec timeout) = 0; virtual Task get_payload_bodies_by_range(BlockNum start, uint64_t count, Msec timeout) = 0; }; diff --git a/silkworm/rpc/engine/remote_execution_engine.cpp b/silkworm/rpc/engine/remote_execution_engine.cpp index 3d0107be2c..5af3be764a 100644 --- a/silkworm/rpc/engine/remote_execution_engine.cpp +++ b/silkworm/rpc/engine/remote_execution_engine.cpp @@ -88,8 +88,8 @@ Task RemoteExecutionEngine::fork_choice_updated(const Fo co_return fork_choice_updated_reply_from_result(fork_choice_result); } -Task RemoteExecutionEngine::get_payload(uint64_t /*payloadId*/, Msec /*timeout*/) { - // We do not support the payload building process yet, so any payloadId is unknown +Task RemoteExecutionEngine::get_payload(uint64_t /*payload_id*/, Msec /*timeout*/) { + // We do not support the payload building process yet, so any payload ID is unknown throw boost::system::system_error{to_system_code(ErrorCode::kUnknownPayload)}; } diff --git a/silkworm/rpc/engine/remote_execution_engine.hpp b/silkworm/rpc/engine/remote_execution_engine.hpp index b699ded5fc..dae349a8ec 100644 --- a/silkworm/rpc/engine/remote_execution_engine.hpp +++ b/silkworm/rpc/engine/remote_execution_engine.hpp @@ -32,7 +32,7 @@ class RemoteExecutionEngine final : public ExecutionEngine { Task new_payload(const NewPayloadRequest& request, Msec timeout) override; Task fork_choice_updated(const ForkChoiceUpdatedRequest& request, Msec timeout) override; - Task get_payload(uint64_t payloadId, Msec timeout) override; + Task get_payload(uint64_t payload_id, Msec timeout) override; Task get_payload_bodies_by_hash(const std::vector& block_hashes, Msec timeout) override; Task get_payload_bodies_by_range(BlockNum start, uint64_t count, Msec timeout) override; diff --git a/silkworm/sync/internals/chain_elements.hpp b/silkworm/sync/internals/chain_elements.hpp index 53dacc9413..a51be262ed 100644 --- a/silkworm/sync/internals/chain_elements.hpp +++ b/silkworm/sync/internals/chain_elements.hpp @@ -42,10 +42,10 @@ struct Link { bool persisted = false; // Whether this link comes from the database record bool preverified = false; // Ancestor of pre-verified header - Link(BlockHeader h, bool persisted_) + Link(BlockHeader h, bool persist) : block_num{h.number}, hash{h.hash()}, // save computation - persisted{persisted_} { + persisted{persist} { header = std::make_shared(std::move(h)); } diff --git a/silkworm/sync/internals/header_chain.cpp b/silkworm/sync/internals/header_chain.cpp index fb04683b07..a778ad8f20 100644 --- a/silkworm/sync/internals/header_chain.cpp +++ b/silkworm/sync/internals/header_chain.cpp @@ -575,7 +575,7 @@ void HeaderChain::request_nack(const GetBlockHeadersPacket66& packet) { SILK_TRACE_M("HeaderChain") << "restoring timestamp due to request nack;" << " request_id=" << packet.request_id; - anchor_queue_.update(anchor, [&](auto& anchor_) { anchor_->restore_timestamp(); }); + anchor_queue_.update(anchor, [&](auto& anchor_arg) { anchor_arg->restore_timestamp(); }); } bool HeaderChain::has_link(Hash hash) { return (links_.find(hash) != links_.end()); } @@ -700,7 +700,7 @@ std::tuple, Penalty> HeaderList::split_into_segments() { return {segments, Penalty::kNoPenalty}; } -HeaderChain::RequestMoreHeaders HeaderChain::process_segment(const Segment& segment, bool is_a_new_block, const PeerId& peerId) { +HeaderChain::RequestMoreHeaders HeaderChain::process_segment(const Segment& segment, bool is_a_new_block, const PeerId& peer_id) { if (segment.empty()) return false; auto [anchor, start] = find_anchor(segment); auto [tip, end] = find_link(segment, start); @@ -755,7 +755,7 @@ HeaderChain::RequestMoreHeaders HeaderChain::process_segment(const Segment& segm } } else { op = "new anchor"; - request_more = new_anchor(segment_slice, peerId); + request_more = new_anchor(segment_slice, peer_id); } // SILK_TRACE << "HeaderChain, segment " << op << " up=" << start_num << " (" << segment[start]->hash() // << ") down=" << end_num << " (" << segment[end - 1]->hash() << ") (more=" << request_more << ")"; @@ -986,13 +986,13 @@ void HeaderChain::extend_up(const std::shared_ptr& attachment_link, Segmen << (segment_slice.rend() - 1)->operator*().number; } -HeaderChain::RequestMoreHeaders HeaderChain::new_anchor(Segment::Slice segment_slice, PeerId peerId) { +HeaderChain::RequestMoreHeaders HeaderChain::new_anchor(Segment::Slice segment_slice, PeerId peer_id) { using std::to_string; // Add or find anchor auto anchor_header = *segment_slice.rbegin(); // lowest header bool check_limits = true; - auto [anchor, pre_existing] = add_anchor_if_not_present(*anchor_header, std::move(peerId), check_limits); + auto [anchor, pre_existing] = add_anchor_if_not_present(*anchor_header, std::move(peer_id), check_limits); // Iterate over headers backwards (from parents towards children) std::shared_ptr prev_link; @@ -1018,7 +1018,7 @@ HeaderChain::RequestMoreHeaders HeaderChain::new_anchor(Segment::Slice segment_s return !pre_existing; } -std::tuple, HeaderChain::Pre_Existing> HeaderChain::add_anchor_if_not_present(const BlockHeader& anchor_header, PeerId peerId, bool check_limits) { +std::tuple, HeaderChain::Pre_Existing> HeaderChain::add_anchor_if_not_present(const BlockHeader& anchor_header, PeerId peer_id, bool check_limits) { using std::to_string; auto a = anchors_.find(anchor_header.parent_hash); @@ -1039,7 +1039,7 @@ std::tuple, HeaderChain::Pre_Existing> HeaderChain::add_ ", limit: " + to_string(kAnchorLimit)); } - std::shared_ptr anchor = std::make_shared(anchor_header, std::move(peerId)); + std::shared_ptr anchor = std::make_shared(anchor_header, std::move(peer_id)); if (anchor->block_num > 0) { anchors_[anchor_header.parent_hash] = anchor; anchor_queue_.push(anchor); diff --git a/silkworm/sync/sync_pos.cpp b/silkworm/sync/sync_pos.cpp index ff2b954591..49fe0404fa 100644 --- a/silkworm/sync/sync_pos.cpp +++ b/silkworm/sync/sync_pos.cpp @@ -376,7 +376,7 @@ Task PoSSync::fork_choice_updated(const rpc::ForkCh } } -Task PoSSync::get_payload(uint64_t /*payloadId*/, std::chrono::milliseconds /*timeout*/) { +Task PoSSync::get_payload(uint64_t /*payload_id*/, std::chrono::milliseconds /*timeout*/) { // Implementation of engine_getPayloadVx method ensure_invariant(false, "get_payload not implemented"); co_return rpc::ExecutionPayloadAndValue{}; diff --git a/silkworm/sync/sync_pos.hpp b/silkworm/sync/sync_pos.hpp index e4c18fd74c..6735d8c5cd 100644 --- a/silkworm/sync/sync_pos.hpp +++ b/silkworm/sync/sync_pos.hpp @@ -42,7 +42,7 @@ class PoSSync : public ChainSync, public rpc::engine::ExecutionEngine { // public interface called by the external PoS client Task new_payload(const rpc::NewPayloadRequest& request, std::chrono::milliseconds timeout) override; Task fork_choice_updated(const rpc::ForkChoiceUpdatedRequest& request, std::chrono::milliseconds timeout) override; - Task get_payload(uint64_t payloadId, std::chrono::milliseconds timeout) override; + Task get_payload(uint64_t payload_id, std::chrono::milliseconds timeout) override; Task get_payload_bodies_by_hash(const std::vector& block_hashes, std::chrono::milliseconds timeout) override; Task get_payload_bodies_by_range(BlockNum start, uint64_t count, std::chrono::milliseconds timeout) override;