Skip to content

Commit ba36778

Browse files
authored
Avoid add duplicate host zone proposal and remove old data when set new host zone. (#146)
* Avoid add duplicate host zone proposal and remove old data when set new host zone. * Remove check host zone config by osmosis denom * Fix lint * Change gas for exec tx proposal
1 parent 7a240b8 commit ba36778

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ ictest-query-osmosis-twap:
131131
cd tests/interchaintest && go test -timeout=25m -race -v -run TestQueryOsmosisTwap .
132132

133133
# Executes all tests via interchaintest after compling a local image as juno:local
134-
ictest-all: ictest-basic ictest-ibc ictest-packet-forward
134+
ictest-all: ictest-basic ictest-ibc ictest-packet-forward ictest-host-zone-proposal ictest-query-osmosis-twap ictest-feeabs
135135

136-
.PHONY: ictest-basic ictest-ibc ictest-packet-forward ictest-all
136+
.PHONY: ictest-basic ictest-ibc ictest-packet-forward ictest-all ictest-host-zone-proposal ictest-query-osmosis-twap ictest-feeabs
137137

138138
###############################################################################
139139
### Proto ###

tests/interchaintest/feeabs/proposal.go

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func AddHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName str
117117
command := []string{
118118
"gov", "submit-legacy-proposal",
119119
"add-hostzone-config", filePath,
120+
"--gas", "auto", "--gas-adjustment", "1.5",
120121
}
121122
return tn.ExecTx(ctx, keyName, command...)
122123
}
@@ -140,6 +141,7 @@ func DeleteHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName
140141
command := []string{
141142
"gov", "submit-legacy-proposal",
142143
"delete-hostzone-config", filePath,
144+
"--gas", "auto", "--gas-adjustment", "1.5",
143145
}
144146
return tn.ExecTx(ctx, keyName, command...)
145147
}
@@ -163,6 +165,7 @@ func SetHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName str
163165
command := []string{
164166
"gov", "submit-legacy-proposal",
165167
"set-hostzone-config", filePath,
168+
"--gas", "auto", "--gas-adjustment", "1.5",
166169
}
167170
return tn.ExecTx(ctx, keyName, command...)
168171
}

x/feeabs/keeper/proposal.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package keeper
22

33
import (
4+
"cosmossdk.io/errors"
5+
46
sdk "github.com/cosmos/cosmos-sdk/types"
57

68
"github.com/osmosis-labs/fee-abstraction/v7/x/feeabs/types"
79
)
810

911
func (k Keeper) AddHostZoneProposal(ctx sdk.Context, p *types.AddHostZoneProposal) error {
1012
if k.HasHostZoneConfig(ctx, p.HostChainConfig.IbcDenom) {
11-
return types.ErrDuplicateHostZoneConfig
13+
return errors.Wrapf(types.ErrDuplicateHostZoneConfig, "duplicate host ibc denom")
1214
}
1315

1416
if err := k.SetHostZoneConfig(ctx, *p.HostChainConfig); err != nil {
@@ -24,9 +26,15 @@ func (k Keeper) DeleteHostZoneProposal(ctx sdk.Context, p *types.DeleteHostZoneP
2426

2527
func (k Keeper) SetHostZoneProposal(ctx sdk.Context, p *types.SetHostZoneProposal) error {
2628
if !k.HasHostZoneConfig(ctx, p.HostChainConfig.IbcDenom) {
27-
return types.ErrHostZoneConfigNotFound
29+
return errors.Wrapf(types.ErrHostZoneConfigNotFound, "host ibc denom not found: %s", p.HostChainConfig.IbcDenom)
30+
}
31+
32+
// delete old host zone config
33+
if err := k.DeleteHostZoneConfig(ctx, p.HostChainConfig.IbcDenom); err != nil {
34+
return err
2835
}
2936

37+
// set new host zone config
3038
if err := k.SetHostZoneConfig(ctx, *p.HostChainConfig); err != nil {
3139
return err
3240
}

x/feeabs/types/epoch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
)
77

88
const (
9-
DefaultSwapPeriod = time.Minute * 1
10-
DefaultQueryPeriod = time.Minute * 1
9+
DefaultSwapPeriod = time.Minute * 5
10+
DefaultQueryPeriod = time.Minute * 5
1111
DefaultSwapEpochIdentifier = "swap"
1212
DefaultQueryEpochIdentifier = "query"
1313
)

0 commit comments

Comments
 (0)