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

Consensus min gas fee of .0025 uosmo #4244

Merged
merged 25 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dfe43ca
Refactor tests a bit
ValarDragon Feb 7, 2023
38946b7
Add consensus min gas fee
ValarDragon Feb 7, 2023
c676d48
Fix tests
ValarDragon Feb 7, 2023
923b45e
Delete more crud
ValarDragon Feb 7, 2023
7a82e14
Cleanup more duplicate test cases
ValarDragon Feb 7, 2023
125d59d
flip isCheckTx sign
ValarDragon Feb 7, 2023
13679ce
One more test needed
ValarDragon Feb 7, 2023
295aebb
Run invalid fee denom test across both check & deliver
ValarDragon Feb 7, 2023
a374529
Remove extra line
ValarDragon Feb 7, 2023
8c7f27d
Merge branch 'main' into dev/consensus_min_gas_fee
ValarDragon Feb 7, 2023
e42e675
Add hack to get around txfee problem in ibctesting
ValarDragon Feb 8, 2023
f40b0c7
Handle genesis
ValarDragon Feb 8, 2023
b278a48
Minor code cleanup
ValarDragon Feb 8, 2023
5db078c
tryfix simulation
ValarDragon Feb 8, 2023
a8b5c4c
Fix for legacy simulator
ValarDragon Feb 8, 2023
275cfb8
Update x/txfees/keeper/feedecorator_test.go
ValarDragon Feb 8, 2023
e7db7e1
Apply matt comments
ValarDragon Feb 8, 2023
1896d2e
See what happens by adding fees
ValarDragon Feb 8, 2023
f3ffdcb
Merge branch 'main' into dev/consensus_min_gas_fee
ValarDragon Feb 13, 2023
bf1b8bc
Add genesis logic update
ValarDragon Feb 13, 2023
81ea3fd
Try fixing e2e
ValarDragon Feb 13, 2023
efe1326
Add some better logging to find error
ValarDragon Feb 13, 2023
540eaff
remove stat, fix typo
ValarDragon Feb 13, 2023
63c07fa
fix(e2e): fix e2e test for consensus min gas fee #4244 (#4317)
p0mvn Feb 16, 2023
af6f4a0
Temp disable geo twap E2E
ValarDragon Feb 16, 2023
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
2 changes: 1 addition & 1 deletion simulation/simtypes/txbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (sim *SimCtx) defaultTxBuilder(
txConfig := params.MakeEncodingConfig().TxConfig // TODO: unhardcode
// TODO: Consider making a default tx builder that charges some random fees
// Low value for amount of work right now though.
fees := sdk.Coins{}
fees := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 25000))
tx, err := genTx(
txConfig,
[]sdk.Msg{msg},
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,32 @@ This section contains common "gotchas" that is sometimes very good to know when

To fix that, check the docker container and see if you node is working. Or remove all related container then rerun e2e test

3. Transaction fees.

Consensus min fee is set to "0.0025". This is how much is charged for 1 unit of gas. By default, we specify the gas limit
of `40000`. Therefore, each transaction should take `fee = 0.0025 uosmo / gas * 400000 gas = 1000 fee token.
The fee denom is set in `tests/e2e/initialization/config.go` by the value of `E2EFeeToken`.
See "Hermes Relayer - Consensus Min Fee" section for the relevant relayer configuration.
## Hermes Relayer
The configuration is built using the script in `tests/e2e/scripts/hermes_bootstrap.sh`
Repository: <https://github.dev/informalsystems/hermes>
### Consensus Min Fee
We set the following parameters Hermes configs to enable the consensus min fee in Osmosis:
- `gas_price` - Specifies the price per gas used of the fee to submit a transaction and
the denomination of the fee. The specified gas price should always be greater or equal to the `min-gas-price`
configured on the chain. This is to ensure that at least some minimal price is
paid for each unit of gas per transaction.
In Osmosis, we set consensus min fee = .0025 uosmo / gas * 400000 gas = 1000
See ConsensusMinFee in x/txfees/types/constants.go
- `default_gas` - the gas amount to use when simulation fails.
## Debugging
This section contains information about debugging osmosis's `e2e` tests.
Expand Down
16 changes: 14 additions & 2 deletions tests/e2e/configurer/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,30 @@ func (c *Config) SendIBC(dstChain *Config, recipient string, token sdk.Coin) {
dstNode, err := dstChain.GetDefaultNode()
require.NoError(c.t, err)

balancesDstPre, err := dstNode.QueryBalances(recipient)
// removes the fee token from balances for calculating the difference in other tokens
// before and after the IBC send.
removeFeeTokenFromBalance := func(balance sdk.Coins) sdk.Coins {
feeTokenBalance := balance.FilterDenoms([]string{initialization.E2EFeeToken})
return balance.Sub(feeTokenBalance)
}

balancesDstPreWithTxFeeBalance, err := dstNode.QueryBalances(recipient)
require.NoError(c.t, err)

balancesDstPre := removeFeeTokenFromBalance(balancesDstPreWithTxFeeBalance)

cmd := []string{"hermes", "tx", "raw", "ft-transfer", dstChain.Id, c.Id, "transfer", "channel-0", token.Amount.String(), fmt.Sprintf("--denom=%s", token.Denom), fmt.Sprintf("--receiver=%s", recipient), "--timeout-height-offset=1000"}
_, _, err = c.containerManager.ExecHermesCmd(c.t, cmd, "Success")
require.NoError(c.t, err)

require.Eventually(
c.t,
func() bool {
balancesDstPost, err := dstNode.QueryBalances(recipient)
balancesDstPostWithTxFeeBalance, err := dstNode.QueryBalances(recipient)
require.NoError(c.t, err)

balancesDstPost := removeFeeTokenFromBalance(balancesDstPostWithTxFeeBalance)

ibcCoin := balancesDstPost.Sub(balancesDstPre)
if ibcCoin.Len() == 1 {
tokenPre := balancesDstPre.AmountOfNoDenomValidation(ibcCoin[0].Denom)
Expand Down
23 changes: 16 additions & 7 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
app "github.com/osmosis-labs/osmosis/v14/app"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/p2p"
coretypes "github.com/tendermint/tendermint/rpc/core/types"

app "github.com/osmosis-labs/osmosis/v14/app"
)

func (n *NodeConfig) CreateBalancerPool(poolFile, from string) uint64 {
Expand Down Expand Up @@ -127,7 +128,7 @@ func (n *NodeConfig) SendIBCTransfer(from, recipient, amount, memo string) {

cmd := []string{"osmosisd", "tx", "ibc-transfer", "transfer", "transfer", "channel-0", recipient, amount, fmt.Sprintf("--from=%s", from), "--memo", memo}

_, _, err := n.containerManager.ExecTxCmdWithSuccessString(n.t, n.chainId, n.Name, cmd, "code: 0")
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd)
Copy link
Member

Choose a reason for hiding this comment

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

Why was this done?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a driveby change to get the execution stack to have one entry point. (At the time I did this line, I thought I'd do the gas if statement in this method, ended up not doing that)

So can be reverted, but looks identical to the ExecTxCmd as far as I can tell?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think this is fine, was getting sidetracked by this but the change LGTM now.

I think I found the main problem. Should have the fix soon

require.NoError(n.t, err)

n.LogActionF("successfully submitted sent IBC transfer")
Expand Down Expand Up @@ -277,6 +278,8 @@ func (n *NodeConfig) BankSend(amount string, sendAddress string, receiveAddress
n.LogActionF("successfully sent bank sent %s from address %s to %s", amount, sendAddress, receiveAddress)
}

// This method also funds fee tokens from the `initialization.ValidatorWalletName` account.
// TODO: Abstract this to be a fee token provider account.
func (n *NodeConfig) CreateWallet(walletName string) string {
n.LogActionF("creating wallet %s", walletName)
cmd := []string{"osmosisd", "keys", "add", walletName, "--keyring-backend=test"}
Expand All @@ -285,19 +288,25 @@ func (n *NodeConfig) CreateWallet(walletName string) string {
re := regexp.MustCompile("osmo1(.{38})")
walletAddr := fmt.Sprintf("%s\n", re.FindString(outBuf.String()))
walletAddr = strings.TrimSuffix(walletAddr, "\n")
n.LogActionF("created wallet %s, waller address - %s", walletName, walletAddr)
n.LogActionF("created wallet %s, wallet address - %s", walletName, walletAddr)
n.BankSend(initialization.WalletFeeTokens.String(), initialization.ValidatorWalletName, walletAddr)
n.LogActionF("Sent fee tokens from %s", initialization.ValidatorWalletName)
return walletAddr
}

func (n *NodeConfig) CreateWalletAndFund(walletName string, tokensToFund []string) string {
n.LogActionF("Sending tokens to %s", walletName)
return n.CreateWalletAndFundFrom(walletName, initialization.ValidatorWalletName, tokensToFund)
}

func (n *NodeConfig) CreateWalletAndFundFrom(newWalletName string, fundingWalletName string, tokensToFund []string) string {
n.LogActionF("Sending tokens to %s", newWalletName)

walletAddr := n.CreateWallet(walletName)
walletAddr := n.CreateWallet(newWalletName)
for _, tokenToFund := range tokensToFund {
n.BankSend(tokenToFund, initialization.ValidatorWalletName, walletAddr)
n.BankSend(tokenToFund, fundingWalletName, walletAddr)
}

n.LogActionF("Successfully sent tokens to %s", walletName)
n.LogActionF("Successfully sent tokens to %s", newWalletName)
return walletAddr
}

Expand Down
9 changes: 9 additions & 0 deletions tests/e2e/configurer/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ var (
InitialMinDeposit = MinDepositValue / 4
// Minimum expedited deposit value for proposal to be submitted.
InitialMinExpeditedDeposit = MinExpeditedDepositValue / 4
// The first id of a pool create via CLI before starting an
// upgrade.
// Note: that we create a pool with id 1 via genesis
// in the initialization package. As a result, the first
// pre-upgrade should have id 2.
// This value gets mutated during the pre-upgrade pool
// creation in case more pools are added to genesis
// in the future
PreUpgradePoolId uint64 = 2
)
11 changes: 6 additions & 5 deletions tests/e2e/configurer/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,20 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
chainA.SendIBC(chainB, chainB.NodeConfigs[0].PublicAddress, initialization.StakeToken)
chainB.SendIBC(chainA, chainA.NodeConfigs[0].PublicAddress, initialization.StakeToken)

chainANode.CreateBalancerPool("pool1A.json", initialization.ValidatorWalletName)
config.PreUpgradePoolId = chainANode.CreateBalancerPool("pool1A.json", initialization.ValidatorWalletName)
poolShareDenom := fmt.Sprintf("gamm/pool/%d", config.PreUpgradePoolId)
chainBNode.CreateBalancerPool("pool1B.json", initialization.ValidatorWalletName)

// enable superfluid assets on chainA
chainA.EnableSuperfluidAsset("gamm/pool/1")
chainA.EnableSuperfluidAsset(poolShareDenom)

// setup wallets and send gamm tokens to these wallets (only chainA)
lockupWalletAddrA, lockupWalletSuperfluidAddrA := chainANode.CreateWallet(lockupWallet), chainANode.CreateWallet(lockupWalletSuperfluid)
chainANode.BankSend("10000000000000000000gamm/pool/1", chainA.NodeConfigs[0].PublicAddress, lockupWalletAddrA)
chainANode.BankSend("10000000000000000000gamm/pool/1", chainA.NodeConfigs[0].PublicAddress, lockupWalletSuperfluidAddrA)
chainANode.BankSend("10000000000000000000"+poolShareDenom, chainA.NodeConfigs[0].PublicAddress, lockupWalletAddrA)
chainANode.BankSend("10000000000000000000"+poolShareDenom, chainA.NodeConfigs[0].PublicAddress, lockupWalletSuperfluidAddrA)

// test lock and add to existing lock for both regular and superfluid lockups (only chainA)
chainA.LockAndAddToExistingLock(sdk.NewInt(1000000000000000000), "gamm/pool/1", lockupWalletAddrA, lockupWalletSuperfluidAddrA)
chainA.LockAndAddToExistingLock(sdk.NewInt(1000000000000000000), poolShareDenom, lockupWalletAddrA, lockupWalletSuperfluidAddrA)

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/containers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const (
// It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset
// for this functionality to be used.
previousVersionOsmoRepository = "osmolabs/osmosis-dev"
previousVersionOsmoTag = "v14.x-6b742c84-1675172347"
previousVersionOsmoTag = "v14.x-4d4583fa-1676370337"
// Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion)
previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain"
previousVersionInitTag = "v14.x-f6813bcb-1674140667-manual"
previousVersionInitTag = "v14.x-4d4583fa-1676370337-manual"
// Hermes repo/version for relayer
relayerRepository = "osmolabs/hermes"
relayerTag = "0.13.0"
Expand Down
34 changes: 31 additions & 3 deletions tests/e2e/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,33 @@ import (
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v14/tests/e2e/initialization"
txfeestypes "github.com/osmosis-labs/osmosis/v14/x/txfees/types"
)

const (
hermesContainerName = "hermes-relayer"
// The maximum number of times debug logs are printed to console
// per CLI command.
maxDebugLogsPerCommand = 3

GasLimit = 400000
)

var defaultErrRegex = regexp.MustCompile(`(E|e)rror`)
var (
// We set consensus min fee = .0025 uosmo / gas * 400000 gas = 1000
Fees = txfeestypes.ConsensusMinFee.Mul(sdk.NewDec(GasLimit)).Ceil().TruncateInt64()

defaultErrRegex = regexp.MustCompile(`(E|e)rror`)

txArgs = []string{"-b=block", "--yes", "--keyring-backend=test", "--log_format=json"}

// See ConsensusMinFee in x/txfees/types/constants.go
txDefaultGasArgs = []string{fmt.Sprintf("--gas=%d", GasLimit), fmt.Sprintf("--fees=%d", Fees) + initialization.E2EFeeToken}
)

// Manager is a wrapper around all Docker instances, and the Docker API.
// It provides utilities to run and interact with all Docker containers used within e2e testing.
Expand Down Expand Up @@ -59,10 +76,21 @@ func (m *Manager) ExecTxCmd(t *testing.T, chainId string, containerName string,
}

// ExecTxCmdWithSuccessString Runs ExecCmd, with flags for txs added.
// namely adding flags `--chain-id={chain-id} -b=block --yes --keyring-backend=test "--log_format=json"`,
// namely adding flags `--chain-id={chain-id} -b=block --yes --keyring-backend=test "--log_format=json" --gas=400000`,
// and searching for `successStr`
func (m *Manager) ExecTxCmdWithSuccessString(t *testing.T, chainId string, containerName string, command []string, successStr string) (bytes.Buffer, bytes.Buffer, error) {
allTxArgs := []string{fmt.Sprintf("--chain-id=%s", chainId), "-b=block", "--yes", "--keyring-backend=test", "--log_format=json"}
allTxArgs := []string{fmt.Sprintf("--chain-id=%s", chainId)}
allTxArgs = append(allTxArgs, txArgs...)
// parse to see if command has gas flags. If not, add default gas flags.
addGasFlags := true
for _, cmd := range command {
if strings.HasPrefix(cmd, "--gas") || strings.HasPrefix(cmd, "--fees") {
addGasFlags = false
}
}
if addGasFlags {
allTxArgs = append(allTxArgs, txDefaultGasArgs...)
}
txCommand := append(command, allTxArgs...)
return m.ExecCmd(t, containerName, txCommand, successStr)
}
Expand Down
Loading