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

EVM Precompiles #564

Merged
merged 33 commits into from
Sep 2, 2022
Merged

EVM Precompiles #564

merged 33 commits into from
Sep 2, 2022

Conversation

mriise
Copy link
Contributor

@mriise mriise commented Aug 19, 2022

previous PRs: #553, #563

tracking issue: filecoin-project/ref-fvm#695

doesnt have the glue yet for redirecting a normal call

actors/evm/src/interpreter/instructions/call.rs Outdated Show resolved Hide resolved
actors/evm/src/interpreter/instructions/call.rs Outdated Show resolved Hide resolved
actors/evm/src/interpreter/instructions/call.rs Outdated Show resolved Hide resolved
actors/evm/src/interpreter/instructions/call.rs Outdated Show resolved Hide resolved
@vyzo
Copy link
Contributor

vyzo commented Aug 24, 2022

This will need a rebase once #575 merges, there are quite a few changes in the interpreter.

@mriise mriise changed the title EVM Precompiles [partial] EVM Precompiles Aug 26, 2022
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine to me, only nit is that I don't think we need the mask and we should just flat out compare the whole address to the precompile addresses.

@maciejwitowski maciejwitowski added this to the M2.1 Selenium (r2) milestone Aug 30, 2022
actors/evm/src/interpreter/precompiles.rs Show resolved Hide resolved
PRECOMPILES[precompile_addr.0[0] as usize - 1](input)
pub struct Precompiles<BS, RT>(PhantomData<BS>, PhantomData<RT>);

impl<BS: Blockstore, RT: Runtime<BS>> Precompiles<BS, RT> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really neat.

actors/evm/src/interpreter/precompiles.rs Outdated Show resolved Hide resolved
fn fixed_hasher(offset: ChainEpoch) -> Box<dyn Fn(&[u8]) -> [u8; 32]> {
let hash = move |_: &[u8]| -> [u8; 32] {
let mut result = [0u8; 32];
fn fixed_hasher(offset: ChainEpoch) -> Box<dyn Fn(SupportedHashes, &[u8]) -> ([u8; 64], usize)> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. What's the max digest length in the EVM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32 bytes, but our hash function can do up to 64 bytes

Co-authored-by: Steven Allen <steven@stebalien.com>
@mriise mriise merged commit 6310cdd into filecoin-project:next Sep 2, 2022
shamb0 pushed a commit to shamb0/builtin-actors that referenced this pull request Oct 3, 2022
* add precompiles from old branc evm-precompiles

* move precompiles file, add blake2 dep with blake2f

* wip call fn, use precompile error type

* use u256 instead of raw bytes (cleans up code)

* remove Message struct as is no longer needed

* attempt getting input & output memory regions

* dont use custom error type, pass in just memory instead of full execution state for memory functions

* write output back into smart contract remove old TODOs

* add blake2f precompile

* edit TODOs

* rustfmt

* add modxp precompile & remove gas limit/accouting for precompiles

* add expairing, use custom error type, remove gas accounting, replace unsafe code

* cleanup unused things and rename precompile error variant

* use fork for blakef2, organize precompiles in file

* move static call type to enum

* add warnings and use different slicing method

* rustfmt

* fix errors from merge

* use InvalidMemAccess again instead of OutOfGas

* lock ref-fvm to specific hash to avoid Token struct changes

* go back to normal EVM precompile addresssing, unlock ref-fvm version hash

* add blake2 and ec ops precompile tests

* fix precompile test errors issues

* Update precompiles
- use methods on runtime for syscalls instead of importing SDK
- fix broken tests
- fix some EC methods that would expect empty bytes instead of error

* implement hash and recover pubkey in tests

* import sepc consts

* rustfmt & clippy

* Update actors/evm/src/interpreter/precompiles.rs

Co-authored-by: Steven Allen <steven@stebalien.com>

Co-authored-by: Steven Allen <steven@stebalien.com>
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

Successfully merging this pull request may close these issues.

5 participants