Skip to content

Commit e6d7085

Browse files
authored
fix(l2): revert substrate-bn patched ecadd precompile for SP1 (#5723)
**Motivation** #5535 introduced a version of ecadd that uses substrate-bn, because both ZisK and SP1 patch this crate to use zkVM accelerators for the operation. After merging, we found an Ethereum Mainnet block failing to execute with a gas mismatch error, which does not happen one commit before merging that PR. This PR reverts the usage of substrate-bn for SP1 only. **Description** <!-- A clear and concise general description of the changes this PR introduces --> <!-- Link to issues: Resolves #111, Resolves #222 --> **Checklist** - [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR includes breaking changes to the `Store` requiring a re-sync. Closes #issue_number
1 parent 1d0a872 commit e6d7085

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/vm/levm/src/precompiles.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ pub fn ecadd(calldata: &Bytes, gas_remaining: &mut u64, _fork: Fork) -> Result<B
743743
bn254_g1_add(first_point, second_point)
744744
}
745745

746-
#[cfg(not(any(feature = "sp1", feature = "zisk")))]
746+
#[cfg(not(feature = "zisk"))]
747747
#[inline]
748748
pub fn bn254_g1_add(first_point: G1, second_point: G1) -> Result<Bytes, VMError> {
749749
let first_point_x = ark_bn254::Fq::from_be_bytes_mod_order(&first_point.0.to_big_endian());
@@ -799,9 +799,11 @@ pub fn bn254_g1_add(first_point: G1, second_point: G1) -> Result<Bytes, VMError>
799799
Ok(Bytes::from(out))
800800
}
801801

802-
#[cfg(any(feature = "sp1", feature = "zisk"))]
802+
#[cfg(feature = "zisk")]
803803
#[inline]
804804
pub fn bn254_g1_add(first_point: G1, second_point: G1) -> Result<Bytes, VMError> {
805+
// SP1 patches the substrate-bn crate too, but some Ethereum Mainnet blocks fail to execute with it with a GasMismatch error
806+
// so for now we will only use it for ZisK.
805807
use substrate_bn::{AffineG1, Fq, G1 as SubstrateG1, Group};
806808

807809
if first_point.is_zero() && second_point.is_zero() {

0 commit comments

Comments
 (0)