Skip to content

Commit

Permalink
rename EigenLayerBridge.sol to be more consistent with EigenLayer nam…
Browse files Browse the repository at this point in the history
…ing semantics
  • Loading branch information
idatsy committed Jun 17, 2024
1 parent b484046 commit 38e2864
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ This proof of concept aims to showcase the potential of EigenLayer in securing d

- **Contracts**:
- `ECDSAUtils.sol`: Provides ECDSA signature utilities.
- `EigenLayerBridge.sol`: Manages bridge operations and attestation validations.
- `BridgeServiceManager.sol`: Manages bridge operations and attestation validations.
- `PermissionedBridge.sol`: Manages bridge operations with manually set operator weights.
- `Events.sol`: Contains event definitions for bridge operations.
- `Structs.sol`: Defines structs and related functions for bridge operations.
- `Vault.sol`: Abstract contract providing common vault functionality for bridge contracts.

- **Tests**:
- `EigenLayerBridge.t.sol`: Tests for `EigenLayerBridge.sol`.
- `EigenLayerBridge.t.sol`: Tests for `BridgeServiceManager.sol`.
- `PermissionedBridge.t.sol`: Tests for `PermissionedBridge.sol`.

## Getting Started
Expand Down
4 changes: 2 additions & 2 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ This proof of concept aims to showcase the potential of EigenLayer in securing d

- **Contracts**:
- `ECDSAUtils.sol`: Provides ECDSA signature utilities.
- `EigenLayerBridge.sol`: Manages bridge operations and attestation validations.
- `BridgeServiceManager.sol`: Manages bridge operations and attestation validations.
- `PermissionedBridge.sol`: Manages bridge operations with manually set operator weights.
- `Events.sol`: Contains event definitions for bridge operations.
- `Structs.sol`: Defines structs and related functions for bridge operations.
- `Vault.sol`: Abstract contract providing common vault functionality for bridge contracts.

- **Tests**:
- `EigenLayerBridge.t.sol`: Tests for `EigenLayerBridge.sol`.
- `EigenLayerBridge.t.sol`: Tests for `BridgeServiceManager.sol`.
- `PermissionedBridge.t.sol`: Tests for `PermissionedBridge.sol`.

## Getting Started
Expand Down
2 changes: 1 addition & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Summary
- [Home](README.md)
# src
- [BridgeServiceManager](src/BridgeServiceManager.sol/contract.BridgeServiceManager.md)
- [ECDSAUtils](src/ECDSAUtils.sol/contract.ECDSAUtils.md)
- [BridgeServiceManager](src/EigenLayerBridge.sol/contract.BridgeServiceManager.md)
- [Events](src/Events.sol/contract.Events.md)
- [PermissionedBridge](src/PermissionedBridge.sol/contract.PermissionedBridge.md)
- [Structs](src/Structs.sol/library.Structs.md)
Expand Down
240 changes: 240 additions & 0 deletions docs/src/src/BridgeServiceManager.sol/contract.BridgeServiceManager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
# BridgeServiceManager
[Git Source](https://github.com/idatsy/eigen-bridge/blob/b48404690919046d685c16cb037d35d4bd1626d5/src/BridgeServiceManager.sol)

**Inherits:**
ECDSAServiceManagerBase, [Vault](/src/Vault.sol/abstract.Vault.md)

Manages bridge operations and attestation validations

*Extends ECDSAServiceManagerBase and Vault for bridging and staking functionality*


## State Variables
### operatorResponses
Tracks bridge requests that this operator has responded to once to avoid duplications

*Double attestations would technically be valid and allow operators to recursively call until funds are released*


```solidity
mapping(address => mapping(uint256 => bool)) public operatorResponses;
```


### bridgeRequestWeights
Tracks the total operator weight attested to a bridge request

*Helpful for determining when enough attestations have been collected to release funds.*


```solidity
mapping(uint256 => uint256) public bridgeRequestWeights;
```


## Functions
### constructor

Initializes the contract with the necessary addresses and parameters


```solidity
constructor(
address _avsDirectory,
address _stakeRegistry,
address _rewardsCoordinator,
address _delegationManager,
uint256 _crankGasCost,
uint256 _AVSReward,
uint256 _bridgeFee,
string memory _name,
string memory _version
)
ECDSAServiceManagerBase(_avsDirectory, _stakeRegistry, _rewardsCoordinator, _delegationManager)
Vault(_crankGasCost, _AVSReward, _bridgeFee, _name, _version);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_avsDirectory`|`address`|The address of the AVS directory contract, managing AVS-related data for registered operators|
|`_stakeRegistry`|`address`|The address of the stake registry contract, managing registration and stake recording|
|`_rewardsCoordinator`|`address`|The address of the rewards coordinator contract, handling rewards distributions|
|`_delegationManager`|`address`|The address of the delegation manager contract, managing staker delegations to operators|
|`_crankGasCost`|`uint256`|The estimated gas cost for calling release funds, used to calculate rebate and incentivize users to call|
|`_AVSReward`|`uint256`|The total reward for AVS attestation|
|`_bridgeFee`|`uint256`|The total fee charged to the user for bridging|
|`_name`|`string`|The name of the contract, used for EIP-712 domain construction|
|`_version`|`string`|The version of the contract, used for EIP-712 domain construction|


### onlyOperator

Ensures that only registered operators can call the function


```solidity
modifier onlyOperator();
```

### rewardAttestation

Rewards the operator for providing a valid attestation

*Placeholder for actual AVS reward distribution pending Eigen M2 implementation*


```solidity
function rewardAttestation(address operator) internal;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`operator`|`address`|The address of the operator to be rewarded|


### publishAttestation

Publishes an attestation for a bridge request


```solidity
function publishAttestation(bytes memory attestation, uint256 _bridgeRequestId) public nonReentrant onlyOperator;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`attestation`|`bytes`|The signed attestation|
|`_bridgeRequestId`|`uint256`|The ID of the bridge request|


### slashMaliciousAttestor

Slashes a malicious attestor's stake

*Placeholder for slashing logic pending Eigen implementations*


```solidity
function slashMaliciousAttestor(address operator, uint256 penalty) internal;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`operator`|`address`|The address of the operator to be slashed|
|`penalty`|`uint256`|The penalty amount to be slashed|


### challengeAttestation

Challenges a potentially fraudulent attestation


```solidity
function challengeAttestation(
bytes memory fraudulentSignature,
Structs.BridgeRequestData memory fraudulentBridgeRequest
) public nonReentrant;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`fraudulentSignature`|`bytes`|The signature of the fraudulent attestation|
|`fraudulentBridgeRequest`|`Structs.BridgeRequestData`|The data of the fraudulent bridge request|


### payoutCrankGasCost

Payouts the crank gas cost to the caller


```solidity
function payoutCrankGasCost() internal;
```

### _releaseFunds

Releases funds to the destination address


```solidity
function _releaseFunds(bytes memory data) public override nonReentrant;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`data`|`bytes`|The bridge request data and signatures|


### releaseFunds

Releases funds to the destination address with typed data for ABI construction


```solidity
function releaseFunds(bytes[] memory signatures, Structs.BridgeRequestData memory data) public nonReentrant;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`signatures`|`bytes[]`|The signatures of the operators attesting to the bridge request|
|`data`|`Structs.BridgeRequestData`|The bridge request data|


### operatorHasMinimumWeight

Checks if the operator has the minimum required weight


```solidity
function operatorHasMinimumWeight(address operator) public view returns (bool);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`operator`|`address`|The address of the operator|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`bool`|True if the operator has the minimum weight, false otherwise|


### getOperatorWeight

Gets the weight of an operator


```solidity
function getOperatorWeight(address operator) public view returns (uint256);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`operator`|`address`|The address of the operator|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`uint256`|The weight of the operator|


### receive

Fallback function to receive ether


```solidity
receive() external payable;
```

2 changes: 1 addition & 1 deletion docs/src/src/ECDSAUtils.sol/contract.ECDSAUtils.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ECDSAUtils
[Git Source](https://github.com/idatsy/eigen-bridge/blob/eebec4f167dbfa8749ada8d03753364230dd7d49/src/ECDSAUtils.sol)
[Git Source](https://github.com/idatsy/eigen-bridge/blob/b48404690919046d685c16cb037d35d4bd1626d5/src/ECDSAUtils.sol)

**Inherits:**
EIP712
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BridgeServiceManager
[Git Source](https://github.com/idatsy/eigen-bridge/blob/eebec4f167dbfa8749ada8d03753364230dd7d49/src/EigenLayerBridge.sol)
[Git Source](https://github.com/idatsy/eigen-bridge/blob/eebec4f167dbfa8749ada8d03753364230dd7d49/src/BridgeServiceManager.sol)

**Inherits:**
ECDSAServiceManagerBase, [Vault](/src/Vault.sol/abstract.Vault.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# EigenLayerBridge
[Git Source](https://github.com/idatsy/eigen-bridge/blob/4bbab8924ec1c5205dc848c3b60057e0c417dbf1/src/EigenLayerBridge.sol)
[Git Source](https://github.com/idatsy/eigen-bridge/blob/4bbab8924ec1c5205dc848c3b60057e0c417dbf1/src/BridgeServiceManager.sol)

**Inherits:**
ECDSAServiceManagerBase, [Vault](/src/Vault.sol/abstract.Vault.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/Events.sol/contract.Events.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Events
[Git Source](https://github.com/idatsy/eigen-bridge/blob/eebec4f167dbfa8749ada8d03753364230dd7d49/src/Events.sol)
[Git Source](https://github.com/idatsy/eigen-bridge/blob/b48404690919046d685c16cb037d35d4bd1626d5/src/Events.sol)

Contains event definitions for bridge operations

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PermissionedBridge
[Git Source](https://github.com/idatsy/eigen-bridge/blob/eebec4f167dbfa8749ada8d03753364230dd7d49/src/PermissionedBridge.sol)
[Git Source](https://github.com/idatsy/eigen-bridge/blob/b48404690919046d685c16cb037d35d4bd1626d5/src/PermissionedBridge.sol)

**Inherits:**
[Vault](/src/Vault.sol/abstract.Vault.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


# Contents
- [BridgeServiceManager](BridgeServiceManager.sol/contract.BridgeServiceManager.md)
- [ECDSAUtils](ECDSAUtils.sol/contract.ECDSAUtils.md)
- [BridgeServiceManager](EigenLayerBridge.sol/contract.BridgeServiceManager.md)
- [Events](Events.sol/contract.Events.md)
- [PermissionedBridge](PermissionedBridge.sol/contract.PermissionedBridge.md)
- [Structs](Structs.sol/library.Structs.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/Structs.sol/library.Structs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Structs
[Git Source](https://github.com/idatsy/eigen-bridge/blob/eebec4f167dbfa8749ada8d03753364230dd7d49/src/Structs.sol)
[Git Source](https://github.com/idatsy/eigen-bridge/blob/b48404690919046d685c16cb037d35d4bd1626d5/src/Structs.sol)

Contains struct definitions and related functions for bridge operations

Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/Vault.sol/abstract.Vault.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Vault
[Git Source](https://github.com/idatsy/eigen-bridge/blob/eebec4f167dbfa8749ada8d03753364230dd7d49/src/Vault.sol)
[Git Source](https://github.com/idatsy/eigen-bridge/blob/b48404690919046d685c16cb037d35d4bd1626d5/src/Vault.sol)

**Inherits:**
[ECDSAUtils](/src/ECDSAUtils.sol/contract.ECDSAUtils.md), [Events](/src/Events.sol/contract.Events.md), ReentrancyGuard, OwnableUpgradeable
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/EigenLayerBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {BridgeServiceManager} from "../src/EigenLayerBridge.sol";
import {BridgeServiceManager} from "../src/BridgeServiceManager.sol";
import "../src/Events.sol";
import {Structs} from "../src/Structs.sol";
import "openzeppelin/contracts/utils/cryptography/EIP712.sol";
Expand Down

0 comments on commit 38e2864

Please sign in to comment.