diff --git a/proxy/grpc/client.go b/proxy/grpc/client.go index 8a234a3..029f4f8 100644 --- a/proxy/grpc/client.go +++ b/proxy/grpc/client.go @@ -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 } @@ -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 } diff --git a/proxy/grpc/server.go b/proxy/grpc/server.go index 5f2516e..ab44c4e 100644 --- a/proxy/grpc/server.go +++ b/proxy/grpc/server.go @@ -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) } @@ -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) } diff --git a/serialization.go b/serialization.go index 6138bf3..91c78e1 100644 --- a/serialization.go +++ b/serialization.go @@ -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.