Skip to content

Commit

Permalink
fix(zkevm_api): getBatchByNumber batch 0 response
Browse files Browse the repository at this point in the history
fixes #958
  • Loading branch information
revitteth committed Aug 14, 2024
1 parent a0e6f21 commit 896dea3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/rpcdaemon/commands/zkevm_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,12 @@ func generateBatchData(
batchBlocks []*eritypes.Block,
forkId uint64,
) (batchL2Data []byte, err error) {
lastBlockNoInPreviousBatch := batchBlocks[0].NumberU64() - 1

lastBlockNoInPreviousBatch := uint64(0)
if batchBlocks[0].NumberU64() != 0 {
lastBlockNoInPreviousBatch = batchBlocks[0].NumberU64() - 1
}

lastBlockInPreviousBatch, err := rawdb.ReadBlockByNumber(tx, lastBlockNoInPreviousBatch)
if err != nil {
return nil, err
Expand Down Expand Up @@ -468,7 +473,7 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
if err != nil {
return nil, err
}
if !found {
if !found && batchNo != 0 {
return nil, nil
}

Expand Down Expand Up @@ -1385,13 +1390,11 @@ func populateBatchDetails(batch *types.Batch) (json.RawMessage, error) {
jBatch["localExitRoot"] = batch.LocalExitRoot
jBatch["sendSequencesTxHash"] = batch.SendSequencesTxHash
jBatch["verifyBatchTxHash"] = batch.VerifyBatchTxHash
jBatch["accInputHash"] = batch.AccInputHash

if batch.ForcedBatchNumber != nil {
jBatch["forcedBatchNumber"] = batch.ForcedBatchNumber
}
if batch.AccInputHash != (common.Hash{}) {
jBatch["accInputHash"] = batch.AccInputHash
}
jBatch["closed"] = batch.Closed
if len(batch.BatchL2Data) > 0 {
jBatch["batchL2Data"] = batch.BatchL2Data
Expand Down

0 comments on commit 896dea3

Please sign in to comment.