mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Fix bug in block root storage (#4663)
## Issue Addressed Fix a bug in the storage of the linear block roots array in the freezer DB. Previously this array was always written as part of state storage (or block backfill). With state pruning enabled by #4610, these states were no longer being written and as a result neither were the block roots. The impact is quite low, we would just log an error when trying to forwards-iterate the block roots, which for validating nodes only happens when they try to look up blocks for peers: > Aug 25 03:42:36.980 ERRO Missing chunk in forwards iterator chunk index: 49726, service: freezer_db Any node checkpoint synced off `unstable` is affected and has a corrupt database. If you see the log above, you need to re-sync with the fix. Nodes that haven't checkpoint synced recently should _not_ be corrupted, even if they ran the buggy version. ## Proposed Changes - Use a `ChunkWriter` to write the block roots when states are not being stored. - Tweak the usage of `get_latest_restore_point` so that it doesn't return a nonsense value when state pruning is enabled. - Tweak the guarantee on the block roots array so that block roots are assumed available up to the split slot (exclusive). This is a bit nicer than relying on anything to do with the latest restore point, which is a nonsensical concept when there aren't any restore points. ## Additional Info I'm looking forward to deleting the chunked vector code for good when we merge tree-states 😁
This commit is contained in:
@@ -45,3 +45,4 @@ network = { path = "../beacon_node/network" }
|
||||
testcontainers = { git = "https://github.com/testcontainers/testcontainers-rs/", rev = "0f2c9851" }
|
||||
unused_port = { path = "../common/unused_port" }
|
||||
task_executor = { path = "../common/task_executor" }
|
||||
logging = { path = "../common/logging" }
|
||||
|
||||
@@ -7,12 +7,21 @@ use beacon_chain::{
|
||||
};
|
||||
use eth2::{types::BlockId, BeaconNodeHttpClient, SensitiveUrl, Timeouts};
|
||||
use http_api::test_utils::{create_api_server, ApiServer};
|
||||
use log::error;
|
||||
use logging::test_logger;
|
||||
use network::NetworkReceivers;
|
||||
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::net::SocketAddr;
|
||||
use std::time::Duration;
|
||||
use testcontainers::{clients::Cli, core::WaitFor, Image, RunnableImage};
|
||||
use tokio::sync::oneshot;
|
||||
use tokio::{runtime, task::JoinHandle};
|
||||
use tokio_postgres::{config::Config as PostgresConfig, Client, NoTls};
|
||||
use types::{Hash256, MainnetEthSpec, Slot};
|
||||
use unused_port::unused_tcp4_port;
|
||||
use url::Url;
|
||||
use watch::{
|
||||
client::WatchHttpClient,
|
||||
@@ -22,17 +31,6 @@ use watch::{
|
||||
updater::{handler::*, run_updater, Config as UpdaterConfig, WatchSpec},
|
||||
};
|
||||
|
||||
use log::error;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::net::SocketAddr;
|
||||
use std::time::Duration;
|
||||
use tokio::{runtime, task::JoinHandle};
|
||||
use tokio_postgres::{config::Config as PostgresConfig, Client, NoTls};
|
||||
use unused_port::unused_tcp4_port;
|
||||
|
||||
use testcontainers::{clients::Cli, core::WaitFor, Image, RunnableImage};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Postgres(HashMap<String, String>);
|
||||
|
||||
@@ -132,6 +130,7 @@ impl TesterBuilder {
|
||||
reconstruct_historic_states: true,
|
||||
..ChainConfig::default()
|
||||
})
|
||||
.logger(test_logger())
|
||||
.deterministic_keypairs(VALIDATOR_COUNT)
|
||||
.fresh_ephemeral_store()
|
||||
.build();
|
||||
|
||||
Reference in New Issue
Block a user