diff --git a/fluffy/eth_data/yaml_eth_types.nim b/fluffy/eth_data/yaml_eth_types.nim index 196c46f2c..5f4394d6c 100644 --- a/fluffy/eth_data/yaml_eth_types.nim +++ b/fluffy/eth_data/yaml_eth_types.nim @@ -7,7 +7,7 @@ {.push raises: [].} -import ssz_serialization/types +import ssz_serialization/types, stew/byteutils type YamlTestProofBellatrix* = object @@ -38,6 +38,6 @@ proc fromHex*[n](T: type array[n, Digest], a: array[n, string]): T = proc toHex*[n](a: array[n, Digest], T: type array[n, string]): T = var res: T for i in 0 ..< a.len: - res[i] = toHex(a[i].data) + res[i] = to0xHex(a[i].data) res diff --git a/fluffy/eth_data/yaml_utils.nim b/fluffy/eth_data/yaml_utils.nim index b3d92554f..78b2949ab 100644 --- a/fluffy/eth_data/yaml_utils.nim +++ b/fluffy/eth_data/yaml_utils.nim @@ -41,6 +41,20 @@ proc loadFromYaml*(T: type, file: string): Result[T, string] = ok(res) proc dumpToYaml*[T](value: T, file: string): Result[void, string] = + # These are the default options aside from outputVersion which is set to none. + const options = PresentationOptions( + containers: cMixed, + indentationStep: 2, + newlines: nlOSDefault, + outputVersion: ovNone, + maxLineLength: some(80), + directivesEnd: deIfNecessary, + suppressAttrs: false, + quoting: sqUnset, + condenseFlow: true, + explicitKeys: false, + ) + let s = newFileStream(file, fmWrite) defer: try: @@ -48,7 +62,8 @@ proc dumpToYaml*[T](value: T, file: string): Result[void, string] = except Exception as e: raiseAssert(e.msg) try: - dump(value, s) + # Dump to yaml, avoiding TAGS and YAML version directives. + dump(value, s, tagStyle = tsNone, options = options, handles = @[]) except YamlPresenterJsonError as e: return err(e.msg) except YamlSerializationError as e: diff --git a/fluffy/tools/eth_data_exporter/cl_data_exporter.nim b/fluffy/tools/eth_data_exporter/cl_data_exporter.nim index e97e64d02..048ae96bc 100644 --- a/fluffy/tools/eth_data_exporter/cl_data_exporter.nim +++ b/fluffy/tools/eth_data_exporter/cl_data_exporter.nim @@ -347,11 +347,11 @@ proc exportBeaconBlockProofBellatrix( let yamlTestProof = YamlTestProofBellatrix( execution_block_header: - beaconBlock.message.body.execution_payload.block_hash.data.toHex, + beaconBlock.message.body.execution_payload.block_hash.data.to0xHex(), beacon_block_body_proof: blockProof.beaconBlockBodyProof.toHex(array[8, string]), - beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.toHex(), + beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.to0xHex(), beacon_block_header_proof: blockProof.beaconBlockHeaderProof.toHex(array[3, string]), - beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.toHex(), + beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.to0xHex(), historical_roots_proof: blockProof.historicalRootsProof.toHex(array[14, string]), slot: blockProof.slot.uint64, ) @@ -469,11 +469,11 @@ proc exportBeaconBlockProofCapella( let yamlTestProof = YamlTestProof( execution_block_header: - beaconBlock.message.body.execution_payload.block_hash.data.toHex, + beaconBlock.message.body.execution_payload.block_hash.data.to0xHex(), beacon_block_body_proof: blockProof.beaconBlockBodyProof.toHex(array[8, string]), - beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.toHex(), + beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.to0xHex(), beacon_block_header_proof: blockProof.beaconBlockHeaderProof.toHex(array[3, string]), - beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.toHex(), + beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.to0xHex(), historical_summaries_proof: blockProof.historicalSummariesProof.toHex(array[13, string]), slot: blockProof.slot.uint64,