From ded3c23e522cd049fe9c943f1d3aaefe32b85ab8 Mon Sep 17 00:00:00 2001 From: Bharath Date: Wed, 26 Jun 2024 12:01:15 +0530 Subject: [PATCH] parameterize rollup id to send to composer --- scenarios/eoatx/eoatx.go | 5 ++++- scenarios/erctx/erctx.go | 5 ++++- scenarios/gasburnertx/gasburnertx.go | 4 +++- scenarios/univ2tx/univ2tx.go | 4 +++- txbuilder/client.go | 8 +++----- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/scenarios/eoatx/eoatx.go b/scenarios/eoatx/eoatx.go index ab613f0..51010ed 100644 --- a/scenarios/eoatx/eoatx.go +++ b/scenarios/eoatx/eoatx.go @@ -36,6 +36,7 @@ type ScenarioOptions struct { RandomTarget bool ComposerAddress string SendViaComposer bool + RollupId string } type Scenario struct { @@ -68,6 +69,8 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error { flags.BoolVar(&s.options.RandomTarget, "random-target", false, "Use random to addresses for transactions") flags.BoolVar(&s.options.SendViaComposer, "send-via-composer", false, "Send transactions via composer") flags.StringVar(&s.options.ComposerAddress, "composer-address", "", "The address of composer to which to send txs to") + flags.StringVar(&s.options.RollupId, "rollup-id", "", "The rollup id of the evm rollup") + return nil } @@ -243,7 +246,7 @@ func (s *Scenario) sendTx(txIdx uint64) (*types.Transaction, *txbuilder.Client, } if s.options.SendViaComposer { - err = client.SendTransactionViaComposer(tx, s.composerConn) + err = client.SendTransactionViaComposer(tx, s.composerConn, s.options.RollupId) if err != nil { return nil, client, err } diff --git a/scenarios/erctx/erctx.go b/scenarios/erctx/erctx.go index 1211273..ff81a2a 100644 --- a/scenarios/erctx/erctx.go +++ b/scenarios/erctx/erctx.go @@ -36,6 +36,7 @@ type ScenarioOptions struct { RandomTarget bool ComposerAddress string SendViaComposer bool + RollupId string } type Scenario struct { @@ -70,6 +71,8 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error { flags.BoolVar(&s.options.RandomTarget, "random-target", false, "Use random to addresses for transactions") flags.StringVar(&s.options.ComposerAddress, "composer-address", "localhost:50051", "Address of the composer service") flags.BoolVar(&s.options.SendViaComposer, "send-via-composer", false, "Send transactions via composer") + flags.StringVar(&s.options.RollupId, "rollup-id", "", "The rollup id of the evm rollup") + return nil } @@ -325,7 +328,7 @@ func (s *Scenario) sendTx(txIdx uint64) (*types.Transaction, *txbuilder.Client, } if s.options.SendViaComposer { - err = client.SendTransactionViaComposer(tx, s.composerConn) + err = client.SendTransactionViaComposer(tx, s.composerConn, s.options.RollupId) if err != nil { return nil, client, err } diff --git a/scenarios/gasburnertx/gasburnertx.go b/scenarios/gasburnertx/gasburnertx.go index 453ef43..ef973cf 100644 --- a/scenarios/gasburnertx/gasburnertx.go +++ b/scenarios/gasburnertx/gasburnertx.go @@ -34,6 +34,7 @@ type ScenarioOptions struct { GasUnitsToBurn uint64 ComposerAddress string SendViaComposer bool + RollupId string } type Scenario struct { @@ -66,6 +67,7 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error { flags.Uint64Var(&s.options.GasUnitsToBurn, "gas-units-to-burn", 2000000, "The number of gas units for each tx to cost") flags.StringVar(&s.options.ComposerAddress, "composer-address", "localhost:50051", "Address of the composer service") flags.BoolVar(&s.options.SendViaComposer, "send-via-composer", false, "Send transactions via composer") + flags.StringVar(&s.options.RollupId, "", "", "The rollup id of the evm rollup") return nil } @@ -283,7 +285,7 @@ func (s *Scenario) sendTx(txIdx uint64) (*types.Transaction, *txbuilder.Client, } if s.options.SendViaComposer { - err = client.SendTransactionViaComposer(tx, s.composerConn) + err = client.SendTransactionViaComposer(tx, s.composerConn, s.options.RollupId) if err != nil { return nil, client, err } diff --git a/scenarios/univ2tx/univ2tx.go b/scenarios/univ2tx/univ2tx.go index c55d65e..83d972a 100644 --- a/scenarios/univ2tx/univ2tx.go +++ b/scenarios/univ2tx/univ2tx.go @@ -35,6 +35,7 @@ type ScenarioOptions struct { RandomAmountToSwap bool ComposerAddress string SendViaComposer bool + RollupId string } type Scenario struct { @@ -75,6 +76,7 @@ func (s *Scenario) Flags(flags *pflag.FlagSet) error { flag.BoolVar(&s.options.RandomAmountToSwap, "random-amount-to-swap", false, "Randomize the amount of tokens to swap in each transaction(in gwei)") flags.StringVar(&s.options.ComposerAddress, "composer-address", "localhost:50051", "Address of the composer service") flags.BoolVar(&s.options.SendViaComposer, "send-via-composer", false, "Send transactions via composer") + flags.StringVar(&s.options.RollupId, "", "", "The rollup id of the evm rollup") return nil } @@ -403,7 +405,7 @@ func (s *Scenario) sendTx(txIdx uint64) (*types.Transaction, *txbuilder.Client, } if s.options.SendViaComposer { - err = client.SendTransactionViaComposer(tx, s.composerConn) + err = client.SendTransactionViaComposer(tx, s.composerConn, s.options.RollupId) if err != nil { return nil, client, err } diff --git a/txbuilder/client.go b/txbuilder/client.go index fe3d037..ea8a653 100644 --- a/txbuilder/client.go +++ b/txbuilder/client.go @@ -154,20 +154,18 @@ func (client *Client) SendTransaction(tx *types.Transaction) error { return client.client.SendTransaction(client.getContext(), tx) } -func (client *Client) SendTransactionViaComposer(tx *types.Transaction, conn *grpc.ClientConn) error { +func (client *Client) SendTransactionViaComposer(tx *types.Transaction, conn *grpc.ClientConn, rollupId string) error { binaryTx, err := tx.MarshalBinary() if err != nil { return err } - client.logger.Infof("Sending tx via composer!") - - rollupId := sha256.Sum256([]byte("astria-dusk-7-evm")) + hashedRollupId := sha256.Sum256([]byte(rollupId)) grpcCollectorServiceClient := composerv1alpha1grpc.NewGrpcCollectorServiceClient(conn) // if the request succeeds, then an empty response will be returned which can be ignored for now _, err = grpcCollectorServiceClient.SubmitRollupTransaction(context.Background(), &astriaComposerPb.SubmitRollupTransactionRequest{ - RollupId: rollupId[:], + RollupId: hashedRollupId[:], Data: binaryTx, }) if err != nil {