Skip to content
This repository was archived by the owner on May 2, 2025. It is now read-only.
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
23 changes: 7 additions & 16 deletions sequencing.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,15 @@ type BatchVerifier interface {
VerifyBatch(ctx context.Context, req VerifyBatchRequest) (*VerifyBatchResponse, error)
}

// RollupId is a unique identifier for a rollup chain
type RollupId = []byte

// Tx is a rollup transaction
type Tx = []byte

// Hash is a cryptographic hash of the Batch
type Hash = []byte

// Batch is a collection of transactions
type Batch struct {
Transactions []Tx
Transactions [][]byte
}

// SubmitRollupTransactionRequest is a request to submit a transaction from rollup to sequencer
type SubmitRollupTransactionRequest struct {
RollupId RollupId
Tx Tx
RollupId []byte
Tx []byte
}

// SubmitRollupTransactionResponse is a response to submitting a transaction from rollup to sequencer
Expand All @@ -66,8 +57,8 @@ type SubmitRollupTransactionResponse struct {

// GetNextBatchRequest is a request to get the next batch of transactions from sequencer to rollup
type GetNextBatchRequest struct {
RollupId RollupId
LastBatchHash Hash
RollupId []byte
LastBatchHash []byte
MaxBytes uint64
}

Expand All @@ -79,8 +70,8 @@ type GetNextBatchResponse struct {

// VerifyBatchRequest is a request to verify a batch of transactions received from the sequencer
type VerifyBatchRequest struct {
RollupId RollupId
BatchHash Hash
RollupId []byte
BatchHash []byte
}

// VerifyBatchResponse is a response to verifying a batch of transactions received from the sequencer
Expand Down
22 changes: 2 additions & 20 deletions serialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,12 @@ import (

// ToProto serializes a batch to a protobuf message.
func (batch *Batch) ToProto() *pbseq.Batch {
return &pbseq.Batch{Transactions: txsToByteSlices(batch.Transactions)}
return &pbseq.Batch{Transactions: batch.Transactions}
}

// FromProto deserializes a batch from a protobuf message.
func (batch *Batch) FromProto(pb *pbseq.Batch) {
batch.Transactions = byteSlicesToTxs(pb.Transactions)
}

func txsToByteSlices(txs []Tx) [][]byte {
if txs == nil {
return nil
}
bytes := make([][]byte, len(txs))
copy(bytes, txs)
return bytes
}

func byteSlicesToTxs(bytes [][]byte) []Tx {
if len(bytes) == 0 {
return nil
}
txs := make([]Tx, len(bytes))
copy(txs, bytes)
return txs
batch.Transactions = pb.Transactions
}

// Marshal serializes a batch to a byte slice.
Expand Down
6 changes: 3 additions & 3 deletions test/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ var ErrInvalidRollupId = errors.New("invalid rollup id")

// TransactionQueue is a queue of transactions
type TransactionQueue struct {
queue []sequencing.Tx
queue [][]byte
mu sync.Mutex
}

// NewTransactionQueue creates a new TransactionQueue
func NewTransactionQueue() *TransactionQueue {
return &TransactionQueue{
queue: make([]sequencing.Tx, 0),
queue: make([][]byte, 0),
}
}

// AddTransaction adds a new transaction to the queue
func (tq *TransactionQueue) AddTransaction(tx sequencing.Tx) {
func (tq *TransactionQueue) AddTransaction(tx []byte) {
tq.mu.Lock()
defer tq.mu.Unlock()
tq.queue = append(tq.queue, tx)
Expand Down
Loading