-
Narwhal is a DAG-based mempool abstraction protocol
-
It was proposed with the approach of first splitting the concerns of:
- making transactions available across the network
- preparing a total-order in consensus with the honest nodes of the network
-
Tusk is the sample consensus protocol made in the Narwhal paper to demonstrate this new way of doing things
-
Blocks of transactions in the narwhal mempool contain not just a serial ordering of transactions but also a serial ordering of past referenced transaction blocks (which can be done with their headers, without the need of the block contents)
- It uses a key-store to record transaction blocks indexed by their digests (hashes) with the following operations:
read(d)
returns the block indexed by the provided digestwrite(d,b)
writes a given block to the storeread_causal(d)
returns the transitive set of all blocks that the block identified by d references (transitive meaning that the definition is recursive and for a block a referenced by a block b referenced by a block c, block a is also a valid element in block c’s defined operation)
- With the above operations allowed on it, the Narwhall mempool guarantees the following properties:
- any two invocations of reading the block for a given digest by honest parties returns the same value (if any value at all)
- an honest party that successfully invoked writing a new block will successfully invoke reading that same block for its digest
- the set returned from
read_causal(d)
is an improper superset of the set returned by one of the blocks that the block indexed with d references - the set returned by invoking
read_causal(d)
returns at least 66% of the blocks written successfully before the invocation of writing them (see point 2) - at least 50% of the blocks returned by an invocation of
read_causal(d)
were written by honest parties
Source Code
Analysis of source of a reference implementation of Narwhal-Tusk written by Alberto Sonnino, one of the authors of the whitepaper:
Crates
Crate | Description |
---|---|
node | Main entry point binary cli (node/src/main.rs) that can either generate keys, spawn a primary process (which also starts a consensus thread to run the Tusk consensus protocol) or spawn a worker process |
primary | Contains the logic to start the primary process which listens for connections from its workers and primary nodes on other validators TODO |
worker | Contains the logic to start the worker process with logic to handle messages from client transactions, from workers on other validators, and finally from the primary on the same validator TODO |
consensus | Contains the logic for the Tusk consensus protocol TODO |
store | Contains the key-store which receives the following commands:
|
network | Utility library for abstracting message sending (unreliable and reliable) and message receiving over a TCP stream |
crypto | Utility library for cryptography-relevant types and functions (Digest, Hash, PublicKey & SecretKey, generate_production_keypair, generate_keypair, Signature & SignatureService) |
config | Logic to read & deserialize a JSON config file to configure Narwhal, including the Committee composition |