diff --git a/CHANGELOG.md b/CHANGELOG.md index 77f7f54ba0..497006bcfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -174,6 +174,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 b25d52664d..e5370ef853 100644 --- a/datanode/gateway/graphql/generated.go +++ b/datanode/gateway/graphql/generated.go @@ -3145,7 +3145,6 @@ type RecurringTransferResolver interface { type ReferralProgramResolver interface { Version(ctx context.Context, obj *vega.ReferralProgram) (int, error) - EndOfProgramTimestamp(ctx context.Context, obj *vega.ReferralProgram) (string, error) WindowLength(ctx context.Context, obj *vega.ReferralProgram) (int, error) } type ReferralSetRefereeResolver interface { @@ -3313,7 +3312,7 @@ type UpdateNetworkParameterResolver interface { } type UpdateReferralProgramResolver interface { BenefitTiers(ctx context.Context, obj *vega.UpdateReferralProgram) ([]*vega.BenefitTier, error) - EndOfProgramTimestamp(ctx context.Context, obj *vega.UpdateReferralProgram) (string, error) + EndOfProgramTimestamp(ctx context.Context, obj *vega.UpdateReferralProgram) (int64, error) WindowLength(ctx context.Context, obj *vega.UpdateReferralProgram) (int, error) StakingTiers(ctx context.Context, obj *vega.UpdateReferralProgram) ([]*vega.StakingTier, error) } @@ -69271,7 +69270,7 @@ func (ec *executionContext) _ReferralProgram_endOfProgramTimestamp(ctx context.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.ReferralProgram().EndOfProgramTimestamp(rctx, obj) + return obj.EndOfProgramTimestamp, nil }) if err != nil { ec.Error(ctx, err) @@ -69283,19 +69282,19 @@ func (ec *executionContext) _ReferralProgram_endOfProgramTimestamp(ctx context.C } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int64) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTimestamp2int64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_ReferralProgram_endOfProgramTimestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ReferralProgram", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Timestamp does not have child fields") }, } return fc, nil @@ -84830,9 +84829,9 @@ func (ec *executionContext) _UpdateReferralProgram_endOfProgramTimestamp(ctx con } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int64) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTimestamp2int64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_UpdateReferralProgram_endOfProgramTimestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -84842,7 +84841,7 @@ func (ec *executionContext) fieldContext_UpdateReferralProgram_endOfProgramTimes IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Timestamp does not have child fields") }, } return fc, nil @@ -106526,25 +106525,12 @@ func (ec *executionContext) _ReferralProgram(ctx context.Context, sel ast.Select atomic.AddUint32(&invalids, 1) } case "endOfProgramTimestamp": - field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._ReferralProgram_endOfProgramTimestamp(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + out.Values[i] = ec._ReferralProgram_endOfProgramTimestamp(ctx, field, obj) - }) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) + } case "windowLength": field := field diff --git a/datanode/gateway/graphql/referral_program_resolver.go b/datanode/gateway/graphql/referral_program_resolver.go index 390211db72..bd6d2dc3f4 100644 --- a/datanode/gateway/graphql/referral_program_resolver.go +++ b/datanode/gateway/graphql/referral_program_resolver.go @@ -19,7 +19,6 @@ import ( "context" "errors" "math" - "time" v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" @@ -44,11 +43,6 @@ func (r *referralProgramResolver) WindowLength(ctx context.Context, obj *vega.Re return int(obj.WindowLength), nil } -func (r *referralProgramResolver) EndOfProgramTimestamp(ctx context.Context, obj *vega.ReferralProgram) (string, error) { - endTime := time.Unix(obj.EndOfProgramTimestamp, 0) - return endTime.Format(time.RFC3339), nil -} - type currentReferralProgramResolver VegaResolverRoot func (r *currentReferralProgramResolver) Version(ctx context.Context, obj *v2.ReferralProgram) (int, error) { diff --git a/datanode/gateway/graphql/schema.graphql b/datanode/gateway/graphql/schema.graphql index 754a874c68..00d7777258 100644 --- a/datanode/gateway/graphql/schema.graphql +++ b/datanode/gateway/graphql/schema.graphql @@ -4339,8 +4339,8 @@ type UpdateMarketState { type UpdateReferralProgram { "Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc." benefitTiers: [BenefitTier!]! - "Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled." - endOfProgramTimestamp: String! + "Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled." + endOfProgramTimestamp: Timestamp! "Number of epochs over which to evaluate a referral set's running volume." windowLength: Int! """ @@ -4372,7 +4372,7 @@ type StakingTier { type UpdateVolumeDiscountProgram { "The benefit tiers for the program" benefitTiers: [VolumeBenefitTier!]! - "The end time of the program" + "Timestamp as Unix time in nanoseconds, after which program ends." endOfProgramTimestamp: Timestamp! "The window length to consider for the volume discount program" windowLength: Int! @@ -5996,8 +5996,8 @@ type ReferralProgram { version: Int! "Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc." benefitTiers: [BenefitTier!]! - "Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled." - endOfProgramTimestamp: String! + "Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled." + endOfProgramTimestamp: Timestamp! "Number of epochs over which to evaluate a referral set's running volume." windowLength: Int! """ @@ -6016,7 +6016,7 @@ 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." + "Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled." endOfProgramTimestamp: Timestamp! "Number of epochs over which to evaluate a referral set's running volume." windowLength: Int! @@ -6269,7 +6269,7 @@ 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." + "Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled." endOfProgramTimestamp: Timestamp! "Number of epochs over which to evaluate parties' running volume." windowLength: Int! diff --git a/datanode/gateway/graphql/update_referral_program_resolver.go b/datanode/gateway/graphql/update_referral_program_resolver.go index 01a5b08a35..296b624cd2 100644 --- a/datanode/gateway/graphql/update_referral_program_resolver.go +++ b/datanode/gateway/graphql/update_referral_program_resolver.go @@ -28,8 +28,9 @@ func (u updateReferralProgramResolver) BenefitTiers(_ context.Context, obj *vega return obj.Changes.BenefitTiers, nil } -func (u updateReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *vega.UpdateReferralProgram) (string, error) { - return time.Unix(obj.Changes.EndOfProgramTimestamp, 0).String(), nil +func (u updateReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *vega.UpdateReferralProgram) (int64, error) { + endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0) + return endTime.UnixNano(), 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 74909efc26..15cf1232d8 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" ) @@ -32,7 +33,8 @@ func (r *updateVolumeDiscountProgramResolver) BenefitTiers( func (r *updateVolumeDiscountProgramResolver) EndOfProgramTimestamp( _ context.Context, obj *vega.UpdateVolumeDiscountProgram, ) (int64, error) { - return obj.Changes.EndOfProgramTimestamp, nil + endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0) + return endTime.UnixNano(), nil } func (r *updateVolumeDiscountProgramResolver) WindowLength(