Skip to content

Commit

Permalink
fix versioned parameter issue
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Mar 8, 2024
1 parent 88850b9 commit b12488c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions x/payment/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ func (k Keeper) SetVersionedParamsWithTs(ctx sdk.Context, verParams types.Versio
func (k Keeper) GetVersionedParamsWithTs(ctx sdk.Context, ts int64) (verParams types.VersionedParams, err error) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VersionedParamsKeyPrefix)

// ReverseIterator will exclusive end, so we increment ts by 1
startKey := types.VersionedParamsKey(ts + 1)
// params are updated in the endblock, so we do not need to make the ts to be included
// for example, if the params is updated in 100 timestamp: the txs that are executed in 100 timestamp
// will use the old parameter, after 100 timestamp, when we passing 100 to query, we should still get
// the old parameter.
startKey := types.VersionedParamsKey(ts)
iterator := store.ReverseIterator(nil, startKey)
defer iterator.Close()
if !iterator.Valid() {
Expand Down
7 changes: 5 additions & 2 deletions x/storage/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,11 @@ func (k Keeper) SetVersionedParamsWithTs(ctx sdk.Context, verParams types.Versio
func (k Keeper) GetVersionedParamsWithTs(ctx sdk.Context, ts int64) (verParams types.VersionedParams, err error) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VersionedParamsKeyPrefix)

// ReverseIterator will exclusive end, so we increment ts by 1
startKey := types.GetParamsKeyWithTimestamp(ts + 1)
// params are updated in the endblock, so we do not need to make the ts to be included
// for example, if the params is updated in 100 timestamp: the txs that are executed in 100 timestamp
// will use the old parameter, after 100 timestamp, when we passing 100 to query, we should still get
// the old parameter.
startKey := types.GetParamsKeyWithTimestamp(ts)
iterator := store.ReverseIterator(nil, startKey)
defer iterator.Close()
if !iterator.Valid() {
Expand Down

0 comments on commit b12488c

Please sign in to comment.