mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-31 16:58:31 +00:00
This reverts commit 21601f59e21a8c6c9583738c4d79fb3ffd54f11d. Reason: `/eth/v1/beacon/light_client/updates?start_period=0&count=128` provides malformed data. Reverting fixes it locally. Download JSON and SSZ, then use this script to validate (Holesky). Need to export some symbols for parsing. ```nim import stew/io2, ./beacon_chain/spec/[digest, forks, helpers, presets], ./beacon_chain/spec/eth2_apis/[eth2_rest_serialization, rest_light_client_calls] let jsonBytes = io2.readAllBytes("/Users/etan/Downloads/json_updates.json").get() let (cfg, unknowns) = readRuntimeConfig("/Users/etan/Documents/Repos/nimbus-eth2/vendor/holesky/custom_config_data/config.yaml") genesis_validators_root = Eth2Digest.fromHex("0x9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1") forkDigests = newClone ForkDigests.init(cfg, genesis_validators_root) let updates = seq[ForkedLightClientUpdate].decodeJsonLightClientObjects(jsonBytes, cfg, forkDigests) var entries = newSeqOfCap[RestVersioned[ForkedLightClientUpdate]](updates.len) for update in updates: let contextEpoch = withForkyUpdate(update): when lcDataFork > LightClientDataFork.None: forkyUpdate.contextEpoch else: continue contextFork = cfg.consensusForkAtEpoch(contextEpoch) entries.add RestVersioned[ForkedLightClientUpdate]( data: update, jsonVersion: contextFork, sszContext: forkDigests[].atconsensusFork(contextFork)) let res = block: var default: seq[byte] try: var stream = memoryOutput() for e in entries: withForkyUpdate(e.data): when lcDataFork > LightClientDataFork.None: var cursor = stream.delayFixedSizeWrite(sizeof(uint64)) let initPos = stream.pos stream.write e.sszContext.data var writer = SszWriter.init(stream) writer.writeValue forkyUpdate cursor.finalWrite (stream.pos - initPos).uint64.toBytesLE() stream.getOutput(seq[byte]) except SerializationError: default except IOError: default let sszBytes = io2.readAllBytes("/Users/etan/Downloads/ssz_updates.ssz").get() let sszUpdates = seq[ForkedLightClientUpdate].decodeSszLightClientObjects(res, cfg, forkDigests) doAssert updates.len == sszUpdates.len for i in 0 ..< updates.len: doAssert updates[i].kind == sszUpdates[i].kind withForkyUpdate(updates[i]): when lcDataFork > LightClientDataFork.None: doAssert forkyUpdate == sszUpdates[i].forky(lcDataFork) doAssert sszBytes == res ```
This commit is contained in:
parent
11d522dd86
commit
a299d17fe7
2
vendor/nim-ssz-serialization
vendored
2
vendor/nim-ssz-serialization
vendored
@ -1 +1 @@
|
||||
Subproject commit 9721c85c8c56509ccc01f1524f40efed1144e90f
|
||||
Subproject commit 9f9c08b9a748b13942594ca0f075ff9dbaaf9bb9
|
Loading…
x
Reference in New Issue
Block a user