Skip to content

Commit 32dd8dd

Browse files
committed
address CI failures
1 parent ce9eee5 commit 32dd8dd

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

graph/src/components/store/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use std::{collections::HashSet, sync::Arc};
44
use crate::{
55
blockchain::{block_stream::FirehoseCursor, BlockPtr, BlockTime},
66
cheap_clone::CheapClone,
7+
components::metrics::block_state::BlockStateMetrics,
78
components::subgraph::Entity,
89
constraint_violation,
910
data::{store::Id, subgraph::schema::SubgraphError},
1011
data_source::CausalityRegion,
1112
derive::CacheWeight,
1213
prelude::DeploymentHash,
1314
util::cache_weight::CacheWeight,
14-
components::metrics::block_state::BlockStateMetrics,
1515
};
1616

1717
use super::{BlockNumber, EntityKey, EntityType, StoreError, StoreEvent, StoredDynamicDataSource};
@@ -511,7 +511,7 @@ impl RowGroup {
511511
.rows
512512
.iter()
513513
.filter_map(|row| match row {
514-
EntityModification::Insert { data, .. }
514+
EntityModification::Insert { data, .. }
515515
| EntityModification::Overwrite { data, .. } => Some(data.as_ref().clone()),
516516
EntityModification::Remove { .. } => None,
517517
})

runtime/wasm/src/host_exports.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ use crate::{error::DeterminismLevel, module::IntoTrap};
3333

3434
use super::module::WasmInstanceData;
3535

36+
use graph::schema::EntityKey;
37+
3638
fn write_poi_event(
3739
proof_of_indexing: &SharedProofOfIndexing,
3840
poi_event: &ProofOfIndexingEvent,
@@ -354,7 +356,7 @@ impl HostExports {
354356
.metrics
355357
.track_storage_size_change(&entity_type, &entity, false);
356358

357-
if !state.entity_cache.contains_key(&key) {
359+
if state.entity_cache.get(&key, GetScope::Store)?.is_none() {
358360
state.metrics.track_entity_count_change(&entity_type, 1);
359361
}
360362

@@ -1250,21 +1252,27 @@ impl HostExports {
12501252
.context("Failed to decode")
12511253
}
12521254

1253-
fn remove_entity(&mut self, key: &EntityKey) -> Result<(), HostExportError> {
1255+
fn remove_entity(
1256+
&mut self,
1257+
key: &EntityKey,
1258+
state: &mut BlockState,
1259+
) -> Result<(), HostExportError> {
12541260
let entity_type = key.entity_type.clone();
1255-
1256-
if let Some(entity) = state.entity_cache.get(&key, GetScope::Store)? {
1257-
// Track removal metrics while we still have the entity data
1261+
1262+
if let Some(entity) = state.entity_cache.get(key, GetScope::Store)? {
12581263
state
12591264
.metrics
12601265
.track_storage_size_change(&entity_type, &entity, true);
12611266
state.metrics.track_entity_count_change(&entity_type, -1);
12621267
}
12631268

1264-
state.modifications.push(EntityModification::remove(
1265-
key.clone(),
1266-
state.block.number,
1267-
));
1269+
state
1270+
.entity_cache
1271+
.modifications
1272+
.push(EntityModification::remove(
1273+
key.clone(),
1274+
state.entity_cache.block_number,
1275+
));
12681276
Ok(())
12691277
}
12701278
}
@@ -1395,3 +1403,9 @@ fn bytes_to_string_is_lossy() {
13951403
)
13961404
)
13971405
}
1406+
1407+
impl From<StoreError> for HostExportError {
1408+
fn from(err: StoreError) -> Self {
1409+
HostExportError::Deterministic(anyhow::Error::from(err))
1410+
}
1411+
}

0 commit comments

Comments
 (0)