Skip to content

Fix HTTP/REST clients HTTP Content-Type header parsers. - #4139

Merged
zah merged 3 commits into
unstablefrom
fix-client-content-type
Sep 19, 2022
Merged

Fix HTTP/REST clients HTTP Content-Type header parsers.#4139
zah merged 3 commits into
unstablefrom
fix-client-content-type

Conversation

@cheatfate

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim Outdated
@etan-status

Copy link
Copy Markdown
Contributor

Hmm, while the Content-Type with charset now parses fine, there's now a weird REST JSON parsing issue, could it be related to the fix, or separate?

% build/nimbus_beacon_node trustedNodeSync --network:sepolia --backfill=false --data-dir="$HOME/Downloads/nimbus/data/sepolia" "--trusted-node-url=https://lodestar-sepolia.chainsafe.io" --blockId=234368 --log-level=DEBUG
NOT 2022-09-17 14:29:45.298+02:00 Starting trusted node sync                 databaseDir=/Users/etan/Downloads/nimbus/data/sepolia/db restUrl=https://lodestar-sepolia.chainsafe.io blockId=234368 backfill=false reindex=false
INF 2022-09-17 14:29:45.486+02:00 Writing genesis state                      stateRoot=fb9afe32 genesis_validators_root=d8ea171f
INF 2022-09-17 14:29:45.522+02:00 Writing genesis block                      blockRoot=fb9b64fe blck="(slot: 0, proposer_index: 0, parent_root: \"00000000\", state_root: \"fb9afe32\", eth1data: (deposit_root: 0000000000000000000000000000000000000000000000000000000000000000, deposit_count: 0, block_hash: 0000000000000000000000000000000000000000000000000000000000000000), graffiti: \"\", proposer_slashings_len: 0, attester_slashings_len: 0, attestations_len: 0, deposits_len: 0, voluntary_exits_len: 0, sync_committee_participants: -1)"
DBG 2022-09-17 14:29:45.525+02:00 Sending REST request to remote server      remote=lodestar-sepolia.chainsafe.io:443 request=/eth/v1/beacon/blocks/genesis/root http_method=GET
DBG 2022-09-17 14:29:46.097+02:00 Got REST response headers from remote server status=200 http_method=GET remote=lodestar-sepolia.chainsafe.io:443 request=/eth/v1/beacon/blocks/genesis/root connection=1
DBG 2022-09-17 14:29:46.097+02:00 Received REST response body from remote server status=200 http_method=GET remote=lodestar-sepolia.chainsafe.io:443 request=/eth/v1/beacon/blocks/genesis/root connection=1 contentType="application/json; charset=\"utf-8\"" size=77
DBG 2022-09-17 14:29:46.098+02:00 Failed to deserialize REST JSON data       err="<data>(1, 9) Unexpected token 'tkString' in place of 'object start bracket'" data="{\"data\":\"0xfb9b64fe445f76696407e1e3cc390371edff147bf712db86db6197d4b31ede43\"}"
ERR 2022-09-17 14:29:46.098+02:00 Unable to download genesis block root      error="Unable to decode REST response, error [Serialization error]" restUrl=https://lodestar-sepolia.chainsafe.io

@github-actions

Copy link
Copy Markdown

Unit Test Results

       9 files   -        3     660 suites   - 200   23m 0s ⏱️ - 52m 19s
1 982 tests ±       0  1 835 ✔️ ±       0  147 💤 ±  0  0 ±0 
8 060 runs   - 2 602  7 889 ✔️  - 2 583  171 💤  - 19  0 ±0 

Results for commit 0f769fa. ± Comparison against base commit 31a777a.

@cheatfate

Copy link
Copy Markdown
Contributor Author

Hmm, while the Content-Type with charset now parses fine, there's now a weird REST JSON parsing issue, could it be related to the fix, or separate?

% build/nimbus_beacon_node trustedNodeSync --network:sepolia --backfill=false --data-dir="$HOME/Downloads/nimbus/data/sepolia" "--trusted-node-url=https://lodestar-sepolia.chainsafe.io" --blockId=234368 --log-level=DEBUG
NOT 2022-09-17 14:29:45.298+02:00 Starting trusted node sync                 databaseDir=/Users/etan/Downloads/nimbus/data/sepolia/db restUrl=https://lodestar-sepolia.chainsafe.io blockId=234368 backfill=false reindex=false
INF 2022-09-17 14:29:45.486+02:00 Writing genesis state                      stateRoot=fb9afe32 genesis_validators_root=d8ea171f
INF 2022-09-17 14:29:45.522+02:00 Writing genesis block                      blockRoot=fb9b64fe blck="(slot: 0, proposer_index: 0, parent_root: \"00000000\", state_root: \"fb9afe32\", eth1data: (deposit_root: 0000000000000000000000000000000000000000000000000000000000000000, deposit_count: 0, block_hash: 0000000000000000000000000000000000000000000000000000000000000000), graffiti: \"\", proposer_slashings_len: 0, attester_slashings_len: 0, attestations_len: 0, deposits_len: 0, voluntary_exits_len: 0, sync_committee_participants: -1)"
DBG 2022-09-17 14:29:45.525+02:00 Sending REST request to remote server      remote=lodestar-sepolia.chainsafe.io:443 request=/eth/v1/beacon/blocks/genesis/root http_method=GET
DBG 2022-09-17 14:29:46.097+02:00 Got REST response headers from remote server status=200 http_method=GET remote=lodestar-sepolia.chainsafe.io:443 request=/eth/v1/beacon/blocks/genesis/root connection=1
DBG 2022-09-17 14:29:46.097+02:00 Received REST response body from remote server status=200 http_method=GET remote=lodestar-sepolia.chainsafe.io:443 request=/eth/v1/beacon/blocks/genesis/root connection=1 contentType="application/json; charset=\"utf-8\"" size=77
DBG 2022-09-17 14:29:46.098+02:00 Failed to deserialize REST JSON data       err="<data>(1, 9) Unexpected token 'tkString' in place of 'object start bracket'" data="{\"data\":\"0xfb9b64fe445f76696407e1e3cc390371edff147bf712db86db6197d4b31ede43\"}"
ERR 2022-09-17 14:29:46.098+02:00 Unable to download genesis block root      error="Unable to decode REST response, error [Serialization error]" restUrl=https://lodestar-sepolia.chainsafe.io

So i have performed same request using curl.

curl https://lodestar-sepolia.chainsafe.io/eth/v1/beacon/blocks/genesis/root
{"data":"0xfb9b64fe445f76696407e1e3cc390371edff147bf712db86db6197d4b31ede43"}

As you can see response generated by lodestar do not follows specification https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockRoot

Because minimal response should be

{"data": {"root": "0xfb9b64fe445f76696407e1e3cc390371edff147bf712db86db6197d4b31ede43"}}

@etan-status

Copy link
Copy Markdown
Contributor

Oh, that indeed explains the error.

@wemeetagain could you please update Lodestar with correct response format for getBlockRoot endpoint?

@zah
zah merged commit ca871a5 into unstable Sep 19, 2022
@zah
zah deleted the fix-client-content-type branch September 19, 2022 09:17
etan-status added a commit that referenced this pull request Sep 19, 2022
#4139 linked to the commit on the feature branch itself instead of the
commit merged to `master`. Fix dependency reference.
etan-status added a commit that referenced this pull request Sep 19, 2022
#4139 linked to the commit on the feature branch itself instead of the
commit merged to `master`. Fix dependency reference.
@dapplion

Copy link
Copy Markdown
Contributor

Not included in LTS, but is in chainsafe/lodestar:next

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.

4 participants