diff --git a/documentation/en/local-dev-net.md b/documentation/en/local-dev-net.md index 24c732db7..3382b6471 100644 --- a/documentation/en/local-dev-net.md +++ b/documentation/en/local-dev-net.md @@ -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 diff --git a/node/modules/chain.go b/node/modules/chain.go index 904c9f23b..0c9943b21 100644 --- a/node/modules/chain.go +++ b/node/modules/chain.go @@ -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 {