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

Documentation #503

Merged
merged 13 commits into from
Jan 18, 2018
Merged

Documentation #503

merged 13 commits into from
Jan 18, 2018

Conversation

lovesh
Copy link
Contributor

@lovesh lovesh commented Jan 17, 2018

No description provided.

Lovesh added 8 commits December 27, 2017 16:28
Signed-off-by: Lovesh <[email protected]>
Signed-off-by: Lovesh <[email protected]>
Signed-off-by: Lovesh <[email protected]>
Signed-off-by: Lovesh <[email protected]>
docs/catchup.md Outdated
@@ -0,0 +1,33 @@
# Ledger catchup

A node uses a process called `catchup` to sync its ledgers with other nodes. It does this process after starting up
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use bullet points to mention all cases where we can start catch-up more explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

The `LedgerManager` performs catchup of each ledger sequentially, which means unless catchup for one ledger is complete, catchup for other will not start.
This is mostly done for simplicity and can be optimised but the pool ledger needs to be caught up first as the pool ledger knows how many nodes are there
in the network. Catchup for any ledger involves these steps:
- Learn the correct state (how many txns, merkle roots) of the ledger by using `LedgerStatus` messages from other nodes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention how and when LedgerStatus is sent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is mentioned below.

docs/catchup.md Outdated
This is mostly done for simplicity and can be optimised but the pool ledger needs to be caught up first as the pool ledger knows how many nodes are there
in the network. Catchup for any ledger involves these steps:
- Learn the correct state (how many txns, merkle roots) of the ledger by using `LedgerStatus` messages from other nodes.
- Once sufficient consistent `LedgerStatus` messages are received so that the node knows the latest state of the ledger, if it finds it ledger to be
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention the exact number of LedgerStatus messages to be sufficient (see quorums.py)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Relevant code:
- LedgerManager: `plenum/common/ledger_manager.py`
- LedgerInfo: `plenum/common/ledger_info.py`
- Catchup message types: `plenum/common/messages/node_messages.py`
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also mention Quorums (quorums.py) containing all quorum values including catch-up quorums.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

docs/catchup.md Outdated
the receiving node B's size is 30 with merkle root `y`, B sends a proof to A that A's ledger with size 20 and root `x` is a subset of B's ledger with size
30 and root `y`.
- After receiving a `ConsistencyProof`, the node verifies it.
- Once the node that is catching up has sufficient consistent `ConsistencyProof` messages, it knows how many transactions it needs to catchup and
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention the exact number of ConsistencyProof messages to be sufficient (see quorums.py)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Lovesh added 2 commits January 18, 2018 15:47
Signed-off-by: Lovesh <[email protected]>
Signed-off-by: Lovesh <[email protected]>
@@ -0,0 +1,54 @@
# Request handling.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the dot at the end

#### Request handling
Below is a description of how a request is processed.
A node on receiving a client request in `validateClientMsg`:
- The node performs static validation checks (validation that does not require any state, like mandatory fields are present, etc), it calls `RequestHandler`'s `doStaticValidation`
Copy link
Contributor

Choose a reason for hiding this comment

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

We also have a schema-based validation before static validation in req handlers. This schema-based validation checks that the request is a valid request semantically with expected types and limitations. Probably we should mention it here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

- The node performs static validation checks (validation that does not require any state, like mandatory fields are present, etc), it calls `RequestHandler`'s `doStaticValidation`
- If the static validation passes, it checks if the signature check is required and does that if needed in `verifySignature`. More on this later.
- Checks if it a generic transaction query (`GET_TXN`). If it is then query the ledger for that particular sequence number and return the result. A `REQNACK` might be sent if the query is not correctly constructed.
- Checks if it a specific query (needs a specific `RequestHandler`), if it is then it uses `process_query` that uses the specific `RequestHandler` to respond to the query. A `REQNACK` might be sent if the query is not correctly constructed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be Checks if it is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

A node on receiving a client request in `validateClientMsg`:
- The node performs static validation checks (validation that does not require any state, like mandatory fields are present, etc), it calls `RequestHandler`'s `doStaticValidation`
- If the static validation passes, it checks if the signature check is required and does that if needed in `verifySignature`. More on this later.
- Checks if it a generic transaction query (`GET_TXN`). If it is then query the ledger for that particular sequence number and return the result. A `REQNACK` might be sent if the query is not correctly constructed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be Checks if it is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

A node has atleast 1 authenticator called `CoreAuthNr` whose `authenticate` method is called over the serialised request data to verify signature.


Relevant code: ``
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use bullet points here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Below is a description of how a request is processed.
A node on receiving a client request in `validateClientMsg`:
- The node performs static validation checks (validation that does not require any state, like mandatory fields are present, etc), it calls `RequestHandler`'s `doStaticValidation`
- If the static validation passes, it checks if the signature check is required and does that if needed in `verifySignature`. More on this later.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention that signature is not required for queries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

- If the `Request` is already in process, then it sends an acknowledgement to the client as a `REQACK`
- If the node has not seen the `Request` before it broadcasts the `Request` to all nodes in a `PROPAGATE`.
- Once a node receives sufficient (`Quorums.propagate`) `PROPAGATE`s for a request, it forwards the request to its replicas.
- A primary replica on receiving a forwarded request does dynamic validation (requiring state, like if violating some unique constraint or doing an unauthorised action)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we mention batching here? That Primary applies dynamic validation for each request in the batch, and that the batch can still be processed if there are invalid requests there. Reject is sent just for invalid requests from the batch,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Batch is an optimisation for consensus, i didn't want to digress, i think a detailed doc explaining our differences in 3PC with RBFT should list batching, merkle roots and checks in 3PC messages, etc

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, that's fine. Probably it's sufficient here to just mention this doc so that one can have a look how this all works with batches.



#### Signature verification
Each node has a `ReqAuthenticator` object which allows to register `ClientAuthNr` objects using `register_authenticator` method. During signature verification,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we mention that we support both single signature and multi-signatures now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe? Do you?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to mention this if we have such a section as signature verification.

Signed-off-by: Lovesh <[email protected]>
A node has atleast 1 authenticator called `CoreAuthNr` whose `authenticate` method is called over the serialised request data to verify signature.


Relevant code: ``
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove `` at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Below is a description of how a request is processed.
A node on receiving a client request in `validateClientMsg`:
- The node performs static validation checks (validation that does not require any state, like mandatory fields are present, etc), it uses `ClientMessageValidator` and
`RequestHandler`'s `doStaticValidation` for this
Copy link
Contributor

Choose a reason for hiding this comment

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

Please put a dot at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Lovesh added 2 commits January 18, 2018 18:42
Signed-off-by: Lovesh <[email protected]>
Signed-off-by: Lovesh <[email protected]>
@ashcherbakov ashcherbakov merged commit 6ec12c4 into master Jan 18, 2018
@lovesh lovesh deleted the documentation branch February 13, 2018 21:15
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.

2 participants