Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Layr-Labs/eigenda into da…
Browse files Browse the repository at this point in the history
…taapioperatorsapiimp
  • Loading branch information
jianoaix committed Dec 13, 2024
2 parents f6a11ac + 7b12ebf commit 2c239d5
Show file tree
Hide file tree
Showing 48 changed files with 601 additions and 457 deletions.
6 changes: 3 additions & 3 deletions api/clients/accountant.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var requiredQuorums = []uint8{0, 1}
type Accountant struct {
// on-chain states
accountID string
reservation *core.ActiveReservation
reservation *core.ReservedPayment
onDemand *core.OnDemandPayment
reservationWindow uint32
pricePerSymbol uint32
Expand All @@ -39,7 +39,7 @@ type BinRecord struct {
Usage uint64
}

func NewAccountant(accountID string, reservation *core.ActiveReservation, onDemand *core.OnDemandPayment, reservationWindow uint32, pricePerSymbol uint32, minNumSymbols uint32, numBins uint32) *Accountant {
func NewAccountant(accountID string, reservation *core.ReservedPayment, onDemand *core.OnDemandPayment, reservationWindow uint32, pricePerSymbol uint32, minNumSymbols uint32, numBins uint32) *Accountant {
//TODO: client storage; currently every instance starts fresh but on-chain or a small store makes more sense
// Also client is currently responsible for supplying network params, we need to add RPC in order to be automatic
// There's a subsequent PR that handles populating the accountant with on-chain state from the disperser
Expand All @@ -65,7 +65,7 @@ func NewAccountant(accountID string, reservation *core.ActiveReservation, onDema
// BlobPaymentInfo calculates and records payment information. The accountant
// will attempt to use the active reservation first and check for quorum settings,
// then on-demand if the reservation is not available. The returned values are
// bin index for reservation payments and cumulative payment for on-demand payments,
// reservation period for reservation payments and cumulative payment for on-demand payments,
// and both fields are used to create the payment header and signature
func (a *Accountant) BlobPaymentInfo(ctx context.Context, numSymbols uint64, quorumNumbers []uint8) (uint32, *big.Int, error) {
now := time.Now().Unix()
Expand Down
18 changes: 9 additions & 9 deletions api/clients/accountant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const numBins = uint32(3)
const salt = uint32(0)

func TestNewAccountant(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 100,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestNewAccountant(t *testing.T) {
}

func TestAccountBlob_Reservation(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 200,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestAccountBlob_Reservation(t *testing.T) {
}

func TestAccountBlob_OnDemand(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 200,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestAccountBlob_OnDemand(t *testing.T) {
}

func TestAccountBlob_InsufficientOnDemand(t *testing.T) {
reservation := &core.ActiveReservation{}
reservation := &core.ReservedPayment{}
onDemand := &core.OnDemandPayment{
CumulativePayment: big.NewInt(500),
}
Expand All @@ -152,7 +152,7 @@ func TestAccountBlob_InsufficientOnDemand(t *testing.T) {
}

func TestAccountBlobCallSeries(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 200,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestAccountBlobCallSeries(t *testing.T) {
}

func TestAccountBlob_BinRotation(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 1000,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestAccountBlob_BinRotation(t *testing.T) {
}

func TestConcurrentBinRotationAndAccountBlob(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 1000,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestConcurrentBinRotationAndAccountBlob(t *testing.T) {
}

func TestAccountBlob_ReservationWithOneOverflow(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 200,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down Expand Up @@ -332,7 +332,7 @@ func TestAccountBlob_ReservationWithOneOverflow(t *testing.T) {
}

func TestAccountBlob_ReservationOverflowReset(t *testing.T) {
reservation := &core.ActiveReservation{
reservation := &core.ReservedPayment{
SymbolsPerSecond: 1000,
StartTimestamp: 100,
EndTimestamp: 200,
Expand Down
2 changes: 1 addition & 1 deletion api/docs/disperser.html
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ <h3 id="disperser.Disperser">Disperser</h3>
<td><a href="#disperser.AuthenticatedRequest">AuthenticatedRequest</a> stream</td>
<td><a href="#disperser.AuthenticatedReply">AuthenticatedReply</a> stream</td>
<td><p>DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the
client to authenticate itself via the AuthenticationData message. The protoco is as follows:
client to authenticate itself via the AuthenticationData message. The protocol is as follows:
1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message
2. The Disperser sends back a BlobAuthHeader message containing information for the client to
verify and sign.
Expand Down
2 changes: 1 addition & 1 deletion api/docs/disperser.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ Disperser defines the public APIs for dispersing blobs.
| DisperseBlob | [DisperseBlobRequest](#disperser-DisperseBlobRequest) | [DisperseBlobReply](#disperser-DisperseBlobReply) | DisperseBlob accepts a single blob to be dispersed. This executes the dispersal async, i.e. it returns once the request is accepted. The client should use GetBlobStatus() API to poll the processing status of the blob.

If DisperseBlob returns the following error codes: INVALID_ARGUMENT (400): request is invalid for a reason specified in the error msg. RESOURCE_EXHAUSTED (429): request is rate limited for the quorum specified in the error msg. user should retry after the specified duration. INTERNAL (500): serious error, user should NOT retry. |
| DisperseBlobAuthenticated | [AuthenticatedRequest](#disperser-AuthenticatedRequest) stream | [AuthenticatedReply](#disperser-AuthenticatedReply) stream | DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the client to authenticate itself via the AuthenticationData message. The protoco is as follows: 1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message 2. The Disperser sends back a BlobAuthHeader message containing information for the client to verify and sign. 3. The client verifies the BlobAuthHeader and sends back the signed BlobAuthHeader in an AuthenticationData message. 4. The Disperser verifies the signature and returns a DisperseBlobReply message. |
| DisperseBlobAuthenticated | [AuthenticatedRequest](#disperser-AuthenticatedRequest) stream | [AuthenticatedReply](#disperser-AuthenticatedReply) stream | DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the client to authenticate itself via the AuthenticationData message. The protocol is as follows: 1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message 2. The Disperser sends back a BlobAuthHeader message containing information for the client to verify and sign. 3. The client verifies the BlobAuthHeader and sends back the signed BlobAuthHeader in an AuthenticationData message. 4. The Disperser verifies the signature and returns a DisperseBlobReply message. |
| GetBlobStatus | [BlobStatusRequest](#disperser-BlobStatusRequest) | [BlobStatusReply](#disperser-BlobStatusReply) | This API is meant to be polled for the blob status. |
| RetrieveBlob | [RetrieveBlobRequest](#disperser-RetrieveBlobRequest) | [RetrieveBlobReply](#disperser-RetrieveBlobReply) | This retrieves the requested blob from the Disperser&#39;s backend. This is a more efficient way to retrieve blobs than directly retrieving from the DA Nodes (see detail about this approach in api/proto/retriever/retriever.proto). The blob should have been initially dispersed via this Disperser service for this API to work. |

Expand Down
2 changes: 1 addition & 1 deletion api/docs/disperser_v2.html
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ <h3 id="disperser.v2.GetPaymentStateRequest">GetPaymentStateRequest</h3>
<td><a href="#bytes">bytes</a></td>
<td></td>
<td><p>Signature over the account ID
TODO: sign over a bin index or a nonce to mitigate signature replay attacks </p></td>
TODO: sign over a reservation period or a nonce to mitigate signature replay attacks </p></td>
</tr>

</tbody>
Expand Down
2 changes: 1 addition & 1 deletion api/docs/disperser_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ GetPaymentStateRequest contains parameters to query the payment state of an acco
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| account_id | [string](#string) | | |
| signature | [bytes](#bytes) | | Signature over the account ID TODO: sign over a bin index or a nonce to mitigate signature replay attacks |
| signature | [bytes](#bytes) | | Signature over the account ID TODO: sign over a reservation period or a nonce to mitigate signature replay attacks |



Expand Down
4 changes: 2 additions & 2 deletions api/docs/eigenda-protos.html
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ <h3 id="disperser.Disperser">Disperser</h3>
<td><a href="#disperser.AuthenticatedRequest">AuthenticatedRequest</a> stream</td>
<td><a href="#disperser.AuthenticatedReply">AuthenticatedReply</a> stream</td>
<td><p>DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the
client to authenticate itself via the AuthenticationData message. The protoco is as follows:
client to authenticate itself via the AuthenticationData message. The protocol is as follows:
1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message
2. The Disperser sends back a BlobAuthHeader message containing information for the client to
verify and sign.
Expand Down Expand Up @@ -2303,7 +2303,7 @@ <h3 id="disperser.v2.GetPaymentStateRequest">GetPaymentStateRequest</h3>
<td><a href="#bytes">bytes</a></td>
<td></td>
<td><p>Signature over the account ID
TODO: sign over a bin index or a nonce to mitigate signature replay attacks </p></td>
TODO: sign over a reservation period or a nonce to mitigate signature replay attacks </p></td>
</tr>

</tbody>
Expand Down
4 changes: 2 additions & 2 deletions api/docs/eigenda-protos.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ Disperser defines the public APIs for dispersing blobs.
| DisperseBlob | [DisperseBlobRequest](#disperser-DisperseBlobRequest) | [DisperseBlobReply](#disperser-DisperseBlobReply) | DisperseBlob accepts a single blob to be dispersed. This executes the dispersal async, i.e. it returns once the request is accepted. The client should use GetBlobStatus() API to poll the processing status of the blob.

If DisperseBlob returns the following error codes: INVALID_ARGUMENT (400): request is invalid for a reason specified in the error msg. RESOURCE_EXHAUSTED (429): request is rate limited for the quorum specified in the error msg. user should retry after the specified duration. INTERNAL (500): serious error, user should NOT retry. |
| DisperseBlobAuthenticated | [AuthenticatedRequest](#disperser-AuthenticatedRequest) stream | [AuthenticatedReply](#disperser-AuthenticatedReply) stream | DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the client to authenticate itself via the AuthenticationData message. The protoco is as follows: 1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message 2. The Disperser sends back a BlobAuthHeader message containing information for the client to verify and sign. 3. The client verifies the BlobAuthHeader and sends back the signed BlobAuthHeader in an AuthenticationData message. 4. The Disperser verifies the signature and returns a DisperseBlobReply message. |
| DisperseBlobAuthenticated | [AuthenticatedRequest](#disperser-AuthenticatedRequest) stream | [AuthenticatedReply](#disperser-AuthenticatedReply) stream | DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the client to authenticate itself via the AuthenticationData message. The protocol is as follows: 1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message 2. The Disperser sends back a BlobAuthHeader message containing information for the client to verify and sign. 3. The client verifies the BlobAuthHeader and sends back the signed BlobAuthHeader in an AuthenticationData message. 4. The Disperser verifies the signature and returns a DisperseBlobReply message. |
| GetBlobStatus | [BlobStatusRequest](#disperser-BlobStatusRequest) | [BlobStatusReply](#disperser-BlobStatusReply) | This API is meant to be polled for the blob status. |
| RetrieveBlob | [RetrieveBlobRequest](#disperser-RetrieveBlobRequest) | [RetrieveBlobReply](#disperser-RetrieveBlobReply) | This retrieves the requested blob from the Disperser&#39;s backend. This is a more efficient way to retrieve blobs than directly retrieving from the DA Nodes (see detail about this approach in api/proto/retriever/retriever.proto). The blob should have been initially dispersed via this Disperser service for this API to work. |

Expand Down Expand Up @@ -912,7 +912,7 @@ GetPaymentStateRequest contains parameters to query the payment state of an acco
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| account_id | [string](#string) | | |
| signature | [bytes](#bytes) | | Signature over the account ID TODO: sign over a bin index or a nonce to mitigate signature replay attacks |
| signature | [bytes](#bytes) | | Signature over the account ID TODO: sign over a reservation period or a nonce to mitigate signature replay attacks |



Expand Down
4 changes: 2 additions & 2 deletions api/grpc/disperser/disperser_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/grpc/disperser/v2/disperser_v2.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/proto/disperser/disperser.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ service Disperser {
rpc DisperseBlob(DisperseBlobRequest) returns (DisperseBlobReply) {}

// DisperseBlobAuthenticated is similar to DisperseBlob, except that it requires the
// client to authenticate itself via the AuthenticationData message. The protoco is as follows:
// client to authenticate itself via the AuthenticationData message. The protocol is as follows:
// 1. The client sends a DisperseBlobAuthenticated request with the DisperseBlobRequest message
// 2. The Disperser sends back a BlobAuthHeader message containing information for the client to
// verify and sign.
Expand Down
2 changes: 1 addition & 1 deletion api/proto/disperser/v2/disperser_v2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ message BlobCommitmentReply {
message GetPaymentStateRequest {
string account_id = 1;
// Signature over the account ID
// TODO: sign over a bin index or a nonce to mitigate signature replay attacks
// TODO: sign over a reservation period or a nonce to mitigate signature replay attacks
bytes signature = 2;
}

Expand Down
38 changes: 36 additions & 2 deletions contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import {IEigenDAThresholdRegistry} from "../src/interfaces/IEigenDAThresholdRegi
import {IEigenDABatchMetadataStorage} from "../src/interfaces/IEigenDABatchMetadataStorage.sol";
import {IEigenDASignatureVerifier} from "../src/interfaces/IEigenDASignatureVerifier.sol";
import {IEigenDARelayRegistry} from "../src/interfaces/IEigenDARelayRegistry.sol";
import {IPaymentVault} from "../src/interfaces/IPaymentVault.sol";
import {PaymentVault} from "../src/payments/PaymentVault.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";
import "forge-std/Test.sol";
import "forge-std/Script.sol";
Expand All @@ -49,6 +50,7 @@ contract EigenDADeployer is DeployOpenEigenLayer {
IStakeRegistry public stakeRegistry;
ISocketRegistry public socketRegistry;
OperatorStateRetriever public operatorStateRetriever;
IPaymentVault public paymentVault;
EigenDARelayRegistry public eigenDARelayRegistry;

BLSApkRegistry public apkRegistryImplementation;
Expand All @@ -59,6 +61,14 @@ contract EigenDADeployer is DeployOpenEigenLayer {
EigenDAThresholdRegistry public eigenDAThresholdRegistryImplementation;
EigenDARelayRegistry public eigenDARelayRegistryImplementation;
ISocketRegistry public socketRegistryImplementation;
IPaymentVault public paymentVaultImplementation;

uint64 _minNumSymbols = 4096;
uint64 _pricePerSymbol = 0.4470 gwei;
uint64 _priceUpdateCooldown = 1;
uint64 _globalSymbolsPerPeriod = 131072;
uint64 _reservationPeriodInterval = 300;
uint64 _globalRatePeriodInterval = 30;

struct AddressConfig {
address eigenLayerCommunityMultisig;
Expand Down Expand Up @@ -135,6 +145,29 @@ contract EigenDADeployer is DeployOpenEigenLayer {
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

{
paymentVault = IPaymentVault(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

paymentVaultImplementation = new PaymentVault();

eigenDAProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(paymentVault))),
address(paymentVaultImplementation),
abi.encodeWithSelector(
PaymentVault.initialize.selector,
addressConfig.eigenDACommunityMultisig,
_minNumSymbols,
_pricePerSymbol,
_priceUpdateCooldown,
_globalSymbolsPerPeriod,
_reservationPeriodInterval,
_globalRatePeriodInterval
)
);
}

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

address[] memory confirmers = new address[](1);
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/core/EigenDABlobVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ contract EigenDABlobVerifier is IEigenDABlobVerifier {
return EigenDABlobVerificationUtils._getNonSignerStakesAndSignature(
operatorStateRetriever,
registryCoordinator,
signedBatch.attestation
signedBatch
);
}

Expand Down
Loading

0 comments on commit 2c239d5

Please sign in to comment.