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

refactor EAM interface #1032

Merged
merged 21 commits into from
Jan 13, 2023
Merged

refactor EAM interface #1032

merged 21 commits into from
Jan 13, 2023

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Jan 12, 2023

See filecoin-project/ref-fvm#1434

These are the core code changes; once we are happy with them I'll have to fix the tests and replace all create invocations with create_external in lotus side.

@vyzo vyzo requested a review from Stebalien January 12, 2023 22:30
actors/eam/src/lib.rs Outdated Show resolved Hide resolved
actors/eam/src/lib.rs Outdated Show resolved Hide resolved
params: Create3Params,
) -> Result<Create3Return, ActorError> {
// we only allow accounts to call this
rt.validate_immediate_caller_type(&[Type::Account, Type::EthAccount])?;
Copy link
Member

Choose a reason for hiding this comment

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

Let's change this to "accept any" and leave a comment that we validate later.

Copy link
Member

Choose a reason for hiding this comment

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

(saves a redundant syscall)

actors/eam/src/lib.rs Show resolved Hide resolved
@Stebalien
Copy link
Member

@vyzo I've made my changes. This just needs some tests now.

@Stebalien
Copy link
Member

TODO:

  1. Update the FIP (FIP0055).
  2. Test creating from an eth account (not just a normal account) and make sure the addresses are derived correctly.

@Stebalien
Copy link
Member

@vyzo passing this back to you.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Approval from my end pending:

  1. An approval of my changes by @vyzo.
  2. The remaining tests.

@Stebalien Stebalien force-pushed the next-eam-refactor branch 3 times, most recently from 1af720b to 90febe0 Compare January 13, 2023 06:21
@@ -38,3 +38,7 @@ pub mod evm {

pub const RESURRECT_METHOD: u64 = 2;
}

pub mod account {
pub const PUBKEY_ADDRESS_METHOD: u64 = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Even if this is a built-in actor and this authorised to call a reserved method, why not call the FRC42 endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? This is internal code, why bother with the user space methods? We can use reserved methods just fine at this level.

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 a "trusted" call (we need the target to actually be an account) so I'd keep using the private one for now.

}
}

fn resolve_caller_external(rt: &mut impl Runtime) -> Result<(EthAddress, EthAddress), ActorError> {
Copy link
Member

Choose a reason for hiding this comment

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

We might have to deal with multisigs a here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't currently allow them, we expect EthAccount or Account; we'll have to be explicit about those.

But yes, we might want to allow multisig ownership of a newly created contract, but that's a can of worms we can open later.

Copy link
Member

Choose a reason for hiding this comment

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

CreateExternal needs to happen from an account. We could introduce an additional "create native" (or something like that), but, IMO, that's not critical right now.

We're also trying to encourage users to switch over to EVM multisigs.

let addr = resolve_eth_address(rt, caller_id)?;
Ok((addr, addr))
}
_ => Err(ActorError::forbidden(format!("disallowed caller code cid {}", caller_code_cid))),
Copy link
Member

Choose a reason for hiding this comment

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

Let's specify the caller type in the error message for better UX/DX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the cost of a syscall to get the type? I don't think that's the right thing to do, aiding debuggability and UX is fine, but this will cost gas.
The user can always lookup the code CID on his own to find the type.

Copy link
Member

Choose a reason for hiding this comment

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

@vyzo we already have the type.

Copy link
Member

Choose a reason for hiding this comment

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

ixed.

@vyzo vyzo force-pushed the next-eam-refactor branch from 08d7c72 to f5e417d Compare January 13, 2023 15:49
@vyzo
Copy link
Contributor Author

vyzo commented Jan 13, 2023

everything (cept the borked coverage job) green.

@Stebalien Stebalien enabled auto-merge (squash) January 13, 2023 17:21
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.

3 participants