lotus/chain/lf3/manifest.go
Jiaying Wang e773b37921
feat:ec: integrate F3 dynamic manifest (#12173) (#12185)
* F3-370: integrate F3 dynamic manifest

* F3-370: make linter happy

* Set manifest sender identities

* Decode manifest sender peer ID from string before using it

Peer ID is of type string internally but the internal string
representation is not the same as the encoded string representation.
Therefore, the latter needs to be decoded and cannot be casted to the
former. Otherwise, it will represent a different ID.

* `make gen` the pain of my life

---------

Co-authored-by: adlrocha <6717133+adlrocha@users.noreply.github.com>
Co-authored-by: Masih H. Derkani <m@derkani.org>
2024-07-04 16:15:33 -04:00

40 lines
1.2 KiB
Go

package lf3
import (
"time"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/filecoin-project/go-f3/gpbft"
"github.com/filecoin-project/go-f3/manifest"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
func NewManifestProvider(nn dtypes.NetworkName, cs *store.ChainStore, sm *stmgr.StateManager, ps *pubsub.PubSub) manifest.ManifestProvider {
m := manifest.LocalDevnetManifest()
m.NetworkName = gpbft.NetworkName(nn)
m.ECDelay = 2 * time.Duration(build.BlockDelaySecs) * time.Second
m.ECPeriod = m.ECDelay
m.BootstrapEpoch = int64(build.F3BootstrapEpoch)
m.ECFinality = int64(build.Finality)
m.CommiteeLookback = 5
ec := &ecWrapper{
ChainStore: cs,
StateManager: sm,
}
switch manifestServerID, err := peer.Decode(build.ManifestServerID); {
case err != nil:
log.Warnw("Cannot decode F3 manifest sever identity; falling back on static manifest provider", "err", err)
return manifest.NewStaticManifestProvider(m)
default:
return manifest.NewDynamicManifestProvider(m, ps, ec, manifestServerID)
}
}