-
Notifications
You must be signed in to change notification settings - Fork 79
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
EVM Precompiles #564
Conversation
…tion state for memory functions
This will need a rebase once #575 merges, there are quite a few changes in the interpreter. |
There was a problem hiding this 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.
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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really neat.
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)> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
* 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>
previous PRs: #553, #563
tracking issue: filecoin-project/ref-fvm#695
doesnt have the glue yet for redirecting a normal call