Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Implements mir-validator, mir consensus and decouples storage #14

Closed
wants to merge 45 commits into from

Conversation

adlrocha
Copy link
Contributor

@adlrocha adlrocha commented Oct 11, 2022

Related Issues

Proposed Changes

This PR integrates the Mir framework and implements a pBFT consensus algorithm over Mir. Mir is implemented as an alternative consensus algorithm for Lotus. In order to run Lotus with Mir, a new build parameter build.Consensus has been provided.

This PR includes:

  • The implementation in chain/consensus/mir of Mir as a new consensus interface.
  • A new mir-validator process that implements all the mining and block producing logic for Mir. make mir-validator can be used to compile the process. This process is responsible for ordering new transactions and proposing new blocks to the network.
  • New buildernet compile parameters (see build/params_buildernet.go) and a new build.Consensus flag used to determine the type of consensus to use. Using the Mir consensus disables the block production and winningPoSt process from lotus-miner and forces the use of fake randomness for windowPoSt. lotus-miner can still be used (and run) in a Mir Lotus network for storage-specific features (on boarding storage, starting storage and retrieval deals, markets, etc.).

What's next?

We currently don't support the ability for other full nodes in the network to sync with a Mir network. Only validators running the consensus algorithm get new blocks. The next PR will include the syncing protocol (implementing #4)

Copy link
Contributor

@dnkolegov dnkolegov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added several cosmetic comments and suggestions!

chain/consensus/mir/validator.go Outdated Show resolved Hide resolved
chain/consensus/mir/validator.go Outdated Show resolved Hide resolved
miner/miner.go Show resolved Hide resolved
cmd/mir-validator/utils.go Outdated Show resolved Hide resolved
cmd/mir-validator/utils.go Outdated Show resolved Hide resolved
chain/consensus/mir/README.md Show resolved Hide resolved
chain/rand/fake.go Show resolved Hide resolved
chain/rand/fake.go Outdated Show resolved Hide resolved
chain/rand/fake.go Outdated Show resolved Hide resolved
chain/rand/fake.go Outdated Show resolved Hide resolved
Copy link
Contributor

@matejpavlovic matejpavlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch of comments. I'll post more in additional batches, so you're not blocked.

chain/consensus/mir/README.md Outdated Show resolved Hide resolved
chain/consensus/mir/README.md Outdated Show resolved Hide resolved
chain/consensus/mir/README.md Show resolved Hide resolved
chain/consensus/mir/README.md Outdated Show resolved Hide resolved
chain/consensus/mir/consensus.go Outdated Show resolved Hide resolved
chain/consensus/mir/mempool/handlers/batches.go Outdated Show resolved Hide resolved
chain/consensus/mir/mempool/handlers/batches.go Outdated Show resolved Hide resolved
chain/consensus/mir/mine.go Outdated Show resolved Hide resolved
chain/consensus/mir/mine.go Outdated Show resolved Hide resolved
chain/consensus/mir/pool/fifo/fifo_pool.go Show resolved Hide resolved
@adlrocha adlrocha marked this pull request as ready for review October 13, 2022 08:00
Copy link
Contributor

@matejpavlovic matejpavlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few more comments, none of them critical.

I also skipped Lotus code that didn't seem to have anything to do with Mir, as I didn't even have a clue what they are supposed to do...

chain/consensus/mir/pool/pool.go Outdated Show resolved Hide resolved
chain/consensus/mir/state_manager.go Outdated Show resolved Hide resolved
Comment on lines +113 to +116
sm.NextBatch <- &Batch{
Messages: msgs,
Validators: maputil.GetSortedKeys(sm.memberships[sm.currentEpoch]),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once snapshots are supported, this will need to happen synchronously. How hard would it be to forego the channel completely and do right here what the mine function does on reading from that channel?

In fact, maybe we could get rid of more of these channels and handle the functionality right in the state manager...

chain/consensus/mir/validator.go Show resolved Hide resolved
chain/consensus/mir/validator.go Outdated Show resolved Hide resolved
chain/consensus/mir/wal.go Outdated Show resolved Hide resolved
cmd/mir-validator/README.md Outdated Show resolved Hide resolved
@adlrocha adlrocha marked this pull request as draft October 13, 2022 17:00
@adlrocha
Copy link
Contributor Author

After the internal review, closing in favor of filecoin-project/lotus#9492 targeting lotus master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants