Skip to content

Commit

Permalink
fix BeginBlock not work on x/feeabs
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed May 29, 2024
1 parent eca3ba3 commit 2b0b2ae
Show file tree
Hide file tree
Showing 10 changed files with 2,663 additions and 254 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- run: make ictest-basic
env:
BRANCH_CI: 'latest'
BRANCH_CI: "latest"

test-ibc:
runs-on: ubuntu-latest
Expand All @@ -57,7 +57,23 @@ jobs:

- run: make ictest-ibc
env:
BRANCH_CI: 'latest'
BRANCH_CI: "latest"

test-ibc-ibcfee:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.21
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: checkout code
uses: actions/checkout@v3

- run: make ictest-ibc-custom
env:
BRANCH_CI: "latest"

test-packet-forward:
runs-on: ubuntu-latest
Expand All @@ -73,7 +89,7 @@ jobs:

- run: make ictest-packet-forward
env:
BRANCH_CI: 'latest'
BRANCH_CI: "latest"

test-host-zone-proposal:
runs-on: ubuntu-latest
Expand All @@ -89,7 +105,7 @@ jobs:

- run: make ictest-host-zone-proposal
env:
BRANCH_CI: 'latest'
BRANCH_CI: "latest"

test-feeabs:
runs-on: ubuntu-latest
Expand All @@ -105,7 +121,7 @@ jobs:

- run: make ictest-feeabs
env:
BRANCH_CI: 'latest'
BRANCH_CI: "latest"

test-query-osmosis-twap:
runs-on: ubuntu-latest
Expand All @@ -121,4 +137,4 @@ jobs:

- run: make ictest-query-osmosis-twap
env:
BRANCH_CI: 'latest'
BRANCH_CI: "latest"
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ictest-basic:

# Executes IBC tests via interchaintest
ictest-ibc:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestFeeabsGaiaIBCTransfer .
cd tests/interchaintest && go test -timeout=25m -race -v -run '^TestFeeabsGaiaIBCTransfer$$' .

# Executes IBC tests via interchaintest
ictest-packet-forward:
Expand All @@ -128,12 +128,12 @@ ictest-packet-forward:
ictest-host-zone-proposal:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestHostZoneProposal .

ictest-feeabs:
cd tests/interchaintest && go test -timeout=25m -race -v -run '^TestFeeAbs$$' .

ictest-query-osmosis-twap:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestQueryOsmosisTwap .

ictest-ibc-custom:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestFeeabsGaiaIBCTransferWithIBCFee .

# ictest-feeabs-ibc-transfer:
# cd tests/interchaintest && go test -timeout=25m -race -v -run TestIBCTransferWithFeeAbs .

Expand Down
197 changes: 197 additions & 0 deletions abc.log

Large diffs are not rendered by default.

2,418 changes: 2,418 additions & 0 deletions feeabs.log

Large diffs are not rendered by default.

240 changes: 0 additions & 240 deletions tests/interchaintest/feeabs_test.go

This file was deleted.

3 changes: 3 additions & 0 deletions tests/interchaintest/query_osmosis_twap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func ParamChangeProposal(t *testing.T, ctx context.Context, feeabs *cosmos.Cosmo

}

<<<<<<< HEAD
<<<<<<< HEAD
}

Expand All @@ -167,6 +168,8 @@ func ParamChangeProposal(t *testing.T, ctx context.Context, feeabs *cosmos.Cosmo
// "osmosis_pool_token_denom_in": "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9",
// "pool_id": "1",
// "status": 0
=======
>>>>>>> be6e671 (fix BeginBlock not work on x/feeabs)
func AddHostZoneProposal(t *testing.T, ctx context.Context, feeabs *cosmos.CosmosChain, feeabsUser ibc.Wallet) {
t.Helper()

Expand Down
1 change: 1 addition & 0 deletions tests/interchaintest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ func SetupOsmosisContracts(t *testing.T,
osmosis *cosmos.CosmosChain,
user ibc.Wallet,
) ([]string, error) {
t.Helper()
registryWasm := "./bytecode/crosschain_registry.wasm"
swaprouterWasm := "./bytecode/swaprouter.wasm"
xcsV2Wasm := "./bytecode/crosschain_swaps.wasm"
Expand Down
3 changes: 2 additions & 1 deletion x/feeabs/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// BeginBlocker of epochs module.
func (k Keeper) BeginBlocker(ctx sdk.Context) {
func (k Keeper) BeginBlock(ctx sdk.Context) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) {
logger := k.Logger(ctx)
Expand All @@ -27,6 +27,7 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) {
shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart

if !shouldEpochStart {
logger.Info(fmt.Sprintf("Epoch with identifier %s has not ended yet", epochInfo.Identifier))
return false
}
epochInfo.CurrentEpochStartHeight = ctx.BlockHeight()
Expand Down
3 changes: 3 additions & 0 deletions x/feeabs/keeper/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func (k Keeper) HandleOsmosisIbcQuery(ctx sdk.Context) (int, error) {
// fee abstraction will not send query to a frozen host zone
// however, it will continue to send query to other host zone if UPDATED, or OUTDATED
// this logic iterate through registered host zones and collect requests before sending it
k.Logger(ctx).Info("start iterate host zone")
k.IterateHostZone(ctx, func(hostZoneConfig types.HostChainFeeAbsConfig) (stop bool) {
if k.IbcQueryHostZoneFilter(ctx, hostZoneConfig, queryTwapEpochInfo) {
return false
Expand Down Expand Up @@ -372,6 +373,7 @@ func (k Keeper) ExecuteAllHostChainSwap(ctx sdk.Context) {

func (k Keeper) IbcQueryHostZoneFilter(ctx sdk.Context, hostZoneConfig types.HostChainFeeAbsConfig, queryTwapEpochInfo types.EpochInfo) bool {
if hostZoneConfig.Status == types.HostChainFeeAbsStatus_FROZEN {
k.Logger(ctx).Info(fmt.Sprintf("Host zone %s is frozen", hostZoneConfig.IbcDenom))
return true
}

Expand All @@ -385,6 +387,7 @@ func (k Keeper) IbcQueryHostZoneFilter(ctx sdk.Context, hostZoneConfig types.Hos
}

if queryTwapEpochInfo.CurrentEpoch < exponential.FutureEpoch {
k.Logger(ctx).Info(fmt.Sprintf("Host zone %s is not ready to query", hostZoneConfig.IbcDenom))
return true
}

Expand Down
Loading

0 comments on commit 2b0b2ae

Please sign in to comment.