Skip to content

Commit c330402

Browse files
vishal-kannaakhilkumarpilliPrathyushaLakkireddyEengineer1
authored
feat: Oracle module (SMA, WMA, EMA) (#883)
* WIP: update few changes in app.go * WIP: fixed app package changes and working on cmd * wip: upgrade resource module * fix typo * fix * update test setup * change types * wip * WIP: fix few more issues * add migrations * remove validate basic * fix remaining issues and add upgrade handler * fix * fix test setup * fix * feat!: upgrade did module to v0.50.x (#878) * wip * wip * wip * wip * feat(params): add migrator support to did module * feat: add autocli support * wip * fix * wip * chore: remove comment * chore: add migrate * chore: add migration in module.go * feat: add SetParams function * go.mod * fix typo * update test_helper * fix * setconfig * fix icq issue * fix proto annotations * feat: change functions * chore: fix param_change_proposal tests * chore: remove comment * fix keeper tests * feat: implement customgetsigner * wip * chore: added query params func and updated the params key * add custom signers * fix key * fix * chore: add params to autocli * add params * fix autocli * update go version * fix typo * fix * Tidy dependencies * fix * update golangci-lint and math version * fix errors * fix lint and errors * update golangci lint version in gha * fix tests setup * fix almost failing unit tests * fix lint and other changes * revert integration test changes * WIP: fee abs tests fix * add resource params query and fix fee abs test * fix few integration tests and update swagger * fixed insufficient funds test issue * WIP: fix query proposal test and address comments * fix faiing integration test * fix unit test * integrate oracle module * WIP: setup v4 upgrade tests * fix upgrade migrations issues * wip * wip * wip * wip * fix post upgrade tests and wip integration tests after upgrade * add usdtusdc currencypair * fix genesis test * fix type tests * implement mocks for price feeder * update tests * implement txn tests * fix proto imports * fix go.mod * wip * run docker nodes with price feeder * Regenerate Pulsar API * Modified to compliant x/oracle Proto * Removed unused Protobuf imports on cheqd-specific modules * Added Protobuf wellknowntypes * fix oracle tx tests * fix: lint fix * fix: fix lint * wip * wip * wip * wip * fix: oracle param_test * wip * wip * fix: app_test.go * wip * wip * update testdata * wip * fix: fix lint * wip * wip * fix: lint fix * fix: updated cosmos-sdk * wip * enable vote extensions in upgradehandler * wip * wip * wip * wip * wip * wip * wip * wip * fix: lint fix * feat: support oracle with osmosis-icq provider (#899) * update oracle params * update params and end blocker * updare params and cheqd price calculation * update feeabs tests * WIP: fix tests * update oracle params * fix sh lint * fix tests * add twap rate check test * fix sh lint * `gofumpt-ed` --------- Co-authored-by: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> * chore: add oracle tests * wip * wip * fix: fix tests * refactor: replace hardcoded "usd" strings with UsdDenom constant * chore: implement custom wma cli * wip * review changes * Note correction * restore optimistic execution * remove test handler * wip * fix: fix lint * wip * wip * wip * wip * fix: cli_diddoc_pricing_negative and cli_diddoc_test * wip: adding usdscaling * fix: fix lint * wip: add autocli for oracle module * wip: add optional field in autocli for exchange-rates * add oracle module in minor upgrade and add tests * revert back oracle autocli * wip: add fixed fee scenario * fix: lint fix * wip: update migrations * fix: fix lint * fix: update expected module version map * wip: add usd ranging in migration * fix: fix lint * wip: fix tests * wip: change usd range in migration * wip: testing * wip: testing * wip: testing * wip * wip * wip: comment the lower fee test cases * wip * Regenerate API * chore: add feegrant deduct logic in the post handler * Remove redundant * feat: update fee-abstraction module to latest version in go.mod * Fix export of address variables in cheqd-init.sh * fix: lint issues * wip: use maxAmount as the fee * wip: correct syntax for fee * chore: increase the difference value and use the minAmount for updateDidDoc * fix: fix lint * fix: use MinAmount in updateDidDoc * chore: add moving average tests * chore: use WMA instead of EMA * fix: fix unit tests * wip: uncomment the lower fee code * wip: reduce the fee amount in cli_diddoc_pricinng_negative and resource * wip: update cli_diddoc_pricing_negative_test * chore: use updated tags for feeabs and price-feeder * wip * wip: use latest cheqd-usd price * wip:change fee * wip: fee change * wip: lower fees * wip:fix in defi_test * wip: add param_change_propsal * fix: fix lint * remove comments * wip * wip: add missing return statement * wip: move constants to util * chore: remove the burn custom cli command * chore: remove the usd default value in the did params * fix: fix lint * fix: update update_param_test * feat: add DefaultUSDParams for both did and resource * fix: fix lint * update test workflow * revert: revert the test workflow * fix: update tests * fix: fix lint * remove update_params_test.go * feat: add query to convert usd to ncheq using moving average * Corrected typo * chore: add slashingEnabled param * update price-feeder config * chore: update godoc * wip: testing mockprovider * fix: lint fix * fix tests * chore: add icq fallback * chore: add the icqprice check in the upgradeHandler and make averaging window as param * chore: update deps * chore: update anteHandler * Resolved remaining conflicts * Resolved conflicts * Resolved error check * Explicit registration of intefaces * Explicit upgrade name and scope * Revert v4 seclusion to original upgrade name * Scope to v4-minor followed by v4-feature * Add v4.1 upgrade integration test and workflow steps Introduces pre-upgrade integration tests for v4.1, supporting scripts and environment files, and updates the CI workflow to run and report these tests. Also adjusts upgrade scripts and test logic to support sequential upgrades and corrects proposal IDs for v4.2. --------- Co-authored-by: akhilkumarpilli <akhilkumar7947@gmail.com> Co-authored-by: PrathyushaLakkireddy <prathyusha@vitwit.com> Co-authored-by: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Co-authored-by: Eengineer1 <tasosderiziotis@gmail.com> Co-authored-by: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com>
1 parent 0bf5f4b commit c330402

File tree

238 files changed

+88100
-2170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+88100
-2170
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Skip build/test folders
55
installer/**
66
networks/**
7-
tests/**
87

98
# Skip Git-related folders
109
.github/**

.github/workflows/test.yml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,58 @@ jobs:
235235
name: report-pre-upgrade.xml
236236
path: report-pre-upgrade.xml
237237

238+
- name: Restart network using new node version (upgrade-v4-latest)
239+
working-directory: ./tests/upgrade/integration
240+
run: |
241+
bash scripts/upgrade_v4.sh
242+
243+
- name: Verifying docker processes (post upgrade v4)
244+
working-directory: ./tests/upgrade/integration
245+
run: |
246+
docker ps -a
247+
248+
- name: Run pre-upgrade-v4_1 tests
249+
working-directory: ./tests/upgrade/integration/v4
250+
run: |
251+
ginkgo -r --race --tags upgrade_integration --focus-file pre_upgrade_v4_1_test.go --keep-going --trace --junit-report ../../../../report-pre-upgrade-v4_1.xml
252+
253+
- name: Upload pre-upgrade-v4_1 tests result
254+
uses: actions/upload-artifact@v4
255+
with:
256+
name: report-pre-upgrade-v4_1.xml
257+
path: report-pre-upgrade-v4_1.xml
258+
259+
- name: Restart network using new node version (upgrade-v4_1-latest)
260+
working-directory: ./tests/upgrade/integration
261+
run: |
262+
bash scripts/upgrade_v4_1.sh
263+
264+
- name: Verifying docker processes (post upgrade v4.1)
265+
working-directory: ./tests/upgrade/integration
266+
run: |
267+
docker ps -a
268+
269+
- name: Run pre-upgrade-v4_2 tests
270+
working-directory: ./tests/upgrade/integration/v4
271+
run: |
272+
ginkgo -r --race --tags upgrade_integration --focus-file pre_upgrade_v4_2_test.go --keep-going --trace --junit-report ../../../../report-pre-upgrade-v4_2.xml
273+
274+
- name: Upload pre-upgrade-v4_2 tests result
275+
uses: actions/upload-artifact@v4
276+
with:
277+
name: report-pre-upgrade-v4_2.xml
278+
path: report-pre-upgrade-v4_2.xml
279+
238280
- name: Restart network using new node version (build-latest)
239281
working-directory: ./tests/upgrade/integration
240282
run: |
241-
bash scripts/upgrade.sh
283+
bash scripts/upgrade_v4_2.sh
242284
243-
- name: Verifying docker processes
285+
- name: Verifying docker processes (post upgrade v4.2)
244286
working-directory: ./tests/upgrade/integration
245287
run: |
246288
docker ps -a
247-
289+
248290
- name: Download binary artifact (build-latest)
249291
uses: actions/download-artifact@v5
250292
id: download
@@ -266,7 +308,7 @@ jobs:
266308
name: report-post-upgrade.xml
267309
path: report-post-upgrade.xml
268310

269-
- name: Run integration tests on upgraded network
311+
- name: Run integration tests on upgraded network with the DefaultUSDParams
270312
working-directory: ./tests/integration
271313
run: |
272314
ginkgo -r --tags integration --race --randomize-suites --keep-going --trace --skip-file cli_defi_test.go --skip-file cli_defi_negative_test.go --junit-report ../../report-upgraded-integration.xml

ante/ante_feeabs_feemarket.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ante
22

33
import (
4+
"cosmossdk.io/math"
45
feeabskeeper "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/keeper"
56
feeabstypes "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/types"
67
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
@@ -50,6 +51,11 @@ func (r *DenomResolverImpl) ConvertToDenom(ctx sdk.Context, coin sdk.DecCoin, de
5051
if err != nil {
5152
return sdk.DecCoin{}, err
5253
}
54+
55+
if amount.IsZero() {
56+
return sdk.NewDecCoinFromDec(denom, math.LegacyZeroDec()), nil
57+
}
58+
5359
return sdk.NewDecCoinFromDec(denom, amount[0].Amount.ToLegacyDec()), nil
5460
}
5561

ante/expected_keepers.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"context"
55

66
"cosmossdk.io/core/address"
7+
"cosmossdk.io/math"
78
didtypes "github.com/cheqd/cheqd-node/x/did/types"
89
resourcetypes "github.com/cheqd/cheqd-node/x/resource/types"
910
sdk "github.com/cosmos/cosmos-sdk/types"
1011
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
12+
"github.com/ojo-network/price-feeder/oracle"
1113
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
1214
)
1315

@@ -39,3 +41,13 @@ type FeeMarketKeeper interface {
3941
SetParams(ctx context.Context, params feemarkettypes.Params) error
4042
ResolveToDenom(ctx context.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error)
4143
}
44+
45+
type OracleKeeper interface {
46+
GetEMA(ctx sdk.Context, denom string) (math.LegacyDec, bool)
47+
GetExchangeRate(ctx sdk.Context, denom string) (math.LegacyDec, error)
48+
GetWMA(ctx sdk.Context, denom string, strategy string) (math.LegacyDec, bool)
49+
}
50+
51+
type PriceFeeder interface {
52+
GetOracle() *oracle.Oracle
53+
}

0 commit comments

Comments
 (0)