Merge pull request #2678 from filecoin-project/asr/genesis-expected
Check repo's genesis against baked-in genesis
This commit is contained in:
commit
cc54efd88b
@ -6,6 +6,14 @@ Build the Lotus Binaries in debug mode, This enables the use of 2048 byte sector
|
||||
make 2k
|
||||
```
|
||||
|
||||
Set the `LOTUS_SKIP_GENESIS_CHECK` environment variable to `_yes_`. This tells your
|
||||
Lotus node that it's okay if the genesis being used doesn't match any baked-in
|
||||
genesis.
|
||||
|
||||
```sh
|
||||
export LOTUS_SKIP_GENESIS_CHECK=_yes_
|
||||
```
|
||||
|
||||
Download the 2048 byte parameters:
|
||||
```sh
|
||||
./lotus fetch-params 2048
|
||||
|
@ -3,6 +3,7 @@ package modules
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/ipfs/go-bitswap"
|
||||
"github.com/ipfs/go-bitswap/network"
|
||||
@ -127,8 +128,18 @@ func LoadGenesis(genBytes []byte) func(dtypes.ChainBlockstore) Genesis {
|
||||
func DoSetGenesis(_ dtypes.AfterGenesisSet) {}
|
||||
|
||||
func SetGenesis(cs *store.ChainStore, g Genesis) (dtypes.AfterGenesisSet, error) {
|
||||
_, err := cs.GetGenesis()
|
||||
genFromRepo, err := cs.GetGenesis()
|
||||
if err == nil {
|
||||
if os.Getenv("LOTUS_SKIP_GENESIS_CHECK") != "_yes_" {
|
||||
expectedGenesis, err := g()
|
||||
if err != nil {
|
||||
return dtypes.AfterGenesisSet{}, xerrors.Errorf("getting expected genesis failed: %w", err)
|
||||
}
|
||||
|
||||
if genFromRepo.Cid() != expectedGenesis.Cid() {
|
||||
return dtypes.AfterGenesisSet{}, xerrors.Errorf("genesis in the repo is not the one expected by this version of Lotus!")
|
||||
}
|
||||
}
|
||||
return dtypes.AfterGenesisSet{}, nil // already set, noop
|
||||
}
|
||||
if err != datastore.ErrNotFound {
|
||||
|
Loading…
Reference in New Issue
Block a user