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

chore: use RFC3339 for bundles timestamp (backport #110) #112

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion proto/kyve/query/v1beta1/bundles.proto
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ message FinalizedAt {
// height is the block height in which the bundle got finalized.
string height = 1 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
// timestamp is the UNIX timestamp of the block in which the bundle got finalized.
string timestamp = 2 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
string timestamp = 2;
}

// StakeSecurity represents the relative security of a finalized bundle
Expand Down
6 changes: 5 additions & 1 deletion testutil/integration/checks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"time"

"github.com/KYVENetwork/chain/x/bundles"
bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types"
"github.com/KYVENetwork/chain/x/delegation"
Expand Down Expand Up @@ -274,7 +276,9 @@ func checkFinalizedBundle(queryBundle querytypes.FinalizedBundle, rawBundle bund
Expect(queryBundle.BundleSummary).To(Equal(rawBundle.BundleSummary))
Expect(queryBundle.DataHash).To(Equal(rawBundle.DataHash))
Expect(queryBundle.FinalizedAt.Height.Uint64()).To(Equal(rawBundle.FinalizedAt.Height))
Expect(queryBundle.FinalizedAt.Timestamp.Uint64()).To(Equal(rawBundle.FinalizedAt.Timestamp))
date, dateErr := time.Parse(time.RFC3339, queryBundle.FinalizedAt.Timestamp)
Expect(dateErr).To(BeNil())
Expect(uint64(date.Unix())).To(Equal(rawBundle.FinalizedAt.Timestamp))
Expect(queryBundle.FromKey).To(Equal(rawBundle.FromKey))
Expect(queryBundle.StorageProviderId).To(Equal(uint64(rawBundle.StorageProviderId)))
Expect(queryBundle.CompressionId).To(Equal(uint64(rawBundle.CompressionId)))
Expand Down
4 changes: 2 additions & 2 deletions x/bundles/keeper/getters_bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"encoding/binary"
"fmt"
"time"

cosmossdk_io_math "cosmossdk.io/math"

Expand Down Expand Up @@ -120,7 +121,6 @@ func (k Keeper) GetFinalizedBundle(ctx sdk.Context, poolId, id uint64) (val type

func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap map[int32]uint64) (queryBundle queryTypes.FinalizedBundle) {
finalizedHeight := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.FinalizedAt.Height))
finalizedTimestamp := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.FinalizedAt.Timestamp))

finalizedBundle := queryTypes.FinalizedBundle{
PoolId: rawFinalizedBundle.PoolId,
Expand All @@ -134,7 +134,7 @@ func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap
DataHash: rawFinalizedBundle.DataHash,
FinalizedAt: &queryTypes.FinalizedAt{
Height: &finalizedHeight,
Timestamp: &finalizedTimestamp,
Timestamp: time.Unix(int64(rawFinalizedBundle.FinalizedAt.Timestamp), 0).Format(time.RFC3339),
},
FromKey: rawFinalizedBundle.FromKey,
StorageProviderId: uint64(rawFinalizedBundle.StorageProviderId),
Expand Down
2 changes: 1 addition & 1 deletion x/query/spec/01_concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ returned. The different version are explained below.
"data_hash": "string",
"finalized_at": {
"height": "number",
"timestamp": "number"
"timestamp": "RFC3339 date string"
},
"from_key": "number",
"storage_provider_id": "number",
Expand Down
182 changes: 90 additions & 92 deletions x/query/types/bundles.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.