Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: parameterize rollup id needed for sending sequence action to composer #42

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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