Skip to content
Merged
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
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,21 @@ if(LANTERN_BUILD_TESTS)
target_link_libraries(lantern_client_state_staleness_test PRIVATE lantern)
add_test(NAME lantern_client_state_staleness COMMAND lantern_client_state_staleness_test)

add_executable(lantern_genesis_anchor_test tests/unit/test_genesis_anchor.c)
add_executable(lantern_genesis_anchor_test
tests/unit/test_genesis_anchor.c
tests/unit/client_test_helpers.c
)
target_link_libraries(lantern_genesis_anchor_test PRIVATE lantern)
target_include_directories(
lantern_genesis_anchor_test
PRIVATE
${PROJECT_SOURCE_DIR}/tests/unit
)
target_compile_definitions(
lantern_genesis_anchor_test
PRIVATE
LANTERN_TEST_FIXTURE_DIR="${PROJECT_SOURCE_DIR}/tests/fixtures"
)
add_test(NAME lantern_genesis_anchor COMMAND lantern_genesis_anchor_test)

add_executable(lantern_genesis_bootstrap_test tests/unit/test_genesis_bootstrap.c)
Expand Down
9 changes: 9 additions & 0 deletions src/core/client_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,15 @@ int http_finalized_state_ssz_cb(void *context, uint8_t **out_bytes, size_t *out_
}

LanternCheckpoint finalized = client->state.latest_finalized;
if (client->has_fork_choice)
{
const LanternCheckpoint *fork_finalized =
lantern_fork_choice_latest_finalized(&client->fork_choice);
if (fork_finalized && !lantern_root_is_zero(&fork_finalized->root))
{
finalized = *fork_finalized;
}
}
lantern_client_unlock_state(client, state_locked);

if (lantern_root_is_zero(&finalized.root))
Expand Down
9 changes: 9 additions & 0 deletions src/core/client_reqresp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,15 @@ int reqresp_build_status(void *context, LanternStatusMessage *out_status)
}

out_status->finalized = client->state.latest_finalized;
if (client->has_fork_choice)
{
const LanternCheckpoint *fork_finalized =
lantern_fork_choice_latest_finalized(&client->fork_choice);
if (fork_finalized && !lantern_root_is_zero(&fork_finalized->root))
{
out_status->finalized = *fork_finalized;
}
}

bool head_set = false;
if (client->has_fork_choice)
Expand Down
11 changes: 10 additions & 1 deletion src/core/client_sync_blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,16 @@ static bool rebuild_state_for_root_locked(
LanternRoot replay_stop_root = {0};
char replay_stop_hex[ROOT_HEX_BUFFER_LEN] = {0};

if (client->has_state)
if (client->has_fork_choice)
{
const LanternCheckpoint *fork_finalized =
lantern_fork_choice_latest_finalized(&client->fork_choice);
if (fork_finalized)
{
replay_stop_root = fork_finalized->root;
}
}
else if (client->has_state)
{
replay_stop_root = client->state.latest_finalized.root;
}
Expand Down
Loading
Loading