Skip to content

Commit

Permalink
EVM: Move CALLACTOR into a precompile (#861)
Browse files Browse the repository at this point in the history
* wip callactor precompile (very broken)

* fill out logic a bit

* rustfmt

* pass in context through to precompiles

* exit with error on static call to callactor, array chunks abstraction

* forgot increment cursor...

* actually use gas from call, assert unused bits in randomness params are zeroed

* pass precompile context to all precompiles
add a chunked parameter reader

* improve parameter reader, check for readonly, new precompiles only read u32 for dynamicly sized bytes

* update sdk

* review changes, fix fn name in runtime

* nit: don't comment out code
  • Loading branch information
mriise authored Nov 22, 2022
1 parent 1b11df4 commit 31acd91
Show file tree
Hide file tree
Showing 3 changed files with 463 additions and 113 deletions.
14 changes: 11 additions & 3 deletions actors/evm/src/interpreter/instructions/call.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use fvm_ipld_encoding::{BytesDe, BytesSer};
use fvm_shared::{address::Address, METHOD_SEND};

use crate::interpreter::precompiles::PrecompileContext;

use {
super::memory::{copy_to_memory, get_memory_region},
crate::interpreter::address::EthAddress,
Expand Down Expand Up @@ -81,7 +83,7 @@ pub fn call<RT: Runtime>(

// NOTE gas is currently ignored as FVM's send doesn't allow the caller to specify a gas
// limit (external invocation gas limit applies). This may changed in the future.
let (_gas, dst, value, input_offset, input_size, output_offset, output_size) = match kind {
let (gas, dst, value, input_offset, input_size, output_offset, output_size) = match kind {
CallKind::Call | CallKind::CallCode => (
stack.pop(),
stack.pop(),
Expand Down Expand Up @@ -120,9 +122,15 @@ pub fn call<RT: Runtime>(
};

if precompiles::Precompiles::<RT>::is_precompile(&dst) {
let context = PrecompileContext {
is_static: matches!(kind, CallKind::StaticCall) || system.readonly,
gas,
value,
};

// TODO: DO NOT FAIL!!!
precompiles::Precompiles::call_precompile(system.rt, dst, input_data)
.map_err(|_| StatusCode::PrecompileFailure)?
precompiles::Precompiles::call_precompile(system.rt, dst, input_data, context)
.map_err(StatusCode::from)?
} else {
let call_result = match kind {
CallKind::Call | CallKind::StaticCall => {
Expand Down
Loading

0 comments on commit 31acd91

Please sign in to comment.