Giter Club home page Giter Club logo

v4-chain's Introduction

dYdX Chain

The dYdX v4 software (the ”dYdX Chain”) is a sovereign blockchain software built using Cosmos SDK and CometBFT. It powers a robust decentralized perpetual futures exchange with a high-performance orderbook and matching engine for a feature-rich, self-custodial perpetual trading experience on any market.

This repository contains the source code for the Cosmos SDK application responsible for running the chain and the associated indexer services. The indexer services are a read-only layer that indexes on-chain and off-chain data from a node and serves it to users in a more performant and user-friendly way.

Getting Started

Architecture Overview

Indexer Deep Dive

Front End Deep Dive

Resources and Documentation

Official Documentation

dYdX Academy

dYdX Blog

Clients

v4-clients

Third-party Clients

C++ Client

Python Client

By clicking the above links to third-party clients, you will leave the dYdX Trading Inc. (“dYdX”) GitHub repository and join repositories made available by third parties, which are independent from and unaffiliated with dYdX. dYdX is not responsible for any action taken or content on third-party repositories.

Directory Structure

audits — Audit reports live here.

docs — Home for documentation pertaining to the entire repo.

indexer — Contains source code for indexer services. See its README for developer documentation.

proto — Contains all protocol buffers used by protocol and indexer.

protocol — Contains source code for the Cosmos SDK app that runs the protocol. See its README for developer documentation.

v4-proto-js — Scripts for publishing proto package to npm.

v4-proto-py — Scripts for publishing proto package to PyPI.

Contributing

If you encounter a bug, please file an issue to let us know. Alternatively, please feel free to contribute a bug fix directly. If you are planning to contribute changes that involve significant design choices, please open an issue for discussion instead.

License and Terms

The dYdX Chain is licensed under AGPLv3 and subject to the v4 Terms of Use. The full license can be found here. dYdX does not deploy or run v4 software for public use, or operate or control any dYdX Chain infrastructure. dYdX products and services are not available to persons or entities who reside in, are located in, are incorporated in, or have registered offices in the United States or Canada, or Restricted Persons (as defined in the dYdX Terms of Use).

v4-chain's People

Contributors

affanv14 avatar brendanchou avatar chenyaoy avatar christopher-li avatar clemire avatar davidesegullo avatar dydxwill avatar eric-warehime avatar giorgionocera avatar jakob-dydx avatar jayy04 avatar jiajames avatar jonfung-dydx avatar lcwik avatar lucas-dydx avatar matthewdowney avatar moo-onthelawn avatar nivasan1 avatar roy-dydx avatar shrenujb avatar sr33j avatar teddyding avatar tqin7 avatar ttl33 avatar tyleroooo avatar vincentwschau avatar yang-dydx avatar yujin512 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v4-chain's Issues

how to add service deployment config to docker compose file ?

Could you please give me an example?

Add service deployment config to docker-compose-local-deployment.yml.

  • Add Service to v4-terraform repo (TODO(DEC-838): Add link to the specific files)
  • Add Github action in .github/workflows/build-and-push.yml to push image to ECR
  • Add Service to be deployed to Orb so it will be shut down, updated, and redeployed
  • Update Auxo to deploy service

V4 indexer few issues

Hello.
I'm currently trying to run indexer instance with synced V4 node. Ran into few issues.
First one - this docker image will not work on x86 architecture, and probably should be changed to default alpine.

Another issue or, rather, a question:

From this comment I see that if incomingBlock > currentBlock + 1 - it should be applied.

But according to this line - if incoming block > currentBlock + 1 - it will be ignored and skipped.

So how can Indexer work correctly?
Currently all blocks from my node are skipped due to currentBlock = 0 and incomingBlock > 7000000

CPU/socket queue/response times spikes every ~8sec

I send transactions from my trading app with /broadcast_tx_sync to my fully operational dydx node and measure response roundtrip time. The problem is that at some times the metric is very high:
Min duration is ~1-2ms. Note: trading app is on the same host with the node, so network latency is minimal.
Max duration: up to 1-2 seconds.

I checked dydx log and found out that in such cases Received new short term order message appears 1-2sec after sending the order, which means the node haven't been receiving the Tx for long time. I opened ss tool and found out that every ~8 sec read queue sizes grow big (up to hundreds of kylobytes) for around half of node network sockets and stay big for 1-2 sec, which means goroutines doesn't read the data from sockets in time. Go perf shows that there are following notable time consumers at that moment:

  • goleveldb functions (~30%)
  • checkTx (~20%)
  • consensus functions (~40%)

To summarize: dydx node has performance spikes every ~8 sec, which can be seen in CPU utilization, in method response times and in socket statistics.

  1. Are those spikes known issue?

  2. Are there obvious reasons node can respond so long (from code/config standpoint)? (1-2 sec)

  3. Can I safely use rocksdb for DB (instead of goleveldb)?

  4. Are there typical optimization advice for configs? (I've seen tendermint guides, but not sure they are applicable)

  5. Can [mempool] recheck be disabled?

Thank you!

OS: ubuntu 20.04, kernel 5.15.0
Dydx chain release: from around January

dydxprotocold launch problem

After init and start dydxprotocol daemon i received an error

Apr 01 dydxprotocold[10905]: 1:41PM INF created new capability module=ibc name=ports/icahost
Apr 01 dydxprotocold[10905]: 1:41PM INF port binded module=x/ibc/port port=icahost
Apr 01 dydxprotocold[10905]: 1:41PM INF claimed capability capability=2 module=icahost name=ports/icahost
Apr 01 dydxprotocold[10905]: 1:41PM INF Closing application.db module=server
Apr 01 dydxprotocold[10905]: 1:41PM INF Closing snapshots/metadata.db module=server
Apr 01 dydxprotocold[10905]: panic: validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPower>
Apr 01 dydxprotocold[10905]: goroutine 1 [running]:
Apr 01 dydxprotocold[10905]: github.com/dydxprotocol/v4-chain/protocol/app.(*App).InitChainer(_, {{0x573e7c8, 0x7863c60}, {0x575f700, 0xc00228d240}, {{0x0, 0x0}, {0xc005b8a810, 0xe}, 0x0, .>
Apr 01 dydxprotocold[10905]:         github.com/dydxprotocol/v4-chain/protocol/app/app.go:1524 +0x3c5
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).InitChain(0xc00158b448, 0xc0007d7b90)
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/baseapp/abci.go:108 +0x722
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server.cometABCIWrapper.InitChain(...)
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/cmt_abci.go:32
Apr 01 dydxprotocold[10905]: github.com/cometbft/cometbft/abci/client.(*unsyncLocalClient).InitChain(0xc00084d8e0?, {0x573ed40?, 0x7863c60?}, 0x7f263811f558?)
Apr 01 dydxprotocold[10905]:         github.com/cometbft/[email protected]/abci/client/unsync_local_client.go:99 +0x26
Apr 01 dydxprotocold[10905]: github.com/cometbft/cometbft/proxy.(*appConnConsensus).InitChain(0xc005762a08, {0x573ed40, 0x7863c60}, 0xc0007d7b90)
Apr 01 dydxprotocold[10905]:         github.com/cometbft/[email protected]/proxy/app_conn.go:78 +0x170
Apr 01 dydxprotocold[10905]: github.com/cometbft/cometbft/consensus.(*Handshaker).ReplayBlocksWithContext(_, {_, _}, {{{0xb, 0x0}, {0x4cb780e, 0x6}}, {0xc005b8a810, 0xe}, 0x1, ...}, ...)
Apr 01 dydxprotocold[10905]:         github.com/cometbft/[email protected]/consensus/replay.go:336 +0xfb3
Apr 01 dydxprotocold[10905]: github.com/cometbft/cometbft/consensus.(*Handshaker).HandshakeWithContext(0xc001cc33d8, {0x573ec98, 0xc005b5cff0}, {0x57642f8, 0xc0001d5dc0})
Apr 01 dydxprotocold[10905]:         github.com/cometbft/[email protected]/consensus/replay.go:274 +0x425
Apr 01 dydxprotocold[10905]: github.com/cometbft/cometbft/node.doHandshake({_, _}, {_, _}, {{{0xb, 0x0}, {0x4cb780e, 0x6}}, {0xc005b8a810, 0xe}, ...}, ...)
Apr 01 dydxprotocold[10905]:         github.com/cometbft/[email protected]/node/setup.go:182 +0x1a9
Apr 01 dydxprotocold[10905]: github.com/cometbft/cometbft/node.NewNodeWithContext({0x573ec98, 0xc005b5cff0}, 0xc000348c80, {0x571b660, 0xc001772000}, 0xc005e48100, {0x5701a40, 0xc005e48240}>
Apr 01 dydxprotocold[10905]:         github.com/cometbft/[email protected]/node/node.go:350 +0x5b7
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server.startCmtNode({0x573ec98, 0xc005b5cff0}, 0xc000348c80, {0x5786058, 0xc0012be408}, 0xc00174ba80)
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/start.go:368 +0x408
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server.startInProcess({_, _}, _, {{{0xc005960300, 0x5c}, 0x0, {0xc00144b520, 0x7}, {0x4d29af1, 0x1}, ...}, ...}, ...)
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/start.go:314 +0x1aa
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server.start({_, _}, _, {{0x0, 0x0, 0x0}, {0x5768058, 0xc005acc030}, 0x0, {0xc0014e7800, ...}, ...}, ...)
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/start.go:232 +0x305
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2.1()
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/start.go:190 +0x69
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server.wrapCPUProfile(0xc00174ba80, 0xc005af1a18)
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/start.go:567 +0x1b3
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2(0xc005f4c608, {0xc00174bba0?, 0x0?, 0x2?})
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/start.go:189 +0x22b
Apr 01 dydxprotocold[10905]: github.com/spf13/cobra.(*Command).execute(0xc005f4c608, {0xc00174bb80, 0x2, 0x2})
Apr 01 dydxprotocold[10905]:         github.com/spf13/[email protected]/command.go:983 +0xaca
Apr 01 dydxprotocold[10905]: github.com/spf13/cobra.(*Command).ExecuteC(0xc0057a8608)
Apr 01 dydxprotocold[10905]:         github.com/spf13/[email protected]/command.go:1115 +0x3ff
Apr 01 dydxprotocold[10905]: github.com/spf13/cobra.(*Command).Execute(...)
Apr 01 dydxprotocold[10905]:         github.com/spf13/[email protected]/command.go:1039
Apr 01 dydxprotocold[10905]: github.com/spf13/cobra.(*Command).ExecuteContext(...)
Apr 01 dydxprotocold[10905]:         github.com/spf13/[email protected]/command.go:1032
Apr 01 dydxprotocold[10905]: github.com/cosmos/cosmos-sdk/server/cmd.Execute(0xc0057a8608, {0x4cc93e2, 0xd}, {0xc001182c60, 0x1f})
Apr 01 dydxprotocold[10905]:         github.com/cosmos/[email protected]/server/cmd/execute.go:34 +0x187
Apr 01 dydxprotocold[10905]: main.main()
Apr 01 dydxprotocold[10905]:         github.com/dydxprotocol/v4-chain/protocol/cmd/dydxprotocold/main.go:22 +0x89
Apr 01 systemd[1]: dydxprotocold.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

daemon version: protocol/v4.0.0

How to place stateful (long-term) order when running chain locally?

How to place stateful (long-term) order when running chain locally?

In the documentation, we have placing an order for short-term only. We wanted to place stateful (long-term) to see orderbook and perpetualMarket API from Indexer. But I could not find how to place it.

In the code, I found this, we can set order_flag to 64 for long-term orders. However, when I run chain locally I cannot add additional flags to this command

./build/dydxprotocold tx clob place-order dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4 0 0 0 1 10 10000 20 --from alice --chain-id localdydxprotocol
./build/dydxprotocold tx clob place-order dydx10fx7sy6ywd5senxae9dwytf8jxek3t2gcen2vs 0 0 0 2 10 10000 20 --from bob --chain-id localdydxprotocol

How can I add stateful (long-term) order? Or how can I connect chain locally on indexer which is also running locally? I tried to call Indexer APIs with Postman as stated in Indexer documentation, but it is not working. For example, http://localhost:3002/v4/height these cannot give any results from chain.

Screenshot 2024-03-11 at 10 57 59

Can't connect v4 node and indexer

I have run v4 node and deployed local Indexer. V4 node is synced. But I see errors in the Indexer
indexer-roundtable-1 | 2024-05-14 08:08:23 [error]: { indexer-roundtable-1 | "at": "loops-helpers/cancel_stale_orders", indexer-roundtable-1 | "message": "uncaught error in an individual loop", indexer-roundtable-1 | "error": { indexer-roundtable-1 | "message": "Unable to find latest block" indexer-roundtable-1 | }, indexer-roundtable-1 | "taskName": "cancel_stale_orders", indexer-roundtable-1 | "disableGroupingHash": true, indexer-roundtable-1 | "timestamp": "2024-05-14T08:08:23.961Z" indexer-roundtable-1 | }
As far as I understood, there are no blocks in the Indexer's database. What should I do to fix it.

protocol/README: incorrect instructions for testing with a local cosmos-sdk or cometbft fork

protocol/README.md suggests inserting the following replace directive in go.mod

	github.com/cosmos/cosmos-sdk v0.47.0-alpha2 => /Users/bryce/projects/cosmos-sdk

in order to test with a local fork of cosmos-sdk. However, that won't work because the docker container cannot access that path.

My workaround has been the following:

  1. Create a new subdirectory protocol/my_forks
  2. Clone dydx's forks of cosmos-sdk, cometbft and iavl into that subdirectory
  3. Add the new subdirectory to .gitignore
  4. Mount the new subdirectory in the Dockerfile:
diff --git a/protocol/Dockerfile b/protocol/Dockerfile
index e7246444..868c820b 100644
--- a/protocol/Dockerfile
+++ b/protocol/Dockerfile
@@ -20,6 +20,7 @@ WORKDIR /dydxprotocol
 COPY go.* ./
 RUN --mount=type=cache,target=/root/.cache/go-build \
     --mount=type=cache,target=/root/go/pkg/mod \
+    --mount=type=bind,source=my_forks,dst=/dydxprotocol/my_forks,ro \
     go mod download

If that sounds like the right approach, I will create a PR that updates the README. I'm not doing that yet because I'm a newcomer to both the dydx and docker and there might be a smarter way.

Error on every block

INF committed state app_hash=59AD9776367D5792F7CE52F95F707FF3A857063B622FA4025072EBD5F94ED7A3 height=1598128 module=state num_txs=4
INF indexed block exents height=1598128 module=txindex
ERR Failed to get all market params error="rpc error: code = Unimplemented desc = unknown service dydxprotocol.prices.Query" module=pricefeed-daemon submodule=market-param-updater
INF Timed out dur=382.679843 height=1598129 module=consensus round=0 step=1
ERR Liquidations daemon returned error error="rpc error: code = Unimplemented desc = unknown service dydxprotocol.subaccounts.Query" module=server
INF received proposal module=consensus proposal={"Type":32,"block_id":{"hash":"2313970AE512F61AE0861E64694277D269F78B9CB82A5499029D88F452BDAC4D","parts":{"hash":"CCD2C6431ED188A0EFDB2BFB66D43D68EE06E464F0AE484E5EBAAF68A92FE716","total":1}},"height":1598129,"pol_round":-1,"round":0,"signature":"Ab0/nLz8d3CkEsLEDq+a9JPrrYOkXAS8jZY3ptvOch94hrmlIH6084kFriaXJD9yYJHKoL6LR6VJhm6ES1ikCA==","timestamp":"2023-11-20T19:13:48.332526277Z"} proposer=DE774AB209136C8453D54603D03EDD1D03B30AB6
INF received complete proposal block hash=2313970AE512F61AE0861E64694277D269F78B9CB82A5499029D88F452BDAC4D height=1598129 module=consensus
ERR Index price for market does not exist marketId=0 module=x/prices
ERR Index price for market does not exist marketId=1 module=x/prices``

occurs on every block

gRPC GetTxResponse has no logs field

Since new version gRPC request to cosmos.tx.v1beta1.Service/GetTx method starts returning response without field logs in txResponse. Previously, number of logs matched the number of messages so that log events can be grouped by messages. Now events only returned in events field without indexing by message.

Request example:

grpcurl -plaintext \
    -d '{"hash":"A0E2AA673A033DCE0E618654C9606560CF30E844B6652885EBD492924F7A6771"}' \
    dydx-dao-grpc-1.polkachu.com:23890 \
    cosmos.tx.v1beta1.Service/GetTx

Response:

{
  "tx": {
    "body": {
      "messages": [
        {},{}
      ]
    }
  },
  "txResponse": {
    "height": "12820184",
    "txhash": "A0E2AA673A033DCE0E618654C9606560CF30E844B6652885EBD492924F7A6771",
    "data": "...",
    "gasWanted": "538925",
    "gasUsed": "449070",
    "tx": {},
    "timestamp": "2024-04-09T01:45:53Z",
    "events": [
      {},{},{}
    ]
  }
}

Error running indexer

docker-compose -f docker-compose-local-deployment.yml up

ERROR: The Compose file is invalid because:
Service postgres has neither an image nor a build context specified. At least one must be provided.

incorrect funding payments

I have a short position opened for a duration of 10 hours on SOL-USD throughout which the funding rate was significantly positive.

Instead of receiving funding, I had to continuously pay funding instead.

account: dydx1ha2svyj82sr5s7l7y54vavnsr66nvyz5vw4zz9

Screenshot 2023-12-06 at 8 56 37 AM

deploy indexer locally

Could you please share me a full example(or script) to run the indexer service locally directly?

docker build error

do you have the problem with docker base image: dydxprotocol/indexer-node:16-alpine-m1
when with dydxprotocol/indexer-node:16-alpine, run postgres-package error.

ubuntu@ip-172-31-0-105:~/v4-chain/indexer$ docker compose -f docker-compose-local-deployment.yml up
WARN[0000] The "NPM_TOKEN" variable is not set. Defaulting to a blank string.
[+] Building 0.5s (14/40) docker:default
=> [postgres internal] load build definition from Dockerfile.postgres.local 0.0s
=> => transferring dockerfile: 643B 0.0s
=> [postgres internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [postgres internal] load metadata for docker.io/library/postgres:12-bullseye 0.3s
=> [vulcan internal] load build definition from Dockerfile.service.local 0.0s
=> => transferring dockerfile: 1.95kB 0.0s
=> [vulcan internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [vulcan internal] load metadata for docker.io/dydxprotocol/indexer-node:16-alpine-m1 0.2s
=> CANCELED [vulcan internal] load build context 0.3s
=> => transferring context: 0.3s
=> CACHED [vulcan 1/28] FROM docker.io/dydxprotocol/indexer-node:16-alpine-m1@sha256:070c10d349cbdfff17fac7c5bba290ac7a4f6a9d0b5635c7ed51cb56bdc953a5 0.0s
=> ERROR [vulcan 2/28] RUN apk add --no-cache bash jq aws-cli 0.3s
=> [postgres internal] load build context 0.0s
=> => transferring context: 854B 0.0s
=> [postgres 1/3] FROM docker.io/library/postgres:12-bullseye@sha256:2e851d595911b2d73b1563f7817fe7c911513d2d06e78d8b23d4fa955e649597 0.0s
=> CACHED [postgres 2/3] COPY initialize-docker-postgres-user.sh /docker-entrypoint-initdb.d/ 0.0s
=> CACHED [postgres 3/3] RUN apt update && apt install -y postgresql-12-plpgsql-check postgresql-12-plprofiler postgresql-12-pldebugger 0.0s
=> [postgres] exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:3875ed339c85d25a09881fa9f118a5d5123a8116a5ecb634c3ba73c10898dd4f 0.0s
=> => naming to docker.io/library/indexer-postgres 0.0s

[vulcan 2/28] RUN apk add --no-cache bash jq aws-cli:
0.206 exec /bin/sh: exec format error


failed to solve: process "/bin/sh -c apk add --no-cache bash jq aws-cli" did not complete successfully: exit code: 1

Successful statesync is followed by a panic

Have been setting up a sentry on the dydx-testnet and mainnet. Statesync fetches and applies the chunks just fine, but then it's followed up with a call to PruneRateLimits() (or at least that's what the error message says).

Tested on dydx-testnet. Not tested on the mainnet.

...
10:53AM INF Applied snapshot chunk to ABCI app chunk=1 format=3 height=1654000 module=statesync total=2
10:53AM INF Verified ABCI app appHash="~��\x00Σ*r��k\x7f�UQo����lj\x1b�����\t���" height=1654000 module=statesync
10:53AM INF Snapshot restored format=3 hash="��w�\x05 \x18H�CC\f�[Q(o�$38\x00g[�pmל���" height=1654000 module=statesync
10:53AM INF service start impl=BlockPool module=blockchain msg={}
10:53AM INF Price update had length of 0 module=pricefeed-daemon submodule=price-updater
10:53AM ERR runTx panic'ed with PerformStatefulPremiumVotesValidation failed, err = PerformStatefulPremiumVotesValidation: failed to determine ClobPair sta
tus for perpetual with id 0: Perpetual ID 0 has no associated CLOB pairs: The provided perpetual ID does not have any associated CLOB pairs [dydxprotocol/v
4-chain/protocol/x/clob/keeper/clob_pair.go:244] /x/perpetuals=true module=server proposer_cons_addr=dydxvalcons1wr9fc5en9jzg3dh5t2vzahfqc8n8dd0h9jx0gt sta
ck trace="goroutine 1981 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x5e\ngithub.com/dydxprotocol/v4-chain/protocol/app.New.NewRunTxPa
nicLoggingMiddleware.func8({0x242d5a0, 0xc033dcb6b0})\n\tgithub.com/dydxprotocol/v4-chain/protocol/app/middleware/middleware.go:20 +0x2f\ngithub.com/dydxpr
otocol/v4-chain/protocol/app.New.(*BaseApp).AddRunTxRecoveryHandler.newRecoveryMiddleware.func9({0x242d5a0?, 0xc033dcb6b0?})\n\tgithub.com/cosmos/cosmos-sd
[email protected]/baseapp/recovery.go:39 +0x2d\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x242d5a0, 0xc033dcb6b0}, 0xc000600000?)\n\tgithub.com/cosmos
/[email protected]/baseapp/recovery.go:28 +0x2f\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x242d5a0, 0xc033dcb6b0}, 0x240?)\n\tgithub.com/cos
mos/[email protected]/baseapp/recovery.go:33 +0x53\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx.func1()\n\tgithub.com/cosmos/[email protected]/
baseapp/baseapp.go:783 +0xfe\npanic({0x242d5a0?, 0xc033dcb6b0?})\n\truntime/panic.go:920 +0x270\ngithub.com/dydxprotocol/v4-chain/protocol/x/perpetuals/kee
per.msgServer.AddPremiumVotes({{0x362d0f8?, 0xc0007a29a0?}}, {0x3613da8?, 0xc033fdb710?}, 0xc033d15518)\n\tgithub.com/dydxprotocol/v4-chain/protocol/x/perp
etuals/keeper/msg_server_add_premium_votes.go:20 +0x1fd\ngithub.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types._Msg_AddPremiumVotes_Handler.func1({0
x3613da8, 0xc033fdb710}, {0x2850860?, 0xc033d15518})\n\tgithub.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types/tx.pb.go:734 +0x72\ngithub.com/cosmos/
cosmos-sdk/baseapp.(*MsgServiceRouter).RegisterService.func2.1({0x3613f30, 0xc033fe42c0}, {0xc036bd06a0?, 0x4104c5?}, 0x2a0?, 0xc033d15590)\n\tgithub.com/c
osmos/[email protected]/baseapp/msg_service_router.go:118 +0x93\ngithub.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types._Msg_AddPremiumVotes_Handler
({0x266bba0?, 0xc001359d20}, {0x3613f30, 0xc033fe42c0}, 0x30c0938, 0xc033dd1160)\n\tgithub.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types/tx.pb.go:7
36 +0x135\ngithub.com/cosmos/cosmos-sdk/baseapp.(*MsgServiceRouter).RegisterService.func2({{0x3613ad0, 0x4db2ce0}, {0x362a7b0, 0xc033d3ae40}, {{0xb, 0x0},
{0xc010b00010, 0xe}, 0x193cf1, {0x636b96e, ...}, ...}, ...}, ...)\n\tgithub.com/cosmos/[email protected]/baseapp/msg_service_router.go:139 +0x343\ngithub.
com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runMsgs(_, {{0x3613ad0, 0x4db2ce0}, {0x362a7b0, 0xc033d3ae40}, {{0xb, 0x0}, {0xc010b00010, 0xe}, 0x193cf1, ...}, .
..}, ...)\n\tgithub.com/cosmos/[email protected]/baseapp/baseapp.go:942 +0x271\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx(0xc00092f200, 0x3, {
0xc0163df6c0, 0x3c, 0x3c})\n\tgithub.com/cosmos/[email protected]/baseapp/baseapp.go:885 +0xe05\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).DeliverTx
ShouldLock(0xc00092f200, {{0xc0163df6c0?, 0x0?, 0x0?}}, 0x8?)\n\tgithub.com/cosmos/[email protected]/baseapp/abci.go:449 +0x252\ngithub.com/cosmos/cosmos-
sdk/baseapp.(*BaseApp).DeliverTx(...)\n\tgithub.com/cosmos/[email protected]/baseapp/abci.go:419\ngithub.com/cometbft/cometbft/abci/client.(*unsyncLocalCl
ient).DeliverTxAsync(0xc00035db90, {{0xc0163df6c0?, 0x0?, 0x0?}})\n\tgithub.com/cometbft/[email protected]/abci/client/unsync_local_client.go:73 +0x56\ngith
ub.com/cometbft/cometbft/proxy.(*appConnConsensus).DeliverTxAsync(0xc001019f38, {{0xc0163df6c0?, 0x20?, 0xb?}})\n\tgithub.com/cometbft/[email protected]/pro
xy/app_conn.go:106 +0x163\ngithub.com/cometbft/cometbft/state.execBlockOnProxyApp({0x3613ef8?, 0xc0019834c0}, {0x3627880, 0xc001019f38}, 0xc0166fe5a0, {0x3
62af70, 0xc000300540}, 0x193cf0?)\n\tgithub.com/cometbft/[email protected]/state/execution.go:378 +0x6b6\ngithub.com/cometbft/cometbft/state.(*BlockExecutor
).ApplyBlock(_, {{{0xb, 0x0}, {0x292fd91, 0x6}}, {0xc001196700, 0xe}, 0x1, 0x193cf0, {{0xc006f40a00, ...}, ...}, ...}, ...)\n\tgithub.com/cometbft/cometbft
@v0.37.2/state/execution.go:210 +0x329\ngithub.com/cometbft/cometbft/blocksync.(*Reactor).poolRoutine(0xc001dae700, 0x1)\n\tgithub.com/cometbft/cometbft@v0
.37.2/blocksync/reactor.go:389 +0xb5a\ncreated by github.com/cometbft/cometbft/blocksync.(*Reactor).SwitchToBlockSync in goroutine 245\n\tgithub.com/cometb
ft/[email protected]/blocksync/reactor.go:124 +0xde\n"
panic: Unexpected invocation of PruneRateLimits

goroutine 1981 [running]:
github.com/dydxprotocol/v4-chain/protocol/x/clob/rate_limit.panicRateLimiter[...].PruneRateLimits(...)
        github.com/dydxprotocol/v4-chain/protocol/x/clob/rate_limit/panic_rate_limiter.go:23
github.com/dydxprotocol/v4-chain/protocol/x/clob/keeper.(*Keeper).PruneRateLimits(_, {{0x3613ad0, 0x4db2ce0}, {0x362a7b0, 0xc033517b80}, {{0xb, 0x0}, {0xc0
10b00010, 0xe}, 0x193cf1, ...}, ...})
        github.com/dydxprotocol/v4-chain/protocol/x/clob/keeper/rate_limit.go:67 +0x5a
github.com/dydxprotocol/v4-chain/protocol/x/clob.EndBlocker({{0x3613ad0, 0x4db2ce0}, {0x362a7b0, 0xc033517b80}, {{0xb, 0x0}, {0xc010b00010, 0xe}, 0x193cf1,
 {0x636b96e, ...}, ...}, ...}, ...)
        github.com/dydxprotocol/v4-chain/protocol/x/clob/abci.go:108 +0x9c9
github.com/dydxprotocol/v4-chain/protocol/x/clob.AppModule.EndBlock({{{0x362aa60, 0xc000c9f1c0}}, 0xc001b02ea0, {0x35e76a0, 0xc000c62e60}, {0x7f2b7c344968,
 0xc0010e6420}, {0x3626fd0, 0xc001412900}, 0xc000c4ac80}, ...)

failed to load latest version after upgrading to latest release

Issue

After upgrading to the latest release (main), I'm running into this issue.

rue,"GrpcStreamingEnabled":false,"NonValidatingFullNode":true,"VEOracleEnabled":true} module=server
4:04PM INF Not initializing Datadog profiler. Application environment has not been provided by the DD_ENV environment variable. module=server
4:04PM INF Parsed Indexer flags Flags={"KafkaAddrs":[],"MaxRetries":3,"SendOffchainData":true} module=server
4:04PM INF Parsed Daemon flags Flags={"Bridge":{"Enabled":true,"EthRpcEndpoint":"https://eth-sepolia.g.alchemy.com/v2/demo","LoopDelayMs":30000},"Liquidation":{"Enabled":true,"LoopDelayMs":1600,"QueryPageLimit":1000},"Price":{"Enabled":false,"LoopDelayMs":3000},"Shared":{"MaxDaemonUnhealthySeconds":300,"PanicOnDaemonFailureEnabled":true,"SocketAddress":"/tmp/daemons.sock"},"Slinky":{"ClientTimeout":2000000000,"Enabled":true,"MetricsEnabled":true,"OracleAddress":"localhost:8080","PrometheusServerAddress":"0.0.0.0:8001"}} module=server
4:04PM INF Parsed CLOB flags Flags={"MaxDeleveragingAttemptsPerBlock":10,"MaxDeleveragingSubaccountsToIterate":500,"MaxLiquidationAttemptsPerBlock":50,"MevTelemetryEnabled":false,"MevTelemetryHosts":[],"MevTelemetryIdentifier":""} module=server
failed to load latest version: version of store vault mismatch root store's version; expected 13308000 got 0; new stores should be added using StoreUpgrades

grpc-web cannot be used

Hello! I have deployed a local node and I want to be able to use the grpc-web port. How should I set it up to use it?

app.toml
###############################################################################

gRPC Configuration

###############################################################################

[grpc]

Enable defines if the gRPC server should be enabled.

enable = true

Address defines the gRPC server address to bind to.

address = "0.0.0.0:9090"

MaxRecvMsgSize defines the max message size in bytes the server can receive.

The default value is 10MB.

max-recv-msg-size = "10485760"

MaxSendMsgSize defines the max message size in bytes the server can send.

The default value is math.MaxInt32.

max-send-msg-size = "2147483647"

###############################################################################

gRPC Web Configuration

###############################################################################

[grpc-web]

GRPCWebEnable defines if the gRPC-web should be enabled.

NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op.

NOTE: gRPC-Web uses the same address as the API server.

enable = true

###############################################################################

Node panic

use the latest dydxprotocol, but on testnet, the node happened this error.
panic: precommit step; +2/3 prevoted for an invalid block: wrong Block.Header.AppHash. Expected 2D4A565C3487A4A5BADCDE07101698280F676153A422CFD7C213D8A1AAFF4765, got 37FE06EE5B27BB371D64ED9DC1C9422EA86793BBF7A4DFA137D4EA520CBF68BE

Add cosmos authz module.

Authz is important to seperate the trading wallet from the wallet containing funds. Currently it is not implemented, verified on the app.go as well as the rest endpoint return 501 not implemented when querying authz related endpoints. Is there any plan to add this module?

deploy indexer locally

Could you please share me a full example(or script) to run the indexer service locally directly?

PRO Delegators RPC endpoint is not configured correctly

The PRO Delegators endpoint added to the chain registry is not configured correctly and all of the routes return 404 (i.e. /health), which impacts third parties that use the chain registry RPC list.

One example of that is the Skip API, which by default uses the first endpoint in the list. This leads to errors like the following one when trying to swap assets to/from the dYdX chain:

BroadcastTxError: Broadcasting transaction failed with code 13 (codespace: sdk). Log: insufficient fees; got: 1893562500000000adydx required: 3787125000000000adv4tnt,3788ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5: insufficient fee
    at SigningStargateClient.broadcastTxSync (/...node_modules/@cosmjs/stargate/build/stargateclient.js:292:35)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SigningStargateClient.broadcastTx (/.../node_modules/@cosmjs/stargate/build/stargateclient.js:269:31) {
  code: 13,
  codespace: 'sdk',
  log: 'insufficient fees; got: 1893562500000000adydx required: 3787125000000000adv4tnt,3788ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5: insufficient fee'
}

I've created this PR to move it to the bottom of the list.

Published: [email protected] not build

Just added the [email protected] to my project, but cant find the imports. Investigated, it seems that the published package is not build, but package.json is referencing files, that dont exist:

  "main": "main/index.js",
  "module": "module/index.js",
  "typings": "types/index.d.ts",

But the published package only contains the src folder.

systemd service fails to start after upgrading to dydxprotocold-v4.0.0-rc1-linux-amd64

after upgrading from working dydxprotocold-v3.0.0 to dydxprotocold-v4.0.0-rc1-linux-amd64 and the application from systemd I am getting the following output:

× dydx-testnet.service - dydx testnet service
     Loaded: loaded (/etc/systemd/system/dydx-testnet.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-02-13 20:27:14 UTC; 1s ago
    Process: 1262758 ExecStart=/usr/local/bin/dydxprotocold start --p2p.seeds=${DYDX_SEED_NODES} --home=${DYDX_ROOT} --non-validating-full-node=true --api.enable --liquidation-daemon-enabled>
   Main PID: 1262758 (code=exited, status=2)
        CPU: 583ms

Feb 13 20:27:14 saturn dydxprotocold[1262758]: github.com/dydxprotocol/v4-chain/protocol/app.New({0x4122660, 0x6283720}, {0x413b320, 0xc0005f37a0}, {0x0, 0x0}, 0x1, {0x40dc5c0, 0xc00140cc40}>
Feb 13 20:27:14 saturn dydxprotocold[1262758]:         github.com/dydxprotocol/v4-chain/protocol/app/app.go:1354 +0xb312
Feb 13 20:27:14 saturn dydxprotocold[1262758]: github.com/dydxprotocol/v4-chain/protocol/cmd/dydxprotocold/cmd.NewRootCmdWithInterceptors(0xc0006785c0?, {0xc0006785c0, 0x1a}, 0x3aae718, 0x3a>
Feb 13 20:27:14 saturn dydxprotocold[1262758]:         github.com/dydxprotocol/v4-chain/protocol/cmd/dydxprotocold/cmd/root.go:88 +0x20a
Feb 13 20:27:14 saturn dydxprotocold[1262758]: github.com/dydxprotocol/v4-chain/protocol/cmd/dydxprotocold/cmd.NewRootCmd(0x0?, {0xc0006785c0?, 0x2e5cd30?})
Feb 13 20:27:14 saturn dydxprotocold[1262758]:         github.com/dydxprotocol/v4-chain/protocol/cmd/dydxprotocold/cmd/root.go:66 +0x2d
Feb 13 20:27:14 saturn dydxprotocold[1262758]: main.main()
Feb 13 20:27:14 saturn dydxprotocold[1262758]:         github.com/dydxprotocol/v4-chain/protocol/cmd/dydxprotocold/main.go:22 +0x54
Feb 13 20:27:14 saturn systemd[1]: dydx-testnet.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Feb 13 20:27:14 saturn systemd[1]: dydx-testnet.service: Failed with result 'exit-code'.

however when running the application from terminal with same arguments as in systemd, the behaviour is matching with v3.0.0, here is the working command line:

export DYDX_ROOT=/var/dydx/testnet
export DYDX_SEED_NODES=19d38bb5cea1378db3e16615e63594dc26119a1a@dydx-testnet4-seednode.allthatnode.com:26656,87ee8de5f0f82af6ee6740a30f8844bbe6434413@seed.dydx-testnet.cros-nest.com:26656,38e5a5ec34c578dc323cbdd9b98330abb448d586@tenderseed.ccvalidators.com:29104,[email protected]:27056,[email protected]:23856,182ab0015fb4b7d751b12a9c0162ac123445eac1@seed.dydx-testnet.stakingcabin.com:26656,[email protected]:26656

sudo -u dydx /usr/local/bin/dydxprotocold start --p2p.seeds=${DYDX_SEED_NODES} --home=${DYDX_ROOT} --non-validating-full-node=true --api.enable --liquidation-daemon-enabled=false --mev-telemetry-enabled=false

dydx-testnet.service:

[Unit]
Description=dydx testnet service 
Wants=network-online.target
After=network.target network-online.target

[Service]
EnvironmentFile=/var/dydx/dydx-testnet.env

Type=simple
User=dydx
RemainAfterExit=yes
ExecStart=/usr/local/bin/dydxprotocold start --p2p.seeds=${DYDX_SEED_NODES} --home=${DYDX_ROOT} --non-validating-full-node=true --api.enable --liquidation-daemon-enabled=false

[Install]
WantedBy=multi-user.target

/var/dydx/dydx-testnet.env

DYDX_ROOT=/var/dydx/testnet
DYDX_SEED_NODES=19d38bb5cea1378db3e16615e63594dc26119a1a@dydx-testnet4-seednode.allthatnode.com:26656,87ee8de5f0f82af6ee6740a30f8844bbe6434413@seed.dydx-testnet.cros-nest.com:26656,38e5a5ec34c578dc323cbdd9b98330abb448d586@tenderseed.ccvalidators.com:29104,[email protected]:27056,[email protected]:23856,182ab0015fb4b7d751b12a9c0162ac123445eac1@seed.dydx-testnet.stakingcabin.com:26656,[email protected]:26656

Integerate linear with CodeRabbit

We recommend integrating linear with CodeRabbit. This can be done through the CodeRabbit UI.
This enables CodeRabbit to use the context from the linked Linear issues during the pull request reviews.

Feel free to reach out to the CodeRabbit team with any questions.

document

Do you have a document to introduce your RPC?

getting `failed to load latest version` after upgrading to latest

Scenario

I patched our code with the latest from v4-chain branch but after starting the chain with the same command, I now get this error
failed to load latest version: version of store ratelimit mismatch root store's version; expected 3517779 got 0; new stores should be added using StoreUpgrades

Edit: I just pulled the new patch and getting a new error now
failed to load latest version: version of store icahost mismatch root store's version; expected 3517779 got 0; new stores should be added using StoreUpgrades

`settled_funding` event ordering non-deterministic due to use of go maps

What happened

While testing the dYdX <> KYVE integration, which validates and archives the entire block and block_results history, we noticed that the events in the block_results have a different order. The actual diff at block 1935793 can be found below:

Node 1:


{
  "type": "settled_funding",
  "attributes": [
    {
      "key": "funding_paid_quote_quantums",
      "value": "-120304"
    },
    {
      "key": "perpetual_id",
      "value": "0"
    },
    {
      "key": "subaccount",
      "value": "dydx19mj886afdpca6pwvk88pq5hkum3vyart26wqyt"
    },
    {
      "key": "subaccount",
      "value": "0"
    }
  ]
},
{
  "type": "settled_funding",
  "attributes": [
    {
      "key": "funding_paid_quote_quantums",
      "value": "-182436"
    },
    {
      "key": "perpetual_id",
      "value": "1"
    },
    {
      "key": "subaccount",
      "value": "dydx19mj886afdpca6pwvk88pq5hkum3vyart26wqyt"
    },
    {
      "key": "subaccount",
      "value": "0"
    }
  ]
}

Node 2:

{
  "type": "settled_funding",
  "attributes": [
    {
      "key": "funding_paid_quote_quantums",
      "value": "-182436"
    },
    {
      "key": "perpetual_id",
      "value": "1"
    },
    {
      "key": "subaccount",
      "value": "dydx19mj886afdpca6pwvk88pq5hkum3vyart26wqyt"
    },
    {
      "key": "subaccount",
      "value": "0"
    }
  ]
},
{
  "type": "settled_funding",
  "attributes": [
    {
      "key": "funding_paid_quote_quantums",
      "value": "-120304"
    },
    {
      "key": "perpetual_id",
      "value": "0"
    },
    {
      "key": "subaccount",
      "value": "dydx19mj886afdpca6pwvk88pq5hkum3vyart26wqyt"
    },
    {
      "key": "subaccount",
      "value": "0"
    }
  ]
},

Origin

This can be traced back to where the event gets emitted in https://github.com/dydxprotocol/v4-chain/blob/main/protocol/x/subaccounts/keeper/subaccount.go#L321. Events are emitted in a random order due to the use of go maps. More on that here.

Impact

This has a very critical impact on KYVE's ability to properly validate and archive the dYdX block and event history, due to multiple entities coming to different conclusions on the order of events. Futhermore, it is not only critical to KYVE, but also to indexers and data analysists, who rely on determistic events and a correct order to fully comprehend what happens on-chain.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.