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

Add essential EIP-7756 tracing fields #2023

Merged
merged 4 commits into from
Jan 27, 2025
Merged

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Jan 25, 2025

Add (for eof) section and funcion depth fields, and make pc container relative instead of code section relative.

Add (for eof) section and funcion depth fields, and make pc container
relative instead of code section relative.
@@ -153,6 +153,7 @@ where

// ExtDelegateCall is not allowed to call non-EOF contracts.
if is_ext_delegate_call && !bytecode.bytes_slice().starts_with(&EOF_MAGIC_BYTES) {
context.journal().checkpoint_revert(checkpoint);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing the depth field to read incorrectly when this case triggered. Not sure if here was any way to leverage it. Also, EOF only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find! Yeah it is good fix and it is EOF only

Copy link

codspeed-hq bot commented Jan 25, 2025

CodSpeed Performance Report

Merging #2023 will improve performances by 4.6%

Comparing shemnon:eof/tracing (21de630) with main (a8f9824)

Summary

⚡ 1 improvements
✅ 7 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
precompile bench | ecrecover precompile 201.8 µs 192.9 µs +4.6%

// SAFETY: `instruction_pointer` should be at an offset from the start of the bytecode.
// In practice this is always true unless a caller modifies the `instruction_pointer` field manually.
self.instruction_pointer
.offset_from(self.base.eof().unwrap().raw.as_ptr()) as usize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already made a change so current pc is doing the same thing as trace_pc

fn pc(&self) -> usize {
// SAFETY: `instruction_pointer` should be at an offset from the start of the bytecode.
// In practice this is always true unless a caller modifies the `instruction_pointer` field manually.
unsafe {
self.instruction_pointer
.offset_from(self.base.bytecode().as_ptr()) as usize
}
}
}

and bytecode() gives self.base.eof().raw here:

pub fn bytecode(&self) -> &Bytes {
match self {
Self::LegacyAnalyzed(analyzed) => analyzed.bytecode(),
Self::Eof(eof) => &eof.body.code,
Self::Eip7702(code) => code.raw(),
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay my mistake, will see to change the fn pc to become trace_pc it is not used in any other place for EOF.

@rakita rakita merged commit 773b909 into bluealloy:main Jan 27, 2025
27 checks passed
This was referenced Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants