Repository navigation
feat(zkevm): add schema-id prefix to stateless guest program input bytes - #2826
Conversation
…serialization target
| @@ -25,8 +26,15 @@ def serialize_stateless_output( | |||
|
|
|||
|
|
|||
| def deserialize_stateless_input(data: Bytes) -> StatelessInput: | |||
| if schema_id != STATELESS_INPUT_SCHEMA_ID: | ||
| raise ValueError( | ||
| f"Unsupported stateless input schema id: 0x{schema_id:02x}" | ||
| ) |
There was a problem hiding this comment.
In the spec, we don't have a single guest program entry point that supports multiple-forks. This is mainly related on how execution-specs is architected having full specs per fork in different folders.
In real EL guest programs which support multiple forks, they will probably have a switch here to act accordingly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## projects/zkevm #2826 +/- ##
==================================================
+ Coverage 85.72% 86.37% +0.64%
==================================================
Files 612 613 +1
Lines 37853 38019 +166
Branches 3932 3964 +32
==================================================
+ Hits 32451 32839 +388
+ Misses 4652 4543 -109
+ Partials 750 637 -113
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
marioevz
left a comment
There was a problem hiding this comment.
LGTM, the single comment is a suggestion that could be addressed later.
c2d368f to
0951b85
Compare
rubo
left a comment
There was a problem hiding this comment.
My only concern is the schema-id size being a single byte. I'm leaning more toward 2-byte or varint.
Yep, sounds good. I think I'll switch to a fixed-two-byte value, mostly because something like LEB128 might be an overkill of fiddling with bits inside zkVM (although compared to the big picture shouldn't be a big deal either). Two-bytes would give us >65k values which should be enough. |
🗒️ Description
This PR adds a
schema-idtwo-byte big-int prefix to the guest program input bytes.Before this PR, the guest input was SSZ-bytes corresponding to
StatelessInput. SSZ encoded bytes does not describe which is the target struct to deserialize to. As a concrete example, different forks would have differentExecutionPayloadthus indirectly differentStatelessInputdefinitions.Guest programs are meant to support multiple forks so they are useful between fork boundaries, thus they need some clear way to distinguish which target
StatelessInputshould be used to deserialize the received input bytes. While this can be done by using some assumptions about SSZ field ordering to readtimestampagainst theChainConfig, this might feel a bit hacky.Note that
schema-idisn't really a signal of a target fork -- it can even mean that the rest of bytes afterschema-idbyte have other encoding formats, so should be interpreted as[schema-id-byte][rest input bytes...]instead of[schema-id-byte][ssz-encoded-stateless-input-for-fork-XXX...](although for a while this might be the right interpretation in practice).Other notes:
schema-idis a two-byte prefix. This should provide enough capacity for the near future. Thought about LEB128, but feels like overkill.schema-id == 0is not a valid value, mainly to avoid being used by error since it is the default value of a byte.0x01is mainly the most obvious value, although in the near future, if we end up supporting historical forks, we might want to redefine this if another ordering feels more natural.🔗 Related Issues or PRs
N/A.
✅ Checklist
just statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_frommarker.Cute Animal Picture