Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): trim and compress genesis CARs in build #12439

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

## Improvements

- Reduce size of embedded genesis CAR files by removing WASM actor blocks and compressing with zstd. This reduces the `lotus` binary size by approximately 10 MiB. ([filecoin-project/lotus#12439](https://github.com/filecoin-project/lotus/pull/12439))

# Node v1.29.0 / 2024-09-02

This is a Lotus Node only release, which includes a variety of new features, improvements, and fixes, particularly focused on enhancing ETH RPC functionality. Key highlights of this release include:
Expand Down
4 changes: 2 additions & 2 deletions build/bootstrap/butterflynet.pi
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWGW6xMTpjEBqndYkqytbu8PWfJmpK4wKLLLNSkXL2QZtD
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWFGz9HegR3Rjrtm8b9WXTM6E3kN1sdd6X1JztuCgQaZSB
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWF76a8Avv74CV55noqKd5rHsM8uwFYhaW4PhMhuE4PQsP
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWCN1G8gK5HXQNDFKxAVmF6bpg436uVyNYFgiX94ZHCPjj
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.