Skip to content

Commit d23ef64

Browse files
committed
improve feemarket e2e tests
1 parent e46b42a commit d23ef64

File tree

9 files changed

+624
-191
lines changed

9 files changed

+624
-191
lines changed

app/app.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import (
6969
upgrades "github.com/CosmosContracts/juno/v30/app/upgrades"
7070
v28 "github.com/CosmosContracts/juno/v30/app/upgrades/v28"
7171
v29 "github.com/CosmosContracts/juno/v30/app/upgrades/v29"
72+
feemarkettypes "github.com/CosmosContracts/juno/v30/x/feemarket/types"
7273
)
7374

7475
const (
@@ -296,6 +297,12 @@ func New(
296297
panic(err)
297298
}
298299

300+
// TODO: IMPORTANT!!! Create real denom resolver, this one uses the same amount
301+
// token amount for every denom. 1ujuno != 1uatom in price.
302+
// Resolve to denom should be based on the price of the denom in an oracle module
303+
// or temporarily use a hardcoded token price ratio from ujuno to x token
304+
app.AppKeepers.FeeMarketKeeper.SetDenomResolver(&feemarkettypes.TestDenomResolver{})
305+
299306
app.SetAnteHandler(anteHandler)
300307
app.SetPostHandler(postHandler)
301308

app/upgrades/v30/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
storetypes "cosmossdk.io/store/types"
55

66
"github.com/CosmosContracts/juno/v30/app/upgrades"
7+
feemarkettypes "github.com/CosmosContracts/juno/v30/x/feemarket/types"
78
)
89

910
const UpgradeName = "v30"
@@ -15,5 +16,8 @@ var Upgrade = upgrades.Upgrade{
1516
Deleted: []string{
1617
"globalfee",
1718
},
19+
Added: []string{
20+
feemarkettypes.ModuleName,
21+
},
1822
},
1923
}

app/upgrades/v30/upgrades.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ package v30
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67

78
upgradetypes "cosmossdk.io/x/upgrade/types"
89

10+
log "cosmossdk.io/log"
911
sdk "github.com/cosmos/cosmos-sdk/types"
1012
"github.com/cosmos/cosmos-sdk/types/module"
1113

1214
"github.com/CosmosContracts/juno/v30/app/keepers"
15+
feemarkettypes "github.com/CosmosContracts/juno/v30/x/feemarket/types"
1316
)
1417

1518
func CreateV30UpgradeHandler(
@@ -29,6 +32,48 @@ func CreateV30UpgradeHandler(
2932
}
3033
logger.Info(fmt.Sprintf("v30: post migration check: %v", versionMap))
3134

35+
err = configureFeemarketParams(ctx, k, logger)
36+
3237
return versionMap, nil
3338
}
3439
}
40+
41+
func configureFeemarketParams(ctx context.Context, k *keepers.AppKeepers, logger log.Logger) error {
42+
mintParams, err := k.MintKeeper.GetParams(ctx)
43+
if err != nil {
44+
logger.Error("v30: failed to get x/mint params")
45+
return errors.New("v30: failed to get x/mint params")
46+
}
47+
48+
consensusParams, err := k.ConsensusParamsKeeper.ParamsStore.Get(ctx)
49+
if err != nil {
50+
logger.Error("v30: failed to get x/consensus params")
51+
return errors.New("v30: failed to get x/consensus params")
52+
}
53+
54+
newFeemarketParams := feemarkettypes.Params{
55+
Alpha: feemarkettypes.DefaultAIMDAlpha,
56+
Beta: feemarkettypes.DefaultAIMDBeta,
57+
Gamma: feemarkettypes.DefaultAIMDGamma,
58+
Delta: feemarkettypes.DefaultAIMDDelta,
59+
MinBaseGasPrice: feemarkettypes.DefaultMinBaseGasPrice,
60+
MinLearningRate: feemarkettypes.DefaultAIMDMinLearningRate,
61+
MaxLearningRate: feemarkettypes.DefaultAIMDMaxLearningRate,
62+
MaxBlockUtilization: uint64(consensusParams.Block.MaxGas),
63+
Window: 16,
64+
FeeDenom: mintParams.MintDenom,
65+
Enabled: true,
66+
DistributeFees: true,
67+
}
68+
69+
sdkCtx := sdk.UnwrapSDKContext(ctx)
70+
err = k.FeeMarketKeeper.SetParams(sdkCtx, newFeemarketParams)
71+
if err != nil {
72+
logger.Error("v30: failed to set x/feemarket params")
73+
return errors.New("v30: failed to set x/feemarket params")
74+
}
75+
76+
logger.Info("v30: successfully set x/feemarket params")
77+
78+
return nil
79+
}

interchaintest/suite/lib.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"testing"
1010
"time"
1111

12-
"cosmossdk.io/math"
1312
"github.com/cosmos/cosmos-sdk/codec"
1413
"github.com/cosmos/cosmos-sdk/crypto/keyring"
1514

@@ -42,24 +41,15 @@ type KeyringOverride struct {
4241
}
4342

4443
type TestTxConfig struct {
45-
SmallSendsNum int
46-
LargeSendsNum int
47-
TargetIncreaseGasPrice math.LegacyDec
44+
SmallSendsNum int
45+
LargeSendsNum int
4846
}
4947

5048
func (tx *TestTxConfig) Validate() error {
5149
if tx.SmallSendsNum < 1 || tx.LargeSendsNum < 1 {
5250
return fmt.Errorf("sends num should be greater than 1")
5351
}
5452

55-
if tx.TargetIncreaseGasPrice.IsNil() {
56-
return fmt.Errorf("target increase gas price is nil")
57-
}
58-
59-
if tx.TargetIncreaseGasPrice.LTE(math.LegacyZeroDec()) {
60-
return fmt.Errorf("target increase gas price is less than or equal to 0")
61-
}
62-
6353
return nil
6454
}
6555

interchaintest/suite/setup.go

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,17 @@ var (
3737
DefaultNumValidators = 1
3838
DefaultNumFullNodes = 0
3939
DefaultHaltHeightDelta = int64(9) // will propose upgrade this many blocks in the future
40-
DefaultMinBaseGasPrice = sdkmath.LegacyMustNewDecFromStr("0.001")
41-
DefaultBaseGasPrice = sdkmath.LegacyMustNewDecFromStr("0.1")
40+
DefaultMinBaseGasPrice = sdkmath.LegacyMustNewDecFromStr("0.002")
41+
DefaultBaseGasPrice = sdkmath.LegacyMustNewDecFromStr("1")
4242
DefaultNoHostMount = false
4343

4444
JunoRepo = "ghcr.io/cosmoscontracts/juno"
45-
HubRepo = "ghcr.io/cosmos/gaia"
4645
junoRepo, junoVersion = GetDockerImageInfo()
4746
JunoImage = ibc.DockerImage{
4847
Repository: junoRepo,
4948
Version: junoVersion,
5049
UIDGID: "1025:1025",
5150
}
52-
HubImage = ibc.DockerImage{
53-
Repository: HubRepo,
54-
Version: "v23.3.0",
55-
UIDGID: "1025:1025",
56-
}
5751

5852
DefaultGenesisKV = []cosmos.GenesisKV{
5953
{
@@ -94,8 +88,8 @@ var (
9488
MinBaseGasPrice: DefaultMinBaseGasPrice,
9589
MinLearningRate: feemarkettypes.DefaultAIMDMinLearningRate,
9690
MaxLearningRate: feemarkettypes.DefaultAIMDMaxLearningRate,
97-
MaxBlockUtilization: 100_000_000,
98-
Window: 16,
91+
MaxBlockUtilization: 3_000_000,
92+
Window: 8,
9993
FeeDenom: DefaultDenom,
10094
Enabled: true,
10195
DistributeFees: false,
@@ -106,7 +100,7 @@ var (
106100
Value: feemarkettypes.State{
107101
BaseGasPrice: DefaultBaseGasPrice,
108102
LearningRate: feemarkettypes.DefaultAIMDMaxLearningRate,
109-
Window: make([]uint64, 16),
103+
Window: make([]uint64, 8),
110104
Index: 0,
111105
},
112106
},
@@ -123,7 +117,7 @@ var (
123117
Gas: "auto",
124118
CoinType: "118",
125119
GasPrices: "",
126-
GasAdjustment: 10,
120+
GasAdjustment: 3,
127121
TrustingPeriod: "112h",
128122
NoHostMount: DefaultNoHostMount,
129123
EncodingConfig: MakeJunoEncoding(),
@@ -141,9 +135,8 @@ var (
141135
}
142136

143137
DefaultTxCfg = TestTxConfig{
144-
SmallSendsNum: 1,
145-
LargeSendsNum: 400,
146-
TargetIncreaseGasPrice: sdkmath.LegacyMustNewDecFromStr("0.11"),
138+
SmallSendsNum: 1,
139+
LargeSendsNum: 400,
147140
}
148141
)
149142

@@ -154,7 +147,7 @@ func init() {
154147
sdk.GetConfig().SetCoinType(118)
155148
}
156149

157-
// junoEncoding registers the Juno specific module codecs so that the associated types and msgs
150+
// MakeJunoEncoding registers the Juno specific module codecs so that the associated types and msgs
158151
// will be supported when writing to the blocksdb sqlite database.
159152
func MakeJunoEncoding() *testutil.TestEncodingConfig {
160153
cfg := cosmos.DefaultEncoding()

interchaintest/suite/tx.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (s *E2ETestSuite) SendCoinsMultiBroadcast(sender, receiver ibc.Wallet, amt,
5959
}
6060
}
6161

62-
tx := s.CreateTx(s.Chain, sender, fees.String(), gas, false, msgs...)
62+
tx := s.CreateTx(s.Chain, sender, fees.String(), gas, true, msgs...)
6363

6464
// get an rpc endpoint for the chain
6565
c := s.Chain.Nodes()[0].Client
@@ -240,7 +240,10 @@ func (s *E2ETestSuite) CreateTx(chain *cosmos.CosmosChain, user cosmos.User, fee
240240
// update sequence number
241241
txf = txf.WithSequence(txf.Sequence())
242242
if bumpSequence {
243-
txf = txf.WithSequence(txf.Sequence() + 1)
243+
if txf.Sequence() == 0 {
244+
txf = txf.WithSequence(0)
245+
}
246+
txf = txf.WithSequence(txf.Sequence())
244247
}
245248

246249
// sign the tx

0 commit comments

Comments
 (0)