Skip to content

Commit

Permalink
Merge pull request #42 from astriaorg/bharath/parameterize-rollup-id
Browse files Browse the repository at this point in the history
chore: parameterize rollup id needed for sending sequence action to composer
  • Loading branch information
bharath-123 authored Jun 26, 2024
2 parents 4416d70 + ded3c23 commit 6472fb4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
5 changes: 4 additions & 1 deletion scenarios/eoatx/eoatx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type ScenarioOptions struct {
RandomTarget bool
ComposerAddress string
SendViaComposer bool
RollupId string
}

type Scenario struct {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion scenarios/erctx/erctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type ScenarioOptions struct {
RandomTarget bool
ComposerAddress string
SendViaComposer bool
RollupId string
}

type Scenario struct {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion scenarios/gasburnertx/gasburnertx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ScenarioOptions struct {
GasUnitsToBurn uint64
ComposerAddress string
SendViaComposer bool
RollupId string
}

type Scenario struct {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion scenarios/univ2tx/univ2tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ScenarioOptions struct {
RandomAmountToSwap bool
ComposerAddress string
SendViaComposer bool
RollupId string
}

type Scenario struct {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 3 additions & 5 deletions txbuilder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6472fb4

Please sign in to comment.