Skip to content

Commit

Permalink
deps: bump go-header and go-fraud (#3326)
Browse files Browse the repository at this point in the history
Bump it
  • Loading branch information
Wondertan committed Apr 21, 2024
1 parent fe94d62 commit 08d118e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 19 deletions.
4 changes: 4 additions & 0 deletions das/daser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ func TestDASer_stopsAfter_BEFP(t *testing.T) {
getter := func(ctx context.Context, height uint64) (*header.ExtendedHeader, error) {
return mockGet.GetByHeight(ctx, height)
}
headGetter := func(ctx context.Context) (*header.ExtendedHeader, error) {
return mockGet.Head(ctx)
}
unmarshaler := fraud.MultiUnmarshaler[*header.ExtendedHeader]{
Unmarshalers: map[fraud.ProofType]func([]byte) (fraud.Proof[*header.ExtendedHeader], error){
byzantine.BadEncoding: func(data []byte) (fraud.Proof[*header.ExtendedHeader], error) {
Expand All @@ -176,6 +179,7 @@ func TestDASer_stopsAfter_BEFP(t *testing.T) {
fserv := fraudserv.NewProofService[*header.ExtendedHeader](ps,
net.Hosts()[0],
getter,
headGetter,
unmarshaler,
ds,
false,
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/alecthomas/jsonschema v0.0.0-20220216202328-9eeeec9d044b
github.com/benbjohnson/clock v1.3.5
github.com/celestiaorg/celestia-app v1.7.0
github.com/celestiaorg/go-fraud v0.2.0
github.com/celestiaorg/go-header v0.6.0
github.com/celestiaorg/celestia-app v1.8.0-rc0
github.com/celestiaorg/go-fraud v0.2.1
github.com/celestiaorg/go-header v0.6.1
github.com/celestiaorg/go-libp2p-messenger v0.2.0
github.com/celestiaorg/nmt v0.20.0
github.com/celestiaorg/rsmt2d v0.11.0
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,18 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/celestiaorg/celestia-app v1.7.0 h1:pFIgQzeMD036ulJ2ShUR/3bDGG6kwNAWaLEE0MXHmgg=
github.com/celestiaorg/celestia-app v1.7.0/go.mod h1:z2H47Gs9gYd3GdQ22d5sbcL8/aBMRcVDtUWT64goMaY=
github.com/celestiaorg/celestia-app v1.8.0-rc0 h1:rjEwN0Im1+2QChr8uPfbdomhGL3lEmGlt0cPUodc5JU=
github.com/celestiaorg/celestia-app v1.8.0-rc0/go.mod h1:z2H47Gs9gYd3GdQ22d5sbcL8/aBMRcVDtUWT64goMaY=
github.com/celestiaorg/celestia-core v1.35.0-tm-v0.34.29 h1:sXERzNXgyHyqTKNQx4S29C/NMDzgav62DaQDNF49HUQ=
github.com/celestiaorg/celestia-core v1.35.0-tm-v0.34.29/go.mod h1:weZR4wYx1Vcw3g1Jc5G8VipG4M+KUDSqeIzyyWszmsQ=
github.com/celestiaorg/cosmos-sdk v1.20.1-sdk-v0.46.16 h1:9U9UthIJSOyVjabD5PkD6aczvqlWOyAFTOXw0duPT5k=
github.com/celestiaorg/cosmos-sdk v1.20.1-sdk-v0.46.16/go.mod h1:Tvsc3YnqvflXTYC8xIy/Q07Es95xZ1pZC/imoKogtbg=
github.com/celestiaorg/dagstore v0.0.0-20230824094345-537c012aa403 h1:Lj73O3S+KJx5/hgZ+IeOLEIoLsAveJN/7/ZtQQtPSVw=
github.com/celestiaorg/dagstore v0.0.0-20230824094345-537c012aa403/go.mod h1:cCGM1UoMvyTk8k62mkc+ReVu8iHBCtSBAAL4wYU7KEI=
github.com/celestiaorg/go-fraud v0.2.0 h1:aaq2JiW0gTnhEdac3l51UCqSyJ4+VjFGTTpN83V4q7I=
github.com/celestiaorg/go-fraud v0.2.0/go.mod h1:lNY1i4K6kUeeE60Z2VK8WXd+qXb8KRzfBhvwPkK6aUc=
github.com/celestiaorg/go-header v0.6.0 h1:Wf2qFHpsvM7PsWJmOYU98+IuErrbWdNS8fte438PIEE=
github.com/celestiaorg/go-header v0.6.0/go.mod h1:PAEtQmVDqw0nhvkVgfhq2JB7oLnv3GqephFUOeaJqIs=
github.com/celestiaorg/go-fraud v0.2.1 h1:oYhxI0gM/EpGRgbVQdRI/LSlqyT65g/WhQGSVGfx09w=
github.com/celestiaorg/go-fraud v0.2.1/go.mod h1:lNY1i4K6kUeeE60Z2VK8WXd+qXb8KRzfBhvwPkK6aUc=
github.com/celestiaorg/go-header v0.6.1 h1:bbmfNTpL9BA7dZU4/pdzH4DlOnxHTd9F5LLVK5hgSrs=
github.com/celestiaorg/go-header v0.6.1/go.mod h1:PAEtQmVDqw0nhvkVgfhq2JB7oLnv3GqephFUOeaJqIs=
github.com/celestiaorg/go-libp2p-messenger v0.2.0 h1:/0MuPDcFamQMbw9xTZ73yImqgTO3jHV7wKHvWD/Irao=
github.com/celestiaorg/go-libp2p-messenger v0.2.0/go.mod h1:s9PIhMi7ApOauIsfBcQwbr7m+HBzmVfDIS+QLdgzDSo=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc=
Expand Down
17 changes: 15 additions & 2 deletions nodebuilder/fraud/constructors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fraud

import (
"context"

"github.com/ipfs/go-datastore"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/host"
Expand All @@ -9,6 +11,7 @@ import (
"github.com/celestiaorg/go-fraud"
"github.com/celestiaorg/go-fraud/fraudserv"
libhead "github.com/celestiaorg/go-header"
"github.com/celestiaorg/go-header/sync"

"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/nodebuilder/p2p"
Expand All @@ -22,13 +25,18 @@ func newFraudServiceWithSync(
lc fx.Lifecycle,
sub *pubsub.PubSub,
host host.Host,
sync *sync.Syncer[*header.ExtendedHeader],
hstore libhead.Store[*header.ExtendedHeader],
registry fraud.ProofUnmarshaler[*header.ExtendedHeader],
ds datastore.Batching,
network p2p.Network,
) (Module, fraud.Service[*header.ExtendedHeader], error) {
syncerEnabled := true
pservice := fraudserv.NewProofService(sub, host, hstore.GetByHeight, registry, ds, syncerEnabled, network.String())
headGetter := func(ctx context.Context) (*header.ExtendedHeader, error) {
return sync.Head(ctx)
}
pservice := fraudserv.NewProofService(sub, host, hstore.GetByHeight,
headGetter, registry, ds, syncerEnabled, network.String())
lc.Append(fx.Hook{
OnStart: pservice.Start,
OnStop: pservice.Stop,
Expand All @@ -42,13 +50,18 @@ func newFraudServiceWithoutSync(
lc fx.Lifecycle,
sub *pubsub.PubSub,
host host.Host,
sync *sync.Syncer[*header.ExtendedHeader],
hstore libhead.Store[*header.ExtendedHeader],
registry fraud.ProofUnmarshaler[*header.ExtendedHeader],
ds datastore.Batching,
network p2p.Network,
) (Module, fraud.Service[*header.ExtendedHeader], error) {
syncerEnabled := false
pservice := fraudserv.NewProofService(sub, host, hstore.GetByHeight, registry, ds, syncerEnabled, network.String())
headGetter := func(ctx context.Context) (*header.ExtendedHeader, error) {
return sync.Head(ctx)
}
pservice := fraudserv.NewProofService(sub, host, hstore.GetByHeight,
headGetter, registry, ds, syncerEnabled, network.String())
lc.Append(fx.Hook{
OnStart: pservice.Start,
OnStop: pservice.Stop,
Expand Down
16 changes: 11 additions & 5 deletions nodebuilder/header/constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,32 @@ func newP2PExchange[H libhead.Header[H]](
// newSyncer constructs new Syncer for headers.
func newSyncer[H libhead.Header[H]](
ex libhead.Exchange[H],
fservice libfraud.Service[H],
store libhead.Store[H],
sub libhead.Subscriber[H],
cfg Config,
) (*sync.Syncer[H], *modfraud.ServiceBreaker[*sync.Syncer[H], H], error) {
) (*sync.Syncer[H], error) {
opts := []sync.Option{sync.WithParams(cfg.Syncer), sync.WithBlockTime(modp2p.BlockTime)}
if MetricsEnabled {
opts = append(opts, sync.WithMetrics())
}

syncer, err := sync.NewSyncer[H](ex, store, sub, opts...)
if err != nil {
return nil, nil, err
return nil, err
}

return syncer, &modfraud.ServiceBreaker[*sync.Syncer[H], H]{
return syncer, nil
}

func newFraudedSyncer[H libhead.Header[H]](
fservice libfraud.Service[H],
syncer *sync.Syncer[H],
) *modfraud.ServiceBreaker[*sync.Syncer[H], H] {
return &modfraud.ServiceBreaker[*sync.Syncer[H], H]{
Service: syncer,
FraudType: byzantine.BadEncoding,
FraudServ: fservice,
}, nil
}
}

// newInitStore constructs an initialized store
Expand Down
3 changes: 2 additions & 1 deletion nodebuilder/header/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ func ConstructModule[H libhead.Header[H]](tp node.Type, cfg *Config) fx.Option {
fx.Provide(func(subscriber *p2p.Subscriber[H]) libhead.Subscriber[H] {
return subscriber
}),
fx.Provide(newSyncer[H]),
fx.Provide(fx.Annotate(
newSyncer[H],
newFraudedSyncer[H],
fx.OnStart(func(
ctx context.Context,
breaker *modfraud.ServiceBreaker[*sync.Syncer[H], H],
Expand Down
6 changes: 4 additions & 2 deletions nodebuilder/header/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/celestiaorg/go-header/sync"

"github.com/celestiaorg/celestia-node/header"
modfraud "github.com/celestiaorg/celestia-node/nodebuilder/fraud"
)

// Service represents the header Service that can be started / stopped on a node.
Expand All @@ -33,14 +34,15 @@ type syncer interface {

// newHeaderService creates a new instance of header Service.
func newHeaderService(
syncer *sync.Syncer[*header.ExtendedHeader],
// getting Syncer wrapped in ServiceBreaker so we ensure service breaker is constructed
syncer *modfraud.ServiceBreaker[*sync.Syncer[*header.ExtendedHeader], *header.ExtendedHeader],
sub libhead.Subscriber[*header.ExtendedHeader],
p2pServer *p2p.ExchangeServer[*header.ExtendedHeader],
ex libhead.Exchange[*header.ExtendedHeader],
store libhead.Store[*header.ExtendedHeader],
) Module {
return &Service{
syncer: syncer,
syncer: syncer.Service,
sub: sub,
p2pServer: p2pServer,
ex: ex,
Expand Down

0 comments on commit 08d118e

Please sign in to comment.