Currently, writing to the ledger of the network is a process that is not synchronized. That is to say that there is no consensus between the peers, and as such data could be lost during the process as multiple actors could try to write at the same time to the ledger - and only one of them would win. This is a problem because we cannot guarantee data integrity, and moreover, since we want to have a CAS ( https://github.com/masa-finance/masa-oracle/issues/381 ) this would lead to invalid data across the nodes.
Proposed solution
As a first pass, we could implement raft consensus among the peers. There is already a well known library ( https://github.com/libp2p/go-libp2p-raft ) which can work with libp2p to have a basic raft consensus.
The idea is to have raft to guarantee that there is only one leader in a specific moment that can write to the ledger, and all the other nodes would have to accept new blocks only by the leader.
Problem
Currently, writing to the ledger of the network is a process that is not synchronized. That is to say that there is no consensus between the peers, and as such data could be lost during the process as multiple actors could try to write at the same time to the ledger - and only one of them would win. This is a problem because we cannot guarantee data integrity, and moreover, since we want to have a CAS ( https://github.com/masa-finance/masa-oracle/issues/381 ) this would lead to invalid data across the nodes.
Proposed solution
As a first pass, we could implement raft consensus among the peers. There is already a well known library ( https://github.com/libp2p/go-libp2p-raft ) which can work with libp2p to have a basic raft consensus.
The idea is to have raft to guarantee that there is only one leader in a specific moment that can write to the ledger, and all the other nodes would have to accept new blocks only by the leader.
Additional context
See also an example of using raft and libp2p here: https://github.com/mudler/go-libp2p-simple-raft
Acceptance criteria
libp2p
protocol