-
Notifications
You must be signed in to change notification settings - Fork 608
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
feat: track and query protocol rev across all modules #6804
Merged
Merged
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8afd659
implement query to get protocol rev across all modules
czarcas7ic 69ab6f7
add cli cmd
czarcas7ic d45713e
Merge branch 'main' into adam/all-protocol-rev-query
czarcas7ic 8a502b1
Auto: update go.mod after push to adam/all-protocol-rev-query that mo…
invalid-email-address e03b23d
add changelog
czarcas7ic 7e6479c
fix txfees tests
czarcas7ic 103fede
add upgrade test
czarcas7ic fc897aa
fix remaining test
czarcas7ic adf5635
change from uint to int
czarcas7ic d37589c
int
czarcas7ic 6561349
dont recalc values at epoch hook call
czarcas7ic 4b0a209
fix upgrade test
czarcas7ic 252add7
clean up
czarcas7ic b49fc97
merge taker fees into single struct
czarcas7ic 60f5b76
add default value for tests
czarcas7ic b7447b9
add genesis test
czarcas7ic bc3ddee
remove old portion of test
czarcas7ic d26db48
Merge branch 'main' into adam/all-protocol-rev-query
czarcas7ic a61bebf
fix test
czarcas7ic da030c5
fix tests
czarcas7ic 2944189
Auto: update go.mod after push to adam/all-protocol-rev-query that mo…
invalid-email-address File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package apptesting | ||
|
||
import ( | ||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
"github.com/cosmos/cosmos-sdk/simapp" | ||
"github.com/cosmos/cosmos-sdk/testutil/testdata" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
|
||
clienttx "github.com/cosmos/cosmos-sdk/client/tx" | ||
|
||
"github.com/osmosis-labs/osmosis/osmomath" | ||
"github.com/osmosis-labs/osmosis/v20/x/txfees/keeper" | ||
"github.com/osmosis-labs/osmosis/v20/x/txfees/types" | ||
) | ||
|
||
var baseGas = uint64(10000) | ||
|
||
func (s *KeeperTestHelper) ExecuteUpgradeFeeTokenProposal(feeToken string, poolId uint64) error { | ||
upgradeProp := types.NewUpdateFeeTokenProposal( | ||
"Test Proposal", | ||
"test", | ||
[]types.FeeToken{ | ||
{ | ||
Denom: feeToken, | ||
PoolID: poolId, | ||
}, | ||
}, | ||
) | ||
return s.App.TxFeesKeeper.HandleUpdateFeeTokenProposal(s.Ctx, &upgradeProp) | ||
} | ||
|
||
func (s *KeeperTestHelper) SetupTxFeeAnteHandlerAndChargeFee(clientCtx client.Context, minGasPrices sdk.DecCoins, gasRequested uint64, isCheckTx, isSimulate bool, txFee sdk.Coins) error { | ||
mempoolFeeOpts := types.NewDefaultMempoolFeeOptions() | ||
mempoolFeeOpts.MinGasPriceForHighGasTx = osmomath.MustNewDecFromStr("0.0025") | ||
|
||
uionPoolId := s.PrepareBalancerPoolWithCoins( | ||
sdk.NewInt64Coin(sdk.DefaultBondDenom, 500), | ||
sdk.NewInt64Coin("uion", 500), | ||
) | ||
err := s.ExecuteUpgradeFeeTokenProposal("uion", uionPoolId) | ||
s.Require().NoError(err) | ||
|
||
if gasRequested == 0 { | ||
gasRequested = baseGas | ||
} | ||
s.Ctx = s.Ctx.WithIsCheckTx(isCheckTx).WithMinGasPrices(minGasPrices) | ||
|
||
// TODO: Cleanup this code. | ||
// TxBuilder components reset for every test case | ||
txBuilder := clientCtx.TxConfig.NewTxBuilder() | ||
priv0, _, addr0 := testdata.KeyTestPubAddr() | ||
acc1 := s.App.AccountKeeper.NewAccountWithAddress(s.Ctx, addr0) | ||
s.App.AccountKeeper.SetAccount(s.Ctx, acc1) | ||
msgs := []sdk.Msg{testdata.NewTestMsg(addr0)} | ||
privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} | ||
signerData := authsigning.SignerData{ | ||
ChainID: s.Ctx.ChainID(), | ||
AccountNumber: accNums[0], | ||
Sequence: accSeqs[0], | ||
} | ||
|
||
gasLimit := gasRequested | ||
sigV2, _ := clienttx.SignWithPrivKey( | ||
1, | ||
signerData, | ||
txBuilder, | ||
privs[0], | ||
clientCtx.TxConfig, | ||
accSeqs[0], | ||
) | ||
|
||
err = simapp.FundAccount(s.App.BankKeeper, s.Ctx, addr0, txFee) | ||
s.Require().NoError(err) | ||
|
||
tx := s.BuildTx(txBuilder, msgs, sigV2, "", txFee, gasLimit) | ||
|
||
mfd := keeper.NewMempoolFeeDecorator(*s.App.TxFeesKeeper, mempoolFeeOpts) | ||
dfd := keeper.NewDeductFeeDecorator(*s.App.TxFeesKeeper, *s.App.AccountKeeper, *s.App.BankKeeper, nil) | ||
antehandlerMFD := sdk.ChainAnteDecorators(mfd, dfd) | ||
_, err = antehandlerMFD(s.Ctx, tx, isSimulate) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,3 +114,11 @@ func MergeCoinMaps[T comparable](currentEpochExpectedDistributionsOne map[T]sdk. | |
} | ||
return newMap | ||
} | ||
|
||
func ConvertCoinArrayToCoins(coinArray []sdk.Coin) sdk.Coins { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While coin arrays can be used in place of a coins object and still be valid, coin array do not posses the same sub methods (ex. Sub, Add, etc), so this method is useful imo. |
||
coins := sdk.Coins{} | ||
for _, coin := range coinArray { | ||
coins = append(coins, coin) | ||
} | ||
return coins | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The methods in the file are extracted from previously existing txfees helpers because they need to be used in other module tests, and I wanted to prevent code duplication.