diff --git a/x/qgb/abci.go b/x/qgb/abci.go index 2ab185b555..048022a588 100644 --- a/x/qgb/abci.go +++ b/x/qgb/abci.go @@ -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) @@ -52,7 +53,7 @@ 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 @@ -60,7 +61,7 @@ func handleDataCommitmentRequest(ctx sdk.Context, k keeper.Keeper) { } } 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