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

Fuzzing utilities package / SSZ decoding for spec #1178

Merged
merged 6 commits into from
Jun 16, 2019
Merged

Conversation

protolambda
Copy link
Contributor

@protolambda protolambda commented Jun 14, 2019

SSZ decoding through pyssz for fuzzing. Intended to use with fuzzing. But maybe it's better to make a generic toolbelt package?

Implemented:

  • translate a pyspec type to a py-ssz sedes (serialization description?)
  • translate a py-ssz decoded value to a pyspec value

Usage:

from eth2spec.phase0 import spec
from preset_loader import loader
from eth2spec.utils.ssz import ssz_impl as spec_ssz_impl

configs_path = "../../configs/"
config_name = "minimal"
presets = loader.load_presets(configs_path, config_name)
spec.apply_constants_preset(presets)

typ = spec.BeaconBlock
v = typ()
v.slot = 123

data = spec_ssz_impl.serialize(v)
print('data', data.hex())

block_sedes = translate_typ(typ)
print('sedes', block_sedes)

raw_value = block_sedes.deserialize(data)
print('raw_value', raw_value)

assert block_sedes.serialize(raw_value) == data

block = translate_value(raw_value, typ)
print('res', block)

assert spec_ssz_impl.hash_tree_root(v) == spec_ssz_impl.hash_tree_root(block)

TODO:

  • decide on packaging (fuzzing? toolbelt?) Moved into pyspec, since it closely works with py-ssz, and needs to be readily accessible for Guido to start fuzzing
  • add setup.py so it can be imported into other modules (see above)
  • update py-ssz dependency version, this version does not use offsets, but it looks like the newest unreleased code on github does

@protolambda protolambda added the scope:SSZ Simple Serialize label Jun 14, 2019
@protolambda
Copy link
Contributor Author

protolambda commented Jun 14, 2019

@hwwhww or @carver can you help me out with a new py-ssz release to read offsets in decoding? (I see offsets in the py-ssz github code, is that working?) 🙏

@carver
Copy link

carver commented Jun 14, 2019

I'm not deeply familiar with py-ssz, I seem to be a pypi maintainer only as emergency backup. Maybe @pipermerriam could help here with the question about read offsets (and a release)?

@protolambda protolambda marked this pull request as ready for review June 14, 2019 17:13
@protolambda protolambda requested a review from djrtwo June 14, 2019 17:14
@protolambda
Copy link
Contributor Author

Blocked by ethereum/py-ssz#74

@protolambda
Copy link
Contributor Author

This PR is ready for review

@djrtwo djrtwo merged commit 25a16bd into v07x Jun 16, 2019
@djrtwo djrtwo deleted the decode-with-pyssz branch June 16, 2019 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants