|
| 1 | +--- |
| 2 | +fip: <to be assigned> |
| 3 | +title: Ethereum Address Manager (EAM) and Ethereum Externally Owned Account (EEOA) |
| 4 | +author: Raúl Kripalani (@raulk), Steven Allen (@stebalien) |
| 5 | +discussions-to: <URL> |
| 6 | +status: Draft |
| 7 | +type: Technical Core |
| 8 | +category: Core |
| 9 | +created: 2022-12-02 |
| 10 | +spec-sections: |
| 11 | +requires: N/A |
| 12 | +replaces: N/A |
| 13 | +--- |
| 14 | + |
| 15 | +# Ethereum Address Manager (EAM) and Ethereum Externally Owned Account (EEOA) |
| 16 | + |
| 17 | +## Simple Summary |
| 18 | + |
| 19 | +TODO. |
| 20 | + |
| 21 | +## Abstract |
| 22 | + |
| 23 | +TODO. |
| 24 | + |
| 25 | +## Change Motivation |
| 26 | + |
| 27 | +TODO. |
| 28 | + |
| 29 | + |
| 30 | +## Specification: Ethereum Address Manager (EAM) |
| 31 | + |
| 32 | +We introduce the **Ethereum Address Manager (EAM) actor** as a singleton |
| 33 | +built-in actor sitting at ID address `10`. This actor fulfills two purposes: |
| 34 | + |
| 35 | +1. It manages the f4 address class namespace under its ID address (i.e. f410), |
| 36 | + assigning Ethereum-compatible addresses under it. |
| 37 | +2. It acts as the entrypoint for deployment of EVM smart contracts, respecting |
| 38 | + Ethereum rules and semantics. |
| 39 | + |
| 40 | +For the latter, this actor offers two Filecoin methods `Create` and `Create2`, |
| 41 | +equivalent to their Ethereum counterparts. In Ethereum, `CREATE` and `CREATE2` |
| 42 | +differ in their address generation rules: |
| 43 | + |
| 44 | +- `CREATE` uses the protocol-provided nonce to derive the contract's address, |
| 45 | + and is thus non-deterministic. |
| 46 | +- `CREATE2` takes an explicit user-provided salt to compute a deterministic |
| 47 | + address. It is suitable for counterfactual deployments. |
| 48 | + |
| 49 | +### Deployment |
| 50 | + |
| 51 | +The EAM is deployed as a singleton actor under ID address `10`. The deployment |
| 52 | +happens during the state migration where this FIP goes live. |
| 53 | + |
| 54 | +The EAM is allow-listed in the Init Actor as a caller of its `Exec4` method, |
| 55 | +specified in FIP-0048. |
| 56 | + |
| 57 | +### Procedure |
| 58 | + |
| 59 | +The procedure to deploy EVM smart contracts to the Filecoin chain is as follows: |
| 60 | + |
| 61 | +1. The contract deployment message enters the Ethereum Address Manager (EAM) |
| 62 | + through the `Create` or `Create2` method. |
| 63 | +2. The EAM computes an `f410` address according to the heuristics of the invoked |
| 64 | + method (see below). The resulting f410 address is semantically equivalent to |
| 65 | + the one Ethereum would've generated for the same inputs, thus retaining tool |
| 66 | + compatibility. |
| 67 | +2. The EAM invokes the Init actor's `Exec4` method (see [FIP-0048 (f4 Address |
| 68 | + Class)]), supplying the CodeCID of the EVM runtime actor, the constructor |
| 69 | + parameters (EVM init code and original creator address), and the assigned |
| 70 | + f410 address. |
| 71 | + |
| 72 | +### State |
| 73 | + |
| 74 | +None. |
| 75 | + |
| 76 | +### Actor interface (methods) |
| 77 | + |
| 78 | +#### Method number `1` (`Create`) |
| 79 | + |
| 80 | +Deploys a smart contract taking EVM init bytecode and accepting a nonce from the |
| 81 | +user. Refer to [Procedure](#procedure) for a description of the deployment |
| 82 | +procedure. |
| 83 | + |
| 84 | +The `create` method is used in two cases: |
| 85 | + |
| 86 | +1. When an EEOA actor deploys a smart contract by submitting a native Ethereum |
| 87 | + transaction containing initcode through the Ethereum JSON-RPC API endpoint. |
| 88 | + The endpoint detects the deployment operation, and translates the Ethereum |
| 89 | + transaction to an `EAM#Create` Filecoin message. |
| 90 | +2. When an EVM smart contract calls the `CREATE` opcode. |
| 91 | + |
| 92 | +Note that this differs from Ethereum in that we take a user-provided nonce as a |
| 93 | +parameter. This is necessary so that the EVM runtime actor can supply the |
| 94 | +contract's nonce when handling `CREATE` to the EAM. This is a mild departure |
| 95 | +from Ethereum's behavior as it allows an EEOA to deploy a contract with an |
| 96 | +arbitrary nonce. No safety violations are possible because the system guarantees |
| 97 | +that we don't deploy over an existing actor anyway (those constraints are |
| 98 | +enforced by the init actor and the FVM itself). |
| 99 | + |
| 100 | +_Input parameters_ |
| 101 | + |
| 102 | +```rust |
| 103 | +// DAG-CBOR tuple encoded. |
| 104 | +pub struct CreateParams { |
| 105 | + /// EVM init code. |
| 106 | + pub initcode: Vec<u8>, |
| 107 | + /// Nonce with which to create this smart contract. |
| 108 | + pub nonce: u64, |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +_Return value_ |
| 113 | + |
| 114 | +```rust |
| 115 | +// DAG-CBOR tuple encoded. |
| 116 | +pub struct Return { |
| 117 | + /// The ID of the EVM runtime actor that was constructed. |
| 118 | + pub actor_id: ActorID, |
| 119 | + /// Its f2 address. |
| 120 | + pub robust_address: Address, |
| 121 | + /// Its Ethereum address, translatable to an f410 address. |
| 122 | + pub eth_address: [u8; 20], |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +_Errors_ |
| 127 | + |
| 128 | +TODO. |
| 129 | + |
| 130 | +#### Method number `2` (`Create2`) |
| 131 | + |
| 132 | +Deploys a smart contract taking EVM init bytecode and accepting a user-provided |
| 133 | +salt to generate a deterministic Ethereum address (translatable to an f410 |
| 134 | +address). Refer to [Procedure](#procedure) for a description of the deployment |
| 135 | +procedure. |
| 136 | + |
| 137 | +`Create2` is used in a single case: to handle the `CREATE2` opcode while |
| 138 | +executing EVM bytecode within the EVM runtime actor. |
| 139 | + |
| 140 | +_Input parameters_ |
| 141 | + |
| 142 | +```rust |
| 143 | +pub struct Create2Params { |
| 144 | + /// EVM init code. |
| 145 | + pub initcode: Vec<u8>, |
| 146 | + /// User provided salt. |
| 147 | + pub salt: [u8; 32], |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +_Return value_ |
| 152 | + |
| 153 | +Same as [`Create`](#method-number-1-create). |
| 154 | + |
| 155 | +## Specification: Ethereum Externally Owned Account (EEOA) |
| 156 | + |
| 157 | +TODO (@aayush). |
| 158 | + |
| 159 | +## Design Rationale |
| 160 | + |
| 161 | +> TODO: |
| 162 | +> - Flat vs nested contract deployment model. |
| 163 | +> - ... |
| 164 | +
|
| 165 | +## Backwards Compatibility |
| 166 | + |
| 167 | +TODO. |
| 168 | + |
| 169 | +## Test Cases |
| 170 | + |
| 171 | +## Security Considerations |
| 172 | + |
| 173 | +TODO. |
| 174 | + |
| 175 | +## Incentive Considerations |
| 176 | + |
| 177 | +TODO. |
| 178 | + |
| 179 | +## Product Considerations |
| 180 | + |
| 181 | +TODO. |
| 182 | + |
| 183 | +## Implementation |
| 184 | + |
| 185 | +TODO. |
| 186 | + |
| 187 | +## Appendix A: Notable differences between FEVM and EVM for smart contract developers |
| 188 | + |
| 189 | +TODO. |
| 190 | + |
| 191 | +## Appendix B: Upgrades |
| 192 | + |
| 193 | +TODO. |
| 194 | + |
| 195 | +## Copyright |
| 196 | + |
| 197 | +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
| 198 | + |
| 199 | + |
| 200 | +[`filecoin-project/builtin-actors`]: https://github.com/filecoin-project/builtin-actors |
| 201 | +[FRC42 calling convention]: https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0042.md |
| 202 | +[FIP-0048 (f4 Address Class)]: https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0048.md |
| 203 | +[Contract ABI spec]: https://docs.soliditylang.org/en/v0.5.3/abi-spec.html |
| 204 | +[Ethereum Paris hard fork]: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md |
| 205 | +[FIP-0049 (Actor events)]: https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0049.md |
0 commit comments