Skip to content

Commit 51357fe

Browse files
committed
remove the indices store
1 parent 5e5a7a2 commit 51357fe

File tree

20 files changed

+26
-223
lines changed

20 files changed

+26
-223
lines changed

src/chain/store/chain_store.rs

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::{
66
index::{ChainIndex, ResolveNullTipset},
77
tipset_tracker::TipsetTracker,
88
};
9-
use crate::db::{EthMappingsStore, EthMappingsStoreExt, IndicesStore, IndicesStoreExt};
9+
use crate::db::{EthMappingsStore, EthMappingsStoreExt};
1010
use crate::interpreter::{BlockMessages, VMTrace};
1111
use crate::libp2p_bitswap::{BitswapStoreRead, BitswapStoreReadWrite};
1212
use crate::message::{ChainMessage, Message as MessageTrait, SignedMessage};
@@ -82,9 +82,6 @@ pub struct ChainStore<DB> {
8282
/// Ethereum mappings store
8383
eth_mappings: Arc<dyn EthMappingsStore + Sync + Send>,
8484

85-
/// Indices store
86-
indices: Arc<dyn IndicesStore + Sync + Send>,
87-
8885
/// Needed by the Ethereum mapping.
8986
chain_config: Arc<ChainConfig>,
9087
}
@@ -121,7 +118,6 @@ where
121118
db: Arc<DB>,
122119
heaviest_tipset_key_provider: Arc<dyn HeaviestTipsetKeyProvider + Sync + Send>,
123120
eth_mappings: Arc<dyn EthMappingsStore + Sync + Send>,
124-
indices: Arc<dyn IndicesStore + Sync + Send>,
125121
chain_config: Arc<ChainConfig>,
126122
genesis_block_header: CachingBlockHeader,
127123
) -> anyhow::Result<Self> {
@@ -139,7 +135,6 @@ where
139135
genesis_block_header,
140136
validated_blocks,
141137
eth_mappings,
142-
indices,
143138
chain_config,
144139
};
145140

@@ -204,15 +199,6 @@ where
204199
.map(|(cid, _)| cid))
205200
}
206201

207-
pub fn put_index<V: Serialize>(&self, key: &Cid, value: &V) -> Result<(), Error> {
208-
self.indices.write_obj(key, value)?;
209-
Ok(())
210-
}
211-
212-
pub fn get_tipset_key_by_events_root(&self, key: &Cid) -> Result<Option<TipsetKey>, Error> {
213-
Ok(self.indices.read_obj(key)?)
214-
}
215-
216202
/// Expands tipset to tipset with all other headers in the same epoch using
217203
/// the tipset tracker.
218204
fn expand_tipset(&self, header: CachingBlockHeader) -> Result<Tipset, Error> {
@@ -754,15 +740,8 @@ mod tests {
754740
message_receipts: Cid::new_v1(DAG_CBOR, MultihashCode::Identity.digest(&[])),
755741
..Default::default()
756742
});
757-
let cs = ChainStore::new(
758-
db.clone(),
759-
db.clone(),
760-
db.clone(),
761-
db,
762-
chain_config,
763-
gen_block.clone(),
764-
)
765-
.unwrap();
743+
let cs =
744+
ChainStore::new(db.clone(), db.clone(), db, chain_config, gen_block.clone()).unwrap();
766745

767746
assert_eq!(cs.genesis_block_header(), &gen_block);
768747
}
@@ -776,15 +755,7 @@ mod tests {
776755
..Default::default()
777756
});
778757

779-
let cs = ChainStore::new(
780-
db.clone(),
781-
db.clone(),
782-
db.clone(),
783-
db,
784-
chain_config,
785-
gen_block,
786-
)
787-
.unwrap();
758+
let cs = ChainStore::new(db.clone(), db.clone(), db, chain_config, gen_block).unwrap();
788759

789760
let cid = Cid::new_v1(DAG_CBOR, MultihashCode::Blake2b256.digest(&[1, 2, 3]));
790761
assert!(!cs.is_block_validated(&cid));

src/chain_sync/chain_follower.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ mod tests {
918918
db.clone(),
919919
db.clone(),
920920
db.clone(),
921-
db.clone(),
922921
Default::default(),
923922
genesis_header.clone().into(),
924923
)

src/daemon/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ async fn create_state_manager(
245245
Arc::clone(db),
246246
Arc::new(db.clone()),
247247
eth_mappings,
248-
db.writer().clone(),
249248
chain_config.clone(),
250249
genesis_header.clone(),
251250
)?);

src/daemon/db_util.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,9 @@ where
329329
let epoch = ts.epoch();
330330
let tsk = ts.key().clone();
331331

332-
let state_output = state_manager
332+
state_manager
333333
.compute_tipset_state(ts.clone(), NO_CALLBACK, VMTrace::NotTraced)
334334
.await?;
335-
for events_root in state_output.events_roots.iter().flatten() {
336-
tracing::trace!("Indexing events root @{epoch}: {events_root}");
337-
338-
state_manager.chain_store().put_index(events_root, &tsk)?;
339-
}
340335

341336
delegated_messages.append(
342337
&mut state_manager

src/db/car/many.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use super::{AnyCar, ZstdFrameCache};
1212
use crate::blocks::TipsetKey;
1313
use crate::db::{
14-
BlockstoreWriteOpsSubscribable, EthMappingsStore, IndicesStore, MemoryDB, PersistentStore,
15-
SettingsStore, SettingsStoreExt,
14+
BlockstoreWriteOpsSubscribable, EthMappingsStore, MemoryDB, PersistentStore, SettingsStore,
15+
SettingsStoreExt,
1616
};
1717
use crate::libp2p_bitswap::BitswapStoreReadWrite;
1818
use crate::rpc::eth::types::EthHash;
@@ -251,20 +251,6 @@ impl<WriterT: EthMappingsStore> EthMappingsStore for ManyCar<WriterT> {
251251
}
252252
}
253253

254-
impl<WriterT: IndicesStore> IndicesStore for ManyCar<WriterT> {
255-
fn read_bin(&self, key: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
256-
IndicesStore::read_bin(self.writer(), key)
257-
}
258-
259-
fn write_bin(&self, key: &Cid, value: &[u8]) -> anyhow::Result<()> {
260-
IndicesStore::write_bin(self.writer(), key, value)
261-
}
262-
263-
fn exists(&self, key: &Cid) -> anyhow::Result<bool> {
264-
IndicesStore::exists(self.writer(), key)
265-
}
266-
}
267-
268254
impl<T: Blockstore + SettingsStore> super::super::HeaviestTipsetKeyProvider for ManyCar<T> {
269255
fn heaviest_tipset_key(&self) -> anyhow::Result<TipsetKey> {
270256
match SettingsStoreExt::read_obj::<TipsetKey>(self, crate::db::setting_keys::HEAD_KEY)? {

src/db/memory.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use super::{EthMappingsStore, SettingsStore, SettingsStoreExt};
55
use crate::blocks::TipsetKey;
6-
use crate::db::{IndicesStore, PersistentStore};
6+
use crate::db::PersistentStore;
77
use crate::libp2p_bitswap::{BitswapStoreRead, BitswapStoreReadWrite};
88
use crate::rpc::eth::types::EthHash;
99
use crate::utils::db::car_stream::CarBlock;
@@ -21,7 +21,6 @@ pub struct MemoryDB {
2121
blockchain_persistent_db: RwLock<HashMap<Cid, Vec<u8>>>,
2222
settings_db: RwLock<HashMap<String, Vec<u8>>>,
2323
pub eth_mappings_db: RwLock<HashMap<EthHash, Vec<u8>>>,
24-
pub indices_db: RwLock<HashMap<Cid, Vec<u8>>>,
2524
}
2625

2726
impl MemoryDB {
@@ -110,23 +109,6 @@ impl EthMappingsStore for MemoryDB {
110109
}
111110
}
112111

113-
impl IndicesStore for MemoryDB {
114-
fn read_bin(&self, key: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
115-
Ok(self.indices_db.read().get(key).cloned())
116-
}
117-
118-
fn write_bin(&self, key: &Cid, value: &[u8]) -> anyhow::Result<()> {
119-
self.indices_db
120-
.write()
121-
.insert(key.to_owned(), value.to_vec());
122-
Ok(())
123-
}
124-
125-
fn exists(&self, key: &Cid) -> anyhow::Result<bool> {
126-
Ok(self.indices_db.read().contains_key(key))
127-
}
128-
}
129-
130112
impl Blockstore for MemoryDB {
131113
fn get(&self, k: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
132114
Ok(self.blockchain_db.read().get(k).cloned().or(self

src/db/mod.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -191,47 +191,6 @@ impl<T: ?Sized + EthMappingsStore> EthMappingsStoreExt for T {
191191
}
192192
}
193193

194-
pub trait IndicesStore {
195-
fn read_bin(&self, key: &Cid) -> anyhow::Result<Option<Vec<u8>>>;
196-
197-
fn write_bin(&self, key: &Cid, value: &[u8]) -> anyhow::Result<()>;
198-
199-
#[allow(dead_code)]
200-
fn exists(&self, key: &Cid) -> anyhow::Result<bool>;
201-
}
202-
203-
impl<T: IndicesStore> IndicesStore for Arc<T> {
204-
fn read_bin(&self, key: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
205-
IndicesStore::read_bin(self.as_ref(), key)
206-
}
207-
208-
fn write_bin(&self, key: &Cid, value: &[u8]) -> anyhow::Result<()> {
209-
IndicesStore::write_bin(self.as_ref(), key, value)
210-
}
211-
212-
fn exists(&self, key: &Cid) -> anyhow::Result<bool> {
213-
IndicesStore::exists(self.as_ref(), key)
214-
}
215-
}
216-
217-
pub trait IndicesStoreExt {
218-
fn read_obj<V: DeserializeOwned>(&self, key: &Cid) -> anyhow::Result<Option<V>>;
219-
fn write_obj<V: Serialize>(&self, key: &Cid, value: &V) -> anyhow::Result<()>;
220-
}
221-
222-
impl<T: ?Sized + IndicesStore> IndicesStoreExt for T {
223-
fn read_obj<V: DeserializeOwned>(&self, key: &Cid) -> anyhow::Result<Option<V>> {
224-
match self.read_bin(key)? {
225-
Some(bytes) => Ok(Some(fvm_ipld_encoding::from_slice(&bytes)?)),
226-
None => Ok(None),
227-
}
228-
}
229-
230-
fn write_obj<V: Serialize>(&self, key: &Cid, value: &V) -> anyhow::Result<()> {
231-
self.write_bin(key, &fvm_ipld_encoding::to_vec(value)?)
232-
}
233-
}
234-
235194
/// Traits for collecting DB stats
236195
pub trait DBStatistics {
237196
fn get_statistics(&self) -> Option<String> {

src/db/parity_db.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2019-2025 ChainSafe Systems
22
// SPDX-License-Identifier: Apache-2.0, MIT
33

4-
use super::{EthMappingsStore, IndicesStore, PersistentStore, SettingsStore};
4+
use super::{EthMappingsStore, PersistentStore, SettingsStore};
55
use crate::blocks::TipsetKey;
66
use crate::db::{DBStatistics, parity_db_config::ParityDbConfig};
77
use crate::libp2p_bitswap::{BitswapStoreRead, BitswapStoreReadWrite};
@@ -39,8 +39,6 @@ pub enum DbColumn {
3939
/// Anything stored in this column can be considered permanent, unless manually
4040
/// deleted.
4141
PersistentGraph,
42-
/// Column for storing indexed values.
43-
Indices,
4442
}
4543

4644
impl DbColumn {
@@ -77,12 +75,6 @@ impl DbColumn {
7775
compression,
7876
..Default::default()
7977
},
80-
DbColumn::Indices => parity_db::ColumnOptions {
81-
preimage: false,
82-
btree_index: false,
83-
compression,
84-
..Default::default()
85-
},
8678
}
8779
})
8880
.collect()
@@ -229,23 +221,6 @@ impl EthMappingsStore for ParityDb {
229221
}
230222
}
231223

232-
impl IndicesStore for ParityDb {
233-
fn read_bin(&self, key: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
234-
self.read_from_column(key.to_bytes(), DbColumn::Indices)
235-
}
236-
237-
fn write_bin(&self, key: &Cid, value: &[u8]) -> anyhow::Result<()> {
238-
self.write_to_column(key.to_bytes(), value, DbColumn::Indices)
239-
}
240-
241-
fn exists(&self, key: &Cid) -> anyhow::Result<bool> {
242-
self.db
243-
.get_size(DbColumn::Indices as u8, &key.to_bytes())
244-
.map(|size| size.is_some())
245-
.context("error checking if key exists")
246-
}
247-
}
248-
249224
fn has_subscribers<T>(tx: &tokio::sync::broadcast::Sender<T>) -> bool {
250225
tx.closed().now_or_never().is_none()
251226
}
@@ -463,7 +438,6 @@ mod test {
463438
DbColumn::Settings => panic!("invalid column for IPLD data"),
464439
DbColumn::EthMappings => panic!("invalid column for IPLD data"),
465440
DbColumn::PersistentGraph => panic!("invalid column for GC enabled IPLD data"),
466-
DbColumn::Indices => panic!("invalid indices column for IPLD data"),
467441
};
468442
let actual = db.read_from_column(cid.to_bytes(), other_column).unwrap();
469443
assert!(actual.is_none());

src/libp2p/chain_exchange/provider.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ mod tests {
176176

177177
let response = make_chain_exchange_response(
178178
&ChainStore::new(
179-
db.clone(),
180179
db.clone(),
181180
db.clone(),
182181
db,

src/rpc/methods/chain.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,6 @@ mod tests {
16111611
db,
16121612
Arc::new(MemoryDB::default()),
16131613
Arc::new(MemoryDB::default()),
1614-
Arc::new(MemoryDB::default()),
16151614
Arc::new(ChainConfig::calibnet()),
16161615
genesis_block_header,
16171616
)

0 commit comments

Comments
 (0)