Skip to content

Commit

Permalink
chore(build): trim and compress genesis CARs in build
Browse files Browse the repository at this point in the history
Ref: filecoin-project/lotus-infra#1627
Ref: filecoin-project/lotus-infra#1628

* Remove WASM actors from butterflynet.car
* Compress with zstd
  • Loading branch information
rvagg committed Sep 10, 2024
1 parent a83d02e commit cdff931
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/buildconstants/params_butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var NetworkBundle = "butterflynet"
var ActorDebugging = false

const BootstrappersFile = "butterflynet.pi"
const GenesisFile = "butterflynet.car"
const GenesisFile = "butterflynet.car.zst"

const UpgradeBreezeHeight = -1
const BreezeGasTampingDuration = 120
Expand Down
2 changes: 1 addition & 1 deletion build/buildconstants/params_calibnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var NetworkBundle = "calibrationnet"
var ActorDebugging = false

const BootstrappersFile = "calibnet.pi"
const GenesisFile = "calibnet.car"
const GenesisFile = "calibnet.car.zst"

const UpgradeBreezeHeight = -1
const BreezeGasTampingDuration = 120
Expand Down
2 changes: 1 addition & 1 deletion build/buildconstants/params_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var NetworkBundle = "caterpillarnet"
var ActorDebugging = false

const BootstrappersFile = "interopnet.pi"
const GenesisFile = "interopnet.car"
const GenesisFile = "interopnet.car.zst"

const GenesisNetworkVersion = network.Version22

Expand Down
2 changes: 1 addition & 1 deletion build/buildconstants/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ActorDebugging = false
const GenesisNetworkVersion = network.Version0

const BootstrappersFile = "mainnet.pi"
const GenesisFile = "mainnet.car"
const GenesisFile = "mainnet.car.zst"

const UpgradeBreezeHeight abi.ChainEpoch = 41280

Expand Down
27 changes: 22 additions & 5 deletions build/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,41 @@ package build

import (
"embed"
"io"
"path"

logging "github.com/ipfs/go-log/v2"
"github.com/klauspost/compress/zstd"

"github.com/filecoin-project/lotus/build/buildconstants"
)

// moved from now-defunct build/paramfetch.go
var log = logging.Logger("build")

//go:embed genesis
var genesisfs embed.FS
//go:embed genesis/*.car.zst
var genesisCars embed.FS

func MaybeGenesis() []byte {
genBytes, err := genesisfs.ReadFile(path.Join("genesis", buildconstants.GenesisFile))
file, err := genesisCars.Open(path.Join("genesis", buildconstants.GenesisFile))
if err != nil {
log.Warnf("loading built-in genesis: %s", err)
log.Warnf("opening built-in genesis: %s", err)
return nil
}
return genBytes
defer file.Close() //nolint

decoder, err := zstd.NewReader(file)
if err != nil {
log.Warnf("creating zstd decoder: %s", err)
return nil
}
defer decoder.Close() //nolint

decompressedBytes, err := io.ReadAll(decoder)
if err != nil {
log.Warnf("reading decompressed genesis file: %s", err)
return nil
}

return decompressedBytes
}
Binary file removed build/genesis/butterflynet.car
Binary file not shown.
Binary file added build/genesis/butterflynet.car.zst
Binary file not shown.
Binary file removed build/genesis/calibnet.car
Binary file not shown.
Binary file added build/genesis/calibnet.car.zst
Binary file not shown.
Binary file removed build/genesis/interopnet.car
Binary file not shown.
Binary file added build/genesis/interopnet.car.zst
Binary file not shown.
Binary file removed build/genesis/mainnet.car
Binary file not shown.
Binary file added build/genesis/mainnet.car.zst
Binary file not shown.

0 comments on commit cdff931

Please sign in to comment.