diff --git a/silkworm/core/types/block_id.hpp b/silkworm/core/types/block_id.hpp index 830e326d2f..40b51648a9 100644 --- a/silkworm/core/types/block_id.hpp +++ b/silkworm/core/types/block_id.hpp @@ -21,7 +21,6 @@ namespace silkworm { -// TODO(canepat) rename BlockNumberAndHash struct BlockId { BlockNum number{}; Hash hash; diff --git a/silkworm/execution/api/active_direct_service.cpp b/silkworm/execution/api/active_direct_service.cpp index eab823f7f7..5d853653b6 100644 --- a/silkworm/execution/api/active_direct_service.cpp +++ b/silkworm/execution/api/active_direct_service.cpp @@ -49,7 +49,7 @@ Task ActiveDirectService::insert_blocks(const Blocks& blocks) { /** Chain Validation and ForkChoice **/ // rpc ValidateChain(ValidationRequest) returns(ValidationReceipt); -Task ActiveDirectService::validate_chain(BlockNumAndHash number_and_hash) { +Task ActiveDirectService::validate_chain(BlockId number_and_hash) { return concurrency::spawn_task(executor_, [](auto* self, auto num_and_hash) { return self->DirectService::validate_chain(num_and_hash); }(this, number_and_hash)); diff --git a/silkworm/execution/api/active_direct_service.hpp b/silkworm/execution/api/active_direct_service.hpp index 83f1e4ce99..469b5ada74 100644 --- a/silkworm/execution/api/active_direct_service.hpp +++ b/silkworm/execution/api/active_direct_service.hpp @@ -45,7 +45,7 @@ class ActiveDirectService : public DirectService, public ActiveComponent { /** Chain Validation and ForkChoice **/ // rpc ValidateChain(ValidationRequest) returns(ValidationReceipt); - Task validate_chain(BlockNumAndHash number_and_hash) override; + Task validate_chain(BlockId number_and_hash) override; // rpc UpdateForkChoice(ForkChoice) returns(ForkChoiceReceipt); Task update_fork_choice(const ForkChoice& fork_choice) override; diff --git a/silkworm/execution/api/direct_service.cpp b/silkworm/execution/api/direct_service.cpp index 04f57639e8..7ef42cfa19 100644 --- a/silkworm/execution/api/direct_service.cpp +++ b/silkworm/execution/api/direct_service.cpp @@ -37,7 +37,7 @@ Task DirectService::insert_blocks(const Blocks& blocks) { /** Chain Validation and ForkChoice **/ // rpc ValidateChain(ValidationRequest) returns(ValidationReceipt); -Task DirectService::validate_chain(BlockNumAndHash number_and_hash) { +Task DirectService::validate_chain(BlockId number_and_hash) { const auto verification = co_await exec_engine_.verify_chain(number_and_hash.hash); co_return verification; } diff --git a/silkworm/execution/api/direct_service.hpp b/silkworm/execution/api/direct_service.hpp index 757dc23d4d..7276ad0385 100644 --- a/silkworm/execution/api/direct_service.hpp +++ b/silkworm/execution/api/direct_service.hpp @@ -42,7 +42,7 @@ class DirectService : public Service { /** Chain Validation and ForkChoice **/ // rpc ValidateChain(ValidationRequest) returns(ValidationReceipt); - Task validate_chain(BlockNumAndHash number_and_hash) override; + Task validate_chain(BlockId number_and_hash) override; // rpc UpdateForkChoice(ForkChoice) returns(ForkChoiceReceipt); Task update_fork_choice(const ForkChoice& fork_choice) override; diff --git a/silkworm/execution/api/endpoint/validation.hpp b/silkworm/execution/api/endpoint/validation.hpp index 7ff37351b8..299e2fbab9 100644 --- a/silkworm/execution/api/endpoint/validation.hpp +++ b/silkworm/execution/api/endpoint/validation.hpp @@ -26,20 +26,18 @@ namespace silkworm::execution::api { -using BlockNumAndHash = BlockId; - struct ValidChain { - BlockNumAndHash current_head; + BlockId current_head; }; struct InvalidChain { - BlockNumAndHash unwind_point; + BlockId unwind_point; std::optional bad_block; std::set bad_headers; }; struct ValidationError { - BlockNumAndHash latest_valid_head; + BlockId latest_valid_head; std::string error; }; diff --git a/silkworm/execution/api/service.hpp b/silkworm/execution/api/service.hpp index 56e6c69ff5..2039c152ec 100644 --- a/silkworm/execution/api/service.hpp +++ b/silkworm/execution/api/service.hpp @@ -46,7 +46,7 @@ struct Service { /** Chain Validation and ForkChoice **/ // rpc ValidateChain(ValidationRequest) returns(ValidationReceipt); - virtual Task validate_chain(BlockNumAndHash) = 0; + virtual Task validate_chain(BlockId) = 0; // rpc UpdateForkChoice(ForkChoice) returns(ForkChoiceReceipt); virtual Task update_fork_choice(const ForkChoice&) = 0; diff --git a/silkworm/execution/grpc/client/endpoint/validation.cpp b/silkworm/execution/grpc/client/endpoint/validation.cpp index 3960823a24..2bc79c0f5b 100644 --- a/silkworm/execution/grpc/client/endpoint/validation.cpp +++ b/silkworm/execution/grpc/client/endpoint/validation.cpp @@ -24,7 +24,7 @@ namespace silkworm::execution::grpc::client { namespace proto = ::execution; -proto::ValidationRequest request_from_block_num_and_hash(const api::BlockNumAndHash& number_and_hash) { +proto::ValidationRequest request_from_block_num_and_hash(const BlockId& number_and_hash) { proto::ValidationRequest request; request.set_number(number_and_hash.number); request.set_allocated_hash(rpc::H256_from_bytes32(number_and_hash.hash).release()); diff --git a/silkworm/execution/grpc/client/endpoint/validation.hpp b/silkworm/execution/grpc/client/endpoint/validation.hpp index 7d4513f585..7610eae41e 100644 --- a/silkworm/execution/grpc/client/endpoint/validation.hpp +++ b/silkworm/execution/grpc/client/endpoint/validation.hpp @@ -23,7 +23,7 @@ namespace silkworm::execution::grpc::client { -::execution::ValidationRequest request_from_block_num_and_hash(const api::BlockNumAndHash&); +::execution::ValidationRequest request_from_block_num_and_hash(const BlockId&); api::ValidationResult validation_result_from_response(const ::execution::ValidationReceipt&); ::execution::ForkChoice request_from_fork_choice(const api::ForkChoice&); diff --git a/silkworm/execution/grpc/client/remote_client.cpp b/silkworm/execution/grpc/client/remote_client.cpp index b139667029..a6b148776a 100644 --- a/silkworm/execution/grpc/client/remote_client.cpp +++ b/silkworm/execution/grpc/client/remote_client.cpp @@ -62,7 +62,7 @@ class RemoteClientImpl final : public api::Service { /** Chain Validation and ForkChoice **/ // rpc ValidateChain(ValidationRequest) returns(ValidationReceipt); - Task validate_chain(api::BlockNumAndHash number_and_hash) override { + Task validate_chain(BlockId number_and_hash) override { auto request = request_from_block_num_and_hash(number_and_hash); const auto reply = co_await rpc::unary_rpc(&Stub::AsyncValidateChain, *stub_, std::move(request), grpc_context_); co_return validation_result_from_response(reply); diff --git a/silkworm/execution/grpc/server/endpoint/validation.cpp b/silkworm/execution/grpc/server/endpoint/validation.cpp index c07b231102..4958a1b5d5 100644 --- a/silkworm/execution/grpc/server/endpoint/validation.cpp +++ b/silkworm/execution/grpc/server/endpoint/validation.cpp @@ -24,7 +24,7 @@ namespace silkworm::execution::grpc::server { namespace proto = ::execution; -api::BlockNumAndHash block_num_and_hash_from_request(const proto::ValidationRequest& request) { +BlockId block_num_and_hash_from_request(const proto::ValidationRequest& request) { return { .number = request.number(), .hash = rpc::bytes32_from_H256(request.hash()), diff --git a/silkworm/execution/grpc/server/endpoint/validation.hpp b/silkworm/execution/grpc/server/endpoint/validation.hpp index 81d7b8fdac..0e70c36938 100644 --- a/silkworm/execution/grpc/server/endpoint/validation.hpp +++ b/silkworm/execution/grpc/server/endpoint/validation.hpp @@ -26,7 +26,7 @@ namespace silkworm::execution::grpc::server { api::ExecutionStatus execution_status_from_proto(const ::execution::ExecutionStatus&); -api::BlockNumAndHash block_num_and_hash_from_request(const ::execution::ValidationRequest&); +BlockId block_num_and_hash_from_request(const ::execution::ValidationRequest&); ::execution::ValidationReceipt response_from_validation_result(const api::ValidationResult&); api::ForkChoice fork_choice_from_request(const ::execution::ForkChoice&); diff --git a/silkworm/node/execution/active_direct_service_test.cpp b/silkworm/node/execution/active_direct_service_test.cpp index de4dbea698..d784a3183a 100644 --- a/silkworm/node/execution/active_direct_service_test.cpp +++ b/silkworm/node/execution/active_direct_service_test.cpp @@ -95,11 +95,11 @@ TEST_CASE_METHOD(ActiveDirectServiceTest, "ActiveDirectServiceTest::insert_block TEST_CASE_METHOD(ActiveDirectServiceTest, "ActiveDirectServiceTest::verify_chain", "[node][execution][api]") { const Hash latest_valid_hash{0x000000000000000000000000000000000000000000000000000000000000000A_bytes32}; const Hash new_hash{0x000000000000000000000000000000000000000000000000000000000000000B_bytes32}; - const BlockNumAndHash latest_valid_head{ + const BlockId latest_valid_head{ .number = 1, .hash = latest_valid_hash, }; - const BlockNumAndHash new_head{ + const BlockId new_head{ .number = 2, .hash = new_hash, }; diff --git a/silkworm/node/execution/direct_service_test.cpp b/silkworm/node/execution/direct_service_test.cpp index 7adecad07a..b7bd5841eb 100644 --- a/silkworm/node/execution/direct_service_test.cpp +++ b/silkworm/node/execution/direct_service_test.cpp @@ -77,11 +77,11 @@ TEST_CASE_METHOD(DirectServiceTest, "DirectService::insert_blocks", "[node][exec TEST_CASE_METHOD(DirectServiceTest, "DirectService::verify_chain", "[node][execution][api]") { const Hash latest_valid_hash{0x000000000000000000000000000000000000000000000000000000000000000A_bytes32}; const Hash new_hash{0x000000000000000000000000000000000000000000000000000000000000000B_bytes32}; - const BlockNumAndHash latest_valid_head{ + const BlockId latest_valid_head{ .number = 1, .hash = latest_valid_hash, }; - const BlockNumAndHash new_head{ + const BlockId new_head{ .number = 2, .hash = new_hash, }; diff --git a/silkworm/sync/sync_pos_test.cpp b/silkworm/sync/sync_pos_test.cpp index a5049a0932..aca529be08 100644 --- a/silkworm/sync/sync_pos_test.cpp +++ b/silkworm/sync/sync_pos_test.cpp @@ -124,7 +124,7 @@ TEST_CASE_METHOD(PoSSyncTest, "PoSSync::new_payload timeout") { for (size_t i{0}; i < requests.size(); ++i) { const auto& request{requests[i]}; const auto& payload{request.execution_payload}; - execution::api::BlockNumAndHash block_number_or_hash{payload.number, payload.block_hash}; + BlockId block_number_or_hash{payload.number, payload.block_hash}; execution::api::BlockNumberOrHash parent_number_or_hash{payload.parent_hash}; SECTION("payload version: v" + std::to_string(payload.version) + " i=" + std::to_string(i)) { EXPECT_CALL(*execution_service, get_header(parent_number_or_hash)) diff --git a/silkworm/sync/test_util/mock_execution_client.hpp b/silkworm/sync/test_util/mock_execution_client.hpp index 5f3fadc235..3b838a2ba8 100644 --- a/silkworm/sync/test_util/mock_execution_client.hpp +++ b/silkworm/sync/test_util/mock_execution_client.hpp @@ -39,7 +39,7 @@ class MockExecutionService : public execution::api::Service { public: MOCK_METHOD((Task), insert_blocks, (const api::Blocks&), (override)); - MOCK_METHOD((Task), validate_chain, (api::BlockNumAndHash), (override)); + MOCK_METHOD((Task), validate_chain, (BlockId), (override)); MOCK_METHOD((Task), update_fork_choice, (const api::ForkChoice&), (override)); MOCK_METHOD((Task), assemble_block, (const api::BlockUnderConstruction&), (override));