Skip to content

Commit b3da74b

Browse files
committed
Merge remote-tracking branch 'origin/unstable' into jimmy/lh-2271-activate-peerdas-at-fulu-fork-and-remove-eip7594_fork_epoch
# Conflicts: # beacon_node/beacon_chain/src/fetch_blobs.rs # beacon_node/store/src/lib.rs # beacon_node/store/src/memory_store.rs
2 parents e813532 + a1b7d61 commit b3da74b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2207
-1113
lines changed

Cargo.lock

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ BUILD_PATH_AARCH64 = "target/$(AARCH64_TAG)/release"
1414
PINNED_NIGHTLY ?= nightly
1515

1616
# List of features to use when cross-compiling. Can be overridden via the environment.
17-
CROSS_FEATURES ?= gnosis,slasher-lmdb,slasher-mdbx,slasher-redb,jemalloc
17+
CROSS_FEATURES ?= gnosis,slasher-lmdb,slasher-mdbx,slasher-redb,jemalloc,beacon-node-leveldb,beacon-node-redb
1818

1919
# Cargo profile for Cross builds. Default is for local builds, CI uses an override.
2020
CROSS_PROFILE ?= release

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ impl<E: EthSpec> PendingComponents<E> {
317317
None,
318318
)
319319
};
320-
321320
let executed_block = recover(diet_executed_block)?;
322321

323322
let AvailabilityPendingExecutedBlock {
@@ -732,7 +731,7 @@ mod test {
732731
use slog::{info, Logger};
733732
use state_processing::ConsensusContext;
734733
use std::collections::VecDeque;
735-
use store::{HotColdDB, ItemStore, LevelDB, StoreConfig};
734+
use store::{database::interface::BeaconNodeBackend, HotColdDB, ItemStore, StoreConfig};
736735
use tempfile::{tempdir, TempDir};
737736
use types::non_zero_usize::new_non_zero_usize;
738737
use types::{ExecPayload, MinimalEthSpec};
@@ -744,7 +743,7 @@ mod test {
744743
db_path: &TempDir,
745744
spec: Arc<ChainSpec>,
746745
log: Logger,
747-
) -> Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>> {
746+
) -> Arc<HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>> {
748747
let hot_path = db_path.path().join("hot_db");
749748
let cold_path = db_path.path().join("cold_db");
750749
let blobs_path = db_path.path().join("blobs_db");
@@ -920,7 +919,11 @@ mod test {
920919
)
921920
where
922921
E: EthSpec,
923-
T: BeaconChainTypes<HotStore = LevelDB<E>, ColdStore = LevelDB<E>, EthSpec = E>,
922+
T: BeaconChainTypes<
923+
HotStore = BeaconNodeBackend<E>,
924+
ColdStore = BeaconNodeBackend<E>,
925+
EthSpec = E,
926+
>,
924927
{
925928
let log = test_logger();
926929
let chain_db_path = tempdir().expect("should get temp dir");

beacon_node/beacon_chain/src/fetch_blobs.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{metrics, AvailabilityProcessingStatus, BeaconChain, BeaconChainTypes
1414
use execution_layer::json_structures::BlobAndProofV1;
1515
use execution_layer::Error as ExecutionLayerError;
1616
use metrics::{inc_counter, inc_counter_by, TryExt};
17-
use slog::{debug, error, o, warn, Logger};
17+
use slog::{debug, error, o, Logger};
1818
use ssz_types::FixedVector;
1919
use state_processing::per_block_processing::deneb::kzg_commitment_to_versioned_hash;
2020
use std::sync::Arc;
@@ -163,6 +163,20 @@ pub async fn fetch_and_process_engine_blobs<T: BeaconChainTypes>(
163163
return Ok(None);
164164
}
165165

166+
if chain
167+
.canonical_head
168+
.fork_choice_read_lock()
169+
.contains_block(&block_root)
170+
{
171+
// Avoid computing columns if block has already been imported.
172+
debug!(
173+
log,
174+
"Ignoring EL blobs response";
175+
"info" => "block has already been imported",
176+
);
177+
return Ok(None);
178+
}
179+
166180
let data_columns_receiver = spawn_compute_and_publish_data_columns_task(
167181
&chain,
168182
block.clone(),
@@ -249,23 +263,20 @@ fn spawn_compute_and_publish_data_columns_task<T: BeaconChainTypes>(
249263
};
250264

251265
if data_columns_sender.send(all_data_columns.clone()).is_err() {
252-
// Data column receiver have been dropped - this may not be an issue if the block is
253-
// already fully imported. This should not happen after the race condition
254-
// described in #6816 is fixed.
255-
warn!(
266+
// Data column receiver have been dropped - block may have already been imported.
267+
// This race condition exists because gossip columns may arrive and trigger block
268+
// import during the computation. Here we just drop the computed columns.
269+
debug!(
256270
log,
257271
"Failed to send computed data columns";
258272
);
273+
return;
259274
};
260275

261-
// Check indices from cache before sending the columns, to make sure we don't
262-
// publish components already seen on gossip.
263-
let is_supernode = chain_cloned.data_availability_checker.is_supernode();
264-
265276
// At the moment non supernodes are not required to publish any columns.
266277
// TODO(das): we could experiment with having full nodes publish their custodied
267278
// columns here.
268-
if !is_supernode {
279+
if !chain_cloned.data_availability_checker.is_supernode() {
269280
return;
270281
}
271282

beacon_node/beacon_chain/src/historical_blocks.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ use std::borrow::Cow;
1010
use std::iter;
1111
use std::time::Duration;
1212
use store::metadata::DataColumnInfo;
13-
use store::{
14-
get_key_for_col, AnchorInfo, BlobInfo, DBColumn, Error as StoreError, KeyValueStore,
15-
KeyValueStoreOp,
16-
};
13+
use store::{AnchorInfo, BlobInfo, DBColumn, Error as StoreError, KeyValueStore, KeyValueStoreOp};
1714
use strum::IntoStaticStr;
1815
use types::{FixedBytesExtended, Hash256, Slot};
1916

@@ -153,7 +150,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
153150
// Store block roots, including at all skip slots in the freezer DB.
154151
for slot in (block.slot().as_u64()..prev_block_slot.as_u64()).rev() {
155152
cold_batch.push(KeyValueStoreOp::PutKeyValue(
156-
get_key_for_col(DBColumn::BeaconBlockRoots.into(), &slot.to_be_bytes()),
153+
DBColumn::BeaconBlockRoots,
154+
slot.to_be_bytes().to_vec(),
157155
block_root.as_slice().to_vec(),
158156
));
159157
}
@@ -169,7 +167,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
169167
let genesis_slot = self.spec.genesis_slot;
170168
for slot in genesis_slot.as_u64()..prev_block_slot.as_u64() {
171169
cold_batch.push(KeyValueStoreOp::PutKeyValue(
172-
get_key_for_col(DBColumn::BeaconBlockRoots.into(), &slot.to_be_bytes()),
170+
DBColumn::BeaconBlockRoots,
171+
slot.to_be_bytes().to_vec(),
173172
self.genesis_block_root.as_slice().to_vec(),
174173
));
175174
}

beacon_node/beacon_chain/src/schema_change/migration_schema_v21.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use crate::validator_pubkey_cache::DatabasePubkey;
33
use slog::{info, Logger};
44
use ssz::{Decode, Encode};
55
use std::sync::Arc;
6-
use store::{
7-
get_key_for_col, DBColumn, Error, HotColdDB, KeyValueStore, KeyValueStoreOp, StoreItem,
8-
};
6+
use store::{DBColumn, Error, HotColdDB, KeyValueStore, KeyValueStoreOp, StoreItem};
97
use types::{Hash256, PublicKey};
108

119
const LOG_EVERY: usize = 200_000;
@@ -62,9 +60,9 @@ pub fn downgrade_from_v21<T: BeaconChainTypes>(
6260
message: format!("{e:?}"),
6361
})?;
6462

65-
let db_key = get_key_for_col(DBColumn::PubkeyCache.into(), key.as_slice());
6663
ops.push(KeyValueStoreOp::PutKeyValue(
67-
db_key,
64+
DBColumn::PubkeyCache,
65+
key.as_slice().to_vec(),
6866
pubkey_bytes.as_ssz_bytes(),
6967
));
7068

beacon_node/beacon_chain/src/schema_change/migration_schema_v22.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::sync::Arc;
44
use store::chunked_iter::ChunkedVectorIter;
55
use store::{
66
chunked_vector::BlockRootsChunked,
7-
get_key_for_col,
87
metadata::{
98
SchemaVersion, ANCHOR_FOR_ARCHIVE_NODE, ANCHOR_UNINITIALIZED, STATE_UPPER_LIMIT_NO_RETAIN,
109
},
@@ -21,7 +20,7 @@ fn load_old_schema_frozen_state<T: BeaconChainTypes>(
2120
) -> Result<Option<BeaconState<T::EthSpec>>, Error> {
2221
let Some(partial_state_bytes) = db
2322
.cold_db
24-
.get_bytes(DBColumn::BeaconState.into(), state_root.as_slice())?
23+
.get_bytes(DBColumn::BeaconState, state_root.as_slice())?
2524
else {
2625
return Ok(None);
2726
};
@@ -136,10 +135,7 @@ pub fn delete_old_schema_freezer_data<T: BeaconChainTypes>(
136135
for column in columns {
137136
for res in db.cold_db.iter_column_keys::<Vec<u8>>(column) {
138137
let key = res?;
139-
cold_ops.push(KeyValueStoreOp::DeleteKey(get_key_for_col(
140-
column.as_str(),
141-
&key,
142-
)));
138+
cold_ops.push(KeyValueStoreOp::DeleteKey(column, key));
143139
}
144140
}
145141
let delete_ops = cold_ops.len();
@@ -175,7 +171,8 @@ pub fn write_new_schema_block_roots<T: BeaconChainTypes>(
175171
// Store the genesis block root if it would otherwise not be stored.
176172
if oldest_block_slot != 0 {
177173
cold_ops.push(KeyValueStoreOp::PutKeyValue(
178-
get_key_for_col(DBColumn::BeaconBlockRoots.into(), &0u64.to_be_bytes()),
174+
DBColumn::BeaconBlockRoots,
175+
0u64.to_be_bytes().to_vec(),
179176
genesis_block_root.as_slice().to_vec(),
180177
));
181178
}
@@ -192,10 +189,8 @@ pub fn write_new_schema_block_roots<T: BeaconChainTypes>(
192189
// OK to hold these in memory (10M slots * 43 bytes per KV ~= 430 MB).
193190
for (i, (slot, block_root)) in block_root_iter.enumerate() {
194191
cold_ops.push(KeyValueStoreOp::PutKeyValue(
195-
get_key_for_col(
196-
DBColumn::BeaconBlockRoots.into(),
197-
&(slot as u64).to_be_bytes(),
198-
),
192+
DBColumn::BeaconBlockRoots,
193+
slot.to_be_bytes().to_vec(),
199194
block_root.as_slice().to_vec(),
200195
));
201196

beacon_node/beacon_chain/src/test_utils.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ use std::str::FromStr;
5858
use std::sync::atomic::{AtomicUsize, Ordering};
5959
use std::sync::{Arc, LazyLock};
6060
use std::time::Duration;
61-
use store::{config::StoreConfig, HotColdDB, ItemStore, LevelDB, MemoryStore};
61+
use store::database::interface::BeaconNodeBackend;
62+
use store::{config::StoreConfig, HotColdDB, ItemStore, MemoryStore};
6263
use task_executor::TaskExecutor;
6364
use task_executor::{test_utils::TestRuntime, ShutdownReason};
6465
use tree_hash::TreeHash;
@@ -118,7 +119,7 @@ pub fn get_kzg(spec: &ChainSpec) -> Arc<Kzg> {
118119
pub type BaseHarnessType<E, THotStore, TColdStore> =
119120
Witness<TestingSlotClock, CachingEth1Backend<E>, E, THotStore, TColdStore>;
120121

121-
pub type DiskHarnessType<E> = BaseHarnessType<E, LevelDB<E>, LevelDB<E>>;
122+
pub type DiskHarnessType<E> = BaseHarnessType<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>;
122123
pub type EphemeralHarnessType<E> = BaseHarnessType<E, MemoryStore<E>, MemoryStore<E>>;
123124

124125
pub type BoxedMutator<E, Hot, Cold> = Box<
@@ -301,7 +302,10 @@ impl<E: EthSpec> Builder<EphemeralHarnessType<E>> {
301302

302303
impl<E: EthSpec> Builder<DiskHarnessType<E>> {
303304
/// Disk store, start from genesis.
304-
pub fn fresh_disk_store(mut self, store: Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>>) -> Self {
305+
pub fn fresh_disk_store(
306+
mut self,
307+
store: Arc<HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>>,
308+
) -> Self {
305309
let validator_keypairs = self
306310
.validator_keypairs
307311
.clone()
@@ -326,7 +330,10 @@ impl<E: EthSpec> Builder<DiskHarnessType<E>> {
326330
}
327331

328332
/// Disk store, resume.
329-
pub fn resumed_disk_store(mut self, store: Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>>) -> Self {
333+
pub fn resumed_disk_store(
334+
mut self,
335+
store: Arc<HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>>,
336+
) -> Self {
330337
let mutator = move |builder: BeaconChainBuilder<_>| {
331338
builder
332339
.resume_from_db()

beacon_node/beacon_chain/tests/op_verification.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use state_processing::per_block_processing::errors::{
1414
AttesterSlashingInvalid, BlockOperationError, ExitInvalid, ProposerSlashingInvalid,
1515
};
1616
use std::sync::{Arc, LazyLock};
17-
use store::{LevelDB, StoreConfig};
17+
use store::database::interface::BeaconNodeBackend;
18+
use store::StoreConfig;
1819
use tempfile::{tempdir, TempDir};
1920
use types::*;
2021

@@ -26,7 +27,7 @@ static KEYPAIRS: LazyLock<Vec<Keypair>> =
2627

2728
type E = MinimalEthSpec;
2829
type TestHarness = BeaconChainHarness<DiskHarnessType<E>>;
29-
type HotColdDB = store::HotColdDB<E, LevelDB<E>, LevelDB<E>>;
30+
type HotColdDB = store::HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>;
3031

3132
fn get_store(db_path: &TempDir) -> Arc<HotColdDB> {
3233
let spec = Arc::new(test_spec::<E>());

0 commit comments

Comments
 (0)