Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit e261069

Browse files
authored
Revert "Change data stream format (#3597)" (#3603)
This reverts commit 5a76fb5.
1 parent 5a76fb5 commit e261069

File tree

16 files changed

+817
-1537
lines changed

16 files changed

+817
-1537
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ generate-code-from-proto: ## Generates code from proto files
164164
cd proto/src/proto/hashdb/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../merkletree/hashdb --go-grpc_out=../../../../../merkletree/hashdb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative hashdb.proto
165165
cd proto/src/proto/executor/v1 && protoc --proto_path=. --go_out=../../../../../state/runtime/executor --go-grpc_out=../../../../../state/runtime/executor --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative executor.proto
166166
cd proto/src/proto/aggregator/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../aggregator/prover --go-grpc_out=../../../../../aggregator/prover --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative aggregator.proto
167-
cd proto/src/proto/datastream/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../state/datastream --go-grpc_out=../../../../../state/datastream --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative datastream.proto
168167

169168
## Help display.
170169
## Pulls comments from beside commands and prints a nicely formatted

proto/src/proto/datastream/v1/datastream.proto

Lines changed: 0 additions & 64 deletions
This file was deleted.

sequencer/batch.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type Batch struct {
2626
imRemainingResources state.BatchResources // remaining batch resources when processing tx-by-tx
2727
finalRemainingResources state.BatchResources // remaining batch resources when a L2 block is processed
2828
closingReason state.ClosingReason
29-
finalLocalExitRoot common.Hash
3029
}
3130

3231
func (w *Batch) isEmpty() bool {
@@ -95,7 +94,6 @@ func (f *finalizer) setWIPBatch(ctx context.Context, wipStateBatch *state.Batch)
9594
countOfTxs: wipStateBatchCountOfTxs,
9695
imRemainingResources: remainingResources,
9796
finalRemainingResources: remainingResources,
98-
finalLocalExitRoot: wipStateBatch.LocalExitRoot,
9997
}
10098

10199
return wipBatch, nil
@@ -295,7 +293,6 @@ func (f *finalizer) openNewWIPBatch(ctx context.Context, batchNumber uint64, sta
295293
imRemainingResources: maxRemainingResources,
296294
finalRemainingResources: maxRemainingResources,
297295
closingReason: state.EmptyClosingReason,
298-
finalLocalExitRoot: newStateBatch.LocalExitRoot,
299296
}, err
300297
}
301298

@@ -331,9 +328,6 @@ func (f *finalizer) closeWIPBatch(ctx context.Context) error {
331328
log.Errorf("error committing close wip batch, error: %v", err)
332329
return err
333330
}
334-
335-
// Sent batch to DS
336-
f.DSSendBatch(f.wipBatch.batchNumber, f.wipBatch.finalStateRoot, f.wipBatch.finalLocalExitRoot)
337331
}
338332

339333
return nil

sequencer/datastreamer.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,22 @@ package sequencer
33
import (
44
"github.com/0xPolygonHermez/zkevm-node/log"
55
"github.com/0xPolygonHermez/zkevm-node/state"
6-
"github.com/0xPolygonHermez/zkevm-node/state/datastream"
7-
"github.com/ethereum/go-ethereum/common"
86
)
97

10-
func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32, minTimestamp uint64) error {
8+
func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.ProcessBlockResponse, l1InfoTreeIndex uint32) error {
119
forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber)
1210

1311
// Send data to streamer
1412
if f.streamServer != nil {
1513
l2Block := state.DSL2Block{
1614
BatchNumber: batchNumber,
1715
L2BlockNumber: blockResponse.BlockNumber,
18-
Timestamp: blockResponse.Timestamp,
19-
Min_timestamp: minTimestamp,
16+
Timestamp: int64(blockResponse.Timestamp),
2017
L1InfoTreeIndex: l1InfoTreeIndex,
2118
L1BlockHash: blockResponse.BlockHashL1,
2219
GlobalExitRoot: blockResponse.GlobalExitRoot,
2320
Coinbase: f.sequencerAddress,
24-
ForkID: forkID,
21+
ForkID: uint16(forkID),
2522
BlockHash: blockResponse.BlockHash,
2623
StateRoot: blockResponse.BlockHash, //From etrog, the blockhash is the block root
2724
}
@@ -60,23 +57,9 @@ func (f *finalizer) DSSendBatchBookmark(batchNumber uint64) {
6057
// Check if stream server enabled
6158
if f.streamServer != nil {
6259
// Send batch bookmark to the streamer
63-
f.dataToStream <- datastream.BookMark{
64-
Type: datastream.BookmarkType_BOOKMARK_TYPE_BATCH,
60+
f.dataToStream <- state.DSBookMark{
61+
Type: state.BookMarkTypeBatch,
6562
Value: batchNumber,
6663
}
6764
}
6865
}
69-
70-
func (f *finalizer) DSSendBatch(batchNumber uint64, stateRoot common.Hash, localExitRoot common.Hash) {
71-
forkID := f.stateIntf.GetForkIDByBatchNumber(batchNumber)
72-
73-
if f.streamServer != nil {
74-
// Send batch to the streamer
75-
f.dataToStream <- datastream.Batch{
76-
Number: batchNumber,
77-
ForkId: forkID,
78-
StateRoot: stateRoot.Bytes(),
79-
LocalExitRoot: localExitRoot.Bytes(),
80-
}
81-
}
82-
}

sequencer/finalizer_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ func TestFinalizer_closeWIPBatch(t *testing.T) {
981981
// arrange
982982
stateMock.Mock.On("CloseWIPBatch", ctx, receipt, mock.Anything).Return(tc.managerErr).Once()
983983
stateMock.On("BeginStateTransaction", ctx).Return(dbTxMock, nilErr).Once()
984-
stateMock.On("GetForkIDByBatchNumber", mock.Anything).Return(uint64(state.FORKID_BLUEBERRY))
985984
if tc.managerErr == nil {
986985
dbTxMock.On("Commit", ctx).Return(nilErr).Once()
987986
} else {

sequencer/forcedbatch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (f *finalizer) handleProcessForcedBatchResponse(ctx context.Context, newBat
197197
}
198198

199199
// Send L2 block to data streamer
200-
err = f.DSSendL2Block(newBatchNumber, forcedL2BlockResponse, 0, forcedL2BlockResponse.Timestamp)
200+
err = f.DSSendL2Block(newBatchNumber, forcedL2BlockResponse, 0)
201201
if err != nil {
202202
//TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer?
203203
log.Errorf("error sending L2 block %d to data streamer, error: %v", forcedL2BlockResponse.BlockNumber, err)

sequencer/l2block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error {
427427
log.Infof("l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum)
428428

429429
// Send L2 block to data streamer
430-
err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex(), l2Block.timestamp)
430+
err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex())
431431
if err != nil {
432432
//TODO: we need to halt/rollback the L2 block if we had an error sending to the data streamer?
433433
log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)

0 commit comments

Comments
 (0)