Skip to content

Commit

Permalink
Disperser Registry (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 authored Dec 17, 2024
1 parent fc5dff1 commit 9c363d1
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 7 deletions.
22 changes: 21 additions & 1 deletion contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {IEigenDASignatureVerifier} from "../src/interfaces/IEigenDASignatureVeri
import {IEigenDARelayRegistry} from "../src/interfaces/IEigenDARelayRegistry.sol";
import {IPaymentVault} from "../src/interfaces/IPaymentVault.sol";
import {PaymentVault} from "../src/payments/PaymentVault.sol";
import {EigenDADisperserRegistry} from "../src/core/EigenDADisperserRegistry.sol";
import {IEigenDADisperserRegistry} from "../src/interfaces/IEigenDADisperserRegistry.sol";
import {EigenDARelayRegistry} from "../src/core/EigenDARelayRegistry.sol";
import {ISocketRegistry, SocketRegistry} from "eigenlayer-middleware/SocketRegistry.sol";
import {DeployOpenEigenLayer, ProxyAdmin, ERC20PresetFixedSupply, TransparentUpgradeableProxy, IPauserRegistry} from "./DeployOpenEigenLayer.s.sol";
Expand Down Expand Up @@ -52,6 +54,7 @@ contract EigenDADeployer is DeployOpenEigenLayer {
OperatorStateRetriever public operatorStateRetriever;
IPaymentVault public paymentVault;
EigenDARelayRegistry public eigenDARelayRegistry;
IEigenDADisperserRegistry public eigenDADisperserRegistry;

BLSApkRegistry public apkRegistryImplementation;
EigenDAServiceManager public eigenDAServiceManagerImplementation;
Expand All @@ -62,6 +65,7 @@ contract EigenDADeployer is DeployOpenEigenLayer {
EigenDARelayRegistry public eigenDARelayRegistryImplementation;
ISocketRegistry public socketRegistryImplementation;
IPaymentVault public paymentVaultImplementation;
IEigenDADisperserRegistry public eigenDADisperserRegistryImplementation;

uint64 _minNumSymbols = 4096;
uint64 _pricePerSymbol = 0.4470 gwei;
Expand Down Expand Up @@ -150,6 +154,10 @@ contract EigenDADeployer is DeployOpenEigenLayer {
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

eigenDADisperserRegistry = IEigenDADisperserRegistry(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

paymentVaultImplementation = new PaymentVault();

eigenDAProxyAdmin.upgradeAndCall(
Expand All @@ -168,6 +176,17 @@ contract EigenDADeployer is DeployOpenEigenLayer {
);
}

eigenDADisperserRegistryImplementation = new EigenDADisperserRegistry();

eigenDAProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(eigenDADisperserRegistry))),
address(eigenDADisperserRegistryImplementation),
abi.encodeWithSelector(
EigenDADisperserRegistry.initialize.selector,
addressConfig.eigenDACommunityMultisig
)
);

indexRegistryImplementation = new IndexRegistry(
registryCoordinator
);
Expand Down Expand Up @@ -256,7 +275,8 @@ contract EigenDADeployer is DeployOpenEigenLayer {
stakeRegistry,
eigenDAThresholdRegistry,
eigenDARelayRegistry,
paymentVault
paymentVault,
eigenDADisperserRegistry
);

address[] memory confirmers = new address[](1);
Expand Down
33 changes: 33 additions & 0 deletions contracts/src/core/EigenDADisperserRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
import {EigenDADisperserRegistryStorage} from "./EigenDADisperserRegistryStorage.sol";
import {IEigenDADisperserRegistry} from "../interfaces/IEigenDADisperserRegistry.sol";
import "../interfaces/IEigenDAStructs.sol";

/**
* @title Registry for EigenDA disperser info
* @author Layr Labs, Inc.
*/
contract EigenDADisperserRegistry is OwnableUpgradeable, EigenDADisperserRegistryStorage, IEigenDADisperserRegistry {

constructor() {
_disableInitializers();
}

function initialize(
address _initialOwner
) external initializer {
_transferOwnership(_initialOwner);
}

function setDisperserInfo(uint32 _disperserKey, DisperserInfo memory _disperserInfo) external onlyOwner {
disperserKeyToInfo[_disperserKey] = _disperserInfo;
emit DisperserAdded(_disperserKey, _disperserInfo.disperserAddress);
}

function disperserKeyToAddress(uint32 _key) external view returns (address) {
return disperserKeyToInfo[_key].disperserAddress;
}
}
18 changes: 18 additions & 0 deletions contracts/src/core/EigenDADisperserRegistryStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "../interfaces/IEigenDAStructs.sol";

/**
* @title Storage variables for the `EigenDADisperserRegistry` contract.
* @author Layr Labs, Inc.
* @notice This storage contract is separate from the logic to simplify the upgrade process.
*/
abstract contract EigenDADisperserRegistryStorage {

mapping(uint32 => DisperserInfo) public disperserKeyToInfo;

// storage gap for upgradeability
// slither-disable-next-line shadowing-state
uint256[49] private __GAP;
}
6 changes: 4 additions & 2 deletions contracts/src/core/EigenDAServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {IStakeRegistry} from "eigenlayer-middleware/interfaces/IStakeRegistry.so
import {IEigenDAThresholdRegistry} from "../interfaces/IEigenDAThresholdRegistry.sol";
import {IEigenDARelayRegistry} from "../interfaces/IEigenDARelayRegistry.sol";
import {IPaymentVault} from "../interfaces/IPaymentVault.sol";
import {IEigenDADisperserRegistry} from "../interfaces/IEigenDADisperserRegistry.sol";
import {EigenDAServiceManagerStorage} from "./EigenDAServiceManagerStorage.sol";
import {EigenDAHasher} from "../libraries/EigenDAHasher.sol";
import "../interfaces/IEigenDAStructs.sol";
Expand Down Expand Up @@ -42,11 +43,12 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
IStakeRegistry __stakeRegistry,
IEigenDAThresholdRegistry __eigenDAThresholdRegistry,
IEigenDARelayRegistry __eigenDARelayRegistry,
IPaymentVault __paymentVault
IPaymentVault __paymentVault,
IEigenDADisperserRegistry __eigenDADisperserRegistry
)
BLSSignatureChecker(__registryCoordinator)
ServiceManagerBase(__avsDirectory, __rewardsCoordinator, __registryCoordinator, __stakeRegistry)
EigenDAServiceManagerStorage(__eigenDAThresholdRegistry, __eigenDARelayRegistry, __paymentVault)
EigenDAServiceManagerStorage(__eigenDAThresholdRegistry, __eigenDARelayRegistry, __paymentVault, __eigenDADisperserRegistry)
{
_disableInitializers();
}
Expand Down
6 changes: 5 additions & 1 deletion contracts/src/core/EigenDAServiceManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {IEigenDAServiceManager} from "../interfaces/IEigenDAServiceManager.sol";
import {IEigenDAThresholdRegistry} from "../interfaces/IEigenDAThresholdRegistry.sol";
import {IEigenDARelayRegistry} from "../interfaces/IEigenDARelayRegistry.sol";
import {IPaymentVault} from "../interfaces/IPaymentVault.sol";
import {IEigenDADisperserRegistry} from "../interfaces/IEigenDADisperserRegistry.sol";

/**
* @title Storage variables for the `EigenDAServiceManager` contract.
Expand Down Expand Up @@ -41,15 +42,18 @@ abstract contract EigenDAServiceManagerStorage is IEigenDAServiceManager {
IEigenDAThresholdRegistry public immutable eigenDAThresholdRegistry;
IEigenDARelayRegistry public immutable eigenDARelayRegistry;
IPaymentVault public immutable paymentVault;
IEigenDADisperserRegistry public immutable eigenDADisperserRegistry;

constructor(
IEigenDAThresholdRegistry _eigenDAThresholdRegistry,
IEigenDARelayRegistry _eigenDARelayRegistry,
IPaymentVault _paymentVault
IPaymentVault _paymentVault,
IEigenDADisperserRegistry _eigenDADisperserRegistry
) {
eigenDAThresholdRegistry = _eigenDAThresholdRegistry;
eigenDARelayRegistry = _eigenDARelayRegistry;
paymentVault = _paymentVault;
eigenDADisperserRegistry = _eigenDADisperserRegistry;
}

/// @notice The current batchId
Expand Down
13 changes: 13 additions & 0 deletions contracts/src/interfaces/IEigenDADisperserRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "./IEigenDAStructs.sol";

interface IEigenDADisperserRegistry {

event DisperserAdded(uint32 indexed key, address indexed disperser);

function setDisperserInfo(uint32 _disperserKey, DisperserInfo memory _disperserInfo) external;

function disperserKeyToAddress(uint32 key) external view returns (address);
}
4 changes: 4 additions & 0 deletions contracts/src/interfaces/IEigenDAStructs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ struct RelayInfo {
string relayURL;
}

struct DisperserInfo {
address disperserAddress;
}

struct BlobVerificationProofV2 {
BlobCertificate blobCertificate;
uint32 blobIndex;
Expand Down
4 changes: 3 additions & 1 deletion contracts/test/rollup/MockRollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {IEigenDARelayRegistry} from "../../src/interfaces/IEigenDARelayRegistry.
import {IPaymentVault} from "../../src/interfaces/IPaymentVault.sol";
import {EigenDARelayRegistry} from "../../src/core/EigenDARelayRegistry.sol";
import {IRegistryCoordinator} from "../../lib/eigenlayer-middleware/src/interfaces/IRegistryCoordinator.sol";
import {IEigenDADisperserRegistry} from "../../src/interfaces/IEigenDADisperserRegistry.sol";
import "../../src/interfaces/IEigenDAStructs.sol";
import "forge-std/StdStorage.sol";

Expand Down Expand Up @@ -96,7 +97,8 @@ contract MockRollupTest is BLSMockAVSDeployer {
stakeRegistry,
eigenDAThresholdRegistry,
eigenDARelayRegistry,
IPaymentVault(address(0))
IPaymentVault(address(0)),
IEigenDADisperserRegistry(address(0))
);

eigenDAThresholdRegistryImplementation = new EigenDAThresholdRegistry();
Expand Down
4 changes: 3 additions & 1 deletion contracts/test/unit/EigenDABlobUtils.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {IEigenDARelayRegistry} from "../../src/interfaces/IEigenDARelayRegistry.
import {EigenDARelayRegistry} from "../../src/core/EigenDARelayRegistry.sol";
import {IPaymentVault} from "../../src/interfaces/IPaymentVault.sol";
import {PaymentVault} from "../../src/payments/PaymentVault.sol";
import {IEigenDADisperserRegistry} from "../../src/interfaces/IEigenDADisperserRegistry.sol";

import "../../src/interfaces/IEigenDAStructs.sol";
import "forge-std/StdStorage.sol";
Expand Down Expand Up @@ -82,7 +83,8 @@ contract EigenDABlobUtilsUnit is BLSMockAVSDeployer {
stakeRegistry,
eigenDAThresholdRegistry,
eigenDARelayRegistry,
IPaymentVault(address(0))
IPaymentVault(address(0)),
IEigenDADisperserRegistry(address(0))
);

eigenDAThresholdRegistryImplementation = new EigenDAThresholdRegistry();
Expand Down
4 changes: 3 additions & 1 deletion contracts/test/unit/EigenDAServiceManagerUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {IRegistryCoordinator} from "../../lib/eigenlayer-middleware/src/interfac
import {IEigenDARelayRegistry} from "../../src/interfaces/IEigenDARelayRegistry.sol";
import {IPaymentVault} from "../../src/interfaces/IPaymentVault.sol";
import {EigenDARelayRegistry} from "../../src/core/EigenDARelayRegistry.sol";
import {IEigenDADisperserRegistry} from "../../src/interfaces/IEigenDADisperserRegistry.sol";
import "../../src/interfaces/IEigenDAStructs.sol";

contract EigenDAServiceManagerUnit is BLSMockAVSDeployer {
Expand Down Expand Up @@ -77,7 +78,8 @@ contract EigenDAServiceManagerUnit is BLSMockAVSDeployer {
stakeRegistry,
eigenDAThresholdRegistry,
eigenDARelayRegistry,
IPaymentVault(address(0))
IPaymentVault(address(0)),
IEigenDADisperserRegistry(address(0))
);

address[] memory confirmers = new address[](1);
Expand Down

0 comments on commit 9c363d1

Please sign in to comment.