Add precompiles for pallet_evm operators: blake2f, modexp, bn128, ed25519verify#7016
Add precompiles for pallet_evm operators: blake2f, modexp, bn128, ed25519verify#7016drewstone wants to merge 5 commits intoparitytech:masterfrom
Conversation
|
Currently BLS precompile cannot be added until I find a no_std compatible repo for doing elilptic curve operations on the BLS381 curve. The repo here mentions adding this functionality but has not indicated it is completed: https://github.com/matter-labs/eip1962 |
sorpaas
left a comment
There was a problem hiding this comment.
Mostly LGTM. The testing error seems to be something unrelated (but we still need to figure out and fix it).
Only grumble is if we can add feature gates for the additional dependencies. Then we enable those feature gates by default for ease of testing.
|
@drewstone any updates? |
|
Welp, now I'm getting |
763e066 to
2a5cc4f
Compare
|
Alright all updated without changing |
|
Just updated again, thanks @NikVolf for the suggestion! |
|
As this touches evm, @sorpaas should sign off at least. |
|
Still hoping @drewstone can add the feature gates as requested in the last review! It's otherwise LGTM. |
|
Will get to this this week! Sorry for the delay @sorpaas |
0f302f2 to
98fd776
Compare
|
@sorpaas I added the feature flags. Lmk what you think! |
sorpaas
left a comment
There was a problem hiding this comment.
Mostly looks good to me, but needs to:
- Check in the updated lock file.
- Fix line width CI.
- Fix the styling nits.
Co-authored-by: Wei Tang <accounts@that.world>
| impl Precompile for Blake2F { | ||
| fn execute( | ||
| input: &[u8], | ||
| target_gas: Option<usize>, | ||
| ) -> core::result::Result<(ExitSucceed, Vec<u8>, usize), ExitError> { | ||
| let cost = ensure_linear_cost(target_gas, input.len(), 15, 3)?; | ||
| let mut state = Blake2b::new(64); | ||
| state.update(&input); | ||
| let ret = state.finalize().as_bytes().to_vec(); | ||
| Ok((ExitSucceed::Returned, ret, cost)) | ||
| } | ||
| } |
There was a problem hiding this comment.
This doesn't seem to be the EIP-152 precompile, but rather the full Blake2 hash function.
|
Pallet EVM was removed, so this pr is not required in Substrate anymore. |
Adds some precompiles to the repo for functionality that may or may not exist on other blockchains but are useful nonetheless. These are not tested as I'm unsure how to test them yet but most of it has been migrated from openethereum and existing EIPs.
The modexp one in particular is unsure to be correct as IO between the rust openethereum client and the substrate implementation are a bit different. I'm unsure how to replicate certain IO operations so I opted to manually implement the input parsing.