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

Feat/smt txn traces #206

Closed
wants to merge 69 commits into from
Closed

Feat/smt txn traces #206

wants to merge 69 commits into from

Conversation

BGluth
Copy link
Contributor

@BGluth BGluth commented May 1, 2024

(WIP) Major refactor to trace decoder in order to add support for SMT & continuations.

Overview

While the original scope of this PR has changed overtime, the original plan was the following:

  • Split logic specific to mpt/smt into their own modules.
  • Stub out support for continuations (and fill in later).
  • Link against two versions of evm_arithmetization (one for mpt, another (branch feat/type2) for smt).
  • Because the logic for processing deltas for smt & mpt traces is very close, abstract away the points where they differ.

However, two design aspects have changed since this PR was started:

  • We are moving back to feature gating instead of double linking (we will never need a single binary that can do both mpt & smt).
  • Continuation support is not as complex as I initially thought and can be simplified. Specifically, we do not need a different payload structure for continuations from the full-node.

Implementation details

Module Splitting

Because initially the plan was to rely on feature gating to handle mpt & smt logic, the decision was made to separate logic for these areas into their own modules, as it's much cleaner to conditionally compile a module rather than individual types and functions. These modules use types/functions that are identical in name but differ in implementation between mpt & smt (eg. GenerationInputs). A clean way to handle this is to use type aliases that change based on a feature flag (eg. GenerationInputs points to the mpt or smt version depending on flags).

Trace Processing Abstraction

As mentioned above, because the majority of the trace parsing logic is shared between mpt & smt trace processing, if we can abstract away the parts that differ, then we can achieve very high code re-usability. In the end, the trace pre-processing stage is nearly 100% identical, but the decoding stage, while still pretty similar, differs in a few more places. As an example, if a trace states that a storage slot is set with a new value, the only core difference is the logic that runs to update the internal trie state.

To handle this abstraction, the preprocessing & decoding stages both are parameterized with empty types that implement two corresponding traits. These traits define the types & methods that differ between the implementations.

BGluth and others added 30 commits April 26, 2024 12:34
- Created type aliases for all `evm_arithmetization` types that we
  need to swap out depending on whether or not we are compiling for
  `mpt` or `smt`.
- Realized that there is no clean way to disable a default feature when
  it absolutely needs to be disabled (eg. when "smt" is enabled).
- Also added a compile time check to enforce that one of these features
  is enabled.
- Prep for `mpt`/`smt` logic feature gating.
Rough draft of SMT & continuation support

- Still need to remove feature gating stuff.
- Realized that we can link again both versions of the library at once
  without conditional compilation.
- It's going to make a lot of sense I think to split the logic that
  generates `mpt` & `smt` tries. This commit just renames a file and
  creates the module for smt tries.
- Because we're going to be dealing with feature flags for SMT stuff,
  it's going to be very worth while I think splitting the logic into
  seperate modules.
- This commit does just that.
- We need to access this normally with a feature gate, but just to rush
  getting something going, we're going to copy it in for now.
- Waiting for Will's impl upstream first.
- Also moved them to `common`.
- Previously was using `Nibbles` for constructing the current key during
  traversal (this was wrong).
@github-actions github-actions bot added crate: evm_arithmetization Anything related to the evm_arithmetization crate. and removed crate: mpt_trie Anything related to the mpt_trie crate. labels May 8, 2024
@BGluth BGluth mentioned this pull request May 8, 2024
@github-actions github-actions bot added the crate: proof_gen Anything related to the proof_gen crate. label May 17, 2024
@github-actions github-actions bot added crate: mpt_trie Anything related to the mpt_trie crate. and removed crate: evm_arithmetization Anything related to the evm_arithmetization crate. labels May 23, 2024
BGluth added 4 commits May 23, 2024 15:40
- Required because we can only run the tests when the appropiate testing
  flag is enabled.
- A lot of the logic is pretty isloated, so I thought that this made
  more sense.
@BGluth BGluth force-pushed the feat/smt_txn_traces branch from 5356183 to aa5dd4c Compare May 24, 2024 16:37
@0xaatif 0xaatif mentioned this pull request Jun 12, 2024
1 task
@BGluth
Copy link
Contributor Author

BGluth commented Jul 10, 2024

I think with @0xaatif taking this on, we can close my PR.

@BGluth BGluth closed this Jul 10, 2024
@Nashtare Nashtare deleted the feat/smt_txn_traces branch November 26, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate: mpt_trie Anything related to the mpt_trie crate. crate: proof_gen Anything related to the proof_gen crate. crate: trace_decoder Anything related to the trace_decoder crate.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants