Code Monkey home page Code Monkey logo

butter's Introduction

The network that spreads! ๐Ÿงˆ

docs License: GPL v3

Abstract

Peer-to-peer (p2p) systems have some interesting properties in regard to scalability and dependability, due to their decentralised nature. They address many of the pitfalls of centralised architectures such as cost of infrastructure and single points of failure, resulting in fault-tolerant networks that can behave autonomously. Many of the current efforts to design peer-to-peer systems use structured elements which improve the performance but re-introduce precariousness present in centralised systems. Butter is a peer-to-peer (p2p) framework loosely inspired by other project such as Gnutella, JXTA and libp2p, its goal is to explore what is achievable in unstructured p2p networks.

Each of the problems in building a p2p middleware corresponds to a module of the framework. Peer discovery is handled by the discover package using a multicast protocol, the NAT traversal and wider internet peer discovery strategy is handled by the wider package, an overlay network can be defined as per the Overlay interface and Butter implements an overlay network to manage data that enables fault-tolerant information retention (persistence) and information retrieval by introducing Peer Content Groups (PCG) and Random Breadth-first search mechanisms respectively.

A Butter node exhibits behaviours to discover new peers and manage known peers with a unique approach to known host management optimising for diversity. Extra application specific functionality can be appended to peers by defining server and client behaviours which are then registered to Butter nodes.

Butter differentiating factors

  • Attempts to maintain data (despite node failure and high churn) while trying to minimise data redundancy (low degree of duplicate data). With many other decentralised networks and blockchains, every node hosts a full copy of the data on the network. While this creates a robust network where data is unlikely to be lost, it would not scale to handle large volumes of data and requires significant time and message complexity for all nodes to maintain a consensus (specially as many of these networks typically operate in a Byzantine model). Butter trivialises consensus by maintaining redundant copies in small groups of specially selected 'diverse' nodes while attempting to robustly maintain data.
  • Diversity is a core concept of the design. The idea is premised on the fact that 'diverse' nodes are likely to be less reliant on common infrastructure and more likely to have different knowledge of the network (e.g. other nodes or information stored). The diversity metric is hence relative to each node and each node, based on its knowledge, decides which nodes are more diverse than others. The metric is then used to determine which nodes to enter into PCGs with, which nodes to query for information and which nodes to maintain relationships with.

This project should facilitate the development of decentralised applications by abstracting away the distributed behaviour from the developers and accommodate nodes with a whole variety of hardware.

Getting Started

Preamble: communicating over the wider internet

The platform assumes a basic understanding of how to port forward (for home use). This is to deal with the pesky issue of NAT traversal when listening out for incoming connections. Port forwarding is actually very simple but may seem daunting at first, so, here is a good guide on how to do it.

The library will either assign or expect the user to provide a port when creating a node. If that node needs to be accessible outside the subnetwork it will be necessary to port forward from the router to the node's assigned/chosen port.

It is worth noting that not every node needs to be forwarded to the wider internet, all it takes is one node on the LAN to be accessible from the internet for the subnetwork to interact across the internet. However, having more public facing nodes decreases the risk of the subnetwork being isolated from the wider Butter network.

Installation

  1. From within your Go project, run the following command:
    go get github.com/butter-network/butter
    This will download the library and configure your go.mod file.
  2. Import the package into your project source:
    package main
    import "github.com/butter-network/butter"

Overlay networks

Butter is designed to be modular. It provides an inbuilt data overlay (implementation of the Overlay interface) to give the network fault-tolerant information retention and retrieval abilities but if you wish to implement your own overlay network that is possible too. You can implement your own version of the Overlay struct. For ease of use you can use the default overlay network using the butter.SpawnDefaultOverlay function.

Examples

Take a look the examples in the examples/ directory.

To run one of the included examples, from the root of the project type:

go run examples/[EXAMPLE_NAME]/main.go
(e.g. go run examples/ohce/main.go)

Contributing

What needs to be done?

  • Integrating Peer Content Groups storage logic, persist example and wiki into the main Butter repository
  • Fix information retrieval (use IR from PCG)
  • Implement heuristic based Information Retrieval
  • Decouple Butter node from TCP protocol
  • Implementing Gossip-based approach to Peer Content Group consensus in order to decrease message complexity maintaining groups
  • Developing stress testing rig in order to detect how information persists at varying levels of churn
  • Developing Information Retrieval test rig to test different retrieval algorithm speeds
  • Cross network communication with some for of NAT traversal technique
  • Looking at potential immutable datastructures built on top of Butter networks (e.g. blockchains)
  • Possibly shifting codebase to Rust
  • Updating documentation

Development

  • See the project board
  • Raise an issue or pull request

Project structure:

Making a peer-to-peer system can be broken down into several sub-problems which are reflected in the package breakdown:

  • Defining the core node behaviours (making the node behave as a peer by both acting as a server and client) and maintaining the network by managing known hosts is implemented in the node/ package
  • Peer discovery on the local network is implemented in the discover/ package
  • NAT traversal and peer discovery on the wider Internet is implemented in the wider/ package
  • A default overlay network for managing data on the Butter network is defined in the dataOverlay/ package
    • Information persistence strategies are stored in the persist/ directory (which contains an implementation of Peer Content Groups which is a fault-tolerant (churn resilient) approach to information retention
    • Information retrieval strategies are stored in the retrieve/ directory (which contains an implementation of Random Breadth-first search which is an efficient approach to information retrieval
  • The utils/ package contains some useful utilities for the project

Testing

When testing on a development machine, it may become necessary to test the behaviour across several IP namespaces (subnetworks), this can be achieved by running nodes in containers.

butter's People

Contributors

a-shine avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

butter's Issues

Upper limit on local knowledge

We make a heuristic decision based on the heuristic - we have a partial view of the world (i.e. our peers) so we use our own information + our partial view to make the best decision - do this recursively and we find information faster

Error listening

Hello,

I just tried to compile (Go v1.19.3) on my Windows 10 (x64) system and the compile went fine for the examples, but when I try to start them up, I get a TCP bind error:

run> .\persist.exe
Error listening: listen tcp 169.254.222.0:0: bind: The requested address is not valid in its context.

This happens on all of the examples.

Any ideas how to fix this?
Thanks

Really Interesting Project

Ive been reading your docs, and it looks like youve done a lot of research into decentralized and distributed systems.

this project is interesting, and i am curious how it works.

can you explain some of the basic mechanisms from this project, for example like transport, discovery, and lookup?

also, if you need help on certain parts of the project, i may be interested in digging into the code and contributing too

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.