Skip to content

Commit

Permalink
fix: section 2 file (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
yiannisbot committed Jul 7, 2020
1 parent 79f7e84 commit 137adeb
Show file tree
Hide file tree
Showing 224 changed files with 12,264 additions and 0 deletions.
14 changes: 14 additions & 0 deletions next/content/systems/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Systems
entries:
- filecoin_nodes
- filecoin_files
- filecoin_vm
- filecoin_blockchain
- filecoin_token
- filecoin_mining
- filecoin_markets
---

# Systems
---
40 changes: 40 additions & 0 deletions next/content/systems/filecoin_blockchain/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
menuIcon: 📦
title: "**Blockchain**"
entries:
- struct
- message_pool
- genesis
- chainsync
- storage_power_consensus
---

# Blockchain
---

{{< hint danger >}}
incTocMap issue
{{< /hint >}}

{{/* < incTocMap "/docs/systems/filecoin_blockchain" 3 > */}}


The Filecoin Blockchain is a distributed virtual machine that achieves consensus, processes messages, accounts for storage, and maintains security in the Filecoin Protocol. It is the main interface linking various actors in the Filecoin system.

It includes:

- A [Message Pool](\missing-link) subsystem that nodes use to track and propagate messages related to the storage market throughout a gossip network.
- A [Virtual Machine](\missing-link) subsystem used to interpret and execute messages in order to update system state.
- A [State Tree](\missing-link) subsystem which manages the creation and maintenance of state trees (the system state) deterministically generated by the vm from a given subchain.
- A [Chain Synchronisation (ChainSync)](\missing-link) susbystem that tracks and propagates validated message blocks, maintaining sets of candidate chains on which the miner may mine and running syntactic validation on incoming blocks.
- A [Storage Power Consensus](\missing-link) subsystem which tracks storage state (i.e., [Storage Subystem](\missing-link)) for a given chain and helps the blockchain system choose subchains to extend and blocks to include in them.

And also:

- A [Chain Manager](\missing-link) -- which maintains a given chain's state, providing facilities to other blockchain subsystems which will query state about the latest chain in order to run, and ensuring incoming blocks are semantically validated before inclusion into the chain.
- A [Block Producer](\missing-link) -- which is called in the event of a successful leader election in order to produce a new block that will extend the current heaviest chain before forwarding it to the syncer for propagation.

At a high-level, the Filecoin blockchain grows through successive rounds of leader election in which a number of miners are elected to generate a block, whose inclusion in the chain will earn them block rewards.
Filecoin's blockchain runs on storage power. That is, its consensus algorithm by which miners agree on which subchain to mine is predicated on the amount of storage backing that subchain. At a high-level, the [Storage Power Consensus](\missing-link) subsystem maintains a _Power Table_ that tracks the amount of storage that [storage miner actors](\missing-link) have contributed to the network through _Sector commitments_ and _Proofs of Spacetime_.

Most of the functions of the Filecoin blockchain system are detailed in the code below.
52 changes: 52 additions & 0 deletions next/content/systems/filecoin_blockchain/blockchain.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import abi "github.com/filecoin-project/specs-actors/actors/abi"
import clock "github.com/filecoin-project/specs/systems/filecoin_nodes/clock"
import st "github.com/filecoin-project/specs/systems/filecoin_vm/state_tree"
import block "github.com/filecoin-project/specs/systems/filecoin_blockchain/struct/block"
import chain "github.com/filecoin-project/specs/systems/filecoin_blockchain/struct/chain"

type SectorID struct {}

type Booting struct {}
type CatchingUp struct {}
type Synchronized struct {}
type SyncState union {
Booting
CatchingUp
Synchronized
}

type BlockchainSubsystem struct @(mutable) {
Clock &clock.UTCClock

LatestEpoch() abi.ChainEpoch
BestChain() chain.Chain
CandidateChains() [chain.Chain]

// // Receiving blocks and tipset
// should be channels or notifications
NewTipsets()
NewBestTipset()

// validateBlockSemantics(Block)
SyncState() SyncState

// call by StorageClient in StorageDealMake
VerifySectorExists(sectorId SectorID) bool

// call by BlockSyncer in BlockReception
HandleBlock(block block.Block) bool

// call by BlockchainSubsystem itself in BlockProduction
ValidateBlock(block block.Block) bool

// call by BlockchainSubsystem itself in BlockProduction
// apply messages in the parent tipset to the StateTree
// and verify state root
TryGenerateStateTree(block block.Block) st.StateTree

// call by clock in BlockReception upon new epoch
AssembleTipsets() [chain.Tipset]

// call by BlockchainSubsystem itself in BlockReception upon new epoch
ChooseTipset(tipsets [chain.Tipset]) chain.Tipset
}
16 changes: 16 additions & 0 deletions next/content/systems/filecoin_blockchain/bootstrap/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
menuTitle: Genesis
statusIcon: 🔁
title: Genesis - starting the Blockchain
---

# Genesis
---

**WARNING:** This section is not yet complete.

Network Bootstrapping starts with production of the genesis block.

The genesis block will contain:
- An initial participant set, including committed storage from these miners (pre-sealed using special-cased randomness)
- An initial randomness ticket

0 comments on commit 137adeb

Please sign in to comment.