-
Notifications
You must be signed in to change notification settings - Fork 238
Conversation
We are already chunking on a sync, see here: https://github.com/0xProject/0x-api/blob/master/src/services/order_watcher_service.ts#L26 so I thought we'd already be covered by this. I have a gut feeling that something more peculiar is happening on a disconnect. When I last tested this I was dropping the Mesh container and restarting it, this would force a reconnect and it would show errors. The underlying connection can report some debug info if |
What @dekz said. Have you looked into using the HTTP endpoint? |
I'd like to try deploying this fix and monitoring for a couple of days. Our writeup in Quip (link) suggests that right now this happens occasionally when I think it's also important to figure out if chunking everywhere fixes it. If it doesn't that indicates an unknown bug in the client. @dekz I'm with you on funky disconnects. I did some testing with the unit tests in https://github.com/0xProject/0x-mesh and noticed weird behaviour on disconnects with the client there too, but it might have just been my local env. |
@xianny that |
Went down a bit of a rabbithole examining the websocket implementation in Mesh and web3.js and trying to rule out bugs there. Most likely cause of this problem (despite currently chunking by 100 orders at a time) is inconsistent order size, e.g. ERC1155 orders. There's no chunking built into the Mesh client, and it also doesn't make use of the fragmentation in the Long-term, we should try to figure out how to use fragmentation in the Mesh client, or add automatic chunking by size of bytes. For now we can switch to using the HTTP endpoint which was implemented in Mesh v9 0xProject/0x-mesh#658; just waiting till #113 is merged |
7994db4
to
a7d06ee
Compare
5b94b5b
to
0b11122
Compare
0b11122
to
790b0ec
Compare
deploy staging |
deploy kovan |
Ready for review again! ChangesAdding orders to mesh should now only be done through The implementation of TestingI deployed this on Kovan and successfully posted 10 orders (websocket) and 60 orders (http) via Potential issuesI don't know what the effects of chunking and sending multiple requests are. Sometimes orderbook syncing has > 1000 orders, which means 10 HTTP requests of 100 orders each. I think this should be OK, but am flagging it as an unknown. Will need https://github.com/0xProject/0x-main-infra/pull/176 to deploy |
deploy kovan |
d561929
to
31193be
Compare
README.md
Outdated
| `CHAIN_ID` | Required. No default. | The chain id you'd like your API to run on (e.g: `1` -> mainnet, `42` -> Kovan, `3` -> Ropsten, `1337` -> Ganache). Defaults to `42` in the API, but required for `docker-compose up`. | | ||
| `ETHEREUM_RPC_URL` | Required. No default. | The URL used to issue JSON RPC requests. Use `http://ganache:8545` to use the local ganache instance. | | ||
| `MESH_WEBSOCKET_URI` | Required. Default for dev: `ws://localhost:60557` | The URL pointing to the 0x Mesh node. A default node is spun up in `docker-compose up` | | ||
| `MESH_HTTP_URI` | Optional. Used when syncing the orderbook; defaults to websocket connection if not provided. | The URL pointing to the Mesh node's HTTP JSON-RPC endpoint. A default node is spun up in `docker-compose up` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would just say "Optional. No default." and then put the description part in the description column.
src/config.ts
Outdated
@@ -40,6 +40,7 @@ export const ETHEREUM_RPC_URL = assertEnvVarType('ETHEREUM_RPC_URL', process.env | |||
export const MESH_WEBSOCKET_URI = _.isEmpty(process.env.MESH_WEBSOCKET_URI) | |||
? 'ws://localhost:60557' | |||
: assertEnvVarType('MESH_WEBSOCKET_URI', process.env.MESH_WEBSOCKET_URI, EnvVarType.Url); | |||
export const MESH_HTTP_URI = process.env.MESH_HTTP_URI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should still use the assertEnvVarType
function right? if it isn't falsey.
src/utils/mesh_client.ts
Outdated
if (_.isEmpty(this.httpURI)) { | ||
return super.addOrdersAsync(orders, pinned); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should just fail right? The function name here is misleading if there is a case where it would post over websockets. You could also rename the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renaming function
src/utils/mesh_client.ts
Outdated
chunks.forEach(async chunk => { | ||
// format request payload | ||
const data = { | ||
jsonrpc: '2.0', | ||
id: +new Date(), | ||
method: 'mesh_addOrders', | ||
params: [chunk, { pinned }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need batching logic for HTTP?
4373a6e
to
7c2d395
Compare
7c2d395
to
15b535e
Compare
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This should fix the
message too big
error that we are getting from Mesh. Chunks orders whenever we are adding orders to Mesh. This already existed inmeshUtils
so it's a tiny code change.Context
We've been getting this error recently especially on start-up when syncing the orderbook with Mesh:
This error is caused by sending too many orders at once to Mesh. We need to always use chunking when calling
meshClient.addOrdersAsync
. The underlying cause is a bug in the websocket client.Discussed with @fabioberger who suggested the best way to deal with it is to add the chunking on the 0x-api side.
Tests
Deployed on staging, smoke tests are passing