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

[OTE-730] Add E2E tests for revshare #2283

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import { MarketMapperRevenueShareParams, MarketMapperRevenueShareParamsSDKType } from "./params";
import { UnconditionalRevShareConfig, UnconditionalRevShareConfigSDKType } from "./revshare";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines `x/revshare`'s genesis state. */

export interface GenesisState {
/** params is the market mapper revenue share params. */
params?: MarketMapperRevenueShareParams;
/** unconditional_rev_share_config is the unconditional rev share config. */

unconditionalRevShareConfig?: UnconditionalRevShareConfig;
}
/** GenesisState defines `x/revshare`'s genesis state. */

export interface GenesisStateSDKType {
/** params is the market mapper revenue share params. */
params?: MarketMapperRevenueShareParamsSDKType;
/** unconditional_rev_share_config is the unconditional rev share config. */

unconditional_rev_share_config?: UnconditionalRevShareConfigSDKType;
}

function createBaseGenesisState(): GenesisState {
return {
params: undefined
params: undefined,
unconditionalRevShareConfig: undefined
};
}

Expand All @@ -24,6 +34,10 @@ export const GenesisState = {
MarketMapperRevenueShareParams.encode(message.params, writer.uint32(10).fork()).ldelim();
}

if (message.unconditionalRevShareConfig !== undefined) {
UnconditionalRevShareConfig.encode(message.unconditionalRevShareConfig, writer.uint32(18).fork()).ldelim();
}

return writer;
},

Expand All @@ -40,6 +54,10 @@ export const GenesisState = {
message.params = MarketMapperRevenueShareParams.decode(reader, reader.uint32());
break;

case 2:
message.unconditionalRevShareConfig = UnconditionalRevShareConfig.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -52,6 +70,7 @@ export const GenesisState = {
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = createBaseGenesisState();
message.params = object.params !== undefined && object.params !== null ? MarketMapperRevenueShareParams.fromPartial(object.params) : undefined;
message.unconditionalRevShareConfig = object.unconditionalRevShareConfig !== undefined && object.unconditionalRevShareConfig !== null ? UnconditionalRevShareConfig.fromPartial(object.unconditionalRevShareConfig) : undefined;
return message;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
import { Params, ParamsSDKType } from "./params";
import { UserStats, UserStatsSDKType } from "./stats";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines the stats module's genesis state. */

export interface GenesisState {
/** The parameters of the module. */
params?: Params;
addressToUserStats: AddressToUserStats[];
}
/** GenesisState defines the stats module's genesis state. */

export interface GenesisStateSDKType {
/** The parameters of the module. */
params?: ParamsSDKType;
address_to_user_stats: AddressToUserStatsSDKType[];
}
/** AddressToUserStats is a struct that contains the user stats for an address. */

export interface AddressToUserStats {
/** The address of the user. */
address: string;
/** The user stats for the address. */

userStats?: UserStats;
}
/** AddressToUserStats is a struct that contains the user stats for an address. */

export interface AddressToUserStatsSDKType {
/** The address of the user. */
address: string;
/** The user stats for the address. */

user_stats?: UserStatsSDKType;
}

function createBaseGenesisState(): GenesisState {
return {
params: undefined
params: undefined,
addressToUserStats: []
};
}

Expand All @@ -26,6 +48,10 @@ export const GenesisState = {
Params.encode(message.params, writer.uint32(10).fork()).ldelim();
}

for (const v of message.addressToUserStats) {
AddressToUserStats.encode(v!, writer.uint32(18).fork()).ldelim();
}

return writer;
},

Expand All @@ -42,6 +68,10 @@ export const GenesisState = {
message.params = Params.decode(reader, reader.uint32());
break;

case 2:
message.addressToUserStats.push(AddressToUserStats.decode(reader, reader.uint32()));
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -54,6 +84,62 @@ export const GenesisState = {
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = createBaseGenesisState();
message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
message.addressToUserStats = object.addressToUserStats?.map(e => AddressToUserStats.fromPartial(e)) || [];
return message;
}

};

function createBaseAddressToUserStats(): AddressToUserStats {
return {
address: "",
userStats: undefined
};
}

export const AddressToUserStats = {
encode(message: AddressToUserStats, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.address !== "") {
writer.uint32(10).string(message.address);
}

if (message.userStats !== undefined) {
UserStats.encode(message.userStats, writer.uint32(18).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): AddressToUserStats {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAddressToUserStats();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.address = reader.string();
break;

case 2:
message.userStats = UserStats.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<AddressToUserStats>): AddressToUserStats {
const message = createBaseAddressToUserStats();
message.address = object.address ?? "";
message.userStats = object.userStats !== undefined && object.userStats !== null ? UserStats.fromPartial(object.userStats) : undefined;
return message;
}

Expand Down
5 changes: 5 additions & 0 deletions proto/dydxprotocol/revshare/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ package dydxprotocol.revshare;

import "gogoproto/gogo.proto";
import "dydxprotocol/revshare/params.proto";
import "dydxprotocol/revshare/revshare.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types";

// GenesisState defines `x/revshare`'s genesis state.
message GenesisState {
// params is the market mapper revenue share params.
MarketMapperRevenueShareParams params = 1 [ (gogoproto.nullable) = false ];
// unconditional_rev_share_config is the unconditional rev share config.
UnconditionalRevShareConfig unconditional_rev_share_config = 2
[ (gogoproto.nullable) = false ];
}
11 changes: 11 additions & 0 deletions proto/dydxprotocol/stats/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ syntax = "proto3";
package dydxprotocol.stats;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "dydxprotocol/stats/params.proto";
import "dydxprotocol/stats/stats.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/stats/types";

// GenesisState defines the stats module's genesis state.
message GenesisState {
// The parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
repeated AddressToUserStats address_to_user_stats = 2;
}

// AddressToUserStats is a struct that contains the user stats for an address.
message AddressToUserStats {
// The address of the user.
string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// The user stats for the address.
UserStats user_stats = 2;
}
6 changes: 5 additions & 1 deletion protocol/app/testdata/default_genesis_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@
"address": "dydx17xpfvakm2amg962yls6f84z3kell8c5leqdyt2",
"revenue_share_ppm": 0,
"valid_days": 0
},
"unconditional_rev_share_config": {
"configs": []
}
},
"rewards": {
Expand Down Expand Up @@ -501,7 +504,8 @@
"stats": {
"params": {
"window_duration": "2592000s"
}
},
"address_to_user_stats": []
},
"subaccounts": {
"subaccounts": []
Expand Down
6 changes: 5 additions & 1 deletion protocol/scripts/genesis/sample_pregenesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3902,6 +3902,9 @@
"address": "dydx17xpfvakm2amg962yls6f84z3kell8c5leqdyt2",
"revenue_share_ppm": 0,
"valid_days": 0
},
"unconditional_rev_share_config": {
"configs": []
}
},
"rewards": {
Expand Down Expand Up @@ -3943,6 +3946,7 @@
"validators": []
},
"stats": {
"address_to_user_stats": [],
"params": {
"window_duration": "2592000s"
}
Expand Down Expand Up @@ -4021,7 +4025,7 @@
]
}
},
"app_version": "5.2.1-172-g351fcccd",
"app_version": "5.2.1-129-g14ed93f0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Unusual app_version Change Detected

The app_version in protocol/scripts/genesis/sample_pregenesis.json was updated to "5.2.1-129-g14ed93f0", which decreases the commit count from "5.2.1-172-g351fcccd". No corresponding commit was found for this change, indicating a potential inconsistency.

  • Location: protocol/scripts/genesis/sample_pregenesis.json
🔗 Analysis chain

Application version updated.

The app_version has been changed from "5.2.1-172-g351fcccd" to "5.2.1-129-g14ed93f0".

This change in version number, particularly the decrease in the commit count (from 172 to 129), is unusual. Let's verify if this is intentional:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check git logs for version changes
git log --oneline | grep -E "5\.2\.1-(172-g351fcccd|129-g14ed93f0)"

Length of output: 69


Script:

#!/bin/bash
# Find all commits that changed the app_version in sample_pregenesis.json
git log -p -S'"app_version"' -- protocol/scripts/genesis/sample_pregenesis.json

Length of output: 138617


Script:

#!/bin/bash
# Search for all occurrences of "app_version" in the codebase
rg '"app_version"'

Length of output: 659

"chain_id": "dydx-sample-1",
"consensus": {
"params": {
Expand Down
6 changes: 5 additions & 1 deletion protocol/testutil/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/dydxprotocol/v4-chain/protocol/testutil/appoptions"
"github.com/dydxprotocol/v4-chain/protocol/testutil/constants"
testlog "github.com/dydxprotocol/v4-chain/protocol/testutil/logger"
affiliatestypes "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types"
assettypes "github.com/dydxprotocol/v4-chain/protocol/x/assets/types"
blocktimetypes "github.com/dydxprotocol/v4-chain/protocol/x/blocktime/types"
bridgetypes "github.com/dydxprotocol/v4-chain/protocol/x/bridge/types"
Expand Down Expand Up @@ -207,7 +208,8 @@ type GenesisStates interface {
govplus.GenesisState |
vaulttypes.GenesisState |
revsharetypes.GenesisState |
marketmapmoduletypes.GenesisState
marketmapmoduletypes.GenesisState |
affiliatestypes.GenesisState
}

// UpdateGenesisDocWithAppStateForModule updates the supplied genesis doc using the provided function. The function
Expand Down Expand Up @@ -269,6 +271,8 @@ func UpdateGenesisDocWithAppStateForModule[T GenesisStates](genesisDoc *types.Ge
moduleName = marketmapmoduletypes.ModuleName
case listingtypes.GenesisState:
moduleName = listingtypes.ModuleName
case affiliatestypes.GenesisState:
moduleName = affiliatestypes.ModuleName
default:
panic(fmt.Errorf("Unsupported type %T", t))
}
Expand Down
Loading
Loading