Skip to content

Commit

Permalink
client cannot send nil to server
Browse files Browse the repository at this point in the history
  • Loading branch information
gupadhyaya committed Aug 19, 2024
1 parent f6a7775 commit 2aa5751
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
16 changes: 2 additions & 14 deletions proxy/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ func (c *Client) SubmitRollupTransaction(ctx context.Context, rollupId []byte, t

// GetNextBatch returns the next batch of transactions from sequencer to rollup.
func (c *Client) GetNextBatch(ctx context.Context, lastBatch *sequencing.Batch) (*sequencing.Batch, error) {
var lbProto *pbseq.Batch
if lastBatch == nil {
lbProto = nil
} else {
lbProto = lastBatch.ToProto()
}
resp, err := c.SequencerOutputClient.GetNextBatch(ctx, lbProto)
resp, err := c.SequencerOutputClient.GetNextBatch(ctx, lastBatch.ToProto())
if err != nil {
return nil, err
}
Expand All @@ -70,13 +64,7 @@ func (c *Client) GetNextBatch(ctx context.Context, lastBatch *sequencing.Batch)

// VerifyBatch verifies a batch of transactions received from the sequencer.
func (c *Client) VerifyBatch(ctx context.Context, batch *sequencing.Batch) (bool, error) {
var bProto *pbseq.Batch
if batch == nil {
bProto = nil
} else {
bProto = batch.ToProto()
}
resp, err := c.BatchVerifierClient.VerifyBatch(ctx, bProto)
resp, err := c.BatchVerifierClient.VerifyBatch(ctx, batch.ToProto())
if err != nil {
return false, err
}
Expand Down
4 changes: 2 additions & 2 deletions proxy/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *proxyInputSrv) SubmitRollupTransaction(ctx context.Context, req *pbseq.
// GetNextBatch returns the next batch of transactions from sequencer to rollup.
func (s *proxyOutputSrv) GetNextBatch(ctx context.Context, req *pbseq.Batch) (*pbseq.Batch, error) {
var lastBatch *sequencing.Batch
if req != nil {
if req.Transactions != nil {
lastBatch = &sequencing.Batch{}
lastBatch.FromProto(req)
}
Expand All @@ -71,7 +71,7 @@ func (s *proxyOutputSrv) GetNextBatch(ctx context.Context, req *pbseq.Batch) (*p
// VerifyBatch verifies a batch of transactions received from the sequencer.
func (s *proxyVerificationSrv) VerifyBatch(ctx context.Context, req *pbseq.Batch) (*pbseq.VerificationResponse, error) {
var batch *sequencing.Batch
if req != nil {
if req.Transactions != nil {
batch = &sequencing.Batch{}
batch.FromProto(req)
}
Expand Down
6 changes: 5 additions & 1 deletion serialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import (

// ToProto serializes a batch to a protobuf message.
func (batch *Batch) ToProto() *pbseq.Batch {
return &pbseq.Batch{Transactions: txsToByteSlices(batch.Transactions)}
var txs [][]byte
if batch != nil {
txs = batch.Transactions
}
return &pbseq.Batch{Transactions: txsToByteSlices(txs)}
}

// FromProto deserializes a batch from a protobuf message.
Expand Down

0 comments on commit 2aa5751

Please sign in to comment.