diff --git a/CHANGELOG.md b/CHANGELOG.md index d8e74bccce1..1772d2bb7ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -172,6 +172,7 @@ - [8729](https://github.com/vegaprotocol/vega/issues/8729) - Stop order direction not set in datanode - [8545](https://github.com/vegaprotocol/vega/issues/8545) - Block Explorer pagination does not order correctly. - [8748](https://github.com/vegaprotocol/vega/issues/8748) - `ListSuccessorMarkets` does not return results. +- [9784](https://github.com/vegaprotocol/vega/issues/9784) - Referral timestamp consistency - [8749](https://github.com/vegaprotocol/vega/issues/8749) - Ensure stop order expiry is in the future - [9337](https://github.com/vegaprotocol/vega/issues/9337) - Non deterministic ordering of vesting ledger events - [8773](https://github.com/vegaprotocol/vega/issues/8773) - Fix panic with stop orders diff --git a/datanode/gateway/graphql/generated.go b/datanode/gateway/graphql/generated.go index 673d18e4c16..0feebe51eeb 100644 --- a/datanode/gateway/graphql/generated.go +++ b/datanode/gateway/graphql/generated.go @@ -2608,6 +2608,7 @@ type CoreSnapshotDataResolver interface { type CurrentReferralProgramResolver interface { Version(ctx context.Context, obj *v2.ReferralProgram) (int, error) + EndOfProgramTimestamp(ctx context.Context, obj *v2.ReferralProgram) (string, error) WindowLength(ctx context.Context, obj *v2.ReferralProgram) (int, error) } type DataSourceDefinitionResolver interface { @@ -3302,12 +3303,13 @@ type UpdateSpotMarketConfigurationResolver interface { } type UpdateVolumeDiscountProgramResolver interface { BenefitTiers(ctx context.Context, obj *vega.UpdateVolumeDiscountProgram) ([]*vega.VolumeBenefitTier, error) - EndOfProgramTimestamp(ctx context.Context, obj *vega.UpdateVolumeDiscountProgram) (int64, error) + EndOfProgramTimestamp(ctx context.Context, obj *vega.UpdateVolumeDiscountProgram) (string, error) WindowLength(ctx context.Context, obj *vega.UpdateVolumeDiscountProgram) (int, error) } type VolumeDiscountProgramResolver interface { Version(ctx context.Context, obj *v2.VolumeDiscountProgram) (int, error) + EndOfProgramTimestamp(ctx context.Context, obj *v2.VolumeDiscountProgram) (string, error) WindowLength(ctx context.Context, obj *v2.VolumeDiscountProgram) (int, error) } type VolumeDiscountStatsResolver interface { @@ -22100,7 +22102,7 @@ func (ec *executionContext) _CurrentReferralProgram_endOfProgramTimestamp(ctx co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndOfProgramTimestamp, nil + return ec.resolvers.CurrentReferralProgram().EndOfProgramTimestamp(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -22112,19 +22114,19 @@ func (ec *executionContext) _CurrentReferralProgram_endOfProgramTimestamp(ctx co } return graphql.Null } - res := resTmp.(int64) + res := resTmp.(string) fc.Result = res - return ec.marshalNTimestamp2int64(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_CurrentReferralProgram_endOfProgramTimestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CurrentReferralProgram", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Timestamp does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil @@ -84727,9 +84729,9 @@ func (ec *executionContext) _UpdateVolumeDiscountProgram_endOfProgramTimestamp(c } return graphql.Null } - res := resTmp.(int64) + res := resTmp.(string) fc.Result = res - return ec.marshalNTimestamp2int64(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_UpdateVolumeDiscountProgram_endOfProgramTimestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -84739,7 +84741,7 @@ func (ec *executionContext) fieldContext_UpdateVolumeDiscountProgram_endOfProgra IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Timestamp does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil @@ -85029,7 +85031,7 @@ func (ec *executionContext) _VolumeDiscountProgram_endOfProgramTimestamp(ctx con }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndOfProgramTimestamp, nil + return ec.resolvers.VolumeDiscountProgram().EndOfProgramTimestamp(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -85041,19 +85043,19 @@ func (ec *executionContext) _VolumeDiscountProgram_endOfProgramTimestamp(ctx con } return graphql.Null } - res := resTmp.(int64) + res := resTmp.(string) fc.Result = res - return ec.marshalNTimestamp2int64(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_VolumeDiscountProgram_endOfProgramTimestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VolumeDiscountProgram", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Timestamp does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil @@ -91529,12 +91531,25 @@ func (ec *executionContext) _CurrentReferralProgram(ctx context.Context, sel ast atomic.AddUint32(&invalids, 1) } case "endOfProgramTimestamp": + field := field - out.Values[i] = ec._CurrentReferralProgram_endOfProgramTimestamp(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._CurrentReferralProgram_endOfProgramTimestamp(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) case "windowLength": field := field @@ -110905,12 +110920,25 @@ func (ec *executionContext) _VolumeDiscountProgram(ctx context.Context, sel ast. atomic.AddUint32(&invalids, 1) } case "endOfProgramTimestamp": + field := field - out.Values[i] = ec._VolumeDiscountProgram_endOfProgramTimestamp(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._VolumeDiscountProgram_endOfProgramTimestamp(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) case "windowLength": field := field diff --git a/datanode/gateway/graphql/referral_program_resolver.go b/datanode/gateway/graphql/referral_program_resolver.go index 390211db728..0a30b9972cc 100644 --- a/datanode/gateway/graphql/referral_program_resolver.go +++ b/datanode/gateway/graphql/referral_program_resolver.go @@ -66,3 +66,8 @@ func (r *currentReferralProgramResolver) WindowLength(ctx context.Context, obj * return int(obj.WindowLength), nil } + +func (r currentReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *v2.ReferralProgram) (string, error) { + endTime := time.Unix(obj.EndOfProgramTimestamp/1e9, 0) + return endTime.Format(time.RFC3339), nil +} diff --git a/datanode/gateway/graphql/schema.graphql b/datanode/gateway/graphql/schema.graphql index b41e9d4209d..c861ee071d0 100644 --- a/datanode/gateway/graphql/schema.graphql +++ b/datanode/gateway/graphql/schema.graphql @@ -4360,8 +4360,8 @@ type StakingTier { type UpdateVolumeDiscountProgram { "The benefit tiers for the program" benefitTiers: [VolumeBenefitTier!]! - "The end time of the program" - endOfProgramTimestamp: Timestamp! + "Timestamp as RFC3339, after which program ends." + endOfProgramTimestamp: String! "The window length to consider for the volume discount program" windowLength: Int! } @@ -6004,8 +6004,8 @@ type CurrentReferralProgram { version: Int! "Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc." benefitTiers: [BenefitTier!]! - "Timestamp as RFC3339Nano, after which when the current epoch ends, the program will end and benefits will be disabled." - endOfProgramTimestamp: Timestamp! + "Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled." + endOfProgramTimestamp: String! "Number of epochs over which to evaluate a referral set's running volume." windowLength: Int! """ @@ -6257,8 +6257,8 @@ type VolumeDiscountProgram { version: Int! "Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc." benefitTiers: [VolumeBenefitTier!]! - "Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the programs will end and benefits will be disabled." - endOfProgramTimestamp: Timestamp! + "Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled." + endOfProgramTimestamp: String! "Number of epochs over which to evaluate parties' running volume." windowLength: Int! "Timestamp as RFC3339Nano when the program ended. If present, the current program has ended and no program is currently running." diff --git a/datanode/gateway/graphql/update_referral_program_resolver.go b/datanode/gateway/graphql/update_referral_program_resolver.go index 01a5b08a350..ede8530254a 100644 --- a/datanode/gateway/graphql/update_referral_program_resolver.go +++ b/datanode/gateway/graphql/update_referral_program_resolver.go @@ -29,7 +29,8 @@ func (u updateReferralProgramResolver) BenefitTiers(_ context.Context, obj *vega } func (u updateReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *vega.UpdateReferralProgram) (string, error) { - return time.Unix(obj.Changes.EndOfProgramTimestamp, 0).String(), nil + endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0) + return endTime.Format(time.RFC3339), nil } func (u updateReferralProgramResolver) WindowLength(_ context.Context, obj *vega.UpdateReferralProgram) (int, error) { diff --git a/datanode/gateway/graphql/update_volume_discount_program_resolver.go b/datanode/gateway/graphql/update_volume_discount_program_resolver.go index 74909efc26c..0941aa79856 100644 --- a/datanode/gateway/graphql/update_volume_discount_program_resolver.go +++ b/datanode/gateway/graphql/update_volume_discount_program_resolver.go @@ -17,6 +17,7 @@ package gql import ( "context" + "time" "code.vegaprotocol.io/vega/protos/vega" ) @@ -31,8 +32,9 @@ func (r *updateVolumeDiscountProgramResolver) BenefitTiers( func (r *updateVolumeDiscountProgramResolver) EndOfProgramTimestamp( _ context.Context, obj *vega.UpdateVolumeDiscountProgram, -) (int64, error) { - return obj.Changes.EndOfProgramTimestamp, nil +) (string, error) { + endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0) + return endTime.Format(time.RFC3339), nil } func (r *updateVolumeDiscountProgramResolver) WindowLength( diff --git a/datanode/gateway/graphql/volume_discount_program_resolver.go b/datanode/gateway/graphql/volume_discount_program_resolver.go index dbf869d5668..9112e21f9e9 100644 --- a/datanode/gateway/graphql/volume_discount_program_resolver.go +++ b/datanode/gateway/graphql/volume_discount_program_resolver.go @@ -19,6 +19,7 @@ import ( "context" "errors" "math" + "time" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" ) @@ -40,3 +41,8 @@ func (r *volumeDiscountProgramResolver) WindowLength(_ context.Context, obj *v2. return int(obj.WindowLength), nil } + +func (r volumeDiscountProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *v2.VolumeDiscountProgram) (string, error) { + endTime := time.Unix(obj.EndOfProgramTimestamp/1e9, 0) + return endTime.Format(time.RFC3339), nil +}