#consensus-algorithm #safe #membership #section #vote #node #join

sn_consensus

Safe Network Membership: Enables nodes to dynamically join and leave a section

23 stable releases

3.5.2 Mar 29, 2023
3.2.2 Feb 28, 2023
3.2.0 Dec 7, 2022
3.1.4 Nov 14, 2022
1.16.0 Mar 28, 2022

#379 in Network programming

Download history 48/week @ 2024-01-22 2/week @ 2024-02-12 1/week @ 2024-02-19 17/week @ 2024-02-26 8/week @ 2024-03-04 14/week @ 2024-03-11 221/week @ 2024-03-18 13/week @ 2024-03-25

257 downloads per month
Used in 4 crates (via sn_interface)

MIT OR BSD-3-Clause

205KB
5K SLoC

sn_consensus

MaidSafe website Safe Network Forum

About

This Safe Network Membership module enables nodes to dynamically join and leave a Safe Network Section.

A consensus algorithm is run by Section Elders to decide on reconfigurations. The algorithm proceeds in stages:

  1. An Elder proposes a reconfig (Join or Leave) on behalf of a joining node. The proposal is broadcast to all Elders
  2. If an Elder detects a split vote, they propose a Merge vote. (this may happen up to O(log(n)) times)
  3. If an Elder sees a super-majority of agreeing votes, they propose a SuperMajority vote
  4. Once an Elder sees a super-majority of SuperMajority votes, they execute the decided on reconfig(s).

Tests

Message Sequence Charts (MSC)

You will notice that after running cargo test, A collection of .msc files are generated..

These files show the progression of vote's as they are processed by the network. They can be rendered using the mscgen. For example the test_round_robin_split_vote test generates charts demonstrating how the network handles split votes from 1 through to 6 members, to render out a chart for the case where 2 members vote differently run:

cargo test # generates the *.msc files in the current directory.

mscgen -T png -i round_robin_split_vote_2.msc -o round_robin_split_vote_2.png

The rendered chart round_robin_split_vote_2.png will look something like the following:

round robin split vote with 2 members

Note that although the lines between network members are perfectly horizontal, this does not mean that the vote was sent and received instantly. When a network member receives a vote, it responds immediately with it's votes (if any) but the simulated network queues up these votes and delivers them deterministically. The horizontal lines show when a vote was finally delivered to it's destination and who it was from.

License

This Safe Network software is dual-licensed under the Modified BSD ( https://opensource.org/licenses/BSD-3-Clause) or the MIT license ( https://opensource.org/licenses/MIT) at your option.

Contributing

Want to contribute? Great 🎉

There are many ways to give back to the project, whether it be writing new code, fixing bugs, or just reporting errors. All forms of contributions are encouraged!

For instructions on how to contribute, see our Guide to contributing.

Dependencies

~5MB
~158K SLoC