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

Split Precompile Constants out of Individual Modules #2081

Open
refcell opened this issue Feb 13, 2025 · 3 comments
Open

Split Precompile Constants out of Individual Modules #2081

refcell opened this issue Feb 13, 2025 · 3 comments

Comments

@refcell
Copy link
Contributor

refcell commented Feb 13, 2025

Description

revm-precompile currently places BLS12-381 precompiles behind the blst feature flag. This restricts everything in the bls12_381 module to only std environments. This ticket is to hoist the constants (for example, bls12-381 g1 addition constants) into a module accessible from a no_std environment.

Constants Module Approach

One option to split these out is to move all the constants into a consts.rs module inside bls12_381 that is not behind the blst feature flag.
Then, remove the blst feature flag on the whole bls12_381 module and place it over only the precompiles within the bls12_381 module.

Effectively, from a no_std environment the api would look like:

revm_precompile
- pub mod bls12_381
  - pub mod consts

And from an std environment, the api would look like:

revm_precompile
- pub mod bls12_381
  - pub mod consts;
  - pub fn precompiles()
  - pub mod g1_add
  - pub mod g1_msm
  - pub mod g2_add
  - pub mod g2_msm
  - pub mod map_fp2_to_g2
  - pub mod map_fp_to_g1
  - pub mod msm
  - pub mod pairing

Motivation

Downstream consumers of revm use revm-precompile to accelerate various precompiles for fault proof programs. For example, in kona, the BLS12-381 precompiles are accelerated. Doing so, requires the use of constants like input length, base fees, and precompile addresses that are already defined in revm, but are inaccessible due to kona-client having a strict no_std requirement.

@rakita
Copy link
Member

rakita commented Feb 14, 2025

This makes sense

@Ayushdubey86
Copy link
Contributor

Ayushdubey86 commented Feb 14, 2025

Hello, linking this pr here, code is done, getting indentation problem, can someone check this out ! @refcell @rakita

@Ayushdubey86
Copy link
Contributor

whomsoever is free, can they check out this pr!

Ayushdubey86 added a commit to Ayushdubey86/revm that referenced this issue Feb 17, 2025
Ayushdubey86 added a commit to Ayushdubey86/revm that referenced this issue Feb 18, 2025
Ayushdubey86 added a commit to Ayushdubey86/revm that referenced this issue Feb 19, 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

No branches or pull requests

3 participants