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

[LoadTesting] Test tokenomics actors balances. #921

Draft
wants to merge 78 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
6738d21
WIP
Olshansk Aug 16, 2024
3e6a146
Merge branch 'main' into inflation
Olshansk Aug 20, 2024
c3a235a
Checkpoint
Olshansk Aug 21, 2024
846bc1d
Finished first version of the documentation
Olshansk Aug 21, 2024
40c56a5
Merge branch 'main' into inflation
Olshansk Aug 21, 2024
98736f3
Revert tokenomic docs
Olshansk Aug 21, 2024
eeabb30
Performed self review
Olshansk Aug 21, 2024
10ef513
Merge with main
Olshansk Aug 22, 2024
0e725a4
Remove everything related to TLMGlobalMintReimbursementRequest
Olshansk Aug 22, 2024
bbe2366
WIP
Olshansk Aug 23, 2024
ad70e70
Fixed the TestProcessTokenLogicModules_TLMBurnEqualsMintValid test
Olshansk Aug 23, 2024
b02ef24
WIP
Olshansk Aug 24, 2024
8663fac
Finished implementing TestProcessTokenLogicModules_TLMBurnEqualsMint_…
Olshansk Aug 25, 2024
085d134
Implemented TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDist…
Olshansk Aug 25, 2024
1de13ba
Updated comments in e2e/tests/0_settlement.feature
Olshansk Aug 25, 2024
b8dff51
Fixed failing unit test
Olshansk Aug 25, 2024
9231d6f
Merge branch 'main' into issues/732_max_claimable_pokt
Olshansk Aug 25, 2024
f79989a
Merge branch 'main' into issues/732_max_claimable_pokt
Olshansk Aug 26, 2024
4c335e7
update compile proto
Olshansk Aug 26, 2024
0020303
Merge remote-tracking branch 'origin/main' into issues/732_tokenomics…
red-0ne Sep 19, 2024
f7a0da7
fix: Remove merge added lines
red-0ne Sep 19, 2024
79ac3e6
feat: Add GMRR
red-0ne Sep 20, 2024
1befc5e
fix: Skip GMRR if GMI is disabled
red-0ne Sep 20, 2024
e5a732b
Merge remote-tracking branch 'origin/main' into issues/732_tokenomics…
red-0ne Oct 13, 2024
197c5a0
fix: Activate GMRR TLM
red-0ne Oct 14, 2024
61a62fa
chore: Add TODO for the relay miner to account for GMRR
red-0ne Oct 14, 2024
942c525
Merge remote-tracking branch 'origin/main' into feat/gmrr
red-0ne Oct 14, 2024
5db96bc
Merge remote-tracking branch 'origin/main' into feat/gmrr
red-0ne Oct 14, 2024
13784b8
fix: Min stake tests
red-0ne Oct 14, 2024
2be5464
Merge remote-tracking branch 'origin/main' into feat/gmrr
red-0ne Oct 14, 2024
3baec62
Merge remote-tracking branch 'origin/main' into feat/gmrr
red-0ne Oct 17, 2024
e91a20e
feat: Add WithProofRequirement option
red-0ne Oct 18, 2024
568ecb9
fix: ensure app stake is always enough
red-0ne Oct 24, 2024
6c836e7
fix: Ensure no over-servicing
red-0ne Oct 24, 2024
fafd2f3
chore: Address reveiw change requests
red-0ne Oct 24, 2024
ba13177
Merge remote-tracking branch 'origin/main' into feat/gmrr
red-0ne Oct 25, 2024
3185741
fix: Add globalmint to tests
red-0ne Oct 25, 2024
1593bfb
fix: Linting errors
red-0ne Oct 25, 2024
b2a14b2
fix: Check cached stake before query
red-0ne Oct 25, 2024
5e6e514
fix: Remove redundant check
red-0ne Oct 25, 2024
2b14bab
feat: Supplier rate limiting
red-0ne Oct 28, 2024
f050d8c
fix: Cmd dependencies
red-0ne Oct 28, 2024
196c2fa
fix: Hidden error
red-0ne Oct 28, 2024
6fea32f
fix: Ineffectual assignement
red-0ne Oct 28, 2024
b175916
Merge remote-tracking branch 'origin/main' into feat/gmrr
red-0ne Oct 28, 2024
7bd6058
chore: Address review change requests
red-0ne Oct 29, 2024
3f1a2b8
Merge remote-tracking branch 'origin/main' into feat/no-overservicing
red-0ne Oct 29, 2024
f304c87
feat: Add overservicing allowance
red-0ne Oct 29, 2024
aaec275
Merge remote-tracking branch 'origin/feat/gmrr' into feat/no-overserv…
red-0ne Oct 29, 2024
2ee8448
fix: Merge error
red-0ne Oct 29, 2024
6170a45
improve: Add per relayer app meter
red-0ne Oct 30, 2024
2784cfb
Merge remote-tracking branch 'origin/main' into feat/gmrr
red-0ne Oct 30, 2024
2bd7240
chore: Address review change requests
red-0ne Oct 30, 2024
4c65e84
Merge remote-tracking branch 'origin/feat/gmrr' into feat/no-overserv…
red-0ne Oct 30, 2024
ee93efa
fix: Rename supplier app stake retrieval fn
red-0ne Oct 30, 2024
1550475
fix: Update godoc comment
red-0ne Oct 30, 2024
cbe98ac
Merge remote-tracking branch 'origin/main' into feat/no-overservicing
red-0ne Oct 30, 2024
cd45da6
chore: Address reivew change requests
red-0ne Oct 30, 2024
5ad3b28
Merge remote-tracking branch 'origin/main' into feat/no-overservicing
red-0ne Oct 31, 2024
e7c288b
fix: Total supply
red-0ne Oct 31, 2024
44a5b19
fix: Add all apps suply
red-0ne Oct 31, 2024
d38c51c
Merge remote-tracking branch 'origin/main' into feat/no-overservicing
red-0ne Nov 5, 2024
c5a3c20
Empty commit
red-0ne Nov 5, 2024
1146aba
chore: Address review change requests
red-0ne Nov 6, 2024
7b8998e
fix: Do not process 0 claim amounts
red-0ne Nov 6, 2024
88a3d45
Empty commit
red-0ne Nov 6, 2024
4b04353
fix: Prevent 0 settlement due to int div
red-0ne Nov 7, 2024
331654f
fix: consumed coin calculation
red-0ne Nov 7, 2024
5438163
wip: update expected balances
red-0ne Nov 11, 2024
1cb995c
chore: Address review change requests
red-0ne Nov 11, 2024
a39d5b2
fix: Remove wrong param comment
red-0ne Nov 11, 2024
a2dd722
chore: Remove already tackled TODOs
red-0ne Nov 11, 2024
2b64d0b
Merge remote-tracking branch 'origin/main' into feat/no-overservicing
red-0ne Nov 11, 2024
586b20e
Merge remote-tracking branch 'origin/main' into feat/no-overservicing
red-0ne Nov 12, 2024
8787c6d
Merge remote-tracking branch 'origin/main' into test/stressonomics
red-0ne Nov 13, 2024
409e952
Merge remote-tracking branch 'origin/feat/no-overservicing' into test…
red-0ne Nov 13, 2024
384852b
Merge remote-tracking branch 'origin/main' into test/stressonomics
red-0ne Nov 13, 2024
ed2f6d0
wip: revamp tx submission
red-0ne Nov 14, 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
237 changes: 165 additions & 72 deletions api/poktroll/tokenomics/event.pulsar.go

Large diffs are not rendered by default.

504 changes: 347 additions & 157 deletions load-testing/tests/relays_stress_helpers_test.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ Feature: Loading gateway server with relays
| gateway | 1 | 10 | 3 |
| supplier | 1 | 10 | 1 |
When a load of concurrent relay requests are sent from the applications
Then the correct pairs count of claim and proof messages should be committed on-chain
Then "0" over servicing events are observed
And "0" slashing events are observed
And "0" expired claim event are observed
And there is as many reimbursment requests as the number of settled claims
And the number of claims submitted and claims settled is the same
And the number of proofs submitted and proofs required is the same
And the actors onchain balances are as expected
223 changes: 195 additions & 28 deletions load-testing/tests/relays_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package tests

import (
"context"
"math/big"
"net/url"
"path/filepath"
"runtime"
Expand All @@ -18,14 +19,19 @@ import (
"github.com/regen-network/gocuke"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/app/volatile"
"github.com/pokt-network/poktroll/cmd/signals"
"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/observable"
"github.com/pokt-network/poktroll/pkg/observable/channel"
"github.com/pokt-network/poktroll/testutil/testclient"
"github.com/pokt-network/poktroll/testutil/testclient/testblock"
"github.com/pokt-network/poktroll/testutil/testclient/testtx"
apptypes "github.com/pokt-network/poktroll/x/application/types"
prooftypes "github.com/pokt-network/poktroll/x/proof/types"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
tokenomicskeeper "github.com/pokt-network/poktroll/x/tokenomics/keeper"
tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types"
)

// The following constants are used to identify the different types of transactions,
Expand Down Expand Up @@ -91,7 +97,8 @@ var (
blockDuration = int64(2)
// newTxEventSubscriptionQuery is the format string which yields a subscription
// query to listen for on-chain Tx events.
newTxEventSubscriptionQuery = "tm.event='Tx'"
newTxEventSubscriptionQuery = "tm.event='Tx'"
newBlockEventSubscriptionQuery = "tm.event='NewBlock'"
// eventsReplayClientBufferSize is the buffer size for the events replay client
// for the subscriptions above.
eventsReplayClientBufferSize = 100
Expand Down Expand Up @@ -127,16 +134,19 @@ type relaysSuite struct {
// batchInfoObs is the observable mapping session information to batch information.
// It is used to determine when to send a batch of relay requests to the network.
batchInfoObs observable.Observable[*relayBatchInfoNotif]
// newTxEventsObs is the observable that notifies the test suite of new
// transactions committed on-chain.
// It is used to check the results of the transactions sent by the test suite.
newTxEventsObs observable.Observable[*types.TxResult]
// txContext is the transaction context used to sign and send transactions.
txContext client.TxContext
// sharedParams is the shared on-chain parameters used in the test.
// It is queried at the beginning of the test.
sharedParams *sharedtypes.Params

// appParams is the application on-chain parameters used in the test.
// It is queried at the beginning of the test.
appParams *apptypes.Params

proofParams *prooftypes.Params
tokenomicsParams *tokenomicstypes.Params

// numRelaysSent is the number of relay requests sent during the test.
numRelaysSent atomic.Uint64
// relayRatePerApp is the rate of relay requests sent per application per second.
Expand Down Expand Up @@ -224,6 +234,46 @@ type relaysSuite struct {
// isEphemeralChain is a flag that indicates whether the test is expected to be
// run on ephemeral chain setups like localnet or long living ones (i.e. Test/DevNet).
isEphemeralChain bool

eventsObs observable.Observable[[]types.Event]

tokenomics *tokenomics
}

type tokenomics struct {
// OverservicedApplications is the list of applications that are overserviced.
OverservicedApplications []*tokenomicstypes.EventApplicationOverserviced
// SuppliersSlashed is the list of suppliers that are slashed.
SuppliersSlashed []*tokenomicstypes.EventSupplierSlashed
// ExpiredClaims is the list of claims that are expired.
ExpiredClaims []*tokenomicstypes.EventClaimExpired
// ReimbursementRequests is the list of reimbursement requests.
ReimbursementRequests []*tokenomicstypes.EventApplicationReimbursementRequest
// ClaimsSettled is the list of claims that are settled.
ClaimsSettled []*tokenomicstypes.EventClaimSettled
// ClaimsSubmitted is the list of claims that are submitted.
ClaimsSubmitted []*prooftypes.EventClaimCreated
// ProofsSubmitted is the list of proofs that are submitted.
ProofsSubmitted []*prooftypes.EventProofSubmitted
// ActorsBalances is the balances of the actors on-chain.
ActorsBalances actorsBalances
}

type actorsBalances struct {
ApplicationBalances map[string]sdk.Coin
ApplicationStakes map[string]sdk.Coin
GatewaysBalances map[string]sdk.Coin
GatewaysStakes map[string]sdk.Coin
SupplierBalances map[string]sdk.Coin
SupplierStakes map[string]sdk.Coin

ApplicationModuleAccountBalance sdk.Coin
SupplierModuleAccountBalance sdk.Coin
GatewayModuleAccountBalance sdk.Coin
TokenomicsModuleAccountBalance sdk.Coin
DAOAccountBalance sdk.Coin
ProposerAccountBalance sdk.Coin
SourceOwnerAccountBalance sdk.Coin
}

// accountInfo contains the account info needed to build and send transactions.
Expand Down Expand Up @@ -271,12 +321,31 @@ func TestLoadRelays(t *testing.T) {
}

func TestLoadRelaysSingleSupplier(t *testing.T) {
gocuke.NewRunner(t, &relaysSuite{}).Path(filepath.Join(".", "relays_stress_single_suppier.feature")).Run()

gocuke.NewRunner(t, &relaysSuite{}).Path(filepath.Join(".", "relays_stress_single_supplier.feature")).Run()
}

func (s *relaysSuite) LocalnetIsRunning() {
s.ctx, s.cancelCtx = context.WithCancel(context.Background())

s.tokenomics = &tokenomics{
OverservicedApplications: make([]*tokenomicstypes.EventApplicationOverserviced, 0),
SuppliersSlashed: make([]*tokenomicstypes.EventSupplierSlashed, 0),
ExpiredClaims: make([]*tokenomicstypes.EventClaimExpired, 0),
ReimbursementRequests: make([]*tokenomicstypes.EventApplicationReimbursementRequest, 0),
ClaimsSettled: make([]*tokenomicstypes.EventClaimSettled, 0),
ClaimsSubmitted: make([]*prooftypes.EventClaimCreated, 0),
ProofsSubmitted: make([]*prooftypes.EventProofSubmitted, 0),
ActorsBalances: actorsBalances{
ApplicationBalances: make(map[string]sdk.Coin),
ApplicationStakes: make(map[string]sdk.Coin),
GatewaysBalances: make(map[string]sdk.Coin),
GatewaysStakes: make(map[string]sdk.Coin),
SupplierBalances: make(map[string]sdk.Coin),
SupplierStakes: make(map[string]sdk.Coin),
},
}

// Cancel the context if this process is interrupted or exits.
// Delete the keyring entries for the application accounts since they are
// not persisted across test runs.
Expand Down Expand Up @@ -359,11 +428,17 @@ func (s *relaysSuite) LocalnetIsRunning() {
s.initFundingAccount(loadTestParams.FundingAccountAddress)

// Initialize the on-chain claims and proofs counter.
s.countClaimAndProofs()
s.forEachSettlement(s.ctx)

// Query for the current shared on-chain params.
s.querySharedParams(loadTestParams.TestNetNode)

// Query for the current app on-chain params.
s.queryAppParams(loadTestParams.TestNetNode)

// Quer for the current proof on-chain params.
s.queryProofParams(loadTestParams.TestNetNode)

// Some suppliers may already be staked at genesis, ensure that staking during
// this test succeeds by increasing the sake amount.
minStakeAmount := s.getProvisionedActorsCurrentStakedAmount()
Expand Down Expand Up @@ -402,26 +477,15 @@ func (s *relaysSuite) MoreActorsAreStakedAsFollows(table gocuke.DataTable) {
// increment the actor count to the maximum.
s.relayLoadDurationBlocks = s.plans.maxActorBlocksToFinalIncrementEnd()

if s.isEphemeralChain {
// Adjust the max delegations parameter to the max gateways to permit all
// applications to delegate to all gateways.
// This is to ensure that requests are distributed evenly across all gateways
// at any given time.
s.sendAdjustMaxDelegationsParamTx(s.plans.gateways.maxActorCount)
s.waitForTxsToBeCommitted()
s.ensureUpdatedMaxDelegations(s.plans.gateways.maxActorCount)
}

// Fund all the provisioned suppliers and gateways since their addresses are
// known and they are not created on the fly, while funding only the initially
// created applications.
fundedSuppliers, fundedGateways, fundedApplications := s.sendFundAvailableActorsTx()
// Funding messages are sent in a single transaction by the funding account,
// only one transaction is expected to be committed.
txResults := s.waitForTxsToBeCommitted()
s.ensureFundedActors(txResults, fundedSuppliers)
s.ensureFundedActors(txResults, fundedGateways)
s.ensureFundedActors(txResults, fundedApplications)
fundedActors := append(fundedSuppliers, fundedGateways...)
fundedActors = append(fundedActors, fundedApplications...)
s.ensureFundedActors(s.ctx, fundedActors)

logger.Info().Msg("Actors funded")

Expand All @@ -430,11 +494,11 @@ func (s *relaysSuite) MoreActorsAreStakedAsFollows(table gocuke.DataTable) {
gateways := fundedGateways[:s.gatewayInitialCount]
applications := fundedApplications[:s.appInitialCount]

stakedActors := append(suppliers, gateways...)
stakedActors = append(stakedActors, applications...)

s.sendInitialActorsStakeMsgs(suppliers, gateways, applications)
txResults = s.waitForTxsToBeCommitted()
s.ensureStakedActors(txResults, EventActionMsgStakeSupplier, suppliers)
s.ensureStakedActors(txResults, EventActionMsgStakeGateway, gateways)
s.ensureStakedActors(txResults, EventActionMsgStakeApplication, applications)
s.ensureStakedActors(s.ctx, stakedActors)

logger.Info().Msg("Actors staked")

Expand All @@ -450,8 +514,7 @@ func (s *relaysSuite) MoreActorsAreStakedAsFollows(table gocuke.DataTable) {

// Delegate the initial applications to the initial gateways
s.sendDelegateInitialAppsTxs(applications, gateways)
txResults = s.waitForTxsToBeCommitted()
s.ensureDelegatedApps(txResults, applications, gateways)
s.ensureDelegatedApps(s.ctx, applications, gateways)

logger.Info().Msg("Apps delegated")

Expand Down Expand Up @@ -508,7 +571,7 @@ func (s *relaysSuite) ALoadOfConcurrentRelayRequestsAreSentFromTheApplications()
// Block the feature step until the test is done.
<-s.ctx.Done()
}
func (s *relaysSuite) TheCorrectPairsCountOfClaimAndProofMessagesShouldBeCommittedOnchain() {
func (s *relaysSuite) TheCorrectCountOfClaimsAndProofsSubmittedOnChain() {
logger.Info().
Int("claims", s.currentClaimCount).
Int("proofs", s.currentProofCount).
Expand All @@ -534,3 +597,107 @@ func (s *relaysSuite) TheCorrectPairsCountOfClaimAndProofMessagesShouldBeCommitt
// "unexpected claims and proofs count",
//)
}

func (s *relaysSuite) OverServicingEventsAreObserved(numEvents int64) {
require.Len(s, s.tokenomics.OverservicedApplications, int(numEvents))
}

func (s *relaysSuite) SlashingEventsAreObserved(numEvents int64) {
require.Len(s, s.tokenomics.SuppliersSlashed, int(numEvents))
}

func (s *relaysSuite) ExpiredClaimEventAreObserved(numEvents int64) {
require.Len(s, s.tokenomics.ExpiredClaims, int(numEvents))
}

func (s *relaysSuite) ThereIsAsManyReimbursmentRequestsAsTheNumberOfSettledClaims() {
require.Equal(s, len(s.tokenomics.ReimbursementRequests), len(s.tokenomics.ClaimsSettled))
}

func (s *relaysSuite) TheNumberOfClaimsSubmittedAndClaimsSettledIsTheSame() {
require.Equal(s, len(s.tokenomics.ClaimsSettled), len(s.tokenomics.ClaimsSubmitted))
}

func (s *relaysSuite) TheNumberOfProofsSubmittedAndProofsRequiredIsTheSame() {
numProofRequiredObserved := 0
for _, claimEvent := range s.tokenomics.ClaimsSettled {
if claimEvent.ProofRequirement != prooftypes.ProofRequirementReason_NOT_REQUIRED {
numProofRequiredObserved++
}
}

require.Len(s, s.tokenomics.ProofsSubmitted, numProofRequiredObserved)
}

func (s *relaysSuite) TheActorsOnchainBalancesAreAsExpected() {
balances := s.tokenomics.ActorsBalances

for _, claimSettlement := range s.tokenomics.ClaimsSettled {
settledUPOKT := claimSettlement.SettledUpokt
claim := claimSettlement.Claim

claimSupplierAddr := claim.SupplierOperatorAddress
_, ok := balances.SupplierBalances[claimSupplierAddr]
require.True(s, ok, "supplier expected balance not found")

claimAppAddr := claim.SessionHeader.ApplicationAddress
_, ok = balances.SupplierBalances[claimAppAddr]
require.True(s, ok, "application expected balance not found")

// account for GMI
mintUPOKT := s.getGlobalInflationMintedUPOKT(settledUPOKT)

// TODO_IN_THIS_PR: Should check with multiple supplier owners

Choose a reason for hiding this comment

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

[linter-name (fail-on-found)] reported by reviewdog 🐶
// TODO_IN_THIS_PR: Should check with multiple supplier owners

supplierMintUPOKT := s.getGlobalInflationActorAllocation(mintUPOKT, s.tokenomicsParams.MintAllocationSupplier)
balances.SupplierBalances[claimSupplierAddr] = balances.SupplierBalances[claimSupplierAddr].
Add(*settledUPOKT).
Add(supplierMintUPOKT)

applicationMintUPOKT := s.getGlobalInflationActorAllocation(mintUPOKT, s.tokenomicsParams.MintAllocationApplication)
balances.ApplicationBalances[claimAppAddr] = balances.ApplicationBalances[claimAppAddr].
Add(applicationMintUPOKT)

balances.ApplicationStakes[claimAppAddr] = balances.ApplicationStakes[claimAppAddr].
Sub(*settledUPOKT).
Sub(mintUPOKT)

balances.ApplicationModuleAccountBalance = balances.ApplicationModuleAccountBalance.
Sub(*settledUPOKT).
Sub(mintUPOKT)

daoMintUPOKT := s.getGlobalInflationActorAllocation(mintUPOKT, s.tokenomicsParams.MintAllocationDao)
balances.DAOAccountBalance = balances.DAOAccountBalance.
Add(daoMintUPOKT).
Add(mintUPOKT)

proposerMintUPOKT := s.getGlobalInflationActorAllocation(mintUPOKT, s.tokenomicsParams.MintAllocationProposer)
balances.ProposerAccountBalance = balances.ProposerAccountBalance.
Add(proposerMintUPOKT)

sourceOwnerMintUPOKT := s.getGlobalInflationActorAllocation(mintUPOKT, s.tokenomicsParams.MintAllocationSourceOwner)
balances.SourceOwnerAccountBalance = balances.SourceOwnerAccountBalance.
Add(sourceOwnerMintUPOKT)
}

for _, proofSubmission := range s.tokenomics.ProofsSubmitted {
operatorAddr := proofSubmission.Claim.SupplierOperatorAddress
balances.SupplierBalances[operatorAddr] = balances.SupplierBalances[operatorAddr].
Sub(*s.proofParams.ProofSubmissionFee)
}
}

func (s *relaysSuite) getGlobalInflationMintedUPOKT(settledUPOKT *sdk.Coin) sdk.Coin {
settlementAmtFloat := new(big.Float).SetUint64(settledUPOKT.Amount.Uint64())
newMintAmtFloat := new(big.Float).Mul(settlementAmtFloat, big.NewFloat(tokenomicskeeper.GlobalInflationPerClaim))
newMintAmtInt, _ := newMintAmtFloat.Int64()
mintUPOKT := sdk.NewCoin(volatile.DenomuPOKT, math.NewInt(newMintAmtInt))
return mintUPOKT
}

func (s *relaysSuite) getGlobalInflationActorAllocation(mintUPOKT sdk.Coin, allocation float64) sdk.Coin {
mintAmtFloat := new(big.Float).SetInt(mintUPOKT.Amount.BigInt())
actorAllocationFloat := new(big.Float).Mul(mintAmtFloat, big.NewFloat(allocation))
actorAllocationInt, _ := actorAllocationFloat.Int64()
actorAllocation := sdk.NewCoin(volatile.DenomuPOKT, math.NewInt(actorAllocationInt))
return actorAllocation
}
23 changes: 22 additions & 1 deletion pkg/client/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//go:generate mockgen -destination=../../testutil/mockclient/session_query_client_mock.go -package=mockclient . SessionQueryClient
//go:generate mockgen -destination=../../testutil/mockclient/shared_query_client_mock.go -package=mockclient . SharedQueryClient
//go:generate mockgen -destination=../../testutil/mockclient/proof_query_client_mock.go -package=mockclient . ProofQueryClient
//go:generate mockgen -destination=../../testutil/mockclient/tokenomics_query_client_mock.go -package=mockclient . TokenomicsQueryClient
//go:generate mockgen -destination=../../testutil/mockclient/service_query_client_mock.go -package=mockclient . ServiceQueryClient
//go:generate mockgen -destination=../../testutil/mockclient/bank_query_client_mock.go -package=mockclient . BankQueryClient
//go:generate mockgen -destination=../../testutil/mockclient/cosmos_tx_builder_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/client TxBuilder
Expand Down Expand Up @@ -272,6 +273,8 @@ type ApplicationQueryClient interface {

// GetAllApplications queries all on-chain applications
GetAllApplications(ctx context.Context) ([]apptypes.Application, error)

GetParams(ctx context.Context) (*apptypes.Params, error)
}

// SupplierQueryClient defines an interface that enables the querying of the
Expand Down Expand Up @@ -342,10 +345,28 @@ type ProofParams interface {
// ProofQueryClient defines an interface that enables the querying of the
// on-chain proof module params.
type ProofQueryClient interface {
// GetParams queries the chain for the current shared module parameters.
// GetParams queries the chain for the current proof module parameters.
GetParams(ctx context.Context) (ProofParams, error)
}

// TokenomicsParams is a go interface type which corresponds to the poktroll.tokenomics.Params
// protobuf message. Since the generated go types don't include interface types, this
// is necessary to prevent dependency cycles.
type TokenomicsParams interface {
GetMintAllocationDao() float64
GetMintAllocationProposer() float64
GetMintAllocationSupplier() float64
GetMintAllocationSourceOwner() float64
GetMintAllocationApplication() float64
}

// TokenomicsQueryClient defines an interface that enables the querying of the
// on-chain tokenomics module params.
type TokenomicsQueryClient interface {
// GetParams queries the chain for the current tokenomics module parameters.
GetParams(ctx context.Context) (TokenomicsParams, error)
}

// ServiceQueryClient defines an interface that enables the querying of the
// on-chain service information
type ServiceQueryClient interface {
Expand Down
Loading
Loading