All Projects → froghub-io → filecoin-sealer-recover

froghub-io / filecoin-sealer-recover

Licence: Apache-2.0 license
Filecoin sector recover

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to filecoin-sealer-recover

nft-website
NFT School: Community education platform for developers in the non-fungible token space.
Stars: ✭ 260 (+409.8%)
Mutual labels:  filecoin
sentinel
Filecoin Network monitoring and analysis tools.
Stars: ✭ 26 (-49.02%)
Mutual labels:  filecoin
bidbot
A Filecoin Network sidecar for storage providers to bid in storage deal auctions.
Stars: ✭ 31 (-39.22%)
Mutual labels:  filecoin
Venus
Filecoin Full Node Implementation in Go
Stars: ✭ 1,901 (+3627.45%)
Mutual labels:  filecoin
tokencore
The core components of the blockchain wallet backend, support a variety of blockchain address generation and offline signatures
Stars: ✭ 412 (+707.84%)
Mutual labels:  filecoin
web3.storage
⁂ The simple file storage service for IPFS & Filecoin
Stars: ✭ 417 (+717.65%)
Mutual labels:  filecoin
borg
Client-server stack for Web3! Turn your Raspberry Pi to a BAS server in minutes and enjoy the freedom of decentralized Web with a superior user experience!
Stars: ✭ 25 (-50.98%)
Mutual labels:  filecoin
digital-copyright
Stamp your code with a trackable digital copyright
Stars: ✭ 17 (-66.67%)
Mutual labels:  filecoin
lighthouse
Get verifiable storage on Filecoin Network directly from Ethereum Smart Contracts
Stars: ✭ 19 (-62.75%)
Mutual labels:  filecoin
estuary
A custom IPFS/Filecoin node that makes it easy to pin IPFS content and make Filecoin deals.
Stars: ✭ 195 (+282.35%)
Mutual labels:  filecoin
filecoin-docs
Filecoin Docs
Stars: ✭ 183 (+258.82%)
Mutual labels:  filecoin
ref-fvm
Reference implementation of the Filecoin Virtual Machine
Stars: ✭ 255 (+400%)
Mutual labels:  filecoin
wfil
Wrapped Filecoin (WFIL), Team WrapFS at HackFS @ethglobal | APOLLO 🚀 @gitcoinco | ETHOnline @ethglobal
Stars: ✭ 13 (-74.51%)
Mutual labels:  filecoin
nft.storage
😋 Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin.
Stars: ✭ 309 (+505.88%)
Mutual labels:  filecoin
nebula-crawler
🌌 A libp2p DHT crawler, monitor, and measurement tool that exposes timely information about DHT networks.
Stars: ✭ 97 (+90.2%)
Mutual labels:  filecoin
add-to-web3
⁂ Github Action to upload your website to web3.storage
Stars: ✭ 22 (-56.86%)
Mutual labels:  filecoin
estuary-www
https://estuary.tech
Stars: ✭ 32 (-37.25%)
Mutual labels:  filecoin
rcvr-api
Recover Cologne Api, kneipen kontakt tracer. recover provides localities a privacy-compliant, safe, and easy way for their guests to check in. See https://www.recoverapp.de/ for more details.
Stars: ✭ 14 (-72.55%)
Mutual labels:  recover
kotal
Blockchain Kubernetes Operator
Stars: ✭ 137 (+168.63%)
Mutual labels:  filecoin
valist
Web3-native software distribution. Publish and install executables, Docker images, WebAssembly, and more. Powered by Ethereum, IPFS, and Filecoin.
Stars: ✭ 107 (+109.8%)
Mutual labels:  filecoin

中文请点击这里

Sector Repair

Filecoin may face sector data loss during sealing or mining, and then destroy PreCommit pre-pledged FILs, or terminate sectors with a maximum loss of 90 days of sector reward. Sector repair can repair the lost files to reduce or avoid the loss.

Causes of sector loss

1. Bad storage disk

Miners are forced to use bare disks for storage to reduce costs and improve their competitiveness in order to reduce packaging costs, and will often use bare disks directly for sector storage. 16T disk, can store more than 130 sectors of 32GiB, if the hard disk is damaged, data can not be recovered and have to terminate the sector, the maximum loss is 90-day of average revenue of sectors across the network.

2. Bad NVMe cache disk

In this case, there are 2 states of the sector that can cause a loss.

  • A sector that has submitted a PreCommit message, but has not submitted a ProveCommit message within 30 days will have its PreCommit pre-pledge FIL destroyed.

  • Setting FinalizeEarly=false, using ProveCommit first before dropping to storage, is equivalent to losing a sector requiring termination of the sector.

How sector repair works

From the reasons can be analyzed, all sectors that need to be recovered are sectors that have already been submitted PreCommit message, once the data is lost, only the original sealing data can be reassembled and resealing the sectors .

p1o, err := ffi.SealPreCommitPhase1(
    sector.ProofType,
    paths.Cache,
    paths.Unsealed,
    paths.Sealed,
    sector.ID.Number,
    sector.ID.Miner,
    ticket,
    ID.Number, sector.ID.Miner, ticket, pieces,
)

p2...

Resealing the CC sector (without deals), pieces is just generated using the official default method, Only the ticket and ProofType need to be obtained additionally

This is the PreCommit message body recorded on the chain.

{
  "RegisteredProof": 9,
  "SectorNumber": 1322006,
  "SealedCid": "bagboea4b5abcasqanjadumno7blvgx4k5pk765cki6vurnpgs2q3trt2trkznhj3",
  "SealRandEpoch": 925221,
  "DealIds": [],
  "Expiration": 2480426,
  "ReplaceCapacity": false,
  "ReplaceSectorDeadline": 0,
  "ReplaceSectorPartition": 0,
  "ReplaceSector": 0
}

ProofType is different for different network versions and sector sizes, detailed code. It is more convenient to use the RegisteredProof directly in the message body.

Using the SealRandEpoch in the precommit message body as the sector's ticketEpoch, the random number is extracted again from the chain server.

ticket, err := fullNodeApi.StateGetRandomnessFromTickets(ctx, crypto.DomainSeparationTag_SealRandomness, ticketEpoch, buf.Bytes(), ts.Key ())
if err ! = nil {
    return nil, nil, err
}

Compare the SealedCid in the PreCommit message body recorded on the chain with the result of the repair procedure PreCommit2 calculation storage.SectorCids, if the result cid is the same the repair is successful!

Install Go

To build filecoin-sealer-recover, you need to install Go 1.16.4 or higher:

wget -c https://golang.org/dl/go1.16.4.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local

Build

  1. To build you need to download some Go modules. These are usually hosted on Github, which has a low bandwidth from China. To work around this, use a local proxy before running by setting the following variables.
export GOPROXY=https://goproxy.cn
  1. Depending on your CPU model, you will want to export additional environment variables:

a. If you have an AMD Zen or Intel Ice Lake CPU (or later), enable the use of SHA extensions by adding these two environment variables:

export RUSTFLAGS="-C target-cpu=native -g"
export FFI_BUILD_FROM_SOURCE=1

See the Filecoin FFI section for more details about this process.

b. Some older Intel and AMD processors without the ADX instruction support may panic with illegal instruction errors. To solve this, add the CGO_CFLAGS environment variable:

export CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
export CGO_CFLAGS="-D__BLST_PORTABLE__"

c. By default, a multicore-sdr option is used in the proofs library. This feature is also used in FFI unless explicitly disabled. To disable building with the multicore-sdr dependency, set FFI_USE_MULTICORE_SDR to 0:

 export FFI_USE_MULTICORE_SDR=0

d.An experimental gpu option using CUDA can be used in the proofs library. This feature is disabled by default (opencl is the default, when FFI_USE_GPU=1 is set.). To enable building with the gpu CUDA dependency, set FFI_USE_CUDA=1 when building from source.

export FFI_USE_CUDA=1
  1. Build and install
# Sector recovery does not distinguish between mainnet or calibnet
make clean all

sudo make install

Install sealer-recover to /usr/local/bin

  1. Once the installation is complete, use the following command to ensure that the installation is successful for the correct network.
sealer-recover --version

Usage

  1. Specify miner number and sector list, export sector information file:
export FULLNODE_API_INFO=...:/ip4/10.10.10.1/tcp/1234/http
sealer-recover export --miner=f01000 1 2 3 4 5 6

Generate the sector recovery metadata file sectors-recovery-f01000.json in the current directory.

Note: To read the sector information, the lotus daemon needs to have a state tree that is old enough to store it, and the full node is the best.

  1. Start the recovery program and execute the list of sectors that the machine performs recovery:
export FIL_PROOFS_USE_MULTICORE_SDR=1
export FIL_PROOFS_MAXIMIZE_CACHING=1
export FIL_PROOFS_USE_GPU_COLUMN_BUILDER=1
export FIL_PROOFS_USE_GPU_TREE_BUILDER=1

sealer-recover recover \
    --sectors-recovery-metadata=./sectors-recovery-f01000.json \
    --parallel=6 \ 
    --sealing-result=/sector \ 
    --sealing-temp=/temp \
    2 4 5

Tools and Parameter Description

Export sector metadata tool:

sealer-recover export [command options] [sectorNum1 sectorNum2 ...]
Parameters Meaning Remarks
miner The miner number of the sectors to be repaired Required

Sector recovery tool:

sealer-recover recover [command options] [sectorNum1 sectorNum2 ...]
Parameters Meaning Remarks
sectors-recovery-metadata specify the metadata file for the sectors recovery Required
parallel Number of parallel sectors to be repaired for sector p1, refer to core count for setting default: 1
sealing-result path to the repaired sector product default: ~/sector
sealing-temp Intermediate product path for repair process, large space required, NVMe disk recommended Default: ~/temp
Minimum space:
32GiB # > 512GiB!
64GiB # > 1024GiB!

Optimization

Use your own modified lotus for packing, which optimizes the repair speed

TODO

  • Support for sectors with deals, retrieving the deals by the deals id of the chain and regenerating the pieces.

Contributing

PRs, bug reports and issue suggestions are welcome! For major changes, please ask questions in issues first so that compatibility and benefits can be discussed.

Other

License

Licensed under Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].