Uh oh!
There was an error while loading. Please reload this page.
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 into
Conversation
drewstone
commented
Sep 3, 2020
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.
bkchr
commented
Sep 8, 2020
@drewstone any updates? |
Uh oh!
There was an error while loading. Please reload this page.
drewstone
commented
Sep 9, 2020
Welp, now I'm getting |
763e066 to
2a5cc4fComparedrewstone
commented
Sep 9, 2020
Alright all updated without changing |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
drewstone
commented
Sep 22, 2020
Just updated again, thanks @NikVolf for the suggestion! |
As this touches evm, @sorpaas should sign off at least. |
sorpaas
commented
Oct 1, 2020
Still hoping @drewstone can add the feature gates as requested in the last review! It's otherwise LGTM. |
drewstone
commented
Oct 10, 2020
Will get to this this week! Sorry for the delay @sorpaas |
0f302f2 to
98fd776Compare@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.
Uh oh!
There was an error while loading. Please reload this page.
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.
bkchr
commented
Nov 24, 2020
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.