Skip to content

Commit

Permalink
Stuff left out
Browse files Browse the repository at this point in the history
  • Loading branch information
mooselumph committed Aug 28, 2024
1 parent e07d1d8 commit a4e139a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion core/assignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestOperatorAssignments(t *testing.T) {
assert.Equal(t, assignment, expectedAssignments[operatorID])

header := &core.BlobCertificate{
BlobAuthHeader: core.BlobAuthHeader{
BlobHeader: core.BlobHeader{
BlobCommitments: encoding.BlobCommitments{
Length: blobLength,
},
Expand Down
4 changes: 2 additions & 2 deletions core/auth.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package core

type BlobRequestAuthenticator interface {
AuthenticateBlobRequest(header BlobAuthHeader) error
AuthenticateBlobRequest(header BlobHeader) error
}

type BlobRequestSigner interface {
SignBlobRequest(header BlobAuthHeader) ([]byte, error)
SignBlobRequest(header BlobHeader) ([]byte, error)
GetAccountID() string
}
4 changes: 2 additions & 2 deletions core/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestAuthentication(t *testing.T) {
privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
signer := auth.NewLocalBlobRequestSigner(privateKeyHex)

testHeader := core.BlobAuthHeader{
testHeader := core.BlobHeader{
BlobCommitments: encoding.BlobCommitments{},
AccountID: signer.GetAccountID(),
Nonce: rand.Uint32(),
Expand All @@ -46,7 +46,7 @@ func TestAuthenticationFail(t *testing.T) {
privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
signer := auth.NewLocalBlobRequestSigner(privateKeyHex)

testHeader := core.BlobAuthHeader{
testHeader := core.BlobHeader{
BlobCommitments: encoding.BlobCommitments{},
AccountID: signer.GetAccountID(),
Nonce: rand.Uint32(),
Expand Down
2 changes: 1 addition & 1 deletion core/auth/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewAuthenticator(config AuthConfig) core.BlobRequestAuthenticator {
}
}

func (*authenticator) AuthenticateBlobRequest(header core.BlobAuthHeader) error {
func (*authenticator) AuthenticateBlobRequest(header core.BlobHeader) error {
sig := header.AuthenticationData

// Ensure the signature is 65 bytes (Recovery ID is the last byte)
Expand Down
23 changes: 10 additions & 13 deletions core/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ type Blob struct {
// Signing the combination of the Nonce and the BlobCommitments prohibits the disperser from
// using the signature to charge the user for a different blob or for dispersing the same blob
// multiple times (Replay attack).
type BlobAuthHeader struct {
type BlobHeader struct {
// Commitments
encoding.BlobCommitments `json:"commitments"`
// AccountID is the account that is paying for the blob to be stored. AccountID is hexadecimal representation of the ECDSA public key
Expand All @@ -238,7 +238,7 @@ type BlobAuthHeader struct {
// BlobRequestHeader contains the original data size of a blob and the security required
type BlobRequestHeader struct {
// BlobAuthHeader
BlobAuthHeader `json:"blob_auth_header"`
BlobHeader `json:"blob_auth_header"`
// For a blob to be accepted by EigenDA, it satisfy the AdversaryThreshold of each quorum contained in SecurityParams
SecurityParams []*SecurityParam `json:"security_params"`
}
Expand Down Expand Up @@ -267,17 +267,14 @@ type BlobQuorumInfo struct {
ChunkLength uint
}

// BlobHeader contains all metadata related to a blob including commitments and parameters for encoding
type BlobHeader struct {
encoding.BlobCommitments
// BlobCertificate contains all metadata related to a blob including commitments and parameters for encoding
type BlobCertificate struct {
BlobHeader
// QuorumInfos contains the quorum specific parameters for the blob
QuorumInfos []*BlobQuorumInfo

// AccountID is the account that is paying for the blob to be stored
AccountID AccountID
}

func (b *BlobHeader) GetQuorumInfo(quorum QuorumID) *BlobQuorumInfo {
func (b *BlobCertificate) GetQuorumInfo(quorum QuorumID) *BlobQuorumInfo {
for _, quorumInfo := range b.QuorumInfos {
if quorumInfo.QuorumID == quorum {
return quorumInfo
Expand All @@ -287,7 +284,7 @@ func (b *BlobHeader) GetQuorumInfo(quorum QuorumID) *BlobQuorumInfo {
}

// Returns the total encoded size in bytes of the blob across all quorums.
func (b *BlobHeader) EncodedSizeAllQuorums() int64 {
func (b *BlobCertificate) EncodedSizeAllQuorums() int64 {
size := int64(0)
for _, quorum := range b.QuorumInfos {

Expand All @@ -309,7 +306,7 @@ type BatchHeader struct {

// EncodedBlob contains the messages to be sent to a group of DA nodes corresponding to a single blob
type EncodedBlob struct {
BlobHeader *BlobHeader
BlobHeader *BlobCertificate
BundlesByOperator map[OperatorID]Bundles
// EncodedBundlesByOperator is bundles in encoded format (not deserialized)
EncodedBundlesByOperator map[OperatorID]EncodedBundles
Expand All @@ -326,15 +323,15 @@ type EncodedBundles map[QuorumID]*ChunksData

// BlobMessage is the message that is sent to DA nodes. It contains the blob header and the associated chunk bundles.
type BlobMessage struct {
BlobHeader *BlobHeader
BlobHeader *BlobCertificate
Bundles Bundles
}

// This is similar to BlobMessage, but keep the commitments and chunks in encoded format
// (i.e. not deserialized)
type EncodedBlobMessage struct {
// TODO(jianoaix): Change the commitments to encoded format.
BlobHeader *BlobHeader
BlobHeader *BlobCertificate
EncodedBundles map[QuorumID]*ChunksData
}

Expand Down
6 changes: 3 additions & 3 deletions disperser/batcher/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ type confirmationMetadata struct {
batchID uuid.UUID
batchHeader *core.BatchHeader
blobs []*disperser.BlobMetadata
blobHeaders []*core.BlobHeader
blobHeaders []*core.BlobCertificate
merkleTree *merkletree.MerkleTree
aggSig *core.SignatureAggregation
}
Expand Down Expand Up @@ -626,7 +626,7 @@ func (b *Batcher) getBatchID(ctx context.Context, txReceipt *types.Receipt) (uin
// numBlobsAttestedByQuorum returns two values:
// 1. the number of blobs that have been successfully attested by all quorums
// 2. map[QuorumID]struct{} contains quorums that have been successfully attested by the quorum (has at least one blob attested in the quorum)
func numBlobsAttestedByQuorum(signedQuorums map[core.QuorumID]*core.QuorumResult, headers []*core.BlobHeader) (int, map[core.QuorumID]struct{}) {
func numBlobsAttestedByQuorum(signedQuorums map[core.QuorumID]*core.QuorumResult, headers []*core.BlobCertificate) (int, map[core.QuorumID]struct{}) {
numPassed := 0
quorums := make(map[core.QuorumID]struct{})
for _, blob := range headers {
Expand All @@ -646,7 +646,7 @@ func numBlobsAttestedByQuorum(signedQuorums map[core.QuorumID]*core.QuorumResult
return numPassed, quorums
}

func isBlobAttested(signedQuorums map[core.QuorumID]*core.QuorumResult, header *core.BlobHeader) bool {
func isBlobAttested(signedQuorums map[core.QuorumID]*core.QuorumResult, header *core.BlobCertificate) bool {
for _, quorum := range header.QuorumInfos {
if _, ok := signedQuorums[quorum.QuorumID]; !ok {
return false
Expand Down

0 comments on commit a4e139a

Please sign in to comment.