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

DuneAPI: new batch wire format (breaking change!) #64

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

msf
Copy link
Contributor

@msf msf commented Jul 23, 2024

This is a breaking change, it changes the block batch format on the wire. It introduces a single JSON line (NDJSON) which is the batch header. This can be DISABLED with DUNEAPI_DISABLE_BATCH_HEADER environment variable

This line indicates how many blocks and the size of each block message In essense, we're length prefixing the batch.
This allows the reader to split out easily all the messages. Until now this wasn't needed because Optimism Stack (EVM stack) uses a fixed 3-line payload for the blocks.
But this isn't the case in other EVM stacks (such as arbitrum nitro)

It uses JSON to encode this information because the jsonRPC message from the blockchain RPC node are already in JSON and the wire format is already NDJSON.

For the server side to handle in a backwards compatible way the payload, it needs to read the first line and attempt to parse it as a BlockBatchHeader message If that fails, it can revert back to the older message format parser

This is a breaking change, it changes the block batch format on the wire.
It introduces a single JSON line (NDJSON) which is the batch header.
This can be DISABLED with `DUNEAPI_DISABLE_BATCH_HEADER`
environment variable

This line indicates how many blocks and the size of each block message
In essense, we're length prefixing the batch.
This allows the reader to split out easily all the messages.
Until now this wasn't needed because Optimism Stack (EVM stack) uses a
fixed 3-line payload for the blocks.
But this isn't the case in other EVM stacks (such as arbitrum nitro)

It uses JSON to encode this information because the jsonRPC message from
the blockchain RPC node are already in JSON and the wire format is already NDJSON.

For the server side to handle in a backwards compatible way the payload,
it needs to read the first line and attempt to parse it as a BlockBatchHeader message
If that fails, it can revert back to the older message format parser
@msf msf requested review from helanto and adammilnesmith July 23, 2024 01:51
Copy link
Contributor

@adammilnesmith adammilnesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

adammilnesmith

This comment was marked as duplicate.

@msf msf merged commit 0152929 into main Jul 23, 2024
1 check passed
@msf msf deleted the new-batching-wire-format branch July 23, 2024 20:06
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