Skip to content

Commit

Permalink
feat: add aggsender to run cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Aug 23, 2024
1 parent f121e17 commit 778fb96
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions agglayer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
type AgglayerClientInterface interface {
SendTx(signedTx SignedTx) (common.Hash, error)
WaitTxToBeMined(hash common.Hash, ctx context.Context) error
SendCertificate(certificate *Certificate) error
}

// AggLayerClient is the client that will be used to interact with the AggLayer
Expand Down
4 changes: 2 additions & 2 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type AggSender struct {
l1Client bridgesync.EthClienter

db kv.RwDB
aggLayerClient agglayer.AggLayerClient
aggLayerClient agglayer.AgglayerClientInterface

sendInterval types.Duration

Expand All @@ -113,7 +113,7 @@ type AggSender struct {
func New(
ctx context.Context,
cfg Config,
aggLayerClient agglayer.AggLayerClient,
aggLayerClient agglayer.AgglayerClientInterface,
l1Syncer *bridgesync.BridgeSync,
l2Syncer *bridgesync.BridgeSync,
l1Client bridgesync.EthClienter,
Expand Down
4 changes: 3 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
AGGORACLE = "aggoracle"
// RPC name to identify the rpc component
RPC = "rpc"
// AGGSENDER name to identify the aggsender component
AGGSENDER = "aggsender"
)

const (
Expand Down Expand Up @@ -51,7 +53,7 @@ var (
Aliases: []string{"co"},
Usage: "List of components to run",
Required: false,
Value: cli.NewStringSlice(SEQUENCE_SENDER, AGGREGATOR, AGGORACLE, RPC),
Value: cli.NewStringSlice(SEQUENCE_SENDER, AGGREGATOR, AGGORACLE, RPC, AGGSENDER),
}
)

Expand Down
22 changes: 22 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import (
zkevm "github.com/0xPolygon/cdk"
dataCommitteeClient "github.com/0xPolygon/cdk-data-availability/client"
jRPC "github.com/0xPolygon/cdk-rpc/rpc"
"github.com/0xPolygon/cdk/agglayer"
"github.com/0xPolygon/cdk/aggoracle"
"github.com/0xPolygon/cdk/aggoracle/chaingersender"
"github.com/0xPolygon/cdk/aggregator"
"github.com/0xPolygon/cdk/aggregator/db"
"github.com/0xPolygon/cdk/aggsender"
"github.com/0xPolygon/cdk/bridgesync"
"github.com/0xPolygon/cdk/claimsponsor"
"github.com/0xPolygon/cdk/config"
Expand Down Expand Up @@ -106,6 +108,13 @@ func start(cliCtx *cli.Context) error {
log.Fatal(err)
}
}()
case AGGSENDER:
aggsender, err := createAggSender(cliCtx.Context, c.AggSender, l1BridgeSync, l2BridgeSync, l1Client, l2Client)
if err != nil {
log.Fatal(err)
}

go aggsender.Start(cliCtx.Context)
}
}

Expand All @@ -114,6 +123,19 @@ func start(cliCtx *cli.Context) error {
return nil
}

func createAggSender(
ctx context.Context,
cfg aggsender.Config,
l1Syncer *bridgesync.BridgeSync,
l2Syncer *bridgesync.BridgeSync,
l1Client bridgesync.EthClienter,
l2Client bridgesync.EthClienter,
) (*aggsender.AggSender, error) {
agglayerClient := agglayer.NewAggLayerClient(cfg.AggLayerUrl)

return aggsender.New(ctx, cfg, agglayerClient, l1Syncer, l2Syncer, l1Client, l2Client)
}

func createAggregator(ctx context.Context, c config.Config, runMigrations bool) *aggregator.Aggregator {
// Migrations
if runMigrations {
Expand Down

0 comments on commit 778fb96

Please sign in to comment.