Skip to content

Commit

Permalink
EVM: use FRC-0042 for invoke (#1021)
Browse files Browse the repository at this point in the history
This also re-numbers all the other method numbers, because we're
removing method 2. This is going to be annoying... but it's better to do
this now than to have a dead method.

fixes filecoin-project/ref-fvm#1256
  • Loading branch information
Stebalien authored Jan 12, 2023
1 parent 9191eb3 commit 610f399
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion actors/eam/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ pub mod evm {
pub input_data: RawBytes,
}

pub const RESURRECT_METHOD: u64 = 7;
pub const RESURRECT_METHOD: u64 = 2;
}
1 change: 1 addition & 0 deletions actors/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ substrate-bn = { version = "0.6.0", default-features = false }
near-blake2 = { version = "0.9.1", git = "https://github.com/filecoin-project/near-blake2.git" }
lazy_static = "1.4.0"
once_cell = { version = "1.16.0", default-features = false}
frc42_dispatch = "3.0.0"

[dev-dependencies]
fil_actors_runtime = { path = "../../runtime", features = ["test_utils", "sector-default"] }
Expand Down
37 changes: 18 additions & 19 deletions actors/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ fn test_method_selector() {
#[repr(u64)]
pub enum Method {
Constructor = METHOD_CONSTRUCTOR,
// TODO: Do we want to use ExportedNums for all of these, per FRC-42?
InvokeContract = 2,
Resurrect = 2,
GetBytecode = 3,
GetStorageAt = 4,
InvokeContractDelegate = 5,
GetBytecodeHash = 6,
Resurrect = 7,
GetBytecodeHash = 4,
GetStorageAt = 5,
InvokeContractDelegate = 6,
InvokeContract = frc42_dispatch::method_hash!("InvokeEVM"),
}

pub struct EvmContractActor;
Expand Down Expand Up @@ -297,19 +296,6 @@ impl ActorCode for EvmContractActor {
RT: Runtime,
RT::Blockstore: Clone,
{
// We reserve all methods below EVM_MAX_RESERVED (<= 1023) method. This is a _subset_ of
// those reserved by FRC0042.
if method > EVM_MAX_RESERVED_METHOD {
return Self::handle_filecoin_method(rt, method, args).map(|d| {
if d.is_empty() {
None
} else {
// TODO: Pass the codec through to here? https://github.com/filecoin-project/ref-fvm/issues/1422
Some(IpldBlock { codec: DAG_CBOR, data: d })
}
});
}

match FromPrimitive::from_u64(method) {
Some(Method::Constructor) => {
Self::constructor(
Expand Down Expand Up @@ -374,6 +360,19 @@ impl ActorCode for EvmContractActor {
)?;
Ok(None)
}
None if method > EVM_MAX_RESERVED_METHOD => {
// We reserve all methods below EVM_MAX_RESERVED (<= 1023) method. This is a
// _subset_ of those reserved by FRC0042.
Self::handle_filecoin_method(rt, method, args).map(|d| {
if d.is_empty() {
None
} else {
// TODO: Pass the codec through to here?
// https://github.com/filecoin-project/ref-fvm/issues/1422
Some(IpldBlock { codec: DAG_CBOR, data: d })
}
})
}
None => Err(actor_error!(unhandled_message; "Invalid method")),
}
}
Expand Down

0 comments on commit 610f399

Please sign in to comment.