Skip to content

Commit

Permalink
feat: gas optimization in qgb end blocker (celestiaorg#1800)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

closes celestiaorg#1778
<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [ ] New and updated code has appropriate documentation
- [ ] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords
  • Loading branch information
rach-id committed May 23, 2023
1 parent 79c6684 commit 7075501
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions x/qgb/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func handleDataCommitmentRequest(ctx sdk.Context, k keeper.Keeper) {
panic(err)
}
}
dataCommitmentWindow := int64(k.GetDataCommitmentWindowParam(ctx))
// this will keep executing until all the needed data commitments are created and we catchup to the current height
for {
hasLastDataCommitment, err := k.HasDataCommitmentInStore(ctx)
Expand All @@ -52,15 +53,15 @@ func handleDataCommitmentRequest(ctx sdk.Context, k keeper.Keeper) {
if err != nil {
panic(err)
}
if ctx.BlockHeight()-int64(lastDataCommitment.EndBlock) >= int64(k.GetDataCommitmentWindowParam(ctx)) {
if ctx.BlockHeight()-int64(lastDataCommitment.EndBlock) >= dataCommitmentWindow {
setDataCommitmentAttestation()
} else {
// the needed data commitments are already created and we need to wait for the next window to elapse
break
}
} else {
// if the store doesn't have a data commitment, we check if the window has passed to create a new data commitment
if ctx.BlockHeight() >= int64(k.GetDataCommitmentWindowParam(ctx)) {
if ctx.BlockHeight() >= dataCommitmentWindow {
setDataCommitmentAttestation()
} else {
// the first data commitment window hasn't elapsed yet to create a commitment
Expand Down

0 comments on commit 7075501

Please sign in to comment.