Skip to content

Commit

Permalink
replace contract changes again
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Nov 21, 2024
1 parent a709ac0 commit 2102da1
Show file tree
Hide file tree
Showing 17 changed files with 1,243 additions and 260 deletions.
260 changes: 245 additions & 15 deletions contracts/bindings/EigenDAServiceManager/binding.go

Large diffs are not rendered by default.

449 changes: 449 additions & 0 deletions contracts/bindings/IEigenDARelayRegistry/binding.go

Large diffs are not rendered by default.

213 changes: 180 additions & 33 deletions contracts/bindings/IEigenDAServiceManager/binding.go

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions contracts/bindings/MockRollup/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function create_binding {
forge clean
forge build

contracts="SocketRegistry AVSDirectory DelegationManager BitmapUtils OperatorStateRetriever RegistryCoordinator BLSApkRegistry IndexRegistry StakeRegistry BN254 EigenDAServiceManager IEigenDAServiceManager MockRollup EjectionManager"
contracts="PaymentVault SocketRegistry AVSDirectory DelegationManager BitmapUtils OperatorStateRetriever RegistryCoordinator BLSApkRegistry IndexRegistry StakeRegistry BN254 EigenDAServiceManager IEigenDAServiceManager MockRollup EjectionManager IEigenDARelayRegistry"
for contract in $contracts; do
create_binding ./ $contract ./bindings
done
Expand Down
8 changes: 6 additions & 2 deletions contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {IBLSApkRegistry} from "eigenlayer-middleware/interfaces/IBLSApkRegistry.
import {EigenDAServiceManager, IAVSDirectory, IRewardsCoordinator} from "../src/core/EigenDAServiceManager.sol";
import {EigenDAHasher} from "../src/libraries/EigenDAHasher.sol";
import {ISocketRegistry, SocketRegistry} from "eigenlayer-middleware/SocketRegistry.sol";
import {IEigenDAThresholdRegistry} from "../src/interfaces/IEigenDAThresholdRegistry.sol";
import {IEigenDARelayRegistry} from "../src/interfaces/IEigenDARelayRegistry.sol";

import {DeployOpenEigenLayer, ProxyAdmin, ERC20PresetFixedSupply, TransparentUpgradeableProxy, IPauserRegistry} from "./DeployOpenEigenLayer.s.sol";
import "forge-std/Test.sol";
Expand Down Expand Up @@ -202,7 +204,9 @@ contract EigenDADeployer is DeployOpenEigenLayer {
avsDirectory,
rewardsCoordinator,
registryCoordinator,
stakeRegistry
stakeRegistry,
IEigenDAThresholdRegistry(address(0)),
IEigenDARelayRegistry(address(0))
);

address[] memory confirmers = new address[](1);
Expand All @@ -224,4 +228,4 @@ contract EigenDADeployer is DeployOpenEigenLayer {

operatorStateRetriever = new OperatorStateRetriever();
}
}
}
12 changes: 6 additions & 6 deletions contracts/script/GenerateUnitTestHashes.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../src/interfaces/IEigenDAServiceManager.sol";

import "forge-std/Script.sol";
import "forge-std/console.sol";

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

// # To generate the hashes needed for core/serialization_test.go:
// forge script script/GenerateUnitTestHashes.s.sol -v
Expand All @@ -18,9 +18,9 @@ contract GenerateHashes is Script {
function run() external {


IEigenDAServiceManager.QuorumBlobParam[] memory quorumBlobParam = new IEigenDAServiceManager.QuorumBlobParam[](1);
QuorumBlobParam[] memory quorumBlobParam = new QuorumBlobParam[](1);

quorumBlobParam[0] = IEigenDAServiceManager.QuorumBlobParam({
quorumBlobParam[0] = QuorumBlobParam({
quorumNumber: 0,
adversaryThresholdPercentage: 80,
confirmationThresholdPercentage: 100,
Expand All @@ -37,14 +37,14 @@ contract GenerateHashes is Script {
});


quorumBlobParam[0] = IEigenDAServiceManager.QuorumBlobParam({
quorumBlobParam[0] = QuorumBlobParam({
quorumNumber: 1,
adversaryThresholdPercentage: 80,
confirmationThresholdPercentage: 100,
chunkLength: 10
});

IEigenDAServiceManager.BlobHeader memory header = IEigenDAServiceManager.BlobHeader({
BlobHeader memory header = BlobHeader({
commitment: commitment,
dataLength: 10,
quorumBlobParams: quorumBlobParam
Expand All @@ -59,4 +59,4 @@ contract GenerateHashes is Script {


}
}
}
57 changes: 53 additions & 4 deletions contracts/src/core/EigenDAServiceManager.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import {Pausable} from "eigenlayer-core/contracts/permissions/Pausable.sol";
Expand All @@ -8,9 +8,11 @@ import {ServiceManagerBase, IAVSDirectory, IRewardsCoordinator, IServiceManager}
import {BLSSignatureChecker} from "eigenlayer-middleware/BLSSignatureChecker.sol";
import {IRegistryCoordinator} from "eigenlayer-middleware/interfaces/IRegistryCoordinator.sol";
import {IStakeRegistry} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";

import {IEigenDAThresholdRegistry} from "../interfaces/IEigenDAThresholdRegistry.sol";
import {IEigenDARelayRegistry} from "../interfaces/IEigenDARelayRegistry.sol";
import {EigenDAServiceManagerStorage} from "./EigenDAServiceManagerStorage.sol";
import {EigenDAHasher} from "../libraries/EigenDAHasher.sol";
import "../interfaces/IEigenDAStructs.sol";

/**
* @title Primary entrypoint for procuring services from EigenDA.
Expand All @@ -36,10 +38,13 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
IAVSDirectory __avsDirectory,
IRewardsCoordinator __rewardsCoordinator,
IRegistryCoordinator __registryCoordinator,
IStakeRegistry __stakeRegistry
IStakeRegistry __stakeRegistry,
IEigenDAThresholdRegistry __eigenDAThresholdRegistry,
IEigenDARelayRegistry __eigenDARelayRegistry
)
BLSSignatureChecker(__registryCoordinator)
ServiceManagerBase(__avsDirectory, __rewardsCoordinator, __registryCoordinator, __stakeRegistry)
EigenDAServiceManagerStorage(__eigenDAThresholdRegistry, __eigenDARelayRegistry)
{
_disableInitializers();
}
Expand Down Expand Up @@ -110,7 +115,7 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
// signed stake > total stake
require(
quorumStakeTotals.signedStakeForQuorum[i] * THRESHOLD_DENOMINATOR >=
quorumStakeTotals.totalStakeForQuorum[i] * uint8(batchHeader.signedStakeForQuorums[i]),
quorumStakeTotals.totalStakeForQuorum[i] * uint8(batchHeader.signedStakeForQuorums[i]),
"EigenDAServiceManager.confirmBatch: signatories do not own at least threshold percentage of a quorum"
);
}
Expand Down Expand Up @@ -147,4 +152,48 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
return referenceBlockNumber + STORE_DURATION_BLOCKS + BLOCK_STALE_MEASURE;
}

/// @notice Returns the blob params for a given blob version
function getBlobParams(uint16 version) external view returns (VersionedBlobParams memory) {
return eigenDAThresholdRegistry.getBlobParams(version);
}

/// @notice Returns the bytes array of quorumAdversaryThresholdPercentages
function quorumAdversaryThresholdPercentages() external view returns (bytes memory) {
return hex"212121";
}

/// @notice Returns the bytes array of quorumAdversaryThresholdPercentages
function quorumConfirmationThresholdPercentages() external view returns (bytes memory) {
return hex"373737";
}

/// @notice Returns the bytes array of quorumsNumbersRequired
function quorumNumbersRequired() external view returns (bytes memory) {
return hex"0001";
}

function getQuorumAdversaryThresholdPercentage(
uint8 quorumNumber
) external view returns (uint8){
return eigenDAThresholdRegistry.getQuorumAdversaryThresholdPercentage(quorumNumber);
}

/// @notice Gets the confirmation threshold percentage for a quorum
function getQuorumConfirmationThresholdPercentage(
uint8 quorumNumber
) external view returns (uint8){
return eigenDAThresholdRegistry.getQuorumConfirmationThresholdPercentage(quorumNumber);
}

/// @notice Checks if a quorum is required
function getIsQuorumRequired(
uint8 quorumNumber
) external view returns (bool){
return eigenDAThresholdRegistry.getIsQuorumRequired(quorumNumber);
}

/// @notice Gets the default security thresholds for V2
function getDefaultSecurityThresholdsV2() external view returns (SecurityThresholds memory) {
return eigenDAThresholdRegistry.getDefaultSecurityThresholdsV2();
}
}
36 changes: 13 additions & 23 deletions contracts/src/core/EigenDAServiceManagerStorage.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

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

import {IEigenDAThresholdRegistry} from "../interfaces/IEigenDAThresholdRegistry.sol";
import {IEigenDARelayRegistry} from "../interfaces/IEigenDARelayRegistry.sol";
/**
* @title Storage variables for the `EigenDAServiceManager` contract.
* @author Layr Labs, Inc.
Expand All @@ -12,7 +13,6 @@ abstract contract EigenDAServiceManagerStorage is IEigenDAServiceManager {
// CONSTANTS
uint256 public constant THRESHOLD_DENOMINATOR = 100;

//TODO: mechanism to change any of these values?
/// @notice Unit of measure (in blocks) for which data will be stored for after confirmation.
uint32 public constant STORE_DURATION_BLOCKS = 2 weeks / 12 seconds;

Expand All @@ -36,26 +36,16 @@ abstract contract EigenDAServiceManagerStorage is IEigenDAServiceManager {
*/
uint32 public constant BLOCK_STALE_MEASURE = 300;

/**
* @notice The quorum adversary threshold percentages stored as an ordered bytes array
* this is the percentage of the total stake that must be adversarial to consider a blob invalid.
* The first byte is the threshold for quorum 0, the second byte is the threshold for quorum 1, etc.
*/
bytes public constant quorumAdversaryThresholdPercentages = hex"212121";

/**
* @notice The quorum confirmation threshold percentages stored as an ordered bytes array
* this is the percentage of the total stake needed to confirm a blob.
* The first byte is the threshold for quorum 0, the second byte is the threshold for quorum 1, etc.
*/
bytes public constant quorumConfirmationThresholdPercentages = hex"373737";
IEigenDAThresholdRegistry public immutable eigenDAThresholdRegistry;
IEigenDARelayRegistry public immutable eigenDARelayRegistry;

/**
* @notice The quorum numbers required for confirmation stored as an ordered bytes array
* these quorum numbers have respective canonical thresholds in the
* quorumConfirmationThresholdPercentages and quorumAdversaryThresholdPercentages above.
*/
bytes public constant quorumNumbersRequired = hex"0001";
constructor(
IEigenDAThresholdRegistry _eigenDAThresholdRegistry,
IEigenDARelayRegistry _eigenDARelayRegistry
) {
eigenDAThresholdRegistry = _eigenDAThresholdRegistry;
eigenDARelayRegistry = _eigenDARelayRegistry;
}

/// @notice The current batchId
uint32 public batchId;
Expand All @@ -69,4 +59,4 @@ abstract contract EigenDAServiceManagerStorage is IEigenDAServiceManager {
// storage gap for upgradeability
// slither-disable-next-line shadowing-state
uint256[47] private __GAP;
}
}
61 changes: 7 additions & 54 deletions contracts/src/interfaces/IEigenDAServiceManager.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import {IServiceManager} from "eigenlayer-middleware/interfaces/IServiceManager.sol";
import {BLSSignatureChecker} from "eigenlayer-middleware/BLSSignatureChecker.sol";
import {BN254} from "eigenlayer-middleware/libraries/BN254.sol";
import {IEigenDAThresholdRegistry} from "./IEigenDAThresholdRegistry.sol";
import "./IEigenDAStructs.sol";

interface IEigenDAServiceManager is IServiceManager {
interface IEigenDAServiceManager is IServiceManager, IEigenDAThresholdRegistry {
// EVENTS

/**
Expand All @@ -22,46 +24,6 @@ interface IEigenDAServiceManager is IServiceManager {
*/
event BatchConfirmerStatusChanged(address batchConfirmer, bool status);

// STRUCTS

struct QuorumBlobParam {
uint8 quorumNumber;
uint8 adversaryThresholdPercentage;
uint8 confirmationThresholdPercentage;
uint32 chunkLength; // the length of the chunks in the quorum
}

struct BlobHeader {
BN254.G1Point commitment; // the kzg commitment to the blob
uint32 dataLength; // the length of the blob in coefficients of the polynomial
QuorumBlobParam[] quorumBlobParams; // the quorumBlobParams for each quorum
}

struct ReducedBatchHeader {
bytes32 blobHeadersRoot;
uint32 referenceBlockNumber;
}

struct BatchHeader {
bytes32 blobHeadersRoot;
bytes quorumNumbers; // each byte is a different quorum number
bytes signedStakeForQuorums; // every bytes is an amount less than 100 specifying the percentage of stake
// that has signed in the corresponding quorum in `quorumNumbers`
uint32 referenceBlockNumber;
}

// Relevant metadata for a given datastore
struct BatchMetadata {
BatchHeader batchHeader; // the header of the data store
bytes32 signatoryRecordHash; // the hash of the signatory record
uint32 confirmationBlockNumber; // the block number at which the batch was confirmed
}

// FUNCTIONS

/// @notice mapping between the batchId to the hash of the metadata of the corresponding Batch
function batchIdToBatchMetadataHash(uint32 batchId) external view returns(bytes32);

/**
* @notice This function is used for
* - submitting data availabilty certificates,
Expand All @@ -73,8 +35,8 @@ interface IEigenDAServiceManager is IServiceManager {
BLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature
) external;

/// @notice This function is used for changing the batch confirmer
function setBatchConfirmer(address _batchConfirmer) external;
/// @notice mapping between the batchId to the hash of the metadata of the corresponding Batch
function batchIdToBatchMetadataHash(uint32 batchId) external view returns(bytes32);

/// @notice Returns the current batchId
function taskNumber() external view returns (uint32);
Expand All @@ -84,13 +46,4 @@ interface IEigenDAServiceManager is IServiceManager {

/// @notice The maximum amount of blocks in the past that the service will consider stake amounts to still be 'valid'.
function BLOCK_STALE_MEASURE() external view returns (uint32);

/// @notice Returns the bytes array of quorumAdversaryThresholdPercentages
function quorumAdversaryThresholdPercentages() external view returns (bytes memory);

/// @notice Returns the bytes array of quorumAdversaryThresholdPercentages
function quorumConfirmationThresholdPercentages() external view returns (bytes memory);

/// @notice Returns the bytes array of quorumsNumbersRequired
function quorumNumbersRequired() external view returns (bytes memory);
}
}
Loading

0 comments on commit 2102da1

Please sign in to comment.