Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Integrate Ojo oracle module #1102

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

rbajollari
Copy link

@rbajollari rbajollari commented Jan 8, 2025

Description

Closes:

Steps to test locally

  1. Run setup scripts for gaia and elys to run as a consumer chain to gaia
  2. Update genesis file of elys so that one of the allowed_pool_creators in the amm module is a test account created by the setup script and vote extensions are enabled at block height 2
  3. Update the price-feeder.example.toml file with the non us binance api endpoint if running from outside the us
  4. Run elsyd with required ojo flags (i.e. elysd start --pricefeeder.config_path=$HOME/elys/cmd/elysd/price-feeder.example.toml --pricefeeder.enable=true --pricefeeder.log_level=debug)
  5. Create a pool for atom and usdc: elysd tx amm create-pool 100uatom,100uusdc 1000000uatom,1000000uusdc uusdc --swap-fee=0.00 --use-oracle=false --from=test1 --keyring-backend=test --chain-id=elys-1 --gas=1000000
  6. A few blocks after the vote extension enable height you should see prices being populated in the oracle module (elysd q oracle list-price) and the external liquidity ratios of the pool created being updated (elysd q amm list-pool)

What has Changed?

What specific problem were you aiming to address, and how did you successfully resolve it? If tests were not uploaded for this pull request or if coverage decreased, please provide an explanation for the change.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Deployment Notes

Are there any specific considerations to take into account when deploying these changes? This may include new dependencies, scripts that need to be executed, or any aspects that can only be evaluated in a deployed environment.

Screenshots and Videos

Please provide any relevant before and after screenshots by uploading them here. Additionally, demo videos can be highly beneficial in demonstrating the process.

@cosmic-vagabond cosmic-vagabond mentioned this pull request Jan 27, 2025
18 tasks
@cosmic-vagabond
Copy link
Contributor

@rbajollari

Prepared test commands:

# retrieve relevant branch from Ojo team’s PR
git remote add ojo [email protected]:ojo-network/elys.git
git fetch --all --tags
git checkout ryan/ojo-oracle

# build binary
git tag -f v999999.999999.999999 && make install

# retrieve latest mainnet snapshot
rm -rf ~/.elys && curl -o - -L https://snapshots.elys.network/elys-snapshot-main.tar.lz4 | lz4 -c -d - | tar -x -C ~/

# start node along with pricefeeder integration
elysd start --pricefeeder.config_path=cmd/elysd/price-feeder.example.toml --pricefeeder.enable=true --pricefeeder.log_level=debug

The commands above utilizes the latest mainnet snapshot in order to test out the new functionality on LocalNet with mainnet data.

Doing so resulted with the following error:

6:39PM INF Replay: Vote blockID=447C9954518F16A833F3CC0351775E03FFBDEAE6932A21AFE4AEC9352E2F4FC9:1:E38B4218FC59 extSigLen=0 extensionLen=0 height=689229 module=consensus peer=local round=0 type=SIGNED_MSG_TYPE_PRECOMMIT
6:39PM INF finalizing commit of block hash=447C9954518F16A833F3CC0351775E03FFBDEAE6932A21AFE4AEC9352E2F4FC9 height=689229 module=consensus num_txs=0 root=044C0758EA4E7ADB8DA1620E3C5071685D1CEEFFF588EA89086534C69C848344
6:39PM INF Closing application.db module=server
6:39PM INF Closing snapshots/metadata.db module=server
panic: runtime error: integer divide by zero

goroutine 1 [running]:
github.com/ojo-network/ojo/x/oracle/keeper.(*Keeper).IsPeriodLastBlock(...)
        /tmp/go/pkg/mod/github.com/ojo-network/[email protected]/x/oracle/keeper/end_blocker.go:33
github.com/ojo-network/ojo/x/oracle/abci.EndBlocker({0x108336b00, 0x140019bdc08}, {{0x108355730, 0x14001f26750}, {0x1082f2300, 0x140017324c8}, {0x10830b6d8, 0x140009e1a40}, {0x1526f95d8, 0x1400173b688}, ...})
        /tmp/go/pkg/mod/github.com/ojo-network/[email protected]/x/oracle/abci/endblocker.go:53 +0xc70
github.com/ojo-network/ojo/x/oracle.AppModule.EndBlock(...)
        /tmp/go/pkg/mod/github.com/ojo-network/[email protected]/x/oracle/module.go:173
github.com/cosmos/cosmos-sdk/types/module.(*Manager).EndBlock(_, {{0x108336ac8, 0x10a587980}, {0x108355ff0, 0x140025683c0}, {{0x0, 0x0}, {0x140026838f0, 0x10}, 0xa844d, ...}, ...})
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/types/module/module.go:804 +0x300
github.com/elys-network/elys/app.(*ElysApp).EndBlocker(...)
        /tmp/elys/app/app.go:362
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).endBlock(0x1400304e488, {0x10a587980?, 0x108355ff0?})
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/baseapp/baseapp.go:798 +0xc4
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).internalFinalizeBlock(0x1400304e488, {0x108336ac8, 0x10a587980}, 0x1400188a3c0)
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/baseapp/abci.go:822 +0xe20
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).FinalizeBlock(0x1400304e488, 0x1400188a3c0)
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/baseapp/abci.go:887 +0x118
github.com/cosmos/cosmos-sdk/server.cometABCIWrapper.FinalizeBlock(...)
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/cmt_abci.go:44
github.com/cometbft/cometbft/abci/client.(*localClient).FinalizeBlock(0x1523aa768?, {0x108336d30?, 0x10a587980?}, 0x10b5cc5b8?)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/abci/client/local_client.go:185 +0xe4
github.com/cometbft/cometbft/proxy.(*appConnConsensus).FinalizeBlock(0x1404b45d4b8, {0x108336d30, 0x10a587980}, 0x1400188a3c0)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/proxy/app_conn.go:104 +0x124
github.com/cometbft/cometbft/state.(*BlockExecutor).applyBlock(_, {{{0xb, 0x0}, {0x140028e0da0, 0x7}}, {0x140028e0db0, 0x10}, 0xa8429, 0xa844c, {{0x140688e2ee0, ...}, ...}, ...}, ...)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/state/execution.go:224 +0x410
github.com/cometbft/cometbft/state.(*BlockExecutor).ApplyVerifiedBlock(...)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/state/execution.go:202
github.com/cometbft/cometbft/consensus.(*State).finalizeCommit(0x14002be2708, 0xa844d)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1772 +0x97c
github.com/cometbft/cometbft/consensus.(*State).tryFinalizeCommit(0x14002be2708, 0xa844d)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1682 +0x26c
github.com/cometbft/cometbft/consensus.(*State).enterCommit.func1()
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1617 +0x8c
github.com/cometbft/cometbft/consensus.(*State).enterCommit(0x14002be2708, 0xa844d, 0x0)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1655 +0xac0
github.com/cometbft/cometbft/consensus.(*State).addVote(0x14002be2708, 0x14000dbb520, {0x0, 0x0})
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:2335 +0x182c
github.com/cometbft/cometbft/consensus.(*State).tryAddVote(0x14002be2708, 0x14000dbb520, {0x0?, 0x0?})
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:2067 +0x28
github.com/cometbft/cometbft/consensus.(*State).handleMsg(0x14002be2708, {{0x1082fc280, 0x14001699f50}, {0x0, 0x0}})
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:929 +0x2fc
github.com/cometbft/cometbft/consensus.(*State).readReplayMessage(0x14002be2708, 0x10826fcc0?, {0x0?, 0x0?})
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/replay.go:82 +0x798
github.com/cometbft/cometbft/consensus.(*State).catchupReplay(0x14002be2708, 0xa844d)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/replay.go:161 +0x53c
github.com/cometbft/cometbft/consensus.(*State).OnStart(0x14002be2708)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:343 +0x148
github.com/cometbft/cometbft/libs/service.(*BaseService).Start(0x14002be2708)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/libs/service/service.go:144 +0x320
github.com/cometbft/cometbft/consensus.(*Reactor).OnStart(0x140044a1050)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/consensus/reactor.go:84 +0x148
github.com/cometbft/cometbft/libs/service.(*BaseService).Start(0x140044a1050)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/libs/service/service.go:144 +0x320
github.com/cometbft/cometbft/p2p.(*Switch).OnStart(0x140027159e0)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/p2p/switch.go:237 +0x7c
github.com/cometbft/cometbft/libs/service.(*BaseService).Start(0x140027159e0)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/libs/service/service.go:144 +0x320
github.com/cometbft/cometbft/node.(*Node).OnStart(0x14002aa8008)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/node/node.go:558 +0x2b8
github.com/cometbft/cometbft/libs/service.(*BaseService).Start(0x14002aa8008)
        /tmp/go/pkg/mod/github.com/cometbft/[email protected]/libs/service/service.go:144 +0x320
github.com/cosmos/cosmos-sdk/server.startCmtNode({0x108336c88, 0x140019192c0}, 0x140009c2500, {0x108380b50, 0x14001c46008}, 0x1400221af20)
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:392 +0x324
github.com/cosmos/cosmos-sdk/server.startInProcess(_, {{{0x14001ad23c0, 0x6}, 0x0, {0x14001ad2ed8, 0x7}, {0x106f96588, 0x1}, {0x106f96588, 0x1}, ...}, ...}, ...)
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:323 +0x11c
github.com/cosmos/cosmos-sdk/server.start(_, {{0x0, 0x0, 0x0}, {0x10835fa18, 0x14002c99860}, 0x0, {0x1400144d060, 0x10}, {0x108380a88, ...}, ...}, ...)
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:240 +0x1d8
github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2.1()
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:198 +0x68
github.com/cosmos/cosmos-sdk/server.wrapCPUProfile(0x1400221af20, 0x140012079f8)
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:570 +0x16c
github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2(0x14002921508, {0x14002c99230?, 0x0?, 0x3?})
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:197 +0x184
github.com/spf13/cobra.(*Command).execute(0x14002921508, {0x14002c991a0, 0x3, 0x3})
        /tmp/go/pkg/mod/github.com/spf13/[email protected]/command.go:985 +0x834
github.com/spf13/cobra.(*Command).ExecuteC(0x14002904008)
        /tmp/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /tmp/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        /tmp/go/pkg/mod/github.com/spf13/[email protected]/command.go:1034
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x14002904008, {0x0, 0x0}, {0x14001687050, 0x12})
        /tmp/go/pkg/mod/github.com/cosmos/[email protected]/server/cmd/execute.go:34 +0x154
main.main()
        /tmp/elys/cmd/elysd/main.go:14 +0x38

I created a new PR (#1126) to resolve conflicts and errors: still a WIP.

This should also help in building a new snapshot with the updated Ojo oracle module. I’ll likely need to remove the Elys Oracle module from the store upgrades and replace it with the new Ojo Oracle module for this to work.

Additionally, I’ve opened another PR (elys-network/post-upgrade-snapshot-generator#97) to update the CI workflow for supporting the new price feeder flags. This will allow us to test the new PR and generate snapshots.

@cosmic-vagabond
Copy link
Contributor

@rbajollari the previous issue was fixed by initializing the default values of the parameters of the module:

app.OracleKeeper.SetParams(ctx, oracletypes.DefaultParams())

now I am getting a different error from endblocker.CalcPrices with the following error:

fmt.wrapError {msg: "post failed: Post \"http://localhost:26657\": dial tcp [::1]:26657: connect: connection refused", err: error(*net/url.Error) *{Op: "Post", URL: "http://localhost:26657", Err: error(*net.OpError) ...}}

I will continue to investigate why this is happening. let me know if you have any insights on that issue.

@cosmic-vagabond
Copy link
Contributor

@rbajollari the issue seems to occur in k.StakingKeeper.GetBondedValidatorsByPower(ctx) due to the initialization of the RPC client that tries to get a response from the RPC server although it is not ready yet, can we have a logic in place to wait for the RPC server to run and port to be ready prior to running k.StakingKeeper.GetBondedValidatorsByPower(ctx)?

@rbajollari
Copy link
Author

@rbajollari the issue seems to occur in k.StakingKeeper.GetBondedValidatorsByPower(ctx) due to the initialization of the RPC client that tries to get a response from the RPC server although it is not ready yet, can we have a logic in place to wait for the RPC server to run and port to be ready prior to running k.StakingKeeper.GetBondedValidatorsByPower(ctx)?

Updated our oracle endblocker so it doesn't error out and stop the chain if that error can't get the validators yet 👍

@cosmic-vagabond
Copy link
Contributor

@rbajollari the issue seems to occur in k.StakingKeeper.GetBondedValidatorsByPower(ctx) due to the initialization of the RPC client that tries to get a response from the RPC server although it is not ready yet, can we have a logic in place to wait for the RPC server to run and port to be ready prior to running k.StakingKeeper.GetBondedValidatorsByPower(ctx)?

Updated our oracle endblocker so it doesn't error out and stop the chain if that error can't get the validators yet 👍

thanks @rbajollari I managed to get the chain running with your latest changes

I am seeing this error now:

8:30AM DBG executing clientless oracle tick module=oracle
8:30AM ERR ERROR_QUERYING_POOL_ASSET_INFO error="ammPool not found for poolId: 1" module=oracle pair="{\"Base\":\"ATOM\",\"Quote\":\"USDT\",\"BaseProxy\":\"ATOM\",\"QuoteProxy\":\"USDC\",\"Address\":\"\",\"PoolID\":1}" provider=binance
highestPrice, lowestPrice, baseAmount, quoteAmount 0 3.01 0 1.6226635059000053e+06
highestPrice, lowestPrice, baseAmount, quoteAmount 9.025 3.01 323802.98999999976 1.6226635059000053e+06
baseDepth 0.5000415523975732
quoteDepth 0.49970913321698673
8:30AM INF EXTERNAL_LIQUIDITY_WAS_CREATED module=oracle pair="{\"Base\":\"ATOM\",\"Quote\":\"USDT\",\"BaseProxy\":\"ATOM\",\"QuoteProxy\":\"USDC\",\"Address\":\"\",\"PoolID\":1}" provider=binance
8:30AM INF finalized block block_app_hash=3056228BCFDCA56242BD0EA9FDF9BF542EDF988780F6AB6C7D1929EAD3F5C0BB height=1077987 module=state num_txs_res=0 num_val_updates=0
8:30AM INF executed block app_hash=3056228BCFDCA56242BD0EA9FDF9BF542EDF988780F6AB6C7D1929EAD3F5C0BB height=1077987 module=state
8:30AM INF committed state block_app_hash=DB4BFB1BDEF06336C46411F4E414405660334AF00D6224428989D418FDF54145 height=1077987 module=state
8:30AM INF indexed block events height=1077987 module=txindex
{"level":"info","event":"sync","pair":"ATOMUSDT","last_update_id":6934472655,"time":"2025-01-30T08:30:22+01:00","message":"BINANCE_ORDER_BOOK_STORE"}
{"level":"debug","event":"ok","pair":"ATOMUSDT","time":"2025-01-30T08:30:23+01:00","message":"BINANCE_ORDER_BOOK_STORE"}
{"level":"debug","event":"ok","pair":"ATOMUSDT","time":"2025-01-30T08:30:24+01:00","message":"BINANCE_ORDER_BOOK_STORE"}
8:30AM INF Timed out dur=2980.173 height=1077988 module=consensus round=0 step=RoundStepNewHeight

even though the AMM pool does have the pool id 1 set:

pool:
- address: elys1qhx3v2xpdgz2l0lcgspwaak99j852zvl4gfzms
  pool_assets:
  - external_liquidity_ratio: "6112477722345833778"
    token:
      amount: "175452930124"
      denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
    weight: "11529215046068469760"
  - external_liquidity_ratio: "1673009738403468093"
    token:
      amount: "3562451746082"
      denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    weight: "11529215046068469760"
  pool_id: "1"
  pool_params:
    fee_denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    swap_fee: "2000000000000000"
    use_oracle: true
  rebalance_treasury: elys129549slgvv2fxqdzthvu93hl4f3y96cd8j359wr9derl3gwmujsq2age6w
  total_shares:
    amount: "4321344889789616225729987"
    denom: amm/pool/1
  total_weight: "23058430092136939520"

same for accounted pool module:

$ elysd q poolaccounted list-accounted-pool
accounted_pool:
- non_amm_pool_tokens:
  - amount: "-4733078"
    denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
  - amount: "13174219"
    denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
  pool_id: "1"
  total_tokens:
  - amount: "175448197046"
    denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
  - amount: "3562464920301"
    denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349

here are my localnet settings for the oracle module:

$ elysd q oracle params    
params:
  accept_list:
  - base_denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    exponent: 6
    symbol_denom: USDC
  - base_denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
    exponent: 6
    symbol_denom: ATOM
  currency_deviation_thresholds:
  - base_denom: USDT
    threshold: "2"
  - base_denom: USDC
    threshold: "2"
  - base_denom: ATOM
    threshold: "2"
  currency_pair_providers:
  - base_denom: USDT
    base_proxy_denom: ""
    crypto_compare_exchange: ""
    extern_liquidity_provider: ""
    pair_address: []
    pool_id: "0"
    providers:
    - coinbase
    - kraken
    - crypto
    quote_denom: USD
    quote_proxy_denom: ""
  - base_denom: USDC
    base_proxy_denom: ""
    crypto_compare_exchange: ""
    extern_liquidity_provider: ""
    pair_address: []
    pool_id: "0"
    providers:
    - kraken
    quote_denom: USD
    quote_proxy_denom: ""
  - base_denom: ATOM
    base_proxy_denom: ATOM
    crypto_compare_exchange: ""
    extern_liquidity_provider: binance
    pair_address: []
    pool_id: "1"
    providers:
    - binance
    - gate
    - coinbase
    quote_denom: USDT
    quote_proxy_denom: USDC
  historic_stamp_period: "30"
  life_time_in_blocks: "1"
  mandatory_list:
  - base_denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    exponent: 6
    symbol_denom: USDC
  - base_denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
    exponent: 6
    symbol_denom: ATOM
  maximum_median_stamps: "24"
  maximum_price_stamps: "60"
  median_stamp_period: "1800"
  min_valid_per_window: "0.050000000000000000"
  price_expiry_time: "86400"
  reward_bands:
  - reward_band: "0.020000000000000000"
    symbol_denom: USDT
  - reward_band: "0.020000000000000000"
    symbol_denom: USDC
  - reward_band: "0.020000000000000000"
    symbol_denom: ATOM
  reward_distribution_window: "5256000"
  slash_fraction: "0.000100000000000000"
  slash_window: "100800"
  vote_period: "1"
  vote_threshold: "0.500000000000000000"

I am setting them here for my tests https://github.com/elys-network/elys/pull/1126/files#diff-0f1d2976054440336a576d47a44a37b80cdf6701dd9113012bce0e3c425819b7R360-R459

also I noticed both list-price and exchange-rates commands are returning an empty:

$ elysd q oracle list-price
price: []
$ elysd q oracle exchange-rates
exchange_rates: []

@rbajollari can you help clarify why that might happen?

@rbajollari
Copy link
Author

@rbajollari the issue seems to occur in k.StakingKeeper.GetBondedValidatorsByPower(ctx) due to the initialization of the RPC client that tries to get a response from the RPC server although it is not ready yet, can we have a logic in place to wait for the RPC server to run and port to be ready prior to running k.StakingKeeper.GetBondedValidatorsByPower(ctx)?

Updated our oracle endblocker so it doesn't error out and stop the chain if that error can't get the validators yet 👍

thanks @rbajollari I managed to get the chain running with your latest changes

I am seeing this error now:

8:30AM DBG executing clientless oracle tick module=oracle
8:30AM ERR ERROR_QUERYING_POOL_ASSET_INFO error="ammPool not found for poolId: 1" module=oracle pair="{\"Base\":\"ATOM\",\"Quote\":\"USDT\",\"BaseProxy\":\"ATOM\",\"QuoteProxy\":\"USDC\",\"Address\":\"\",\"PoolID\":1}" provider=binance
highestPrice, lowestPrice, baseAmount, quoteAmount 0 3.01 0 1.6226635059000053e+06
highestPrice, lowestPrice, baseAmount, quoteAmount 9.025 3.01 323802.98999999976 1.6226635059000053e+06
baseDepth 0.5000415523975732
quoteDepth 0.49970913321698673
8:30AM INF EXTERNAL_LIQUIDITY_WAS_CREATED module=oracle pair="{\"Base\":\"ATOM\",\"Quote\":\"USDT\",\"BaseProxy\":\"ATOM\",\"QuoteProxy\":\"USDC\",\"Address\":\"\",\"PoolID\":1}" provider=binance
8:30AM INF finalized block block_app_hash=3056228BCFDCA56242BD0EA9FDF9BF542EDF988780F6AB6C7D1929EAD3F5C0BB height=1077987 module=state num_txs_res=0 num_val_updates=0
8:30AM INF executed block app_hash=3056228BCFDCA56242BD0EA9FDF9BF542EDF988780F6AB6C7D1929EAD3F5C0BB height=1077987 module=state
8:30AM INF committed state block_app_hash=DB4BFB1BDEF06336C46411F4E414405660334AF00D6224428989D418FDF54145 height=1077987 module=state
8:30AM INF indexed block events height=1077987 module=txindex
{"level":"info","event":"sync","pair":"ATOMUSDT","last_update_id":6934472655,"time":"2025-01-30T08:30:22+01:00","message":"BINANCE_ORDER_BOOK_STORE"}
{"level":"debug","event":"ok","pair":"ATOMUSDT","time":"2025-01-30T08:30:23+01:00","message":"BINANCE_ORDER_BOOK_STORE"}
{"level":"debug","event":"ok","pair":"ATOMUSDT","time":"2025-01-30T08:30:24+01:00","message":"BINANCE_ORDER_BOOK_STORE"}
8:30AM INF Timed out dur=2980.173 height=1077988 module=consensus round=0 step=RoundStepNewHeight

even though the AMM pool does have the pool id 1 set:

pool:
- address: elys1qhx3v2xpdgz2l0lcgspwaak99j852zvl4gfzms
  pool_assets:
  - external_liquidity_ratio: "6112477722345833778"
    token:
      amount: "175452930124"
      denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
    weight: "11529215046068469760"
  - external_liquidity_ratio: "1673009738403468093"
    token:
      amount: "3562451746082"
      denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    weight: "11529215046068469760"
  pool_id: "1"
  pool_params:
    fee_denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    swap_fee: "2000000000000000"
    use_oracle: true
  rebalance_treasury: elys129549slgvv2fxqdzthvu93hl4f3y96cd8j359wr9derl3gwmujsq2age6w
  total_shares:
    amount: "4321344889789616225729987"
    denom: amm/pool/1
  total_weight: "23058430092136939520"

same for accounted pool module:

$ elysd q poolaccounted list-accounted-pool
accounted_pool:
- non_amm_pool_tokens:
  - amount: "-4733078"
    denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
  - amount: "13174219"
    denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
  pool_id: "1"
  total_tokens:
  - amount: "175448197046"
    denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
  - amount: "3562464920301"
    denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349

here are my localnet settings for the oracle module:

$ elysd q oracle params    
params:
  accept_list:
  - base_denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    exponent: 6
    symbol_denom: USDC
  - base_denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
    exponent: 6
    symbol_denom: ATOM
  currency_deviation_thresholds:
  - base_denom: USDT
    threshold: "2"
  - base_denom: USDC
    threshold: "2"
  - base_denom: ATOM
    threshold: "2"
  currency_pair_providers:
  - base_denom: USDT
    base_proxy_denom: ""
    crypto_compare_exchange: ""
    extern_liquidity_provider: ""
    pair_address: []
    pool_id: "0"
    providers:
    - coinbase
    - kraken
    - crypto
    quote_denom: USD
    quote_proxy_denom: ""
  - base_denom: USDC
    base_proxy_denom: ""
    crypto_compare_exchange: ""
    extern_liquidity_provider: ""
    pair_address: []
    pool_id: "0"
    providers:
    - kraken
    quote_denom: USD
    quote_proxy_denom: ""
  - base_denom: ATOM
    base_proxy_denom: ATOM
    crypto_compare_exchange: ""
    extern_liquidity_provider: binance
    pair_address: []
    pool_id: "1"
    providers:
    - binance
    - gate
    - coinbase
    quote_denom: USDT
    quote_proxy_denom: USDC
  historic_stamp_period: "30"
  life_time_in_blocks: "1"
  mandatory_list:
  - base_denom: ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
    exponent: 6
    symbol_denom: USDC
  - base_denom: ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9
    exponent: 6
    symbol_denom: ATOM
  maximum_median_stamps: "24"
  maximum_price_stamps: "60"
  median_stamp_period: "1800"
  min_valid_per_window: "0.050000000000000000"
  price_expiry_time: "86400"
  reward_bands:
  - reward_band: "0.020000000000000000"
    symbol_denom: USDT
  - reward_band: "0.020000000000000000"
    symbol_denom: USDC
  - reward_band: "0.020000000000000000"
    symbol_denom: ATOM
  reward_distribution_window: "5256000"
  slash_fraction: "0.000100000000000000"
  slash_window: "100800"
  vote_period: "1"
  vote_threshold: "0.500000000000000000"

I am setting them here for my tests https://github.com/elys-network/elys/pull/1126/files#diff-0f1d2976054440336a576d47a44a37b80cdf6701dd9113012bce0e3c425819b7R360-R459

also I noticed both list-price and exchange-rates commands are returning an empty:

$ elysd q oracle list-price
price: []
$ elysd q oracle exchange-rates
exchange_rates: []

@rbajollari can you help clarify why that might happen?

I pushed some changes in the amm endblocker which makes sure that the oracle's module kvstore has that pool information which the price feeder uses for getting the liquidity data. That fixes the pool not being found error. As far as the prices not showing up I think that might be from the oracle params you're setting (specifically the currency provider pairs) not giving enough providers for the price feeder to run correctly. Can you try it again just setting the oracle params to their default values?

@cosmic-vagabond
Copy link
Contributor

I pushed some changes in the amm endblocker which makes sure that the oracle's module kvstore has that pool information which the price feeder uses for getting the liquidity data. That fixes the pool not being found error. As far as the prices not showing up I think that might be from the oracle params you're setting (specifically the currency provider pairs) not giving enough providers for the price feeder to run correctly. Can you try it again just setting the oracle params to their default values?

@rbajollari thanks for those changes, I am not getting the not found amm pool id error anymore, I am seeing a new error though, it says that the USDC asset info cannot be found:

7:57PM ERR ERROR_QUERYING_POOL_ASSET_INFO error="pool asset info does not contain USDC" module=oracle pair="{\"Base\":\"ATOM\",\"Quote\":\"USDT\",\"BaseProxy\":\"ATOM\",\"QuoteProxy\":\"USDC\",\"Address\":\"\",\"PoolID\":1}" provider=binance

even though I set both ATOM and USDC asset infos as shown in my test branch here 0b0bf64

do you have any idea why this is happening? thanks

@rbajollari
Copy link
Author

I pushed some changes in the amm endblocker which makes sure that the oracle's module kvstore has that pool information which the price feeder uses for getting the liquidity data. That fixes the pool not being found error. As far as the prices not showing up I think that might be from the oracle params you're setting (specifically the currency provider pairs) not giving enough providers for the price feeder to run correctly. Can you try it again just setting the oracle params to their default values?

@rbajollari thanks for those changes, I am not getting the not found amm pool id error anymore, I am seeing a new error though, it says that the USDC asset info cannot be found:

7:57PM ERR ERROR_QUERYING_POOL_ASSET_INFO error="pool asset info does not contain USDC" module=oracle pair="{\"Base\":\"ATOM\",\"Quote\":\"USDT\",\"BaseProxy\":\"ATOM\",\"QuoteProxy\":\"USDC\",\"Address\":\"\",\"PoolID\":1}" provider=binance

even though I set both ATOM and USDC asset infos as shown in my test branch here 0b0bf64

do you have any idea why this is happening? thanks

Looks like the price feeder logic I copied over from the elys price feeder fork requires the USDC_DENOM to be set in the env variable before running it. I ran export USDC_DENOM=uusdc before running the binary and that seems to have gotten rid of that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants