-
Notifications
You must be signed in to change notification settings - Fork 81
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
basic EVM smart contract actor #517
Conversation
Our EVM implementation is a fork of https://github.com/vorot93/evmodin with several changes, amongst which are:
|
I would recommend using the “toronto-demo” branch. It has more progress than master |
this requried quite a bit of surgery...
Unfortunately this makes us depend on a branch of the bundler tool, but it's acceptable for now.
These mappings will not be managed by the EVM actor, but rather by the environment through address classes.
// create an instance of the platform abstraction layer -- note: do we even need this? | ||
let system = System::new(rt, init_contract_state_cid).map_err(|e| { | ||
ActorError::unspecified(format!("failed to create execution abstraction layer: {e:?}")) | ||
})?; |
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.
We will need to reintroduce a trait here (like evmodin had Host) to make this abstraction layer useful for testing.
|
||
let state = State::new( | ||
rt.store(), | ||
RawBytes::new(contract_bytecode.to_vec()), |
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.
nit: This is a mouthful to read as a parameter, would probably extract it to a local var and name it for what it is (evm_bytecode_bytes, or something).
// TODO this is fine in a transaction for now, as we don't have yet cross-contact calls | ||
// some refactoring will be needed when we start making cross contract calls. | ||
rt.transaction(|state: &mut State, 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.
Yes, all of this will evolve as we implement https://github.com/filecoin-project/fvm-specs/issues/107.
{ | ||
rt.validate_immediate_caller_accept_any()?; | ||
|
||
if params.bytecode.len() > MAX_CODE_SIZE { |
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.
I'd actually call this field init_code
because that's what the Ethereum protocol calls it (it's the constructor code).
#[inline] | ||
pub fn sload<'r, BS: Blockstore, RT: Runtime<BS>>( | ||
state: &mut ExecutionState, | ||
platform: &'r System<'r, 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.
There's some naming incongruence left over from past refactors. Platform/System/Host... Need to fix this eventually.
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.
There are obviously many TODOs, many bugs lurking, and many things that will get rewritten, but it serves as a reasonable starting point. I'm happy to merge this into next
and continue iterating there.
Ah, I also moved my notes on evmodin divergence to a README.md file under the interpreter module: https://github.com/filecoin-project/builtin-actors/pull/517/files#diff-4ff2e70b4b59321d541e648b02188a6139aefb30079fea0c467e3b6c23415009R1 |
Co-authored-by: Raúl Kripalani <raul@protocol.ai>
Closes filecoin-project/ref-fvm#693.
This contains the implementation of a basic EVM smart contract actor, based on what currently lives https://github.com/filecoin-project/fvm-evm/, but simplified to account for new designs around account abstraction and extensible addressing at the protocol level.
Supported features
Not supported yet
The memory management needs to be reviewed entirely.
In other words, there is still a ton of work to do, but this introduces an initial landmark to set as a departure point for all upcoming work.
The EVM actor has been included in the bundle produced by this repo.
Once this PR is merged, the https://github.com/filecoin-project/fvm-evm/ repo can be archived.