Skip to content

Commit

Permalink
Fix getBlockHashes
Browse files Browse the repository at this point in the history
  • Loading branch information
avalkov committed Feb 24, 2025
1 parent 7f2fef3 commit 611d90a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion x/milestone/abci/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,25 @@ func getBlockHashes(ctx sdk.Context, startBlock uint64, contractCaller helper.IC
return nil, fmt.Errorf("failed to get latest header")
}

if startBlock > latestHeader.Number.Uint64() {
return nil, fmt.Errorf("start block number %d is greater than latest block number %d", startBlock, latestHeader.Number.Uint64())
}

result := make([][]byte, 0)
latestBlockNumber := latestHeader.Number.Uint64()

if latestBlockNumber-startBlock > maxBlocksInProposition {
fetchBlock := startBlock + maxBlocksInProposition
latestHeader, err := contractCaller.GetBorChainBlock(ctx, big.NewInt(int64(fetchBlock)))
latestHeader, err = contractCaller.GetBorChainBlock(ctx, big.NewInt(int64(fetchBlock)))
if err != nil {
return nil, fmt.Errorf("failed to get header for block number %d: %w", fetchBlock, err)
}

if latestHeader == nil {
return nil, fmt.Errorf("failed to get header for block number %d", fetchBlock)
}

latestBlockNumber = latestHeader.Number.Uint64()
}

for startBlock < latestBlockNumber {
Expand Down

0 comments on commit 611d90a

Please sign in to comment.