-
Notifications
You must be signed in to change notification settings - Fork 130
fix(l2): fix block execution with SP1 #5542
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a gas mismatch error when executing blocks with SP1 by conditionally handling the type conversion in the bn254_g1_mul precompile. The issue was introduced by PR #5529, which unified the behavior across SP1 and ZisK but inadvertently changed SP1's multiplication semantics.
Key Changes:
- Modified the
bn254_g1_mulfunction to only convertAffineG1toG1when theziskfeature is enabled - For SP1, the point remains as
AffineG1during scalar multiplication to preserve correct gas calculation behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let g1 = AffineG1::new(g1_x, g1_y) | ||
| .map_err(|_| PrecompileError::InvalidPoint)?; | ||
|
|
||
| // Small difference between the patched versions of substrate-bn |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should explain WHY this conditional conversion is needed and what the actual difference is between the SP1 and ZisK substrate-bn patches. Consider expanding it to something like:
// SP1's substrate-bn patch implements multiplication for AffineG1 * Fr differently
// than ZisK's patch. For ZisK, we need to convert to G1 first, while SP1 requires
// AffineG1 to avoid gas mismatch issues (e.g., block 23919500 from Mainnet).This would help future maintainers understand the reasoning behind this platform-specific behavior.
| // Small difference between the patched versions of substrate-bn | |
| // SP1's substrate-bn patch implements multiplication for AffineG1 * Fr differently | |
| // than ZisK's patch. For ZisK, we need to convert to G1 first, while SP1 requires | |
| // AffineG1 to avoid gas mismatch issues (e.g., block 23919500 from Mainnet). |
Lines of code reportTotal lines added: Detailed view |
Benchmark Results ComparisonNo significant difference was registered for any benchmark run. Detailed ResultsBenchmark Results: BubbleSort
Benchmark Results: ERC20Approval
Benchmark Results: ERC20Mint
Benchmark Results: ERC20Transfer
Benchmark Results: Factorial
Benchmark Results: FactorialRecursive
Benchmark Results: Fibonacci
Benchmark Results: FibonacciRecursive
Benchmark Results: ManyHashes
Benchmark Results: MstoreBench
Benchmark Results: Push
Benchmark Results: SstoreBench_no_opt
|
Motivation
Execution with SP1 was failing after PR #5529 which changes a line of the
ecmulprecompile to make it compatible with an API difference between the substrate-bn patch of SP1 and ZisK.Apparently this also changes the behavior of the multiplication for the SP1 patch, and some blocks (like block 23919500 from Mainnet) were failing to execute due to a gas mismatch error.
Reverting the change for SP1 fixes the issue.