-
Notifications
You must be signed in to change notification settings - Fork 470
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
Add ERC: Nitro Protocol for State Channels with Account Abstraction #728
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,160 @@ | ||||||
--- | ||||||
eip: 7250 | ||||||
title: Nitro Protocol for State Channels with Account Abstraction | ||||||
Check failure on line 3 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorpreamble header `title` value is too long (max 44)
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERCs are for Ethereum standardization and not product/protocol promotion.
Suggested change
Can this ERC be used by any state channel implementation, or is it limited to Nitro based state channels? |
||||||
description: A standard for implementing interoperable state channels on Ethereum using the Nitro Protocol, integrated with ERC-4337 for enhanced account abstraction. | ||||||
Check failure on line 4 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorpreamble header `description` value is too long (max 140)
Check failure on line 4 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorpreamble header `description` should not contain `standard` (or similar words.)
|
||||||
author: Consensys Mesh (@statechennels), Layer 3 Foundation (@layer-3), Louis Bellet (@mod) | ||||||
discussions-to: https://github.com/ethereum/EIPs/discussions/7250 | ||||||
Check failure on line 6 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorpreamble header `discussions-to` should point to a thread on ethereum-magicians.org
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create a discussions topic in Eth Magicians with a link to this PR: https://ethereum-magicians.org/c/ercs/57 |
||||||
status: Draft | ||||||
type: Standards Track | ||||||
category: ERC | ||||||
created: 2024-11-22 | ||||||
requires: 4337 | ||||||
--- | ||||||
|
||||||
## Abstract | ||||||
|
||||||
This ERC standardizes the Nitro Protocol for state channels, enabling efficient off-chain state execution and on-chain dispute resolution. Integrated with ERC-4337 account abstraction, it leverages the capabilities of programmable wallets and plugins to enhance functionality, including custom state channel validators using NitroApps. The proposal defines essential structs and interfaces for Nitro-based state channels, supporting interoperability across Ethereum-based systems. | ||||||
Check failure on line 16 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorthe first match of the given pattern must be a link
|
||||||
|
||||||
## Motivation | ||||||
|
||||||
State channels offer a mechanism for off-chain execution, improving scalability and reducing transaction costs. However, existing implementations are not standardized and lack native support for account abstraction. By integrating Nitro Protocol with ERC-4337, this ERC enables advanced wallet functionality, custom plugins for state validation, and seamless interoperability across Ethereum-compatible systems. | ||||||
Check failure on line 20 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorthe first match of the given pattern must be a link
|
||||||
|
||||||
## Specification | ||||||
|
||||||
### Structs | ||||||
|
||||||
The Nitro Protocol defines the following key structs: | ||||||
|
||||||
#### `FixedPart` | ||||||
Defines immutable parameters of the state channel: | ||||||
|
||||||
```solidity | ||||||
struct FixedPart { | ||||||
address[] participants; // List of participant addresses | ||||||
uint48 channelNonce; // Unique channel identifier | ||||||
address appDefinition; // Address of the application-specific contract | ||||||
uint48 challengeDuration; // Challenge duration in seconds | ||||||
} | ||||||
``` | ||||||
|
||||||
#### `VariablePart` | ||||||
Defines the dynamic parameters of a channel's state: | ||||||
|
||||||
```solidity | ||||||
struct VariablePart { | ||||||
ExitFormat.SingleAssetExit[] outcome; // Asset distribution upon channel finalization | ||||||
bytes appData; // Application-specific data | ||||||
uint48 turnNum; // State version number | ||||||
bool isFinal; // Flag for instant finalization | ||||||
} | ||||||
``` | ||||||
|
||||||
#### `SignedVariablePart` | ||||||
Represents a signed state update: | ||||||
|
||||||
```solidity | ||||||
struct SignedVariablePart { | ||||||
VariablePart variablePart; | ||||||
Signature[] sigs; // Participant signatures | ||||||
} | ||||||
``` | ||||||
|
||||||
#### `Outcome` | ||||||
Describes asset distribution after channel finalization: | ||||||
|
||||||
```solidity | ||||||
struct Outcome { | ||||||
SingleAssetExit[] singleAssetExits; | ||||||
} | ||||||
|
||||||
struct SingleAssetExit { | ||||||
address asset; // Asset type (native or ERC20) | ||||||
bytes assetMetadata; // Metadata for exotic assets | ||||||
Allocation[] allocations; // Distribution of funds | ||||||
} | ||||||
|
||||||
struct Allocation { | ||||||
bytes32 destination; // Destination (channel ID or external address) | ||||||
uint256 amount; // Allocation amount | ||||||
uint8 allocationType; // Type (0 = simple, 1 = guarantee) | ||||||
bytes metadata; // Additional data for guarantees | ||||||
} | ||||||
``` | ||||||
|
||||||
### Interfaces | ||||||
|
||||||
#### `IForceMoveApp` | ||||||
Defines the application-specific execution rules: | ||||||
|
||||||
```solidity | ||||||
interface IForceMoveApp { | ||||||
function stateIsSupported( | ||||||
FixedPart calldata fixedPart, | ||||||
RecoveredVariablePart[] calldata proof, | ||||||
RecoveredVariablePart calldata candidate | ||||||
) external view returns (bool, string memory); | ||||||
} | ||||||
``` | ||||||
|
||||||
#### `IAdjudicator` | ||||||
Handles on-chain dispute resolution: | ||||||
|
||||||
```solidity | ||||||
interface IAdjudicator { | ||||||
function challenge( | ||||||
bytes32 channelId, | ||||||
FixedPart calldata fixedPart, | ||||||
SignedVariablePart[] calldata proof, | ||||||
SignedVariablePart calldata candidate | ||||||
) external; | ||||||
|
||||||
function finalize(bytes32 channelId) external; | ||||||
} | ||||||
``` | ||||||
|
||||||
### Integration with ERC-4337 | ||||||
Check failure on line 115 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorthe first match of the given pattern must be a link
|
||||||
|
||||||
#### Benefits | ||||||
1. **Custom Validation Plugins:** State validation logic can be implemented as NitroApps and used as account abstraction plugins, enabling diverse use cases (e.g., payment channels, virtual channels). | ||||||
2. **Programmable Wallets:** Wallets using ERC-4337 can interact directly with Nitro-based state channels. | ||||||
Check failure on line 119 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorthe first match of the given pattern must be a link
|
||||||
3. **Interoperability:** Unified standard for account abstraction and state channels across Ethereum. | ||||||
|
||||||
#### Example | ||||||
```solidity | ||||||
contract NitroAccount is IAccount { | ||||||
function validateUserOp( | ||||||
UserOperation calldata userOp, | ||||||
bytes32 userOpHash, | ||||||
uint256 missingAccountFunds | ||||||
) external override returns (uint256) { | ||||||
// Validate state updates using NitroApp logic | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
## Rationale | ||||||
|
||||||
This ERC builds on the modularity of Nitro Protocol and the flexibility of ERC-4337, creating a unified standard for state channel implementations. By decoupling execution rules from core protocol logic, it ensures adaptability for various applications while maintaining a secure and efficient dispute resolution process. | ||||||
Check failure on line 137 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorthe first match of the given pattern must be a link
|
||||||
|
||||||
## Backwards Compatibility | ||||||
|
||||||
This ERC depends on ERC-4337 and assumes its availability for account abstraction functionality. Legacy state channel implementations without Nitro compatibility will require adaptation. | ||||||
Check failure on line 141 in ERCS/erc-7250.md GitHub Actions / EIP Walidatorthe first match of the given pattern must be a link
|
||||||
|
||||||
## Test Cases | ||||||
|
||||||
1. **Channel Initialization:** | ||||||
- Deploy a channel with two participants and verify the `FixedPart` parameters. | ||||||
2. **State Update:** | ||||||
- Submit a valid `SignedVariablePart` and ensure it is accepted by the `IAdjudicator`. | ||||||
3. **Dispute Resolution:** | ||||||
- Simulate a challenge and verify proper execution of the `finalize` function. | ||||||
|
||||||
## Security Considerations | ||||||
|
||||||
- **Signature Validation:** Ensure that all state updates are cryptographically signed by the required participants. | ||||||
- **Replay Protection:** Use unique `channelNonce` values to prevent replay attacks. | ||||||
- **Application Logic Safety:** Carefully audit application-specific logic to avoid vulnerabilities. | ||||||
|
||||||
## Copyright | ||||||
|
||||||
Copyright and related rights waived via [CC0](../LICENSE). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assigning next sequential EIP/ERC/RIP number.
Numbers are assigned by editors & associates.
Please also update the filename.