Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into nonces-requeuing
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id authored Dec 4, 2023
2 parents 0e19f98 + 2dc89ef commit fdb26a4
Show file tree
Hide file tree
Showing 8 changed files with 395 additions and 131 deletions.
37 changes: 37 additions & 0 deletions cmd/blobstream/base/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ const (

FlagLogLevel = "log.level"
FlagLogFormat = "log.format"

FlagBackupRelayer = "relayer.backup"
FlagBackupRelayerWaitTime = "relayer.wait-time"
)

func AddLogLevelFlag(cmd *cobra.Command) {
Expand Down Expand Up @@ -271,6 +274,40 @@ func GetEVMGasLimitFlag(cmd *cobra.Command) (uint64, bool, error) {
return val, changed, nil
}

func AddBackupRelayerFlag(cmd *cobra.Command) {
cmd.Flags().Bool(
FlagBackupRelayer,
false,
"Set the relayer to be a backup, i.e. not relay attestations until the `relayer.wait-time` is elapsed and no primary relayer has relayed any",
)
}

func GetBackupRelayerFlag(cmd *cobra.Command) (bool, bool, error) {
changed := cmd.Flags().Changed(FlagBackupRelayer)
val, err := cmd.Flags().GetBool(FlagBackupRelayer)
if err != nil {
return false, changed, err
}
return val, changed, nil
}

func AddBackupRelayerWaitTimeFlag(cmd *cobra.Command) {
cmd.Flags().Uint64(
FlagBackupRelayerWaitTime,
15,
"The wait time, in minutes, to wait for primary relayers to relay attestations before proceeding to relay them",
)
}

func GetBackupRelayerWaitTimeFlag(cmd *cobra.Command) (uint64, bool, error) {
changed := cmd.Flags().Changed(FlagBackupRelayerWaitTime)
val, err := cmd.Flags().GetUint64(FlagBackupRelayerWaitTime)
if err != nil {
return 0, changed, err
}
return val, changed, nil
}

func AddHomeFlag(cmd *cobra.Command, serviceName string, defaultHomeDir string) {
cmd.Flags().String(FlagHome, defaultHomeDir, fmt.Sprintf("The Blobstream %s home directory", serviceName))
}
Expand Down
29 changes: 13 additions & 16 deletions cmd/blobstream/orchestrator/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,30 @@ func Start() *cobra.Command {
defer cancel()

stopFuncs := make([]func() error, 0)
defer func() {
for _, f := range stopFuncs {
err := f()
if err != nil {
logger.Error(err.Error())
}
}
}()

tmQuerier, appQuerier, stops, err := common.NewTmAndAppQuerier(logger, config.CoreRPC, config.CoreGRPC, config.GRPCInsecure)
stopFuncs = append(stopFuncs, stops...)
tmQuerier, appQuerier, storeStops, err := common.NewTmAndAppQuerier(logger, config.CoreRPC, config.CoreGRPC, config.GRPCInsecure)
stopFuncs = append(stopFuncs, storeStops...)
if err != nil {
return err
}

s, stops, err := common.OpenStore(logger, config.Home, store.OpenOptions{
s, storeStops, err := common.OpenStore(logger, config.Home, store.OpenOptions{
HasDataStore: true,
BadgerOptions: store.DefaultBadgerOptions(config.Home),
HasSignatureStore: false,
HasEVMKeyStore: true,
HasP2PKeyStore: true,
})
stopFuncs = append(stopFuncs, stops...)
if err != nil {
stopFuncs = append(stopFuncs, storeStops...)
return err
}

Expand All @@ -110,25 +118,14 @@ func Start() *cobra.Command {
return err
}
stopFuncs = append(stopFuncs, func() error { return dht.Close() })
stopFuncs = append(stopFuncs, storeStops...)

// creating the p2p querier
p2pQuerier := p2p.NewQuerier(dht, logger)
retrier := helpers.NewRetrier(logger, 5, 30*time.Second)

defer func() {
for _, f := range stopFuncs {
err := f()
if err != nil {
logger.Error(err.Error())
}
}
}()

// creating the broadcaster
broadcaster := orchestrator.NewBroadcaster(p2pQuerier.BlobstreamDHT)
if err != nil {
return err
}

// creating the orchestrator
orch := orchestrator.New(
Expand Down
Loading

0 comments on commit fdb26a4

Please sign in to comment.