From 1c2fe6e1490fda33b4d101b28c48f2cf929ceff4 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Tue, 15 Oct 2024 13:12:52 +0800 Subject: [PATCH 1/2] chore: add more logs on manifest and initial power table --- f3.go | 12 ++++++++++-- store.go | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/f3.go b/f3.go index cf68609e..7d32c441 100644 --- a/f3.go +++ b/f3.go @@ -20,6 +20,7 @@ import ( "github.com/filecoin-project/go-f3/internal/writeaheadlog" "github.com/filecoin-project/go-f3/manifest" + "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/host" @@ -187,11 +188,18 @@ func (m *F3) Start(startCtx context.Context) (_err error) { } { var maybeNetworkName gpbft.NetworkName + var bootstrapEpoch int64 + var finality int64 + var initialPowerTable *cid.Cid if m := m.manifest.Load(); m != nil { maybeNetworkName = m.NetworkName + bootstrapEpoch = m.BootstrapEpoch + finality = m.EC.Finality + initialPowerTable = &m.InitialPowerTable } - log.Infow("F3 is starting", "initialDelay", initialDelay, - "hasPendingManifest", hasPendingManifest, "NetworkName", maybeNetworkName) + log.Infow("F3 is starting", "initialDelay", initialDelay, "hasPendingManifest", hasPendingManifest, + "NetworkName", maybeNetworkName, "bootstrapEpoch", bootstrapEpoch, "finality", finality, + "initialPowerTable", initialPowerTable) } m.errgrp.Go(func() (_err error) { diff --git a/store.go b/store.go index 28207a5f..b4a9fe15 100644 --- a/store.go +++ b/store.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/filecoin-project/go-f3/certexchange" + "github.com/filecoin-project/go-f3/certs" "github.com/filecoin-project/go-f3/certstore" "github.com/filecoin-project/go-f3/ec" "github.com/filecoin-project/go-f3/gpbft" @@ -45,6 +46,9 @@ func loadInitialPowerTable(ctx context.Context, ec ec.Backend, m *manifest.Manif } else if pt, err := ec.GetPowerTable(ctx, ts.Key()); err != nil { log.Debugw("failed to load the bootstrap power table for F3 from state", "error", err) } else { + if ptCid, err := certs.MakePowerTableCID(pt); err == nil { + log.Infof("loaded initial power table at epoch %d: %s", epoch, ptCid) + } return pt, nil } if !m.InitialPowerTable.Defined() { From f7e05009ffa028546cbe2b21e0d60342585e9ce2 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Thu, 24 Oct 2024 10:08:54 +0800 Subject: [PATCH 2/2] resolve comments --- f3.go | 20 ++++++-------------- store.go | 3 +++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/f3.go b/f3.go index 7d32c441..db6cec8c 100644 --- a/f3.go +++ b/f3.go @@ -20,7 +20,6 @@ import ( "github.com/filecoin-project/go-f3/internal/writeaheadlog" "github.com/filecoin-project/go-f3/manifest" - "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/host" @@ -186,20 +185,13 @@ func (m *F3) Start(startCtx context.Context) (_err error) { } hasPendingManifest = false } - { - var maybeNetworkName gpbft.NetworkName - var bootstrapEpoch int64 - var finality int64 - var initialPowerTable *cid.Cid - if m := m.manifest.Load(); m != nil { - maybeNetworkName = m.NetworkName - bootstrapEpoch = m.BootstrapEpoch - finality = m.EC.Finality - initialPowerTable = &m.InitialPowerTable - } + + if m := m.manifest.Load(); m != nil { log.Infow("F3 is starting", "initialDelay", initialDelay, "hasPendingManifest", hasPendingManifest, - "NetworkName", maybeNetworkName, "bootstrapEpoch", bootstrapEpoch, "finality", finality, - "initialPowerTable", initialPowerTable) + "NetworkName", m.NetworkName, "BootstrapEpoch", m.BootstrapEpoch, "Finality", m.EC.Finality, + "InitialPowerTable", m.InitialPowerTable, "CommitteeLookback", m.CommitteeLookback) + } else { + log.Infow("F3 is starting", "initialDelay", initialDelay, "hasPendingManifest", hasPendingManifest) } m.errgrp.Go(func() (_err error) { diff --git a/store.go b/store.go index b4a9fe15..e8609a32 100644 --- a/store.go +++ b/store.go @@ -48,6 +48,9 @@ func loadInitialPowerTable(ctx context.Context, ec ec.Backend, m *manifest.Manif } else { if ptCid, err := certs.MakePowerTableCID(pt); err == nil { log.Infof("loaded initial power table at epoch %d: %s", epoch, ptCid) + if m.InitialPowerTable.Defined() && m.InitialPowerTable != ptCid { + log.Warnf("initial power table mismatch, loaded from EC: %s, from manifest: %s", ptCid, m.InitialPowerTable) + } } return pt, nil }