Skip to content

Commit

Permalink
Revert "delete 'shallow blocks' in block cache when not using firehose (
Browse files Browse the repository at this point in the history
#4691)" (#4752)

* Revert "delete 'shallow blocks' in block cache when not using firehose (#4691)"

This reverts commit f7fec01.

* store: Restore migration for shallow blocks index
  • Loading branch information
leoyvens authored Jul 12, 2023
1 parent c9280f1 commit 80aa2b0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 47 deletions.
10 changes: 0 additions & 10 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,6 @@ async fn main() {
Some(&eth_firehose_only_networks)
};

let eth_firehose_only_network_names = match eth_firehose_only_networks {
Some(firehose_only) => Some(Vec::from_iter(firehose_only.networks.keys())),
None => None,
};

network_store
.block_store()
.cleanup_shallow_blocks(eth_firehose_only_network_names)
.unwrap();

let ethereum_chains = ethereum_networks_as_chains(
&mut blockchain_map,
&logger,
Expand Down
19 changes: 1 addition & 18 deletions store/postgres/src/block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
use graph::{
blockchain::ChainIdentifier,
components::store::BlockStore as BlockStoreTrait,
prelude::{error, info, warn, BlockNumber, BlockPtr, Logger, ENV_VARS},
prelude::{error, warn, BlockNumber, BlockPtr, Logger, ENV_VARS},
};
use graph::{constraint_violation, prelude::CheapClone};
use graph::{
Expand Down Expand Up @@ -442,23 +442,6 @@ impl BlockStore {
Ok(())
}

pub fn cleanup_shallow_blocks(
&self,
firehose_networks: Option<Vec<&String>>,
) -> Result<(), StoreError> {
for store in self.stores.read().unwrap().values() {
if let Some(fh_nets) = firehose_networks.clone() {
if fh_nets.contains(&&store.chain) {
continue;
};
}

info!(&self.logger, "Cleaning shallow blocks on non-firehose chain"; "network" => &store.chain);
store.cleanup_shallow_blocks()?
}
Ok(())
}

fn truncate_block_caches(&self) -> Result<(), StoreError> {
for store in self.stores.read().unwrap().values() {
store.truncate_block_cache()?
Expand Down
19 changes: 0 additions & 19 deletions store/postgres/src/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ mod data {
data jsonb not null
);
create index blocks_number ON {nsp}.blocks using btree(number);
create index blocks_expr_idx ON {nsp}.blocks USING BTREE ((data->'block'->'data')) where data->'block'->'data' = 'null'::jsonb;
create table {nsp}.call_cache (
id bytea not null primary key,
Expand Down Expand Up @@ -419,18 +418,6 @@ mod data {
Ok(())
}

pub(super) fn cleanup_shallow_blocks(&self, conn: &PgConnection) -> Result<(), StoreError> {
let table_name = match &self {
Storage::Shared => ETHEREUM_BLOCKS_TABLE_NAME,
Storage::Private(Schema { blocks, .. }) => &blocks.qname,
};
conn.batch_execute(&format!(
"delete from {} WHERE data->'block'->'data' = 'null'::jsonb;",
table_name
))?;
Ok(())
}

/// Insert a block. If the table already contains a block with the
/// same hash, then overwrite that block since it may be adding
/// transaction receipts. If `overwrite` is `true`, overwrite a
Expand Down Expand Up @@ -1566,12 +1553,6 @@ impl ChainStore {
.delete_blocks_by_hash(&conn, &self.chain, block_hashes)
}

pub fn cleanup_shallow_blocks(&self) -> Result<(), StoreError> {
let conn = self.get_conn()?;
self.storage.cleanup_shallow_blocks(&conn)?;
Ok(())
}

pub fn truncate_block_cache(&self) -> Result<(), StoreError> {
let conn = self.get_conn()?;
self.storage.truncate_block_cache(&conn)?;
Expand Down

0 comments on commit 80aa2b0

Please sign in to comment.