6block
Published in

6block

Filecoin-Introduction to WinningPoSt Logic

Written by Star Li, translated from the original article.

Part of Lotus PoSt (Proof of Spacetime) has changed from electionPoSt to two new PoSt; one is winningPoSt and the other is windowPoSt. Let ’s talk about winningPoSt first. winningPoSt, as the name suggests, is PoSt when it is winning. The so-called winning is to obtain the block reward.

Simply put, winningPoSt is a sector randomly checked, and the 66 randomly selected Merkle paths in this sector are correct. The code logic begins with the code of Lotus go. It all starts with the block-the mineOne function of the Miner structure of lotus / miner / miner.go.

Among them, the MinerGetBaseInfo function is to obtain some basic information, including the sector information that needs to be extracted. The ComputeProof function is to calculate the winningPoSt proof.

The specific implementation of this logic is implemented in rust-fil-proofs, which is the rust language. From go to rust-fil-proofs, many interfaces are crossed:

Star Ideas

Among them, the MinerGetBaseInfo function is to obtain some basic information, including the sector information that needs to be extracted. The ComputeProof function is to calculate the winningPoSt proof.

The specific implementation of this logic is implemented in rust-fil-proofs, which is the rust language. From go to rust-fil-proofs, many interfaces are crossed:

The interface in the middle will not be discussed, we will just look at the two API functions provided by rust-fil-proofs.

01 Random Number Setting

The number of sectors and the total number of leaves for random inspection are defined in rust-fil-proofs / filecoin-proofs / src / constants.rs:

That is to say, to extract a sector from the effective sector, and spot check 66 leaf nodes on this sector.

02 Sector Random Check Logic

The generate_winning_post_sector_challenge function implements the spot check logic of the sector. How does the core logic spot check the sector? The specific logic is in the function of fallback :: generate_sector_challenges:

Simply put, the sha256 hash is calculated by using the random_information of random_provider_id and the random number of the sector and calculating the result with the current limited number of sectors. That is, the sector_index is the sector ID of the final spot check.

03 Challenge Leaf Spot Check Logic

generate_winning_post checks the leaf nodes on the Merkle tree (replica_r_last) formed by the selected sectors. The calculation logic of spot checking leaf nodes is in the function of fallback :: generate_leaf_challenge:

Hash the random information, sector id, and challenge leaf number. Then challenged_range_index is the hash result modulo the total number of leaves. The 32G Sector has 1G leaves.

04 Zero-Knowledge Proof Circuit

The calculation part of zero-knowledge proof can be viewed in the rust-fil-proofs / post / fallback directory. The general logic module and structure can be seen in the previous article introduction: Filecoin-PoREP Circuit Introduction

Next we look at the sector structure in rust-fil-proofs / post / fallback / circuit.rs. This structure represents a spot check. It can be seen from the synthesize function:

comm_r is a public input, while comm_r_last and comm_c are private inputs.

Verify that comm_r is calculated by comm_c and comm_r_last.

Conclusion

Lotus PoSt includes two parts: winningPoSt and windowPoSt. winningPoSt is the PoSt certificate that needs to be provided when obtaining the block reward. From all valid sectors, extract a sector and check the 66 leaves on the sector.

Star Idea

Technology changes the world

Long press the QR code to follow me

Technical translation by K. Branigan.

Wonderful review of past articles (use translator)

Filecoin logic and zero-knowledge proof applications:

Elliptic curve:

The theoretical knowledge of zk-SNARK (Groth16):

Basic library source code analysis of zero-knowledge proof:

Practical examples of zero-knowledge proof:

GPU accelerated theory and practice

Zero-knowledge proof application scenarios:

Zcash logic introduction:

Summary at the end of the year:

Source code analysis

Other

More 6Block Mining Pool: Twitter, Telegram, Bitcointalk

--

--

--

6block focuses on “Unicorn” projects in the blockchain area, providing solutions for cryptocurrency mining, including highly efficient mining programs, mining pools, hardware, cloud mining, and wallets.

Recommended from Medium

Automated Feature Engineering web app using Flask+MongoDB+Docker and Make it Python installable…

“Build once, deploy many times” to multi-environment Kubernetes

Scanning for memory issues in your data pipelines

The first principles of ‘Testing’

How to Become a Software Engineer without a Computer Science degree

Hybrid Cloud Task-4

AI and human, an inevitable new division of labor

GO-JEK Upscale Experience

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
6block

6block

blockchain technology

More from Medium

Reflection on Project 1A & 1B

Notice of BSN’s Major Updates on May 15th, 2022

ThankQ Protocol — Blockchain-based Point Platform

DeepSquare & Openfabric On A Mission To Democratize Artificial Intelligence