-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efae3d0
commit 117670a
Showing
9 changed files
with
237 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigenda/common/geth" | ||
"github.com/Layr-Labs/eigenda/common/logging" | ||
"github.com/Layr-Labs/eigenda/core/encoding" | ||
"github.com/Layr-Labs/eigenda/disperser" | ||
"github.com/Layr-Labs/eigenda/disperser/grpc" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
type Config struct { | ||
BatcherConfig disperser.BatcherConfig | ||
EthClientConfig geth.EthClientConfig | ||
EncoderConfig encoding.EncoderConfig | ||
LoggerConfig logging.Config | ||
ServerConfig grpc.ServerConfig | ||
|
||
Address string | ||
} | ||
|
||
func NewConfig(ctx *cli.Context) Config { | ||
config := Config{ | ||
EthClientConfig: geth.ReadEthClientConfig(ctx), | ||
EncoderConfig: encoding.ReadCLIConfig(ctx), | ||
LoggerConfig: logging.ReadCLIConfig(ctx), | ||
ServerConfig: grpc.ServerConfig{ | ||
GrpcPort: ctx.GlobalString(grpcPortFlag.Name), | ||
}, | ||
BatcherConfig: disperser.BatcherConfig{ | ||
PullInterval: ctx.GlobalDuration(pullIntervalFlag.Name), | ||
}, | ||
Address: ctx.GlobalString(addressFlag.Name), | ||
} | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/Layr-Labs/eigenda/common" | ||
"github.com/Layr-Labs/eigenda/core" | ||
"github.com/Layr-Labs/eigenda/core/encoding" | ||
"github.com/Layr-Labs/eigenda/core/eth" | ||
"github.com/Layr-Labs/eigenda/disperser" | ||
"github.com/Layr-Labs/eigenda/disperser/grpc" | ||
"github.com/Layr-Labs/eigenda/disperser/inmem" | ||
) | ||
|
||
type Disperser struct { | ||
Batcher *disperser.Batcher | ||
Server *grpc.DispersalServer | ||
} | ||
|
||
func NewDisperser(config Config, logger common.Logger) (*Disperser, error) { | ||
|
||
queue := inmem.NewBlobStore() | ||
|
||
client := &grpc.Dispatcher{} | ||
agg := &core.StdSignatureAggregator{} | ||
asgn := &core.StdAssignmentCoordinator{} | ||
|
||
enc, err := encoding.NewEncoder(config.EncoderConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tx, err := eth.NewTransactor(logger, config.EthClientConfig, config.Address) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
cst := eth.NewChainState(tx) | ||
|
||
batcher := disperser.NewBatcher(config.BatcherConfig, queue, client, nil, cst, asgn, enc, agg, logger) | ||
|
||
server := grpc.NewDispersalServer(config.ServerConfig, queue, logger) | ||
|
||
return &Disperser{ | ||
Batcher: batcher, | ||
Server: server, | ||
}, nil | ||
} | ||
|
||
func (d *Disperser) Start(ctx context.Context) error { | ||
|
||
d.Batcher.Start(ctx) | ||
|
||
d.Server.Start(ctx) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigenda/common" | ||
"github.com/Layr-Labs/eigenda/common/geth" | ||
"github.com/Layr-Labs/eigenda/common/logging" | ||
"github.com/Layr-Labs/eigenda/core/encoding" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
const envVarPrefix = "DISPERSER" | ||
|
||
var ( | ||
/* Required Flags */ | ||
pullIntervalFlag = cli.DurationFlag{ | ||
Name: "pull-interval", | ||
Usage: "Interval at which to pull from the queue", | ||
Required: true, | ||
EnvVar: common.PrefixEnvVar(envVarPrefix, "PULL_INTERVAL"), | ||
} | ||
grpcPortFlag = cli.StringFlag{ | ||
Name: "grpc-port", | ||
Usage: "Port at which disperser listens for grpc calls", | ||
Required: true, | ||
EnvVar: common.PrefixEnvVar(envVarPrefix, "GRPC_PORT"), | ||
} | ||
addressFlag = cli.StringFlag{ | ||
Name: "address", | ||
Usage: "Address of the disperser", | ||
Required: true, | ||
EnvVar: common.PrefixEnvVar(envVarPrefix, "ADDRESS"), | ||
} | ||
) | ||
|
||
var requiredFlags = []cli.Flag{ | ||
pullIntervalFlag, | ||
grpcPortFlag, | ||
addressFlag, | ||
} | ||
|
||
var optionalFlags = []cli.Flag{} | ||
|
||
// Flags contains the list of configuration options available to the binary. | ||
var Flags []cli.Flag | ||
|
||
func init() { | ||
Flags = append(requiredFlags, optionalFlags...) | ||
Flags = append(Flags, encoding.CLIFlags(envVarPrefix)...) | ||
Flags = append(Flags, geth.EthClientFlags(envVarPrefix)...) | ||
Flags = append(Flags, logging.CLIFlags(envVarPrefix)...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/Layr-Labs/eigenda/common" | ||
"github.com/Layr-Labs/eigenda/node/flags" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var ( | ||
// Version is the version of the binary. | ||
Version string | ||
GitCommit string | ||
GitDate string | ||
) | ||
|
||
func main() { | ||
|
||
app := cli.NewApp() | ||
app.Flags = flags.Flags | ||
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate) | ||
app.Name = "dl-disperser" | ||
app.Usage = "DataLayr Disperser" | ||
app.Description = "Service for encoding blobs and distributing coded chunks to nodes" | ||
|
||
app.Action = RunDisperser | ||
err := app.Run(os.Args) | ||
if err != nil { | ||
log.Fatalln("Application failed.", "Message:", err) | ||
} | ||
|
||
select {} | ||
} | ||
|
||
func RunDisperser(ctx *cli.Context) error { | ||
|
||
config := NewConfig(ctx) | ||
|
||
var logger common.Logger = nil | ||
|
||
dis, err := NewDisperser(config, logger) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = dis.Start(context.Background()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters