Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made it so that it always returned an event when cyclelist is rotated #442

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions x/oracle/keeper/cycle_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"encoding/hex"
"errors"
"strconv"

Expand Down Expand Up @@ -79,6 +80,7 @@ func (k Keeper) RotateQueries(ctx context.Context) error {
}
querymeta.CycleList = true
querymeta.Expiration = uint64(blockHeight) + querymeta.RegistrySpecBlockWindow
emitRotateQueriesEvent(sdkCtx, hex.EncodeToString(queryId), strconv.Itoa(int(querymeta.Id)))
return k.Query.Set(ctx, collections.Join(queryId, querymeta.Id), querymeta)

}
Expand All @@ -89,6 +91,7 @@ func (k Keeper) RotateQueries(ctx context.Context) error {
if querymeta.Expiration <= uint64(blockHeight) && !querymeta.HasRevealedReports { // wrong, shouldn't use same query if expired
querymeta.Expiration = uint64(blockHeight) + querymeta.RegistrySpecBlockWindow
}
emitRotateQueriesEvent(sdkCtx, hex.EncodeToString(queryId), strconv.Itoa(int(querymeta.Id)))

return k.Query.Set(ctx, collections.Join(queryId, querymeta.Id), querymeta)
}
Expand All @@ -97,14 +100,7 @@ func (k Keeper) RotateQueries(ctx context.Context) error {
if err != nil {
return err
}
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
"rotating-cyclelist-with-existing-nontipped-query",
sdk.NewAttribute("query_id", string(queryId)),
sdk.NewAttribute("Old QueryMeta Id", strconv.Itoa(int(querymeta.Id))),
sdk.NewAttribute("New QueryMeta Id", strconv.Itoa(int(nextId))),
),
})
emitRotateQueriesEvent(sdkCtx, hex.EncodeToString(queryId), strconv.Itoa(int(nextId)))
querymeta.Id = nextId
querymeta.Expiration = uint64(blockHeight) + querymeta.RegistrySpecBlockWindow
querymeta.HasRevealedReports = false
Expand All @@ -113,6 +109,16 @@ func (k Keeper) RotateQueries(ctx context.Context) error {
return k.Query.Set(ctx, collections.Join(queryId, querymeta.Id), querymeta)
}

func emitRotateQueriesEvent(sdkCtx sdk.Context, queryId, nextId string) {
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
"rotating-cyclelist-with-next-query",
sdk.NewAttribute("query_id", queryId),
sdk.NewAttribute("New QueryMeta Id", nextId),
),
})
}

func (k Keeper) ClearOldqueries(ctx context.Context, queryId []byte) error {
rng := collections.NewPrefixedPairRange[[]byte, uint64](queryId)

Expand Down
Loading