Skip to content

Commit 4ff3714

Browse files
author
Zoran Cvetkov
committed
debug POIs
1 parent f632822 commit 4ff3714

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

core/src/subgraph/runner.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,7 @@ async fn update_proof_of_indexing(
16611661
stopwatch: &StopwatchMetrics,
16621662
entity_cache: &mut EntityCache,
16631663
) -> Result<(), Error> {
1664+
println!("UPDATE POI: {:?}", block_time);
16641665
// Helper to store the digest as a PoI entity in the cache
16651666
fn store_poi_entity(
16661667
entity_cache: &mut EntityCache,
@@ -1689,6 +1690,7 @@ async fn update_proof_of_indexing(
16891690

16901691
let block_number = proof_of_indexing.get_block();
16911692
let mut proof_of_indexing = proof_of_indexing.take();
1693+
// println!("UPDATE POI2: {:?}", proof_of_indexing);
16921694

16931695
for (causality_region, stream) in proof_of_indexing.drain() {
16941696
// Create the special POI entity key specific to this causality_region
@@ -1704,6 +1706,7 @@ async fn update_proof_of_indexing(
17041706

17051707
// Grab the current digest attribute on this entity
17061708
let poi_digest = entity_cache.schema.poi_digest().clone();
1709+
println!("POI DIGEST: {:?}", poi_digest);
17071710
let prev_poi = entity_cache
17081711
.get(&entity_key, GetScope::Store)
17091712
.map_err(Error::from)?
@@ -1713,6 +1716,7 @@ async fn update_proof_of_indexing(
17131716
});
17141717

17151718
// Finish the POI stream, getting the new POI value.
1719+
println!("RUNNER POI PAUSE: {:?}", prev_poi);
17161720
let updated_proof_of_indexing = stream.pause(prev_poi.as_deref());
17171721
let updated_proof_of_indexing: Bytes = (&updated_proof_of_indexing[..]).into();
17181722

graph/src/components/subgraph/proof_of_indexing/online.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ impl BlockEventStream {
123123
pub fn pause(mut self, prev: Option<&[u8]>) -> Vec<u8> {
124124
self.hasher
125125
.write(&self.vec_length, &[1, 0, self.block_index, 0]);
126-
match self.hasher {
126+
let hash = match self.hasher {
127127
Hashers::Legacy(mut digest) => {
128128
if let Some(prev) = prev {
129+
println!();
130+
println!("OLD PREV: {}", hex::encode(prev));
129131
let prev = SetHasher::from_bytes(prev);
130132
// SequenceNumber::root() is misleading here since the parameter
131133
// is unused.
@@ -139,16 +141,25 @@ impl BlockEventStream {
139141
prev.try_into()
140142
.expect("Expected valid fast stable hash representation")
141143
} else {
144+
println!();
145+
println!("NEW DIFFERENT PREV2: {}", hex::encode(prev));
146+
// prev[..32]
147+
// .try_into()
148+
// .expect("Expected valid fast stable hash representation")
142149
let mut hasher = Sha256::new();
143150
hasher.update(prev);
144151
hasher.finalize().into()
145152
};
153+
println!();
154+
println!("NEW PREV: {}", hex::encode(prev));
146155
let prev = FastStableHasher::from_bytes(prev);
147156
digest.mixin(&prev);
148157
}
149158
digest.to_bytes().to_vec()
150159
}
151-
}
160+
};
161+
println!("HASH: {}", hex::encode(hash.clone()));
162+
hash
152163
}
153164

154165
fn write(&mut self, event: &ProofOfIndexingEvent<'_>) {

tests/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ impl Config {
175175
.stdout(stdout)
176176
.stderr(stderr)
177177
.args(args)
178+
// .env("RUST_BACKTRACE", "1")
178179
.env("GRAPH_STORE_WRITE_BATCH_DURATION", "5");
179180

180181
status!(

tests/tests/integration_tests.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -836,14 +836,23 @@ async fn test_subgraph_grafting(ctx: TestContext) -> anyhow::Result<()> {
836836
"2a6c4b65d659e0485371a93bc1ac0f0d7bc0f25a454b5f23a842335fea0638d5",
837837
];
838838

839-
let pois: Vec<&str> = vec![
840-
"0x4f3e32c290fd6aa3613a0bbd0cc4367ae082036086cf75f292f8eaf798648a27",
841-
"0x6053124bc1042dfc9c153b49c626f11860a1bc34d0fde384526a2dbed909d242",
842-
"0xca535e3a5be9b93012f6173b33cf9c053cac8028dda9c398b619b67f53a9e1a4",
843-
];
839+
// local
840+
// let pois: Vec<&str> = vec![
841+
// "0x4f3e32c290fd6aa3613a0bbd0cc4367ae082036086cf75f292f8eaf798648a27",
842+
// "0x6053124bc1042dfc9c153b49c626f11860a1bc34d0fde384526a2dbed909d242",
843+
// "0xca535e3a5be9b93012f6173b33cf9c053cac8028dda9c398b619b67f53a9e1a4",
844+
// ];
845+
846+
// CI
847+
// let pois: Vec<&str> = vec![
848+
// "0xf6aafd84e07d49d0c417d5ca65a7483bf35ce78d1347d4caa1b418a538b1cd63",
849+
// "0xda37bb750cb4dfecd7c244d01b4e167a3f928ea5a0f97e60ef202381cf975e33",
850+
// "0xd5fb0e91dae61529932998cf3e213ecb9df80061b82a94a4421883d6d0ebb29b",
851+
// ];
844852

845853
for i in 1..4 {
846854
let block_hash = get_bloock_hash(i).await.unwrap();
855+
println!("hash: {}", block_hash);
847856
// We need to make sure that the preconditions for POI are fulfiled
848857
// namely that the anvil produces the proper block hashes for the
849858
// blocks of which we will check the POI
@@ -866,14 +875,15 @@ async fn test_subgraph_grafting(ctx: TestContext) -> anyhow::Result<()> {
866875
assert_eq!(None, resp.get("errors"));
867876
assert!(resp["data"]["proofOfIndexing"].is_string());
868877
let poi = resp["data"]["proofOfIndexing"].as_str().unwrap();
878+
println!("poi: {}", poi);
869879
// Check the expected value of the POI. The transition from the old legacy
870880
// hashing to the new one is done in the block #2 anything before that
871881
// should not change as the legacy code will not be updated. Any change
872882
// after that might indicate a change in the way new POI is now calculated.
873883
// Change on the block #2 would mean a change in the transitioning
874884
// from the old to the new algorithm hence would be reflected only
875885
// subgraphs that are grafting from pre 0.0.5 to 0.0.6 or newer.
876-
assert_eq!(poi, pois[(i - 1) as usize]);
886+
// assert_eq!(poi, pois[(i - 1) as usize]);
877887
}
878888

879889
Ok(())
@@ -1023,7 +1033,8 @@ async fn integration_tests() -> anyhow::Result<()> {
10231033
// Test "api-version-v0-0-4" was commented out in the original; what's
10241034
// up with that?
10251035

1026-
let test_name_to_run = std::env::var("TEST_CASE").ok();
1036+
// let test_name_to_run = std::env::var("TEST_CASE").ok();
1037+
let test_name_to_run = Some("grafting");
10271038

10281039
let cases = vec![
10291040
TestCase::new("ganache-reverts", test_ganache_reverts),
@@ -1038,6 +1049,8 @@ async fn integration_tests() -> anyhow::Result<()> {
10381049
TestCase::new("timestamp", test_timestamp),
10391050
TestCase::new("ethereum-api-tests", test_eth_api),
10401051
TestCase::new("topic-filter", test_topic_filters),
1052+
TestCase::new("topic-filter", test_topic_filters),
1053+
// TestCase::new("grafted", test_subgraph_grafting),
10411054
TestCase::new_with_grafting("grafting", test_subgraph_grafting, "grafted"),
10421055
TestCase::new_with_source_subgraph(
10431056
"subgraph-data-sources",

0 commit comments

Comments
 (0)