feat: add vyper selector detection via calldata flow tracing#683
Closed
Jon-Becker wants to merge 2 commits intomainfrom
Closed
feat: add vyper selector detection via calldata flow tracing#683Jon-Becker wants to merge 2 commits intomainfrom
Jon-Becker wants to merge 2 commits intomainfrom
Conversation
implements vyper function selector discovery by tracing calldata flow through vyper's O(1) bucket-based dispatcher pattern. adds compiler-aware branching in find_function_selectors and resolve_entry_point to support both solidity (PUSH4 pattern matching) and vyper (symbolic execution tracing) strategies, with fallback for unknown compilers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
adds unit tests for extract_selector_from_condition, find_vyper_selectors, resolve_vyper_entry_point, and end-to-end compiler-aware selector detection. includes vm integration tests with synthetic vyper bytecode and decompiler integration tests for both raw bytecode and rpc-based vyper contracts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| // look for a hex pattern in the string | ||
| for word in selector_str.split_whitespace() { | ||
| if word.starts_with("0x") { | ||
| let hex_part = &word[2..]; |
Contributor
There was a problem hiding this comment.
warning: stripping a prefix manually
--> crates/vm/src/ext/selectors.rs:305:28
|
305 | let hex_part = &word[2..];
| ^^^^^^^^^^
|
note: the prefix was tested here
--> crates/vm/src/ext/selectors.rs:304:9
|
304 | if word.starts_with("0x") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#manual_strip
= note: `#[warn(clippy::manual_strip)]` on by default
help: try using the `strip_prefix` method
|
304 ~ if let Some(hex_part) = word.strip_prefix("0x") {
305 ~ if hex_part.len() <= 8 && hex_part.chars().all(|c| c.is_ascii_hexdigit()) {
|
Contributor
❌ Eval Report for 23a87ac
|
Contributor
Benchmark for 23a87acClick to view benchmark
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed? Why?
added support for detecting function selectors in vyper-compiled contracts. vyper uses a different selector matching approach than solidity (compare-and-jump pattern with calldata at offset 0), which required implementing calldata flow tracing to identify selectors.
this allows the decompile command to work with any vyper contract, extracting function selectors properly.
Notes to reviewers
key files:
crates/vm/src/ext/selectors.rs- added calldata flow tracing logic for vyper selector detection (~520 lines)crates/vm/tests/test_vyper_selectors.rs- unit tests for vyper selector detectioncrates/core/tests/test_decompile.rs- integration tests with real vyper contractsHow has it been tested?