Skip to content

Commit

Permalink
Avoid add duplicate host zone proposal and remove old data when set n…
Browse files Browse the repository at this point in the history
…ew 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
  • Loading branch information
tnv1 authored Mar 2, 2024
1 parent 7a240b8 commit ba36778
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ ictest-query-osmosis-twap:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestQueryOsmosisTwap .

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

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

###############################################################################
### Proto ###
Expand Down
3 changes: 3 additions & 0 deletions tests/interchaintest/feeabs/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func AddHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName str
command := []string{
"gov", "submit-legacy-proposal",
"add-hostzone-config", filePath,
"--gas", "auto", "--gas-adjustment", "1.5",
}
return tn.ExecTx(ctx, keyName, command...)
}
Expand All @@ -140,6 +141,7 @@ func DeleteHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName
command := []string{
"gov", "submit-legacy-proposal",
"delete-hostzone-config", filePath,
"--gas", "auto", "--gas-adjustment", "1.5",
}
return tn.ExecTx(ctx, keyName, command...)
}
Expand All @@ -163,6 +165,7 @@ func SetHostZoneProposal(c *cosmos.CosmosChain, ctx context.Context, keyName str
command := []string{
"gov", "submit-legacy-proposal",
"set-hostzone-config", filePath,
"--gas", "auto", "--gas-adjustment", "1.5",
}
return tn.ExecTx(ctx, keyName, command...)
}
Expand Down
12 changes: 10 additions & 2 deletions x/feeabs/keeper/proposal.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package keeper

import (
"cosmossdk.io/errors"

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

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

func (k Keeper) AddHostZoneProposal(ctx sdk.Context, p *types.AddHostZoneProposal) error {
if k.HasHostZoneConfig(ctx, p.HostChainConfig.IbcDenom) {
return types.ErrDuplicateHostZoneConfig
return errors.Wrapf(types.ErrDuplicateHostZoneConfig, "duplicate host ibc denom")
}

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

func (k Keeper) SetHostZoneProposal(ctx sdk.Context, p *types.SetHostZoneProposal) error {
if !k.HasHostZoneConfig(ctx, p.HostChainConfig.IbcDenom) {
return types.ErrHostZoneConfigNotFound
return errors.Wrapf(types.ErrHostZoneConfigNotFound, "host ibc denom not found: %s", p.HostChainConfig.IbcDenom)
}

// delete old host zone config
if err := k.DeleteHostZoneConfig(ctx, p.HostChainConfig.IbcDenom); err != nil {
return err
}

// set new host zone config
if err := k.SetHostZoneConfig(ctx, *p.HostChainConfig); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions x/feeabs/types/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
)

const (
DefaultSwapPeriod = time.Minute * 1
DefaultQueryPeriod = time.Minute * 1
DefaultSwapPeriod = time.Minute * 5
DefaultQueryPeriod = time.Minute * 5
DefaultSwapEpochIdentifier = "swap"
DefaultQueryEpochIdentifier = "query"
)
Expand Down

0 comments on commit ba36778

Please sign in to comment.