A modified version of the Raft consensus protocol for highly-efficient cooperative Ethereum SSV implementations
Go to file
zah 725b8b3288
Expand the README with more details
2024-05-08 14:38:23 +03:00
.github/workflows Refactoring 2024-02-09 16:56:33 +02:00
.vscode Code refactoring 2024-02-07 15:29:53 +02:00
doc Added Diego Ongaro Raft paper and Stanford PhD Dissertation 2023-09-03 07:23:23 +03:00
scripts/ci Change script permissions 2024-02-09 17:00:08 +02:00
src Fix lastTerm access 2024-02-29 19:26:11 +02:00
tests Remove logs 2024-02-29 19:27:03 +02:00
.editorconfig Add license and .editorconfig 2023-08-03 19:58:40 +03:00
.gitignore Added Diego Ongaro Raft paper and Stanford PhD Dissertation 2023-09-03 07:23:23 +03:00
LICENSE-APACHEv2 Add preliminary API definitions and project roadmap 2023-08-09 13:06:34 +03:00
LICENSE-MIT Add preliminary API definitions and project roadmap 2023-08-09 13:06:34 +03:00
README.md Expand the README with more details 2024-05-08 14:38:23 +03:00
config.nim Test CI 2024-02-13 13:59:14 +02:00
nim.projectMapping Refactoring 2024-02-09 16:56:33 +02:00
nimble.lock Fix CI 2024-02-13 14:40:59 +02:00
raft.nimble Fix CI 2024-02-13 14:40:59 +02:00
raft.nims Fix CI 2024-02-13 14:40:59 +02:00

README.md

nim-raft

This repository provides an implementation of the Raft consensus algorithm that is well suited for application-specific customizations of the protocol.

We plan to leverage this implementation to create a highly-efficient setup for operating a redundant set of Nimbus beacon nodes and/or validator clients that rely on BLS threshold signatures to achieve improved resilience and security. Further details can be found in our roadmap here:

https://github.com/status-im/nimbus-eth2/issues/3416

Our implementation is heavily inspired by the Raft implementation in ScyllaDB

https://github.com/scylladb/scylladb/tree/master/raft

Design goals

The main goal is to separate implementation of the raft state machine from the other implementation details such as storage, network communication, etc. In order to achieve this, we want to keep the state machine absolutely deterministic. Aspects such as networking, logging, acquiring current time, random number generation, disc operation, etc are delegated to the hosting application through the state machine interface. This ensures better testability and easier integration in arbitrary host application architectures.

BLS-Raft

Besides the base Raft algorithm, this repository implements an extension of Raft that effectively authenticates all Raft messages with BLS signatures of the participants. Through the use of BLS threshold signing, this augments the act of reaching consensus with the creation of a corresponding group BLS signature in cluster configuration such as 2 out of 3, 3 out of 5, etc.

In the context of Ethereum distributed validating, the consensus represents the sequence of validator messages that are signed and submitted to the Ethereum network. Examined through the familiar context of using Raft for database replication, you can think of the proposed approach as a replication mechanism for the slashing protection database that is typically maintained by an Ethereum client.

How does it work?

The immutability of entries in the Raft log poses a challenge when working with BLS threshold signing, particularly in generating message signatures. Since the signature requires shares from other nodes in the network, partially signed messages cannot be added directly to the Raft log. To overcome this, an alternative method for collecting signature shares from other nodes before adding the message to the log becomes necessary. Although various approaches exist, they introduce delays and increased network traffic to the protocol.

To address this challenge, we propose utilizing Raft exclusively for replicating messages and introduce a second layer atop Raft to ensure signature collection. The process unfolds as follows:

  1. The leader node generates a new message.
  2. The leader signs the message.
  3. The message and its signature are saved in the leader's state.
  4. The message is added to the Raft log.
  5. The Raft replication message is encapsulated within a signature request message.
  6. Follower nodes sign each message, retaining the signatures in their states.
  7. Upon creating a replication response message, the follower node attaches signatures for each uncommitted message in its log.
  8. When the leader receives the response, it adds new signatures to its state. Once Raft indicates the commitment of a message, the leader reconstructs the BLS signature and submits the signed message to the network.
  9. If the leader is down after successful replication but before submitting the message to the network, a new leader is elected. This new leader initiates replication messages to gather information about the process, collect signatures for uncommitted entries, and prune messages not replicated to the threshold.

Since this approach doesn't introduce any new messages in the Raft protocol, but merely adds additional data to each message, it retains the round-trip efficiency of the base algorithm.

Contributing

Style Guide

Please adhere to the Status Nim Style Guide when making contributions.

Running Tests

Make sure that all tests are passing when executed with nimble test.