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

docs(Integrations): P2P-Persistence integration #15

Merged
merged 6 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The implementation of the protocol is accessible [here](https://github.com/pokt-
- [Consensus](consensus/README.md)
- [P2P](p2p/README.md)
- [Persistence](persistence/README.md)
- [Cross module integrations](integrations/README.md)

## Support & Contact

Expand Down
71 changes: 71 additions & 0 deletions integrations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Pocket Network 1.0 Cross Module Integrations

<table style="text-align: center;">
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
<tr style="text-align: center;">
<td style="border-collapse: collapse;">
<p align="center">
Alessandro De Blasis
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
@deblasis<br>
</p>
</td>

<td style="border-width: 0px;">
<p align="center">
Andrew Nguyen
@andrewnguyen22 <br>
</p>
</td>

<td style="border-width: 0px;">
<p align="center">
Daniel Olshansky
@olshansky <br>
</p>
</td>

</tr>
</table>

<tr>
<td style="border-width: 0px;">
<p align="center">
Version 1.0.0<br>
</p>
</td>
</tr>

## Overview

In this section, we will describe in which way the various modules interact with each other.

## Introduction

While we proceed in the R&D of the individual modules, we need to consider that even if we are developing them in a microservice fashion, they still need to communicate with each other so that the application and therefore the Protocol itself can function as expected.

The purpose of this document is not to highlight the capabilities of each model but to focus on the point of contact/interactions with a brief explanation about the motivation behind the integration under discussion.

## Integrations

### Bus

An application `Bus` serves as a cross-cutting integration medium.
Without going too much into technical details, its main features for the purposes of this document are:

- acts as a service discovery layer, allowing to get instances of a module from within another
Copy link
Member

Choose a reason for hiding this comment

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

I would add details that point #1 is "synchronous communication" and point #2 is "asynchronous communication".

We could even copy-pasta the mermaid diagram from the implementation repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your points but perhaps this document should be less "loaded" with technicalities and try to explain things in simpler terms, good enough to have an idea of how it works at a high level

Regarding the diagram, if we copy-pasta it, we would have to keep track of it and keep them aligned.

I am sure that whoever reads this and is interested in how it works under the hood, they already pulled the main repo, probably as a first step actually.

Lemme know where your mind is at. Maybe we could ask Jess' point of view on this. I guess her input would be valuable. (not tagging her on purpose in the meantime).

My 2c. Let's keep it simple, actually, I was thinking that it might sound even too technical already perhaps 🤔

Copy link
Member

@Olshansk Olshansk Jan 26, 2023

Choose a reason for hiding this comment

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

I agree. This whole thing spec needs a revamp and I personally think pokt-network/pocket#438 does a better job at introducing the P2P module.

There will be more changes as we also have decided to adopt LibP2P.

  • I've done an initial "revamp" of persistence (but will need another one in the future)
  • Utility is in progress
  • @bryanchriswhite should be able to take p2p on over time
  • The bus & intermodule DI-like bus-like design will evolve over time as well. @deblasis 👀
  • Looking at @gokutheengineer for consensus

After we launch V1 (and have real data), we can write a single whitepaper capturing everything and publish on arxiv :)

- provides access to messaging functionality (EventBus)

### P2P - Persistence

#### P2P AddressBook management / Network Churn

Regardless of the underlying algorithm, `P2P` is a stateful business, there's state that has to be stored in memory (RAM) but there's also state that has to be persisted on the blockchain.
Olshansk marked this conversation as resolved.
Show resolved Hide resolved

In particular, when it comes `Network Churn` where `Actors` such as `Validators` are involved, joining and leaving the network, P2P has to integrate with Persistence in order to keep track of which actors were part of the network at that point in time (`Height` in Protocol terms).
Copy link
Member

Choose a reason for hiding this comment

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

NIT: Should we backticket P2P and Persistence?

deblasis marked this conversation as resolved.
Show resolved Hide resolved

The running instance of the P2P module in a node, keeps in memory an "Address List" of the peers and that's being updated constantly.
deblasis marked this conversation as resolved.
Show resolved Hide resolved

Whenever the `Consensus` determines a new `Height`, an event via the `Bus` notifies its listeners (`P2P` included) that the list of the current `Actors` that are part of the network has to be stored in `Persistence`.
deblasis marked this conversation as resolved.
Show resolved Hide resolved

Essentially, in simple terms, we can now call a function that returns the list of the Validators at a certain `Height`.

This function is used to deliver messages that are relevant only for a specific `Height` to the relevant actors.