Skip to content

Commit

Permalink
Merge branch 'master' into aa-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
drortirosh authored Dec 2, 2023
2 parents af239f6 + 4f6d6ad commit 651990f
Show file tree
Hide file tree
Showing 21 changed files with 2,925 additions and 78 deletions.
32 changes: 18 additions & 14 deletions ERCS/erc-6860.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
eip: 6860
title: Web3 URL to EVM Call Message Translation
description: A translation of an HTTP-style Web3 URL to an EVM call message
author: Qi Zhou (@qizhou), Chao Pi (@pichaoqkc), Sam Wilson (@SamWilsn)
author: Qi Zhou (@qizhou), Chao Pi (@pichaoqkc), Sam Wilson (@SamWilsn), Nicolas Deschildre (@nand2)
discussions-to: https://ethereum-magicians.org/t/eip-4804-web3-url-to-evm-call-message-translation/8300
status: Draft
type: Standards Track
Expand Down Expand Up @@ -57,7 +57,7 @@ domainName = *( unreserved / pct-encoded / sub-delims ) ; As in RFC 3986
The way to resolve the domain name from a domain name service to an address is specified in [ERC-6821](./eip-6821.md) for the Ethereum Name service, and will be discussed in later ERCs for other name services.

```
chainid = 1*DIGIT
chainid = %x31-39 *DIGIT
```

**chainid** indicates which chain to resolve **contractName** and call the message. If not specified, the protocol will use the primary chain of the name service provider used, e.g., 1 for eth. If no name service provider was used, the default chainid is 1.
Expand Down Expand Up @@ -184,14 +184,16 @@ attrName = "returns"
/ "returnTypes"
attrValue = [ "(" [ retTypes ] ")" ]
retTypes = retType *( "," retType )
retType = *( "[]" ) retRawType
retRawType = "bool" / "uint" [ intSizes ] / "int" [ intSize ] / "address" / "bytes" [ bytesSizes ] / "string"
bytesSizes = DIGIT
/ ( "1" / "2" ) DIGIT
/ "31" / "32"
retType = retRawType *( "[" [ %x31-39 *DIGIT ] "]" )
retRawType = "(" retTypes ")"
/ retBaseType
retBaseType = "bool" / "uint" [ intSizes ] / "int" [ intSize ] / "address" / "bytes" [ bytesSizes ] / "string"
bytesSizes = %x31-39 ; 1-9
/ ( "1" / "2" ) DIGIT ; 10-29
/ "31" / "32" ; 31-32
```

The "returns" attribute in **aQuery** tells the format of the returned data.
The "returns" attribute in **aQuery** tells the format of the returned data. It follows the syntax of the arguments part of the ethereum ABI function signature (``uint`` and ``int`` aliases are authorized).

- If the "returns" attribute value is undefined or empty, the returned message data will be treated as ABI-encoded bytes and the decoded bytes will be returned to the frontend. The MIME type returned to the frontend will be undefined by default, but will be overriden if the last argument is of string type and has a **fileExtension**, in which case the MIME type will be deduced from the filename extension. (Note that **fileExtension** is not excluded from the string argument given to the smartcontract)
- If the "returns" attribute value is equal to "()", the raw bytes of the returned message data will be returned, encoded as a "0x"-prefixed hex string in an array in JSON format: ``["0xXXXXX"]``
Expand Down Expand Up @@ -288,7 +290,7 @@ schema = "w3" / "web3"
userinfo = address
contractName = address
/ domainName
chainid = 1*DIGIT
chainid = %x31-39 *DIGIT
pathQuery = mPathQuery ; path+query for manual mode
/ aPathQuery ; path+query for auto mode
Expand Down Expand Up @@ -375,11 +377,13 @@ attrName = "returns"
/ "returnTypes"
attrValue = [ "(" [ retTypes ] ")" ]
retTypes = retType *( "," retType )
retType = retRawType *( "[]" )
retRawType = "bool" / "uint" [ intSizes ] / "int" [ intSize ] / "address" / "bytes" [ bytesSizes ] / "string"
bytesSizes = DIGIT
/ ( "1" / "2" ) DIGIT
/ "31" / "32"
retType = retRawType *( "[" [ %x31-39 *DIGIT ] "]" )
retRawType = "(" retTypes ")"
/ retBaseType
retBaseType = "bool" / "uint" [ intSizes ] / "int" [ intSize ] / "address" / "bytes" [ bytesSizes ] / "string"
bytesSizes = %x31-39 ; 1-9
/ ( "1" / "2" ) DIGIT ; 10-29
/ "31" / "32" ; 31-32
domainName = *( unreserved / pct-encoded / sub-delims ) ; As in RFC 3986
Expand Down
113 changes: 76 additions & 37 deletions ERCS/erc-6900.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Each step is modular, supporting different implementations for each execution fu

**Modular Smart Contract Accounts** **MAY** implement

- `IPluginLoupe.sol` to support visibility in plugin configuration on-chain.
- `IAccountLoupe.sol` to support visibility in plugin configuration on-chain.

**Plugins** **MUST** implement

Expand Down Expand Up @@ -123,8 +123,14 @@ interface IPluginManager {
uint8 postExecHookFunctionId;
}
event PluginInstalled(address indexed plugin, bytes32 manifestHash);
event PluginUninstalled(address indexed plugin, bytes32 manifestHash, bool onUninstallSucceeded);
event PluginInstalled(
address indexed plugin,
bytes32 manifestHash,
FunctionReference[] dependencies,
InjectedHook[] injectedHooks
);
event PluginUninstalled(address indexed plugin, bool indexed callbacksSucceeded);
/// @notice Install a plugin to the modular account.
/// @param plugin The plugin to install.
Expand Down Expand Up @@ -168,29 +174,29 @@ Standard execute functions SHOULD check whether the call's target implements the
**If the target is a plugin, the call SHOULD revert.** This prevents accidental misconfiguration or misuse of plugins (both installed and uninstalled).

```solidity
struct Execution {
struct Call {
// The target contract for account to execute.
address target;
// The value for the execution.
// The value for the call.
uint256 value;
// The call data for the execution.
// The call data for the call.
bytes data;
}
interface IStandardExecutor {
/// @notice Standard execute method.
/// @dev If the target is a plugin, the call SHOULD revert.
/// @param target The target contract for account to execute.
/// @param value The value for the execution.
/// @param data The call data for the execution.
/// @param value The value for the call.
/// @param data The call data for the call.
/// @return The return data from the call.
function execute(address target, uint256 value, bytes calldata data) external payable returns (bytes memory);
/// @notice Standard executeBatch method.
/// @dev If the target is a plugin, the call SHOULD revert.
/// @param executions The array of executions.
/// @param calls The array of calls.
/// @return An array containing the return data from the calls.
function executeBatch(Execution[] calldata executions) external payable returns (bytes[] memory);
function executeBatch(Call[] calldata calls) external payable returns (bytes[] memory);
}
```

Expand Down Expand Up @@ -220,40 +226,63 @@ interface IPluginExecutor {
}
```

#### `IPluginLoupe.sol`
#### `IAccountLoupe.sol`

Plugin inspection interface. Modular Smart Contract Accounts **MAY** implement this interface to support visibility in plugin configuration on-chain.

```solidity
// Treats the first 20 bytes as an address, and the last byte as a function identifier.
type FunctionReference is bytes21;
interface IPluginLoupe {
// Config for a Plugin Execution function
interface IAccountLoupe {
/// @notice Config for an execution function, given a selector
struct ExecutionFunctionConfig {
address plugin;
FunctionReference userOpValidationFunction;
FunctionReference runtimeValidationFunction;
}
/// @notice Pre and post hooks for a given selector
/// @dev It's possible for one of either `preExecHook` or `postExecHook` to be empty
struct ExecutionHooks {
FunctionReference preExecHook;
FunctionReference postExecHook;
}
/// @notice Gets the validation functions and plugin address for a selector
/// @dev If the selector is a native function, the plugin address will be the address of the account
/// @param selector The selector to get the configuration for
/// @return The configuration for this selector
function getExecutionFunctionConfig(bytes4 selector) external view returns (ExecutionFunctionConfig memory);
/// @notice Gets the pre and post execution hooks for a selector
/// @param selector The selector to get the hooks for
/// @return The pre and post execution hooks for this selector
function getExecutionHooks(bytes4 selector) external view returns (ExecutionHooks[] memory);
/// @notice Gets the pre and post permitted call hooks applied for a plugin calling this selector
/// @param callingPlugin The plugin that is calling the selector
/// @param selector The selector the plugin is calling
/// @return The pre and post permitted call hooks for this selector
function getPermittedCallHooks(address callingPlugin, bytes4 selector)
external
view
returns (ExecutionHooks[] memory);
function getPreUserOpValidationHooks(bytes4 selector) external view returns (FunctionReference[] memory);
function getPreRuntimeValidationHooks(bytes4 selector) external view returns (FunctionReference[] memory);
/// @notice Gets the pre user op and runtime validation hooks associated with a selector
/// @param selector The selector to get the hooks for
/// @return preUserOpValidationHooks The pre user op validation hooks for this selector
/// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector
function getPreValidationHooks(bytes4 selector)
external
view
returns (
FunctionReference[] memory preUserOpValidationHooks,
FunctionReference[] memory preRuntimeValidationHooks
);
/// @notice Gets an array of all installed plugins
/// @return The addresses of all installed plugins
function getInstalledPlugins() external view returns (address[] memory);
}
```
Expand Down Expand Up @@ -379,11 +408,6 @@ enum ManifestAssociatedFunctionType {
PRE_HOOK_ALWAYS_DENY
}
struct ManifestExecutionFunction {
bytes4 selector;
string[] permissions;
}
// For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address
// of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`.
struct ManifestFunction {
Expand All @@ -403,41 +427,56 @@ struct ManifestExecutionHook {
ManifestFunction postExecHook;
}
struct PluginManifest {
struct ManifestExternalCallPermission {
address externalAddress;
bool permitAnySelector;
bytes4[] selectors;
}
struct SelectorPermission {
bytes4 functionSelector;
string permissionDescription;
}
/// @dev A struct holding fields to describe the plugin in a purely view context. Intended for front end clients.
struct PluginMetadata {
// A human-readable name of the plugin.
string name;
// The version of the plugin, following the semantic versioning scheme.
string version;
// The author field SHOULD be a username representing the identity of the user or organization
// that created this plugin.
string author;
// String desciptions of the relative sensitivity of specific functions. The selectors MUST be selectors for
// functions implemented by this plugin.
SelectorPermission[] permissionDescriptors;
}
/// @dev A struct describing how the plugin should be installed on a modular account.
struct PluginManifest {
// List of ERC-165 interfaceIds to add to account to support introspection checks.
bytes4[] interfaceIds;
// If this plugin depends on other plugins' validation functions and/or hooks, the interface IDs of
// those plugins MUST be provided here, with its position in the array matching the `dependencyIndex`
// members of `ManifestFunction` structs used in the manifest.
bytes4[] dependencyInterfaceIds;
// Execution functions defined in this plugin to be installed on the MSCA.
ManifestExecutionFunction[] executionFunctions;
// Native functions or execution functions already installed on the MSCA that this plugin will be
// able to call.
bytes4[] executionFunctions;
// Plugin execution functions already installed on the MSCA that this plugin will be able to call.
bytes4[] permittedExecutionSelectors;
// External contract calls that this plugin will be able to make.
bool permitAnyExternalContract;
// Boolean to indicate whether the plugin can call any external contract addresses.
bool permitAnyExternalAddress;
// Boolean to indicate whether the plugin needs access to spend native tokens of the account.
bool canSpendNativeToken;
ManifestExternalCallPermission[] permittedExternalCalls;
ManifestAssociatedFunction[] userOpValidationFunctions;
ManifestAssociatedFunction[] runtimeValidationFunctions;
ManifestAssociatedFunction[] preUserOpValidationHooks;
ManifestAssociatedFunction[] preRuntimeValidationHooks;
ManifestExecutionHook[] executionHooks;
ManifestExecutionHook[] permittedCallHooks;
}
```

### Expected behavior
Expand Down Expand Up @@ -474,7 +513,7 @@ The function MUST store the plugin's permitted function selectors and external c
The function MUST parse through the execution functions, validation functions, and hooks in the manifest and add them to the modular account after resolving each `ManifestFunction` type.

- Each function selector MUST be added as a valid execution function on the modular account. If the function selector has already been added or matches the selector of a native function, the function SHOULD revert.
- If an associated function that is to be added already exists, the function SHOULD revert.
- If a validation function is to be added to a selector that already has that type of validation function, the function SHOULD revert.

Next, the function MUST call the plugin's `onInstall` callback with the data provided in the `installData` parameter. This serves to initialize the plugin state for the modular account. If `onInstall` reverts, the `installPlugin` function MUST revert.

Expand All @@ -493,11 +532,11 @@ The function MUST revert if the plugin is not installed on the modular account.
The function SHOULD perform the following checks:

- Revert if the hash of the manifest used at install time does not match the computed Keccak-256 hash of the plugin's current manifest. This prevents unclean removal of plugins that attempt to force a removal of a different plugin configuration than the one that was originally approved by the client for installation. To allow for removal of such plugins, the modular account MAY implement the capability for the manifest to be encoded in the config field as a parameter.
- Revert if there is at least 1 other installed plugin that depends on execution functions, validation functions, or hooks added by this plugin. Plugins used as dependencies must not be uninstalled while dependent plugins exist.
- Revert if there is at least 1 other installed plugin that depends on validation functions or hooks added by this plugin. Plugins used as dependencies must not be uninstalled while dependent plugins exist.

The function SHOULD update account storage to reflect the uninstall via inspection functions, such as those defined by `IPluginLoupe`. Each dependency's record SHOULD also be updated to reflect that it has no longer has this plugin as a dependent.
The function SHOULD update account storage to reflect the uninstall via inspection functions, such as those defined by `IAccountLoupe`. Each dependency's record SHOULD also be updated to reflect that it has no longer has this plugin as a dependent.

The function MUST remove records for the plugin's dependencies, injected permitted call hooks, permitted function selectors, and external contract calls. The hooks to remove MUST be exactly the same as what was provided during installation. It is up to the implementing modular account to decide how to keep this invariant. The config parameter field MAY be used.
The function MUST remove records for the plugin's dependencies, injected permitted call hooks, permitted function selectors, and permitted external calls. The hooks to remove MUST be exactly the same as what was provided during installation. It is up to the implementing modular account to decide how to keep this invariant. The config parameter field MAY be used.

The function MUST parse through the execution functions, validation functions, and hooks in the manifest and remove them from the modular account after resolving each `ManifestFunction` type.

Expand Down Expand Up @@ -550,7 +589,7 @@ No backward compatibility issues found.

## Reference Implementation

See `https://github.com/alchemyplatform/ERC-6900-Ref-Implementation`
See `https://github.com/erc6900/reference-implementation`

## Security Considerations

Expand Down
Loading

0 comments on commit 651990f

Please sign in to comment.