Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push & Pull protocol unit test #24

Merged
merged 35 commits into from
Aug 25, 2023
Merged

Push & Pull protocol unit test #24

merged 35 commits into from
Aug 25, 2023

Conversation

matheus23
Copy link
Member

@matheus23 matheus23 commented Jul 26, 2023

This PR implements a unit test that pushes a random DAG from one MemoryBlockStore to another via CAR files.

Closes #16
Closes #17
Closes #18

It doesn't really do #19, because in this version, CAR mirror is treated as mostly stateless.
The only state that needs to be kept is client-side, and it's the most recent response that it got from the server (so it knows what else remains to be sent or whether the protocol is done).
And (in this version) the server side is always completely stateless.

Should this become a performance issue, then we can easily add a bunch of memoization caches.
Some ideas for such caches:

  1. Cache the references between blocks. I.e. a mapping between Cid -> Vec<Cid>, instead of having to fetch the block everytime & recompute links.
  2. Cache the transitive closure of certain subgraphs. I.e. a mapping between Cid -> Vec<Cid>, but this time with all transitive references. Storing the whole transitive closure is going to be faster, but also requires a quadratic amount of memory in the depth of the DAG, if done for every block.
  3. Cache a bloom filter of transitive closures. I.e. a mapping between Cid -> Bloom. This one is neater, but also needs more thought, since it's likely the bloom will be the wrong size. Before we do this, we should probably do other versions first and see how memory-hungry they are.

@matheus23 matheus23 self-assigned this Jul 26, 2023
car-mirror/src/lib.rs Outdated Show resolved Hide resolved
@matheus23 matheus23 changed the title Implement some DAG walking First Unit test Aug 18, 2023
@matheus23 matheus23 changed the title First Unit test Push protocol unit test Aug 18, 2023
Also:
- Put `CarFile` bytes into a newtype
- Abstract out push&pull protocol parts into `common`
- Abstract out test utilities
@matheus23 matheus23 changed the title Push protocol unit test Push & Pull protocol unit test Aug 21, 2023
@matheus23 matheus23 marked this pull request as ready for review August 21, 2023 17:55
Copy link
Member

@appcypher appcypher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First off, huge kudos to you for diving into the intricacies of the car-mirror protocol and coming up with a great unit test! 🚀 I can see the effort and attention to detail that went into addressing the push & pull mechanisms, especially considering the nuances of state management.
That said, I have some questions and some nitpicks.

car-mirror/src/common.rs Outdated Show resolved Hide resolved
car-mirror/src/common.rs Show resolved Hide resolved
car-mirror/src/common.rs Outdated Show resolved Hide resolved
car-mirror/src/dag_walk.rs Show resolved Hide resolved
car-mirror/src/incremental_verification.rs Outdated Show resolved Hide resolved
car-mirror/src/incremental_verification.rs Outdated Show resolved Hide resolved
car-mirror/src/messages.rs Outdated Show resolved Hide resolved
car-mirror/src/push.rs Outdated Show resolved Hide resolved
car-mirror/src/incremental_verification.rs Outdated Show resolved Hide resolved
car-mirror/src/test_utils/blockstore_utils.rs Outdated Show resolved Hide resolved
Copy link
Member

@appcypher appcypher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🎉

@appcypher appcypher merged commit 7e9b79a into main Aug 25, 2023
9 checks passed
@appcypher
Copy link
Member

Oh snap! Merged it by mistake.

@matheus23 matheus23 deleted the matheus23/dag_walking branch August 25, 2023 11:20
@matheus23
Copy link
Member Author

All good, wanted to merge it anyways

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement CAR file reader/writer Integrate deterministic-bloom Implement in-memory blockstore walking
2 participants