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

CNS-870: IPRPC part 2 - IPRPC pool implementation #1223

Merged
merged 105 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
4e50842
CNS-866: make pool methods support all denoms
oren-lava Feb 7, 2024
c0d1cd9
CNS-868: scaffold map iprpc subscriptions
oren-lava Feb 7, 2024
426a2c8
CNS-868: scaffold single min iprpc cost
oren-lava Feb 7, 2024
d5f74ed
CNS-868: scaffold query show iprpc data
oren-lava Feb 8, 2024
a93e64b
CNS-868: scaffold tx set iprpc data
oren-lava Feb 8, 2024
95542cb
CNS-868: fix msg server to return error on bad authority
oren-lava Feb 8, 2024
6e2a2ec
CNS-868: tx proposal cli to automatically make proposal
oren-lava Feb 8, 2024
5e7d39e
CNS-868: unit test
oren-lava Feb 11, 2024
09b6c21
CNS-868: fix lint
oren-lava Feb 11, 2024
43db988
CNS-868: another lint fix
oren-lava Feb 11, 2024
02745cf
CNS-870: define iprpc pool
oren-lava Feb 11, 2024
2982f86
CNS-870: scaffold list iprpc reward
oren-lava Feb 11, 2024
4911a13
CNS-870: count iprpc cu
oren-lava Feb 11, 2024
a3317ac
CNS-870: implemented iprpc pool
oren-lava Feb 13, 2024
a04e912
CNS-870: fix lint
oren-lava Feb 13, 2024
f18c95e
CNS-870: updated IPRPC reward to work with Current and not Count
oren-lava Feb 13, 2024
3db52d2
CNS-868: make min cost flag in set-iprpc-data required
oren-lava Feb 14, 2024
dc29e1a
CNS-868: genesis fixes
oren-lava Feb 14, 2024
d3a07dd
CNS-868: PR fix
oren-lava Feb 14, 2024
f9fe122
Merge branch 'CNS-868-iprpc-data-implementation' into CNS-870-iprpc-p…
oren-lava Feb 14, 2024
bb5f4b7
CNS-869: scaffold TX fund iprpc
oren-lava Feb 14, 2024
6d9c6c0
CNS-871: implemented iprpc provider reward
oren-lava Feb 15, 2024
fa40bcf
CNS-871: fix query client context in all queries
oren-lava Feb 15, 2024
754e215
CNS-871: scaffold query iprpc spec rewards
oren-lava Feb 15, 2024
b7ba787
CNS-872: fix for iprpc reward object update
oren-lava Feb 15, 2024
6b9cb8f
CNS-872: update pool test with iprpc pool
oren-lava Feb 15, 2024
8ae57c5
CNS-872: create small helper
oren-lava Feb 15, 2024
e287193
CNS-872: make mock bank keeper support multiple coins
oren-lava Feb 15, 2024
bbf3f11
CNS-872: fix mock bank keeper
oren-lava Feb 15, 2024
aaf6d4b
CNS-872: fix iprpc reward bug
oren-lava Feb 18, 2024
f7932f1
CNS-870: count iprpc cu with cu tracker and not with sub expiry
oren-lava Feb 18, 2024
ef4c685
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 18, 2024
7ff42ad
CNS-869: fund iprpc only from the next month
oren-lava Feb 18, 2024
bcac04b
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 18, 2024
28c3d86
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 18, 2024
6013bc8
CNS-870: changes for bug fixes
oren-lava Feb 18, 2024
6138058
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 18, 2024
b8785b7
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 18, 2024
8ad5bc3
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 18, 2024
7581b83
CNS-870: fix small bug in addSpecsFunds
oren-lava Feb 18, 2024
5cdea20
CNS-870: fix addSpecFunds bug
oren-lava Feb 18, 2024
b8b5786
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 18, 2024
edcb4b6
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 18, 2024
8ef5b5c
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 18, 2024
79fa8e8
CNS-870: change funcs to use sdk.Coins instead of Coin
oren-lava Feb 19, 2024
64cc384
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 19, 2024
cf35d39
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 19, 2024
d14504b
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 19, 2024
d21b0fc
CNS-871: change popAllSpecBasepays to optionally delete
oren-lava Feb 19, 2024
51110f1
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 19, 2024
1106020
CNS-870: fix handling reward transfer when there are no providers tha…
oren-lava Feb 20, 2024
becc28c
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 20, 2024
6abf4b7
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 20, 2024
95c2314
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 20, 2024
04b7f19
CNS-872: unit tests
oren-lava Feb 21, 2024
52e4a15
CNS-870: fix lint
oren-lava Feb 21, 2024
24e547b
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 21, 2024
f485bc4
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 21, 2024
7ef65b5
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 21, 2024
4814577
CNS-872: fix mock bank keeper
oren-lava Feb 21, 2024
129211e
CNS-868: small PR fixes
oren-lava Feb 26, 2024
2a0f469
CNS-870: small PR fixes
oren-lava Feb 26, 2024
2e83acc
Merge branch 'CNS-868-iprpc-data-implementation' into CNS-870-iprpc-p…
oren-lava Feb 26, 2024
5cca4e2
CNS-870: move IPRPC functionality to different file and divide to fun…
oren-lava Feb 26, 2024
e57b01d
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 26, 2024
11fdc6e
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 26, 2024
28cc50a
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 26, 2024
374d197
CNS-871: change query name
oren-lava Feb 26, 2024
42ab2df
CNS-870: change zero coins
oren-lava Feb 26, 2024
80e3986
CNS-870: small PR fixes
oren-lava Feb 26, 2024
e1da79c
CNS-870: simplify transferSpecFundsToNextMonth
oren-lava Feb 26, 2024
205a303
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 26, 2024
2c12923
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 26, 2024
702bf1e
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 26, 2024
ce6e041
CNS-872: fix lint
oren-lava Feb 26, 2024
a4062fe
CNS-870: small fixes
oren-lava Feb 26, 2024
d30df6d
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
oren-lava Feb 26, 2024
45bc5cf
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Feb 26, 2024
2f67bf3
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Feb 26, 2024
e67137f
pr changes
Feb 26, 2024
c8d22db
Merge branch 'main' into CNS-870-iprpc-pool-implementation
Feb 28, 2024
f06d3ae
other changes
Feb 28, 2024
07f4dff
pr changes
Mar 3, 2024
da8576b
Merge branch 'CNS-870-iprpc-pool-implementation' into CNS-869-iprpc-f…
Mar 5, 2024
4dbcc1d
pr change
Mar 5, 2024
c73d48a
pr changes
Mar 5, 2024
4911226
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-qu
oren-lava Mar 6, 2024
258a6e1
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Mar 6, 2024
617a02d
CNS-872: small fix
oren-lava Mar 6, 2024
7f71d5d
CNS-872: unit test fix
oren-lava Mar 6, 2024
63298c1
CNS-872L lint fix
oren-lava Mar 6, 2024
ef79aef
CNS-869: fix min iprpc cost charge bug
oren-lava Mar 6, 2024
584cf88
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Mar 6, 2024
258faa4
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Mar 6, 2024
31124f5
CNS-872: fix unit tests
oren-lava Mar 6, 2024
b246353
CNS-869: iprpc pool fund fix
oren-lava Mar 6, 2024
e3ba213
Merge branch 'CNS-869-iprpc-fund-tx' into CNS-871-iprpc-queries
oren-lava Mar 6, 2024
74a5cca
Merge branch 'CNS-871-iprpc-queries' into CNS-872-iprpc-unit-tests
oren-lava Mar 6, 2024
38f4d48
CNS-872: iprpc unit tests fix
oren-lava Mar 6, 2024
85ba689
CNS-872: PR fix
oren-lava Mar 6, 2024
d24e2b9
CNS-872: added unit test
oren-lava Mar 6, 2024
1a0e230
CNS-872: added min cost unit test
oren-lava Mar 6, 2024
4154781
Merge pull request #1242 from lavanet/CNS-872-iprpc-unit-tests
Yaroms Mar 6, 2024
227d6b8
Merge pull request #1227 from lavanet/CNS-869-iprpc-fund-tx
Yaroms Mar 6, 2024
452620c
Merge pull request #1228 from lavanet/CNS-871-iprpc-queries
Yaroms Mar 6, 2024
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
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ var (
string(rewardsmoduletypes.ProviderRewardsDistributionPool): {authtypes.Burner, authtypes.Staking},
string(rewardsmoduletypes.ProvidersRewardsAllocationPool): {authtypes.Minter, authtypes.Staking},
dualstakingmoduletypes.ModuleName: {authtypes.Burner, authtypes.Staking},
string(rewardsmoduletypes.IprpcPoolName): nil,
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down
5 changes: 4 additions & 1 deletion proto/lavanet/lava/dualstaking/delegator_reward.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ message DelegatorReward {
string delegator = 1;
string provider = 2;
string chain_id = 3;
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amount = 4 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
5 changes: 4 additions & 1 deletion proto/lavanet/lava/dualstaking/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@ message QueryDelegatorRewardsResponse {
message DelegatorRewardInfo {
string provider = 1;
string chain_id = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amount = 3 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
8 changes: 4 additions & 4 deletions proto/lavanet/lava/pairing/debug_query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import "lavanet/lava/projects/project.proto";

message QueryDebugQueryResponse {
uint64 block_reward = 1;
uint64 val_dist_pool_balance = 2;
uint64 val_alloc_pool_balance = 3;
uint64 provider_dist_pool_balance = 4;
uint64 provider_alloc_pool_balance = 5;
string val_dist_pool_balance = 2;
string val_alloc_pool_balance = 3;
string provider_dist_pool_balance = 4;
string provider_alloc_pool_balance = 5;
uint64 provider_full_reward = 6;
uint64 provider_reward_no_bonus = 7;
uint64 block = 8;
Expand Down
2 changes: 2 additions & 0 deletions proto/lavanet/lava/rewards/base_pay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ message BasePay {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

uint64 iprpc_cu = 3;
}

// aggregated rewards for the provider through out the month
Expand Down
3 changes: 3 additions & 0 deletions proto/lavanet/lava/rewards/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package lavanet.lava.rewards;
import "gogoproto/gogo.proto";
import "lavanet/lava/rewards/params.proto";
import "lavanet/lava/rewards/base_pay.proto";
import "lavanet/lava/rewards/iprpc.proto";
import "lavanet/lava/timerstore/timer.proto";
import "cosmos/base/v1beta1/coin.proto";
// this line is used by starport scaffolding # genesis/proto/import
Expand All @@ -17,5 +18,7 @@ message GenesisState {
repeated BasePayGenesis base_pays = 3 [(gogoproto.nullable) = false];
repeated string iprpc_subscriptions = 4;
cosmos.base.v1beta1.Coin min_iprpc_cost = 5 [(gogoproto.nullable) = false];
repeated IprpcReward iprpc_rewards = 6 [(gogoproto.nullable) = false];
uint64 iprpc_rewards_current = 7;
// this line is used by starport scaffolding # genesis/proto/state
}
20 changes: 20 additions & 0 deletions proto/lavanet/lava/rewards/iprpc.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
package lavanet.lava.rewards;

option go_package = "github.com/lavanet/lava/x/rewards/types";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

// object that holds the list for iprpc funcs for a specific month id
message IprpcReward {
uint64 id = 1; // month id
repeated Specfund spec_funds = 2 [(gogoproto.nullable) = false];
}

message Specfund {
string spec = 1;
repeated cosmos.base.v1beta1.Coin fund = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
37 changes: 36 additions & 1 deletion proto/lavanet/lava/rewards/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "lavanet/lava/rewards/params.proto";
import "lavanet/lava/rewards/iprpc.proto";
import "cosmos/base/v1beta1/coin.proto";
// this line is used by starport scaffolding # 1

Expand All @@ -31,11 +32,21 @@ service Query {
rpc ShowIprpcData(QueryShowIprpcDataRequest) returns (QueryShowIprpcDataResponse) {
option (google.api.http).get = "/lavanet/lava/rewards/show_iprpc_data";
}

// ProviderReward queries for the providers reward for their services
rpc ProviderReward(QueryProviderRewardRequest) returns (QueryProviderRewardResponse) {
option (google.api.http).get = "/lavanet/lava/rewards/provider_reward";
}

// IprpcProviderRewardEstimation queries for a provider's current IPRPC reward (relative to its serviced CU)
rpc IprpcProviderRewardEstimation(QueryIprpcProviderRewardEstimationRequest) returns (QueryIprpcProviderRewardEstimationResponse) {
option (google.api.http).get = "/lavanet/lava/rewards/iprpc_provider_reward/{provider}";
}

// IprpcSpecReward queries for a spec's IPRPC reward
rpc IprpcSpecReward(QueryIprpcSpecRewardRequest) returns (QueryIprpcSpecRewardResponse) {
option (google.api.http).get = "/lavanet/lava/rewards/iprpc_spec_reward/{spec}";
}
// this line is used by starport scaffolding # 2
}

Expand All @@ -53,7 +64,10 @@ message QueryPoolsRequest {}

message PoolInfo {
string name = 1; // pool name
cosmos.base.v1beta1.Coin balance = 2 [(gogoproto.nullable) = false]; // pool balance
repeated cosmos.base.v1beta1.Coin balance = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
]; // pool balance (all types of tokens)
}

// QueryPoolsResponse is response type for the Query/Pools RPC method.
Expand Down Expand Up @@ -99,4 +113,25 @@ message QueryProviderRewardResponse {
repeated RewardInfo rewards = 1 [(gogoproto.nullable) = false];
}

// QueryIprpcProviderRewardEstimationRequest is request type for the Query/IprpcProviderRewardEstimation RPC method.
message QueryIprpcProviderRewardEstimationRequest {
string provider = 1;
}

// QueryIprpcProviderRewardEstimationResponse is response type for the Query/IprpcProviderRewardEstimation RPC method.
message QueryIprpcProviderRewardEstimationResponse {
repeated Specfund spec_funds = 1 [(gogoproto.nullable) = false];
}

// QueryIprpcSpecRewardRequest is request type for the Query/IprpcSpecReward RPC method.
message QueryIprpcSpecRewardRequest {
string spec = 1;
}

// QueryIprpcSpecRewardResponse is response type for the Query/IprpcSpecReward RPC method.
message QueryIprpcSpecRewardResponse {
repeated IprpcReward iprpc_rewards = 1 [(gogoproto.nullable) = false];
uint64 current_month_id = 2;
}

// this line is used by starport scaffolding # 3
14 changes: 14 additions & 0 deletions proto/lavanet/lava/rewards/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option go_package = "github.com/lavanet/lava/x/rewards/types";
// Msg defines the Msg service.
service Msg {
rpc SetIprpcData(MsgSetIprpcData) returns (MsgSetIprpcDataResponse);
rpc FundIprpc(MsgFundIprpc) returns (MsgFundIprpcResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}

Expand All @@ -23,4 +24,17 @@ message MsgSetIprpcData {
message MsgSetIprpcDataResponse {
}

message MsgFundIprpc {
string creator = 1;
uint64 duration = 2; // vesting duration in months
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
]; // tokens to be distributed as reward
string spec = 4; // spec on which the providers get incentive
}

message MsgFundIprpcResponse {
}

// this line is used by starport scaffolding # proto/tx/message
2 changes: 2 additions & 0 deletions scripts/cli_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ echo "Testing rewards q commands"
trace lavad q rewards pools >/dev/null
trace lavad q rewards block-reward >/dev/null
trace lavad q rewards show-iprpc-data > /dev/null
trace lavad q rewards iprpc-provider-reward > /dev/null
trace lavad q rewards iprpc-spec-reward > /dev/null
trace lavad q rewards provider-reward >/dev/null

echo "Testing events command"
Expand Down
1 change: 1 addition & 0 deletions scripts/init_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if [ "$1" == "debug" ]; then
else
lavad add-genesis-account providers_rewards_allocation_pool 30000000000000ulava --module-account
fi
lavad add-genesis-account iprpc_pool 0ulava --module-account
lavad gentx alice 10000000000000ulava --chain-id $chainID
lavad collect-gentxs
lavad start --pruning=nothing
4 changes: 4 additions & 0 deletions scripts/init_chain_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ sleep_until_next_epoch
HEALTH_FILE="config/health_examples/health_template.yml"
create_health_config $HEALTH_FILE $(lavad keys show user1 -a) $(lavad keys show servicer2 -a) $(lavad keys show servicer3 -a)

lavad tx gov submit-legacy-proposal set-iprpc-data 1000000000ulava --min-cost 100ulava --add-subscriptions $(lavad keys show -a user1) --from alice -y
wait_count_blocks 1
lavad tx gov vote $(latest_vote) yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE

if [[ "$1" != "--skip-providers" ]]; then
. ${__dir}/setup_providers.sh
echo "letting providers start and running health check"
Expand Down
30 changes: 27 additions & 3 deletions testutil/common/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ func (ts *Tester) GetBalance(accAddr sdk.AccAddress) int64 {
return ts.Keepers.BankKeeper.GetBalance(ts.Ctx, accAddr, denom).Amount.Int64()
}

func (ts *Tester) GetBalances(accAddr sdk.AccAddress) sdk.Coins {
return ts.Keepers.BankKeeper.GetAllBalances(ts.Ctx, accAddr)
}

func (ts *Tester) FindPlan(index string, block uint64) (planstypes.Plan, bool) {
return ts.Keepers.Plans.FindPlan(ts.Ctx, index, block)
}
Expand Down Expand Up @@ -610,9 +614,14 @@ func (ts *Tester) TxPairingUnfreezeProvider(addr, chainID string) (*pairingtypes
return ts.Servers.PairingServer.UnfreezeProvider(ts.GoCtx, msg)
}

func (ts *Tester) TxRewardsSetIprpcDataProposal(ctx sdk.Context, authority string, cost sdk.Coin, subs []string) (*rewardstypes.MsgSetIprpcDataResponse, error) {
func (ts *Tester) TxRewardsSetIprpcDataProposal(authority string, cost sdk.Coin, subs []string) (*rewardstypes.MsgSetIprpcDataResponse, error) {
msg := rewardstypes.NewMsgSetIprpcData(authority, cost, subs)
return ts.Servers.RewardsServer.SetIprpcData(sdk.WrapSDKContext(ctx), msg)
return ts.Servers.RewardsServer.SetIprpcData(ts.GoCtx, msg)
}

func (ts *Tester) TxRewardsFundIprpc(creator string, spec string, duration uint64, fund sdk.Coins) (*rewardstypes.MsgFundIprpcResponse, error) {
msg := rewardstypes.NewMsgFundIprpc(creator, spec, duration, fund)
return ts.Servers.RewardsServer.FundIprpc(ts.GoCtx, msg)
}

// TxCreateValidator: implement 'tx staking createvalidator' and bond its tokens
Expand Down Expand Up @@ -859,11 +868,26 @@ func (ts *Tester) QueryRewardsBlockReward() (*rewardstypes.QueryBlockRewardRespo
return ts.Keepers.Rewards.BlockReward(ts.GoCtx, msg)
}

func (ts *Tester) QueryShowIprpcData() (*rewardstypes.QueryShowIprpcDataResponse, error) {
// QueryRewardsShowIprpcData implements 'q rewards show-iprpc-data'
func (ts *Tester) QueryRewardsShowIprpcData() (*rewardstypes.QueryShowIprpcDataResponse, error) {
msg := &rewardstypes.QueryShowIprpcDataRequest{}
return ts.Keepers.Rewards.ShowIprpcData(ts.GoCtx, msg)
}

func (ts *Tester) QueryRewardsIprpcProviderRewardEstimation(provider string) (*rewardstypes.QueryIprpcProviderRewardEstimationResponse, error) {
msg := &rewardstypes.QueryIprpcProviderRewardEstimationRequest{
Provider: provider,
}
return ts.Keepers.Rewards.IprpcProviderRewardEstimation(ts.GoCtx, msg)
}

func (ts *Tester) QueryRewardsIprpcSpecReward(spec string) (*rewardstypes.QueryIprpcSpecRewardResponse, error) {
msg := &rewardstypes.QueryIprpcSpecRewardRequest{
Spec: spec,
}
return ts.Keepers.Rewards.IprpcSpecReward(ts.GoCtx, msg)
}

// block/epoch helpers
// QueryRewardsProviderReward implements 'q rewards provider-reward'
func (ts *Tester) QueryRewardsProviderReward(chainID string, provider string) (*rewardstypes.QueryProviderRewardResponse, error) {
Expand Down
2 changes: 1 addition & 1 deletion testutil/e2e/paymentE2E.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (lt *lavaTest) getRewards(addresses []string) ([]sdk.Coin, error) {
}
total := sdk.NewCoin(commonconsts.TestTokenDenom, sdk.ZeroInt())
for _, r := range res.Rewards {
total = total.Add(r.Amount)
total = total.AddAmount(r.Amount.AmountOf(commonconsts.TestTokenDenom))
}
rewards = append(rewards, total)
}
Expand Down
43 changes: 5 additions & 38 deletions testutil/keeper/mock_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,9 @@ func (k mockBankKeeper) GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk
}

func (k mockBankKeeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error {
// TODO support multiple coins
moduleAcc := GetModuleAddress(recipientModule)
if amt.Len() > 1 {
return fmt.Errorf("mockbankkeeper dont support more than 1 coin")
}
coin := amt[0]

accountCoin := k.GetBalance(ctx, senderAddr, coin.Denom)
if coin.Amount.GT(accountCoin.Amount) {
accountCoins := k.GetAllBalances(ctx, senderAddr)
if !accountCoins.IsAllGTE(amt) {
return fmt.Errorf("not enough coins")
}

Expand All @@ -99,47 +93,20 @@ func (k mockBankKeeper) UndelegateCoinsFromModuleToAccount(ctx sdk.Context, send
}

func (k mockBankKeeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error {
// TODO support multiple coins
moduleAcc := GetModuleAddress(senderModule)

if amt.Len() > 1 {
return fmt.Errorf("mockbankkeeper doesn't support more than 1 coin")
}
coin := amt[0]

accountCoin := k.GetBalance(ctx, moduleAcc, coin.Denom)
if coin.Amount.GT(accountCoin.Amount) {
accountCoins := k.GetAllBalances(ctx, moduleAcc)
if !accountCoins.IsAllGTE(amt) {
return fmt.Errorf("not enough coins")
}

k.SubFromBalance(moduleAcc, amt)

k.AddToBalance(recipientAddr, amt)

return nil
}

func (k mockBankKeeper) SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error {
// TODO support multiple coins

senderModuleAcc := GetModuleAddress(senderModule)
recipientModuleAcc := GetModuleAddress(recipientModule)

if amt.Len() > 1 {
return fmt.Errorf("mockbankkeeper doesn't support more than 1 coin")
}
coin := amt[0]

senderAccountCoin := k.GetBalance(ctx, senderModuleAcc, coin.Denom)
if coin.Amount.GT(senderAccountCoin.Amount) {
return fmt.Errorf("not enough coins")
}

k.SubFromBalance(senderModuleAcc, amt)

k.AddToBalance(recipientModuleAcc, amt)

return nil
return k.SendCoinsFromAccountToModule(ctx, senderModuleAcc, recipientModule, amt)
}

func (k mockBankKeeper) DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error {
Expand Down
12 changes: 12 additions & 0 deletions utils/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@ func NextMonth(date time.Time) time.Time {
time.UTC,
)
}

func IsMiddleOfMonthPassed(date time.Time) bool {
// Get the total number of days in the current month
_, month, year := date.Date()
daysInMonth := time.Date(year, month+1, 0, 0, 0, 0, 0, time.UTC).Day()

// Calculate the middle day of the month
middleDay := daysInMonth / 2

// Check if the day of the given date is greater than the middle day
return date.Day() > middleDay
}
Loading
Loading