Skip to content

Commit

Permalink
dasm integration
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 committed May 2, 2024
1 parent 52bbbdd commit 76d0cca
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
5 changes: 3 additions & 2 deletions contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {StakeRegistry, IStrategy} from "eigenlayer-middleware/StakeRegistry.sol"
import {IStakeRegistry, IDelegationManager} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";
import {IServiceManager} from "eigenlayer-middleware/interfaces/IServiceManager.sol";
import {IBLSApkRegistry} from "eigenlayer-middleware/interfaces/IBLSApkRegistry.sol";

import {IEigenDAPaymentManager} from "../src/interfaces/IEigenDAPaymentManager.sol";
import {EigenDAServiceManager, IAVSDirectory, IPaymentCoordinator} from "../src/core/EigenDAServiceManager.sol";
import {EigenDAHasher} from "../src/libraries/EigenDAHasher.sol";

Expand Down Expand Up @@ -189,7 +189,8 @@ contract EigenDADeployer is DeployOpenEigenLayer {
IAVSDirectory(address(avsDirectory)),
IPaymentCoordinator(address(0)),
registryCoordinator,
stakeRegistry
stakeRegistry,
IEigenDAPaymentManager(address(0))
);

address[] memory confirmers = new address[](1);
Expand Down
20 changes: 18 additions & 2 deletions contracts/src/core/EigenDAServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ pragma solidity ^0.8.9;
import {Pausable} from "eigenlayer-core/contracts/permissions/Pausable.sol";
import {IPauserRegistry} from "eigenlayer-core/contracts/interfaces/IPauserRegistry.sol";

import {ServiceManagerBase, IAVSDirectory, IPaymentCoordinator} from "eigenlayer-middleware/ServiceManagerBase.sol";
import {ServiceManagerBase, IAVSDirectory, IPaymentCoordinator, IServiceManager} from "eigenlayer-middleware/ServiceManagerBase.sol";
import {BLSSignatureChecker} from "eigenlayer-middleware/BLSSignatureChecker.sol";
import {IRegistryCoordinator} from "eigenlayer-middleware/interfaces/IRegistryCoordinator.sol";
import {IStakeRegistry} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";

import {EigenDAServiceManagerStorage} from "./EigenDAServiceManagerStorage.sol";
import {EigenDAHasher} from "../libraries/EigenDAHasher.sol";
import {IEigenDAPaymentManager} from "../interfaces/IEigenDAPaymentManager.sol";

/**
* @title Primary entrypoint for procuring services from EigenDA.
Expand All @@ -36,8 +37,10 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
IAVSDirectory __avsDirectory,
IPaymentCoordinator __paymentCoordinator,
IRegistryCoordinator __registryCoordinator,
IStakeRegistry __stakeRegistry
IStakeRegistry __stakeRegistry,
IEigenDAPaymentManager __paymentManager
)
EigenDAServiceManagerStorage(__paymentManager)
BLSSignatureChecker(__registryCoordinator)
ServiceManagerBase(__avsDirectory, __paymentCoordinator, __registryCoordinator, __stakeRegistry)
{
Expand Down Expand Up @@ -124,6 +127,19 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
batchId = batchIdMemory + 1;
}

function payForRange(
IPaymentCoordinator.RangePayment[] calldata rangePayments
) public override(ServiceManagerBase, IServiceManager) {
require(msg.sender == address(paymentManager), "EigenDAServiceManager.payForRange: only payment manager can pay for range");

for (uint256 i = 0; i < rangePayments.length; ++i) {
rangePayments[i].token.transferFrom(msg.sender, address(this), rangePayments[i].amount);
rangePayments[i].token.approve(address(_paymentCoordinator), rangePayments[i].amount);
}

_paymentCoordinator.payForRange(rangePayments);
}

/// @notice This function is used for changing the batch confirmer
function setBatchConfirmer(address _batchConfirmer) external onlyOwner() {
_setBatchConfirmer(_batchConfirmer);
Expand Down
9 changes: 9 additions & 0 deletions contracts/src/core/EigenDAServiceManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
pragma solidity ^0.8.9;

import {IEigenDAServiceManager} from "../interfaces/IEigenDAServiceManager.sol";
import {IEigenDAPaymentManager} from "../interfaces/IEigenDAPaymentManager.sol";

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

/// @notice The payment manager contract for the EigenDA AVS
IEigenDAPaymentManager public immutable paymentManager;

// CONSTANTS
uint256 public constant THRESHOLD_DENOMINATOR = 100;

Expand Down Expand Up @@ -57,6 +62,10 @@ abstract contract EigenDAServiceManagerStorage is IEigenDAServiceManager {
*/
bytes public constant quorumNumbersRequired = hex"00";

constructor(IEigenDAPaymentManager _paymentManager) {
paymentManager = _paymentManager;
}

/// @notice The current batchId
uint32 public batchId;

Expand Down
5 changes: 3 additions & 2 deletions contracts/test/unit/EigenDABlobUtils.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {EigenDAHasher} from "../../src/libraries/EigenDAHasher.sol";
import {EigenDABlobUtilsHarness} from "../harnesses/EigenDABlobUtilsHarness.sol";
import {EigenDAServiceManager} from "../../src/core/EigenDAServiceManager.sol";
import {IEigenDAServiceManager} from "../../src/interfaces/IEigenDAServiceManager.sol";

import {IEigenDAPaymentManager} from "../../src/interfaces/IEigenDAPaymentManager.sol";

import "forge-std/StdStorage.sol";

Expand Down Expand Up @@ -46,7 +46,8 @@ contract EigenDABlobUtilsUnit is BLSMockAVSDeployer {
avsDirectory,
IPaymentCoordinator(address(0)),
registryCoordinator,
stakeRegistry
stakeRegistry,
IEigenDAPaymentManager(address(0))
);

address[] memory confirmers = new address[](1);
Expand Down
5 changes: 3 additions & 2 deletions contracts/test/unit/EigenDAServiceManagerUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {EigenDAServiceManager, IPaymentCoordinator} from "../../src/core/EigenDA
import {EigenDAHasher} from "../../src/libraries/EigenDAHasher.sol";
import {EigenDAServiceManager} from "../../src/core/EigenDAServiceManager.sol";
import {IEigenDAServiceManager} from "../../src/interfaces/IEigenDAServiceManager.sol";

import {IEigenDAPaymentManager} from "../../src/interfaces/IEigenDAPaymentManager.sol";

contract EigenDAServiceManagerUnit is BLSMockAVSDeployer {
using BN254 for BN254.G1Point;
Expand All @@ -35,7 +35,8 @@ contract EigenDAServiceManagerUnit is BLSMockAVSDeployer {
avsDirectory,
IPaymentCoordinator(address(0)),
registryCoordinator,
stakeRegistry
stakeRegistry,
IEigenDAPaymentManager(address(0))
);

address[] memory confirmers = new address[](1);
Expand Down
4 changes: 3 additions & 1 deletion contracts/test/unit/MockRollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {EigenDAServiceManager, IPaymentCoordinator} from "../../src/core/EigenDA
import {IEigenDAServiceManager} from "../../src/interfaces/IEigenDAServiceManager.sol";
import {EigenDARollupUtils} from "../../src/libraries/EigenDARollupUtils.sol";
import {BN254} from "eigenlayer-middleware/libraries/BN254.sol";
import {IEigenDAPaymentManager} from "../../src/interfaces/IEigenDAPaymentManager.sol";

import "forge-std/StdStorage.sol";

Expand Down Expand Up @@ -56,7 +57,8 @@ contract MockRollupTest is BLSMockAVSDeployer {
avsDirectory,
IPaymentCoordinator(address(0)),
registryCoordinator,
stakeRegistry
stakeRegistry,
IEigenDAPaymentManager(address(0))
);

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

0 comments on commit 76d0cca

Please sign in to comment.