Skip to content

Commit

Permalink
chore(deps): Bumps go-header and openrpc (cosmos#1256)
Browse files Browse the repository at this point in the history
Co-authored-by: Ganesha Upadhyaya <gupadhyaya@Ganeshas-MacBook-Pro-2.local>
  • Loading branch information
renaynay and Ganesha Upadhyaya authored Oct 17, 2023
1 parent c984734 commit 5819a12
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ proto/tendermint
types/pb/tendermint
.vscode/launch.json
*/**.html
*.idea
2 changes: 1 addition & 1 deletion block/block-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ See [tutorial] for running a multi-node network with both sequencer and non-sequ
[defaultDABlockTime]: https://github.com/rollkit/rollkit/blob/main/block/manager.go#L32
[initialBackoff]: https://github.com/rollkit/rollkit/blob/main/block/manager.go#L48
[go-header]: https://github.com/celestiaorg/go-header
[block-sync]: https://github.com/rollkit/rollkit/blob/main/node/block_sync.go
[block-sync]: https://github.com/rollkit/rollkit/blob/main/block/block_sync.go
[full-node]: https://github.com/rollkit/rollkit/blob/main/node/full.go
[block-manager]: https://github.com/rollkit/rollkit/blob/main/block/manager.go
[tutorial]: https://rollkit.dev/tutorials/full-and-sequencer-node#getting-started
26 changes: 20 additions & 6 deletions block/block_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,22 @@ func (bSyncService *BlockSyncService) isInitialized() bool {
return bSyncService.blockStore.Height() > 0
}

// OnStart is a part of Service interface.
// Start is a part of Service interface.
func (bSyncService *BlockSyncService) Start() error {
// have to do the initializations here to utilize the p2p node which is created on start
ps := bSyncService.p2p.PubSub()
chainIDBlock := bSyncService.genesis.ChainID + "-block"
bSyncService.sub = goheaderp2p.NewSubscriber[*types.Block](ps, pubsub.DefaultMsgIdFn, chainIDBlock)

var err error
bSyncService.sub, err = goheaderp2p.NewSubscriber[*types.Block](
ps,
pubsub.DefaultMsgIdFn,
goheaderp2p.WithSubscriberNetworkID(chainIDBlock),
)
if err != nil {
return err
}

if err := bSyncService.sub.Start(bSyncService.ctx); err != nil {
return fmt.Errorf("error while starting subscriber: %w", err)
}
Expand All @@ -132,7 +142,6 @@ func (bSyncService *BlockSyncService) Start() error {
return fmt.Errorf("error while starting block store: %w", err)
}

var err error
_, _, network, err := bSyncService.p2p.Info()
if err != nil {
return fmt.Errorf("error while fetching the network: %w", err)
Expand All @@ -154,7 +163,12 @@ func (bSyncService *BlockSyncService) Start() error {
return fmt.Errorf("error while starting exchange: %w", err)
}

if bSyncService.syncer, err = newBlockSyncer(bSyncService.ex, bSyncService.blockStore, bSyncService.sub, goheadersync.WithBlockTime(bSyncService.conf.BlockTime)); err != nil {
if bSyncService.syncer, err = newBlockSyncer(
bSyncService.ex,
bSyncService.blockStore,
bSyncService.sub,
[]goheadersync.Option{goheadersync.WithBlockTime(bSyncService.conf.BlockTime)},
); err != nil {
return fmt.Errorf("error while creating syncer: %w", err)
}

Expand Down Expand Up @@ -235,9 +249,9 @@ func newBlockSyncer(
ex header.Exchange[*types.Block],
store header.Store[*types.Block],
sub header.Subscriber[*types.Block],
opt goheadersync.Options,
opts []goheadersync.Option,
) (*goheadersync.Syncer[*types.Block], error) {
return goheadersync.NewSyncer[*types.Block](ex, store, sub, opt)
return goheadersync.NewSyncer[*types.Block](ex, store, sub, opts...)
}

func (bSyncService *BlockSyncService) StartSyncer() error {
Expand Down
24 changes: 19 additions & 5 deletions block/header_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@ func (hSyncService *HeaderSynceService) isInitialized() bool {
func (hSyncService *HeaderSynceService) Start() error {
// have to do the initializations here to utilize the p2p node which is created on start
ps := hSyncService.p2p.PubSub()
hSyncService.sub = goheaderp2p.NewSubscriber[*types.SignedHeader](ps, pubsub.DefaultMsgIdFn, hSyncService.genesis.ChainID)

var err error
hSyncService.sub, err = goheaderp2p.NewSubscriber[*types.SignedHeader](
ps,
pubsub.DefaultMsgIdFn,
goheaderp2p.WithSubscriberNetworkID(hSyncService.genesis.ChainID),
)
if err != nil {
return err
}

if err := hSyncService.sub.Start(hSyncService.ctx); err != nil {
return fmt.Errorf("error while starting subscriber: %w", err)
}
Expand All @@ -131,7 +141,6 @@ func (hSyncService *HeaderSynceService) Start() error {
return fmt.Errorf("error while starting header store: %w", err)
}

var err error
_, _, network, err := hSyncService.p2p.Info()
if err != nil {
return fmt.Errorf("error while fetching the network: %w", err)
Expand All @@ -151,7 +160,12 @@ func (hSyncService *HeaderSynceService) Start() error {
return fmt.Errorf("error while starting exchange: %w", err)
}

if hSyncService.syncer, err = newSyncer(hSyncService.ex, hSyncService.headerStore, hSyncService.sub, goheadersync.WithBlockTime(hSyncService.conf.BlockTime)); err != nil {
if hSyncService.syncer, err = newSyncer(
hSyncService.ex,
hSyncService.headerStore,
hSyncService.sub,
[]goheadersync.Option{goheadersync.WithBlockTime(hSyncService.conf.BlockTime)},
); err != nil {
return fmt.Errorf("error while creating syncer: %w", err)
}

Expand Down Expand Up @@ -234,9 +248,9 @@ func newSyncer(
ex header.Exchange[*types.SignedHeader],
store header.Store[*types.SignedHeader],
sub header.Subscriber[*types.SignedHeader],
opt goheadersync.Options,
opts []goheadersync.Option,
) (*goheadersync.Syncer[*types.SignedHeader], error) {
return goheadersync.NewSyncer[*types.SignedHeader](ex, store, sub, opt)
return goheadersync.NewSyncer[*types.SignedHeader](ex, store, sub, opts...)
}

func (hSyncService *HeaderSynceService) StartSyncer() error {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/rollkit/rollkit
go 1.20

require (
github.com/celestiaorg/go-header v0.3.3
github.com/celestiaorg/go-header v0.4.0
github.com/celestiaorg/nmt v0.20.0
github.com/celestiaorg/rsmt2d v0.11.0
github.com/celestiaorg/utils v0.1.0
Expand All @@ -23,7 +23,7 @@ require (
github.com/libp2p/go-libp2p-pubsub v0.9.3
github.com/multiformats/go-multiaddr v0.11.0
github.com/prometheus/client_golang v1.17.0
github.com/rollkit/celestia-openrpc v0.2.0
github.com/rollkit/celestia-openrpc v0.3.0
github.com/rs/cors v1.10.1
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.17.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n
github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg=
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.3.3 h1:Y04hdJIJfD5hapyqK0ZQMgMTH5PQGV9YpcIf56LGc4E=
github.com/celestiaorg/go-header v0.3.3/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c=
github.com/celestiaorg/go-header v0.4.0 h1:Ine/xpvFx8o9p6fXW+h2RSPp68rn7VUxTkW1okJxcEY=
github.com/celestiaorg/go-header v0.4.0/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c=
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 Expand Up @@ -1351,8 +1351,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rollkit/celestia-openrpc v0.2.0 h1:miSxBgiKtDBZk0dUgreAMubIPXU/Qtf9Q36+E7yZdeE=
github.com/rollkit/celestia-openrpc v0.2.0/go.mod h1:0fNIcIMbG0ZceCoh4tINNhuzhmebUMDV0cJqZboe/wg=
github.com/rollkit/celestia-openrpc v0.3.0 h1:jMLsdLNQ7T20yiNDlisBhlyurFOpN1gZ6vC068FPrQA=
github.com/rollkit/celestia-openrpc v0.3.0/go.mod h1:2ZhU01YF2hsHIROWzxfMZOYM09Kgyy4roH5JWoNJzp0=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo=
Expand Down

0 comments on commit 5819a12

Please sign in to comment.