Skip to content
Merged
8 changes: 3 additions & 5 deletions build/buildconstants/f3manifest_calibnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
"Pause": false,
"ProtocolVersion": 7,
"InitialInstance": 0,
"BootstrapEpoch": 2081674,
"NetworkName": "calibrationnet",
"BootstrapEpoch": 3385534,
"NetworkName": "calibrationnet2",
"ExplicitPower": null,
"IgnoreECPower": false,
"InitialPowerTable": {
"/": "bafy2bzaceab236vmmb3n4q4tkvua2n4dphcbzzxerxuey3mot4g3cov5j3r2c"
},
"InitialPowerTable": null,
"CommitteeLookback": 10,
"CatchUpAlignment": 15000000000,
"Gpbft": {
Expand Down
22 changes: 4 additions & 18 deletions chain/lf3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ import (
"github.com/filecoin-project/go-state-types/abi"

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

type Config struct {
// BaseNetworkName is the base from which dynamic network names are defined and is usually
// the name of the network defined by the static manifest. This must be set correctly or,
// e.g., pubsub topic filters won't work correctly.
BaseNetworkName gpbft.NetworkName
// StaticManifest this instance's default manifest absent any dynamic manifests. Also see
// PrioritizeStaticManifest.
StaticManifest *manifest.Manifest
Expand Down Expand Up @@ -59,18 +54,9 @@ func NewManifest(
}
}

// NewConfig creates a new F3 config based on the node's build parameters and the passed network
// name.
func NewConfig(nn dtypes.NetworkName) *Config {
// Use "filecoin" as the network name on mainnet, otherwise use the network name. Yes,
// mainnet is called testnetnet in state.
if nn == "testnetnet" {
nn = "filecoin"
// NewConfig creates a new F3 config based on the node's build parameters.
func NewConfig() *Config {
return &Config{
StaticManifest: buildconstants.F3Manifest(),
}
c := &Config{
BaseNetworkName: gpbft.NetworkName(nn),
StaticManifest: buildconstants.F3Manifest(),
}

return c
}
13 changes: 10 additions & 3 deletions chain/store/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"golang.org/x/xerrors"

"github.com/filecoin-project/go-f3/certstore"
"github.com/filecoin-project/go-f3/manifest"
"github.com/filecoin-project/go-state-types/abi"

bstore "github.com/filecoin-project/lotus/blockstore"
Expand Down Expand Up @@ -236,9 +237,15 @@ func (cs *ChainStore) Import(ctx context.Context, f3Ds dtypes.F3DS, r io.Reader)
prefix := F3DatastorePrefix()
f3DsWrapper := namespace.Wrap(f3Ds, prefix)

log.Info("Importing F3Data to datastore")
if err := certstore.ImportSnapshotToDatastore(ctx, f3r, f3DsWrapper); err != nil {
return nil, nil, xerrors.Errorf("failed to import f3Data to datastore: %w", err)
var f3Manifest *manifest.Manifest = buildconstants.F3Manifest()
if f3Manifest == nil {
log.Warnf("Snapshot contains F3 data but F3 manifest is not available in this build. Skipping F3 data import.")
// Skip F3 import but continue with chain import
} else {
log.Info("Importing F3Data to datastore")
if err := certstore.ImportSnapshotToDatastore(ctx, f3r, f3DsWrapper, f3Manifest); err != nil {
return nil, nil, xerrors.Errorf("failed to import f3Data to datastore: %w", err)
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions chain/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store_test
import (
"bytes"
"context"
"encoding/json"
"io"
"testing"

Expand All @@ -15,10 +16,12 @@ import (
"github.com/filecoin-project/go-f3/certs"
"github.com/filecoin-project/go-f3/certstore"
"github.com/filecoin-project/go-f3/gpbft"
"github.com/filecoin-project/go-f3/manifest"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"

"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/consensus"
"github.com/filecoin-project/lotus/chain/consensus/filcns"
Expand Down Expand Up @@ -270,6 +273,23 @@ func TestChainExportImportWithF3Data(t *testing.T) {
lc = cert
}

{
// patch out embedded manifest for testing
oldManifest := buildconstants.F3ManifestBytes

var manif manifest.Manifest
if err := json.Unmarshal(buildconstants.F3ManifestBytes, &manif); err != nil {
t.Fatal(err)
}
manif.InitialPowerTable = ptCid
defer func() {
buildconstants.F3ManifestBytes = oldManifest
}()
if buildconstants.F3ManifestBytes, err = json.Marshal(manif); err != nil {
t.Fatal(err)
}
}

certStore, err := certstore.OpenStore(context.TODO(), f3ds)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/filecoin-project/go-cbor-util v0.0.2
github.com/filecoin-project/go-commp-utils/v2 v2.1.0
github.com/filecoin-project/go-crypto v0.1.0
github.com/filecoin-project/go-f3 v0.8.10
github.com/filecoin-project/go-f3 v0.8.11
github.com/filecoin-project/go-fil-commcid v0.3.1
github.com/filecoin-project/go-hamt-ipld/v3 v3.4.1
github.com/filecoin-project/go-jsonrpc v0.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ github.com/filecoin-project/go-commp-utils/v2 v2.1.0/go.mod h1:NbxJYlhxtWaNhlVCj
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ=
github.com/filecoin-project/go-crypto v0.1.0 h1:Pob2MphoipMbe/ksxZOMcQvmBHAd3sI/WEqcbpIsGI0=
github.com/filecoin-project/go-crypto v0.1.0/go.mod h1:K9UFXvvoyAVvB+0Le7oGlKiT9mgA5FHOJdYQXEE8IhI=
github.com/filecoin-project/go-f3 v0.8.10 h1:Mm+daAn9EKqTTDY3ICbPTR2i3Opjb4gr6Y7bJ8oCA84=
github.com/filecoin-project/go-f3 v0.8.10/go.mod h1:hFvb2CMxHDmlJAVzfiIL/V8zCtNMQqfSnhP5TyM6CHI=
github.com/filecoin-project/go-f3 v0.8.11 h1:4bH5PHTKCTI4zi39JBqqHSDbw+QKzPuTX/Q7aTrA/gA=
github.com/filecoin-project/go-f3 v0.8.11/go.mod h1:2zNRQ9abAdwR31wIlxoZMnTToxFsEg68DJoxhq/WZLw=
github.com/filecoin-project/go-fil-commcid v0.3.1 h1:4EfxpHSlvtkOqa9weG2Yt5kxFmPib2xU7Uc9Lbqk7fs=
github.com/filecoin-project/go-fil-commcid v0.3.1/go.mod h1:z7Ssf8d7kspF9QRAVHDbZ+43JK4mkhbGH5lyph1TnKY=
github.com/filecoin-project/go-fil-commp-hashhash v0.2.0 h1:HYIUugzjq78YvV3vC6rL95+SfC/aSTVSnZSZiDV5pCk=
Expand Down
6 changes: 2 additions & 4 deletions itests/f3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ func TestF3_InactiveModes(t *testing.T) {
if tc.mode == "not running" {
m := newTestManifest(BaseNetworkName, 1<<32, blockTime)
cfg := &lf3.Config{
BaseNetworkName: BaseNetworkName,
StaticManifest: m,
StaticManifest: m,
}
opts = append(opts, kit.F3Config(cfg))
}
Expand Down Expand Up @@ -383,8 +382,7 @@ func setupWithStaticManifest(t *testing.T, manif *manifest.Manifest, testBootstr
})

cfg := &lf3.Config{
BaseNetworkName: BaseNetworkName,
StaticManifest: manif,
StaticManifest: manif,
}

nodeOpts := []kit.NodeOpt{kit.WithAllSubsystems(), kit.F3Config(cfg)}
Expand Down
10 changes: 4 additions & 6 deletions node/modules/lp2p/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,10 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {

allowTopics = append(allowTopics, drandTopics...)

if in.F3Config != nil {
if in.F3Config.StaticManifest != nil {
gpbftTopic := manifest.PubSubTopicFromNetworkName(in.F3Config.BaseNetworkName)
chainexTopic := manifest.ChainExchangeTopicFromNetworkName(in.F3Config.BaseNetworkName)
allowTopics = append(allowTopics, gpbftTopic, chainexTopic)
}
if in.F3Config != nil && in.F3Config.StaticManifest != nil {
gpbftTopic := manifest.PubSubTopicFromNetworkName(in.F3Config.StaticManifest.NetworkName)
chainexTopic := manifest.ChainExchangeTopicFromNetworkName(in.F3Config.StaticManifest.NetworkName)
allowTopics = append(allowTopics, gpbftTopic, chainexTopic)
}

options = append(options,
Expand Down