From 5861704fc5f3cc986b033a5f6493558806b9cc84 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 19 Jun 2024 16:39:29 +0200 Subject: [PATCH] F3 WIP Signed-off-by: Jakub Sztandera --- chain/lf3/ec.go | 161 ++++++++++++++++++++++++++++++++++++ chain/lf3/f3.go | 82 ++++++++++++++++++ chain/lf3/signer.go | 35 ++++++++ go.mod | 16 ++-- go.sum | 26 +++--- node/builder.go | 2 + node/builder_chain.go | 2 + node/modules/lp2p/pubsub.go | 2 + 8 files changed, 308 insertions(+), 18 deletions(-) create mode 100644 chain/lf3/ec.go create mode 100644 chain/lf3/f3.go create mode 100644 chain/lf3/signer.go diff --git a/chain/lf3/ec.go b/chain/lf3/ec.go new file mode 100644 index 00000000000..14b555fd8cb --- /dev/null +++ b/chain/lf3/ec.go @@ -0,0 +1,161 @@ +package lf3 + +import ( + "context" + "sort" + "time" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-f3" + "github.com/filecoin-project/go-f3/gpbft" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/lotus/chain/actors/builtin/power" + "github.com/filecoin-project/lotus/chain/stmgr" + "github.com/filecoin-project/lotus/chain/store" + "github.com/filecoin-project/lotus/chain/types" + "golang.org/x/xerrors" +) + +type ecWrapper struct { + ChainStore *store.ChainStore + StateManager *stmgr.StateManager + Manifest f3.Manifest +} + +type tsWrapper struct { + inner *types.TipSet +} + +func (ts *tsWrapper) Key() gpbft.TipSetKey { + return ts.inner.Key().Bytes() +} + +func (ts *tsWrapper) Beacon() []byte { + // TOOD: verify if correct + return ts.inner.MinTicket().VRFProof +} + +func (ts *tsWrapper) Epoch() int64 { + return int64(ts.inner.Height()) +} + +func (ts *tsWrapper) Timestamp() time.Time { + return time.Unix(int64(ts.inner.Blocks()[0].Timestamp), 0) +} + +func wrapTS(ts *types.TipSet) f3.TipSet { + if ts == nil { + return nil + } + return &tsWrapper{ts} +} + +// GetTipsetByEpoch should return a tipset before the one requested if the requested +// tipset does not exist due to null epochs +func (ec *ecWrapper) GetTipsetByEpoch(ctx context.Context, epoch int64) (f3.TipSet, error) { + ts, err := ec.ChainStore.GetTipsetByHeight(ctx, abi.ChainEpoch(epoch), nil, true) + if err != nil { + return nil, xerrors.Errorf("getting tipset by height: %w", err) + } + return wrapTS(ts), nil +} + +func (ec *ecWrapper) GetTipset(ctx context.Context, tsk gpbft.TipSetKey) (f3.TipSet, error) { + tskLotus, err := types.TipSetKeyFromBytes([]byte(tsk)) + if err != nil { + return nil, xerrors.Errorf("decoding tsk: %w", err) + } + + ts, err := ec.ChainStore.GetTipSetFromKey(ctx, tskLotus) + if err != nil { + return nil, xerrors.Errorf("getting tipset by key: %w", err) + } + + return wrapTS(ts), nil +} + +func (ec *ecWrapper) GetHead(_ context.Context) (f3.TipSet, error) { + return wrapTS(ec.ChainStore.GetHeaviestTipSet()), nil +} + +func (ec *ecWrapper) GetParent(ctx context.Context, tsF3 f3.TipSet) (f3.TipSet, error) { + var ts *types.TipSet + if tsW, ok := tsF3.(*tsWrapper); ok { + ts = tsW.inner + } else { + tskLotus, err := types.TipSetKeyFromBytes([]byte(tsF3.Key())) + if err != nil { + return nil, xerrors.Errorf("decoding tsk: %w", err) + } + ts, err = ec.ChainStore.GetTipSetFromKey(ctx, tskLotus) + if err != nil { + return nil, xerrors.Errorf("getting tipset by key for get parent: %w", err) + } + } + parentTs, err := ec.ChainStore.GetTipSetFromKey(ctx, ts.Parents()) + if err != nil { + return nil, xerrors.Errorf("getting parent tipset: %w", err) + } + return wrapTS(parentTs), nil +} + +func (ec *ecWrapper) GetPowerTable(ctx context.Context, tskF3 gpbft.TipSetKey) (gpbft.PowerEntries, error) { + tskLotus, err := types.TipSetKeyFromBytes([]byte(tskF3)) + if err != nil { + return nil, xerrors.Errorf("decoding tsk: %w", err) + } + ts, err := ec.ChainStore.GetTipSetFromKey(ctx, tskLotus) + if err != nil { + return nil, xerrors.Errorf("getting tipset by key for get parent: %w", err) + } + log.Infof("collecting power table for: %d", ts.Height()) + stCid := ts.ParentState() + + sm := ec.StateManager + + powerAct, err := sm.LoadActor(ctx, power.Address, ts) + powerState, err := power.Load(ec.ChainStore.ActorStore(ctx), powerAct) + + var powerEntries gpbft.PowerEntries + err = powerState.ForEachClaim(func(miner address.Address, claim power.Claim) error { + if claim.QualityAdjPower.LessThanEqual(big.Zero()) { + return nil + } + + // TODO: optimize + ok, err := powerState.MinerNominalPowerMeetsConsensusMinimum(miner) + if err != nil { + return xerrors.Errorf("checking consensus minimums: %w", err) + } + if !ok { + return nil + } + + id, err := address.IDFromAddress(miner) + if err != nil { + return xerrors.Errorf("transforming address to ID: %w", err) + } + + pe := gpbft.PowerEntry{ + ID: gpbft.ActorID(id), + Power: claim.QualityAdjPower.Int, + } + waddr, err := stmgr.GetMinerWorkerRaw(ctx, sm, stCid, miner) + if err != nil { + return xerrors.Errorf("GetMinerWorkerRaw failed: %w", err) + } + if waddr.Protocol() != address.BLS { + return xerrors.Errorf("wrong type of worker address") + } + pe.PubKey = gpbft.PubKey(waddr.Payload()) + powerEntries = append(powerEntries, pe) + return nil + }) + if err != nil { + return nil, xerrors.Errorf("collecting the power table: %w", err) + } + + sort.Sort(powerEntries) + return powerEntries, nil +} diff --git a/chain/lf3/f3.go b/chain/lf3/f3.go new file mode 100644 index 00000000000..5876e472f05 --- /dev/null +++ b/chain/lf3/f3.go @@ -0,0 +1,82 @@ +package lf3 + +import ( + "context" + "time" + + "github.com/filecoin-project/go-f3" + "github.com/filecoin-project/go-f3/blssig" + "github.com/filecoin-project/go-f3/gpbft" + "github.com/filecoin-project/lotus/api" + "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" + "github.com/ipfs/go-datastore" + "github.com/ipfs/go-datastore/namespace" + logging "github.com/ipfs/go-log/v2" + pubsub "github.com/libp2p/go-libp2p-pubsub" + "github.com/libp2p/go-libp2p/core/host" + "go.uber.org/fx" + "golang.org/x/xerrors" +) + +type F3 struct { + f3 *f3.F3 +} + +type F3Params struct { + fx.In + + NetworkName dtypes.NetworkName + PubSub *pubsub.PubSub + Host host.Host + ChainStore *store.ChainStore + StateManager *stmgr.StateManager + Datastore dtypes.MetadataDS + Wallet api.Wallet +} + +var log = logging.Logger("f3") + +func New(lc fx.Lifecycle, params F3Params) (*F3, error) { + logging.SetLogLevel("f3", "DEBUG") + manifest := f3.LocalnetManifest() + manifest.NetworkName = gpbft.NetworkName(params.NetworkName) + manifest.ECDelay = time.Duration(build.BlockDelaySecs) * time.Second + manifest.ECPeriod = manifest.ECDelay + manifest.BootstrapEpoch = 210 + manifest.ECFinality = 200 + ds := namespace.Wrap(params.Datastore, datastore.NewKey("/f3")) + ec := &ecWrapper{ + ChainStore: params.ChainStore, + StateManager: params.StateManager, + Manifest: manifest, + } + verif := blssig.VerifierWithKeyOnG1() + module, err := f3.New(context.TODO(), 1000 /*TODO expose signing*/, manifest, ds, + params.Host, params.PubSub, &signer{params.Wallet}, verif, ec, log) + + if err != nil { + return nil, xerrors.Errorf("creating F3: %w", err) + } + + var liftimeContext context.Context + var cancel func() + lc.Append(fx.StartStopHook( + func(ctx context.Context) { + liftimeContext, cancel = context.WithCancel(ctx) + go func() { + err := module.Run(0, liftimeContext) + if err != nil { + log.Errorf("running f3: %+v", err) + } + }() + }, func() { + cancel() + })) + + return &F3{ + f3: module, + }, nil +} diff --git a/chain/lf3/signer.go b/chain/lf3/signer.go new file mode 100644 index 00000000000..6dc3d361c1e --- /dev/null +++ b/chain/lf3/signer.go @@ -0,0 +1,35 @@ +package lf3 + +import ( + "context" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-f3/gpbft" + "github.com/filecoin-project/lotus/api" + "golang.org/x/xerrors" +) + +type signer struct { + wallet api.Wallet +} + +// Signs a message with the secret key corresponding to a public key. +func (s *signer) Sign(sender gpbft.PubKey, msg []byte) ([]byte, error) { + addr, err := address.NewBLSAddress(sender) + if err != nil { + return nil, xerrors.Errorf("converting pubkey to address: %w", err) + } + sig, err := s.wallet.WalletSign(context.TODO(), addr, msg, api.MsgMeta{Type: api.MTUnknown}) + if err != nil { + return nil, xerrors.Errorf("error while signing: %w", err) + } + return sig.Data, nil +} + +// MarshalPayloadForSigning marshals the given payload into the bytes that should be signed. +// This should usually call `Payload.MarshalForSigning(NetworkName)` except when testing as +// that method is slow (computes a merkle tree that's necessary for testing). +// Implementations must be safe for concurrent use. +func (s *signer) MarshalPayloadForSigning(nn gpbft.NetworkName, p *gpbft.Payload) []byte { + return p.MarshalForSigning(nn) +} diff --git a/go.mod b/go.mod index 08d462377d7..d398be2aca2 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,11 @@ replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi // pro replace github.com/filecoin-project/test-vectors => ./extern/test-vectors // provided via a git submodule +replace github.com/filecoin-project/go-f3 => ../go-f3 + require ( contrib.go.opencensus.io/exporter/prometheus v0.4.2 - github.com/BurntSushi/toml v1.3.0 + github.com/BurntSushi/toml v1.3.2 github.com/DataDog/zstd v1.4.5 github.com/GeertJohan/go.rice v1.0.3 github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee @@ -26,7 +28,7 @@ require ( github.com/dgraph-io/badger/v2 v2.2007.4 github.com/docker/go-units v0.5.0 github.com/drand/drand v1.5.11 - github.com/drand/kyber v1.3.0 + github.com/drand/kyber v1.3.1 github.com/dustin/go-humanize v1.0.1 github.com/elastic/go-elasticsearch/v7 v7.14.0 github.com/elastic/go-sysinfo v1.7.0 @@ -41,6 +43,7 @@ require ( github.com/filecoin-project/go-commp-utils v0.1.3 github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 github.com/filecoin-project/go-crypto v0.0.1 + github.com/filecoin-project/go-f3 v0.0.0-20240619112353-e4ef2ea3078f github.com/filecoin-project/go-fil-commcid v0.1.0 github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0 github.com/filecoin-project/go-jsonrpc v0.3.2 @@ -102,7 +105,7 @@ require ( github.com/klauspost/compress v1.17.8 github.com/koalacxr/quantile v0.0.1 github.com/libp2p/go-buffer-pool v0.1.0 - github.com/libp2p/go-libp2p v0.34.1 + github.com/libp2p/go-libp2p v0.35.0 github.com/libp2p/go-libp2p-kad-dht v0.25.2 github.com/libp2p/go-libp2p-pubsub v0.11.0 github.com/libp2p/go-libp2p-record v0.2.0 @@ -130,7 +133,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/triplewz/poseidon v0.0.0-20230828015038-79d8165c88ed - github.com/urfave/cli/v2 v2.25.5 + github.com/urfave/cli/v2 v2.27.2 github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba github.com/whyrusleeping/cbor-gen v0.1.1 github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 @@ -163,6 +166,7 @@ require ( require ( github.com/GeertJohan/go.incremental v1.0.0 // indirect github.com/Jorropo/jsync v1.0.1 // indirect + github.com/Kubuxu/go-broadcast v0.0.0-20240212204713-7007a1e29a19 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/StackExchange/wmi v1.2.1 // indirect @@ -174,7 +178,7 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cilium/ebpf v0.9.1 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/crackcomm/go-gitignore v0.0.0-20231225121904-e25f5bc08668 // indirect github.com/cskr/pubsub v1.0.2 // indirect github.com/daaku/go.zipexe v1.0.2 // indirect @@ -311,7 +315,7 @@ require ( github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.opentelemetry.io/otel/metric v1.26.0 // indirect diff --git a/go.sum b/go.sum index d1d53543052..190abad11f4 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOv github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.0 h1:Ws8e5YmnrGEHzZEzg0YvK/7COGYtTC5PbaH9oSSbgfA= -github.com/BurntSushi/toml v1.3.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= @@ -58,6 +58,8 @@ github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee h1:8doiS7ib3zi6/K1 github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee/go.mod h1:W0GbEAA4uFNYOGG2cJpmFJ04E6SD1NLELPYZB57/7AY= github.com/Jorropo/jsync v1.0.1 h1:6HgRolFZnsdfzRUj+ImB9og1JYOxQoReSywkHOGSaUU= github.com/Jorropo/jsync v1.0.1/go.mod h1:jCOZj3vrBCri3bSU3ErUYvevKlnbssrXeCivybS5ABQ= +github.com/Kubuxu/go-broadcast v0.0.0-20240212204713-7007a1e29a19 h1:bsIcfR08tLQBbFeSkx6KLkwgfAk6JPnfbMjIqN1QxJc= +github.com/Kubuxu/go-broadcast v0.0.0-20240212204713-7007a1e29a19/go.mod h1:5LOj/fF3Oc/cvJqzDiyfx4XwtBPRWUYEz+V+b13sH5U= github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y= github.com/Kubuxu/imtui v0.0.0-20210401140320-41663d68d0fa h1:1PPxEyGdIGVkX/kqMvLJ95a1dGS1Sz7tpNEgehEYYt0= github.com/Kubuxu/imtui v0.0.0-20210401140320-41663d68d0fa/go.mod h1:WUmMvh9wMtqj1Xhf1hf3kp9RvL+y6odtdYxpyZjb90U= @@ -171,8 +173,8 @@ github.com/corpix/uarand v0.1.1/go.mod h1:SFKZvkcRoLqVRFZ4u25xPmp6m9ktANfbpXZ7SJ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crackcomm/go-gitignore v0.0.0-20231225121904-e25f5bc08668 h1:ZFUue+PNxmHlu7pYv+IYMtqlaO/0VwaGEqKepZf9JpA= github.com/crackcomm/go-gitignore v0.0.0-20231225121904-e25f5bc08668/go.mod h1:p1d6YEZWvFzEh4KLyvBcVSnrfNDDvK2zfK/4x2v/4pE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -212,8 +214,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/drand/drand v1.5.11 h1:7sskUTCsX2lgFiWdGvPh3/P0ZDQKi1lCtI7RQKK010k= github.com/drand/drand v1.5.11/go.mod h1:TvJjCJ/s4Usn4pKRpDC0N1QaCwSt3YC8fRqhZdpOUU0= -github.com/drand/kyber v1.3.0 h1:TVd7+xoRgKQ4Ck1viNLPFy6IWhuZM36Bq6zDXD8Asls= -github.com/drand/kyber v1.3.0/go.mod h1:f+mNHjiGT++CuueBrpeMhFNdKZAsy0tu03bKq9D5LPA= +github.com/drand/kyber v1.3.1 h1:E0p6M3II+loMVwTlAp5zu4+GGZFNiRfq02qZxzw2T+Y= +github.com/drand/kyber v1.3.1/go.mod h1:f+mNHjiGT++CuueBrpeMhFNdKZAsy0tu03bKq9D5LPA= github.com/drand/kyber-bls12381 v0.3.1 h1:KWb8l/zYTP5yrvKTgvhOrk2eNPscbMiUOIeWBnmUxGo= github.com/drand/kyber-bls12381 v0.3.1/go.mod h1:H4y9bLPu7KZA/1efDg+jtJ7emKx+ro3PU7/jWUVt140= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -820,8 +822,8 @@ github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFG github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= github.com/libp2p/go-libp2p v0.1.0/go.mod h1:6D/2OBauqLUoqcADOJpn9WbKqvaM07tDw68qHM0BxUM= github.com/libp2p/go-libp2p v0.1.1/go.mod h1:I00BRo1UuUSdpuc8Q2mN7yDF/oTUTRAX6JWpTiK9Rp8= -github.com/libp2p/go-libp2p v0.34.1 h1:fxn9vyLo7vJcXQRNvdRbyPjbzuQgi2UiqC8hEbn8a18= -github.com/libp2p/go-libp2p v0.34.1/go.mod h1:snyJQix4ET6Tj+LeI0VPjjxTtdWpeOhYt5lEY0KirkQ= +github.com/libp2p/go-libp2p v0.35.0 h1:1xS1Bkr9X7GtdvV6ntLnDV9xB1kNjHK1lZ0eaO6gnhc= +github.com/libp2p/go-libp2p v0.35.0/go.mod h1:snyJQix4ET6Tj+LeI0VPjjxTtdWpeOhYt5lEY0KirkQ= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= github.com/libp2p/go-libp2p-autonat v0.1.0/go.mod h1:1tLf2yXxiE/oKGtDwPYWTSYG3PtvYlJmg7NeVtPRqH8= @@ -1286,8 +1288,8 @@ github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6 github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc= -github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= +github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= @@ -1347,8 +1349,8 @@ github.com/xorcare/golden v0.6.0/go.mod h1:7T39/ZMvaSEZlBPoYfVFmsBLmUl3uz9IuzWj/ github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542 h1:oWgZJmC1DorFZDpfMfWg7xk29yEOZiXmo/wZl+utTI8= github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542/go.mod h1:7T39/ZMvaSEZlBPoYfVFmsBLmUl3uz9IuzWj/U6FtvQ= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= github.com/yugabyte/pgx/v5 v5.5.3-yb-2 h1:SDk2waZb2o6dSLYqk+vq0Ur2jnIv+X2A+P+QPR1UThU= github.com/yugabyte/pgx/v5 v5.5.3-yb-2/go.mod h1:2SxizGfDY7UDCRTtbI/xd98C/oGN7S/3YoGF8l9gx/c= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/node/builder.go b/node/builder.go index 2ea9dcac55c..dfff37d766a 100644 --- a/node/builder.go +++ b/node/builder.go @@ -128,6 +128,8 @@ const ( StoreEventsKey + F3Key + _nInvokes // keep this last ) diff --git a/node/builder_chain.go b/node/builder_chain.go index b273a168cc1..12cc1ea3ca0 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -17,6 +17,7 @@ import ( "github.com/filecoin-project/lotus/chain/exchange" "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/index" + "github.com/filecoin-project/lotus/chain/lf3" "github.com/filecoin-project/lotus/chain/market" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/messagesigner" @@ -148,6 +149,7 @@ var ChainNode = Options( Override(RunPeerMgrKey, modules.RunPeerMgr), Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages), Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks), + Override(F3Key, lf3.New), ), ) diff --git a/node/modules/lp2p/pubsub.go b/node/modules/lp2p/pubsub.go index 408ab17a63e..f540a642428 100644 --- a/node/modules/lp2p/pubsub.go +++ b/node/modules/lp2p/pubsub.go @@ -16,6 +16,7 @@ import ( "go.uber.org/fx" "golang.org/x/xerrors" + "github.com/filecoin-project/go-f3/gpbft" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/metrics" "github.com/filecoin-project/lotus/node/config" @@ -377,6 +378,7 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) { build.BlocksTopic(in.Nn), build.MessagesTopic(in.Nn), build.IndexerIngestTopic(in.Nn), + gpbft.NetworkName(in.Nn).PubSubTopic(), } allowTopics = append(allowTopics, drandTopics...) options = append(options,