Skip to content

Commit b0793f4

Browse files
committed
minor fixes
1 parent 6ca2a3b commit b0793f4

5 files changed

Lines changed: 18 additions & 23 deletions

File tree

block/batch.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ import (
44
"sync"
55
)
66

7-
// BatchQueue is a queue of transactions
7+
// BatchQueue is a queue of transaction batches with timestamps
88
type BatchQueue struct {
99
queue []BatchWithTime
1010
mu sync.Mutex
1111
}
1212

13-
// NewBatchQueue creates a new TransactionQueue
13+
// NewBatchQueue creates a new BatchQueue
1414
func NewBatchQueue() *BatchQueue {
1515
return &BatchQueue{
1616
queue: make([]BatchWithTime, 0),
1717
}
1818
}
1919

20-
// AddBatch adds a new transaction to the queue
20+
// AddBatch adds a new batch to the queue
2121
func (bq *BatchQueue) AddBatch(batch BatchWithTime) {
2222
bq.mu.Lock()
2323
defer bq.mu.Unlock()
2424
bq.queue = append(bq.queue, batch)
2525
}
2626

27-
// Next returns the next transaction in the queue
27+
// Next returns the next batch in the queue
2828
func (bq *BatchQueue) Next() *BatchWithTime {
2929
bq.mu.Lock()
3030
defer bq.mu.Unlock()

block/manager.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
goheaderstore "github.com/celestiaorg/go-header/store"
2929

3030
"github.com/rollkit/go-sequencing"
31-
seqGRPC "github.com/rollkit/go-sequencing/proxy/grpc"
31+
"github.com/rollkit/go-sequencing/proxy/grpc"
3232
"github.com/rollkit/rollkit/config"
3333
"github.com/rollkit/rollkit/da"
3434
"github.com/rollkit/rollkit/mempool"
@@ -161,7 +161,7 @@ type Manager struct {
161161
// in the DA
162162
daIncludedHeight atomic.Uint64
163163
// grpc client for sequencing middleware
164-
seqClient *seqGRPC.Client
164+
seqClient *grpc.Client
165165
lastBatchHash []byte
166166
bq *BatchQueue
167167
}
@@ -199,7 +199,7 @@ func NewManager(
199199
store store.Store,
200200
mempool mempool.Mempool,
201201
mempoolReaper *mempool.CListMempoolReaper,
202-
seqClient *seqGRPC.Client,
202+
seqClient *grpc.Client,
203203
proxyApp proxy.AppConnConsensus,
204204
dalc *da.DAClient,
205205
eventBus *cmtypes.EventBus,
@@ -815,9 +815,6 @@ func (m *Manager) getHeadersFromHeaderStore(ctx context.Context, startHeight, en
815815
if startHeight > endHeight {
816816
return nil, fmt.Errorf("startHeight (%d) is greater than endHeight (%d)", startHeight, endHeight)
817817
}
818-
if startHeight == 0 {
819-
startHeight++
820-
}
821818
headers := make([]*types.SignedHeader, endHeight-startHeight+1)
822819
for i := startHeight; i <= endHeight; i++ {
823820
header, err := m.headerStore.GetByHeight(ctx, i)
@@ -833,9 +830,6 @@ func (m *Manager) getDataFromDataStore(ctx context.Context, startHeight, endHeig
833830
if startHeight > endHeight {
834831
return nil, fmt.Errorf("startHeight (%d) is greater than endHeight (%d)", startHeight, endHeight)
835832
}
836-
if startHeight == 0 {
837-
startHeight++
838-
}
839833
data := make([]*types.Data, endHeight-startHeight+1)
840834
for i := startHeight; i <= endHeight; i++ {
841835
d, err := m.dataStore.GetByHeight(ctx, i)

block/pending_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestPendingBlocks(t *testing.T) {
3434
},
3535
{
3636
name: "mock successful DA submission of some blocks by manually setting last submitted height",
37-
init: fillWithBlocks,
37+
init: fillWithBlockData,
3838
exec: func(ctx context.Context, t *testing.T, pb *PendingHeaders) {
3939
pb.lastSubmittedHeight.Store(testHeight)
4040
},
@@ -43,7 +43,7 @@ func TestPendingBlocks(t *testing.T) {
4343
},
4444
{
4545
name: "mock successful DA submission of all blocks by manually setting last submitted height",
46-
init: fillWithBlocks,
46+
init: fillWithBlockData,
4747
exec: func(ctx context.Context, t *testing.T, pb *PendingHeaders) {
4848
pb.lastSubmittedHeight.Store(numBlocks)
4949
},
@@ -52,7 +52,7 @@ func TestPendingBlocks(t *testing.T) {
5252
},
5353
{
5454
name: "mock successful DA submission of all blocks by setting last submitted height using store",
55-
init: fillWithBlocks,
55+
init: fillWithBlockData,
5656
exec: func(ctx context.Context, t *testing.T, pb *PendingHeaders) {
5757
pb.lastSubmittedHeight.Store(pb.store.Height())
5858
},
@@ -85,7 +85,7 @@ func newPendingBlocks(t *testing.T) *PendingHeaders {
8585
return pendingBlocks
8686
}
8787

88-
func fillWithBlocks(ctx context.Context, t *testing.T, pb *PendingHeaders) {
88+
func fillWithBlockData(ctx context.Context, t *testing.T, pb *PendingHeaders) {
8989
for i := uint64(1); i <= numBlocks; i++ {
9090
h, d := types.GetRandomBlock(i, 0)
9191
require.NoError(t, pb.store.SaveBlockData(ctx, h, d, &types.Signature{}))

mempool/reaper.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
cmtypes "github.com/cometbft/cometbft/types"
99

1010
"github.com/cometbft/cometbft/libs/log"
11-
seqGRPC "github.com/rollkit/go-sequencing/proxy/grpc"
11+
"github.com/rollkit/go-sequencing/proxy/grpc"
1212
)
1313

1414
// ReapInterval is the interval at which the reaper checks the mempool for transactions to reap.
@@ -22,16 +22,16 @@ const (
2222
type CListMempoolReaper struct {
2323
mempool Mempool
2424
stopCh chan struct{}
25-
grpcClient *seqGRPC.Client
25+
grpcClient *grpc.Client
2626
ctx context.Context
2727
rollupId []byte
2828
submitted map[cmtypes.TxKey]struct{}
2929
mu sync.RWMutex // Add a mutex to protect the submitted map
3030
logger log.Logger
3131
}
3232

33-
// NewCListMempool initializes the mempool and sets up the gRPC client.
34-
func NewCListMempoolReaper(mempool Mempool, rollupId []byte, seqClient *seqGRPC.Client, logger log.Logger) *CListMempoolReaper {
33+
// NewCListMempoolReaper initializes the mempool and sets up the gRPC client.
34+
func NewCListMempoolReaper(mempool Mempool, rollupId []byte, seqClient *grpc.Client, logger log.Logger) *CListMempoolReaper {
3535
return &CListMempoolReaper{
3636
mempool: mempool,
3737
stopCh: make(chan struct{}),
@@ -61,6 +61,7 @@ func (r *CListMempoolReaper) StartReaper() error {
6161
return nil
6262
}
6363

64+
// UpdateCommitedTxs removes the committed transactions from the submitted map.
6465
func (r *CListMempoolReaper) UpdateCommitedTxs(txs []cmtypes.Tx) {
6566
r.mu.Lock() // Lock the mutex before modifying the map
6667
defer r.mu.Unlock()

sequencing/mock/cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"os/signal"
99
"syscall"
1010

11-
seqGRPC "github.com/rollkit/go-sequencing/proxy/grpc"
11+
"github.com/rollkit/go-sequencing/proxy/grpc"
1212
"github.com/rollkit/go-sequencing/test"
1313
)
1414

@@ -25,7 +25,7 @@ func main() {
2525

2626
dummySequencer := test.NewDummySequencer()
2727

28-
srv := seqGRPC.NewServer(dummySequencer, dummySequencer, dummySequencer)
28+
srv := grpc.NewServer(dummySequencer, dummySequencer, dummySequencer)
2929
log.Printf("Listening on: %s:%s", "localhost", "50051")
3030
if err := srv.Serve(lis); err != nil {
3131
log.Fatal("error while serving:", err)

0 commit comments

Comments
 (0)