Skip to content

Commit

Permalink
Update core types
Browse files Browse the repository at this point in the history
  • Loading branch information
mooselumph committed Oct 15, 2024
1 parent fa0c9e7 commit 39b52d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
26 changes: 14 additions & 12 deletions core/v2/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func TestMain(m *testing.M) {
// makeTestComponents makes a prover and verifier currently using the only supported backend.
func makeTestComponents() (encoding.Prover, encoding.Verifier, error) {
config := &kzg.KzgConfig{
G1Path: "../inabox/resources/kzg/g1.point.300000",
G2Path: "../inabox/resources/kzg/g2.point.300000",
CacheDir: "../inabox/resources/kzg/SRSTables",
G1Path: "../../inabox/resources/kzg/g1.point.300000",
G2Path: "../../inabox/resources/kzg/g2.point.300000",
CacheDir: "../../inabox/resources/kzg/SRSTables",
SRSOrder: 8192,
SRSNumberToLoad: 8192,
NumWorker: uint64(runtime.GOMAXPROCS(0)),
Expand All @@ -85,7 +85,7 @@ func makeTestComponents() (encoding.Prover, encoding.Verifier, error) {
return p, v, nil
}

func makeTestBlob(t *testing.T, p encoding.Prover, version uint8, refBlockNumber uint64, length int, quorums []corev2.QuorumID) (corev2.BlobHeader, []byte) {
func makeTestBlob(t *testing.T, p encoding.Prover, version uint8, refBlockNumber uint64, length int, quorums []corev2.QuorumID) (corev2.BlobCertificate, []byte) {

data := make([]byte, length*31)
_, err := rand.Read(data)

Check failure on line 91 in core/v2/core_test.go

View workflow job for this annotation

GitHub Actions / Linter

SA1019: rand.Read has been deprecated since Go 1.20 because it shouldn't be used: For almost all use cases, crypto/rand.Read is more appropriate. (staticcheck)
Expand All @@ -100,10 +100,12 @@ func makeTestBlob(t *testing.T, p encoding.Prover, version uint8, refBlockNumber
t.Fatal(err)
}

header := corev2.BlobHeader{
Version: version,
QuorumNumbers: quorums,
BlobCommitments: commitments,
header := corev2.BlobCertificate{
BlobHeader: corev2.BlobHeader{
Version: version,
QuorumNumbers: quorums,
BlobCommitments: commitments,
},
ReferenceBlockNumber: refBlockNumber,
}

Expand All @@ -113,7 +115,7 @@ func makeTestBlob(t *testing.T, p encoding.Prover, version uint8, refBlockNumber

// prepareBatch takes in multiple blob, encodes them, generates the associated assignments, and the batch header.
// These are the products that a disperser will need in order to disperse data to the DA nodes.
func prepareBlobs(t *testing.T, operatorCount uint, headers []corev2.BlobHeader, blobs [][]byte) (map[corev2.OperatorID][]*corev2.BlobShard, chainio.IndexedChainState) {
func prepareBlobs(t *testing.T, operatorCount uint, headers []corev2.BlobCertificate, blobs [][]byte) (map[corev2.OperatorID][]*corev2.BlobShard, chainio.IndexedChainState) {

cst, err := mock.MakeChainDataMock(map[uint8]int{
0: int(operatorCount),
Expand Down Expand Up @@ -176,8 +178,8 @@ func prepareBlobs(t *testing.T, operatorCount uint, headers []corev2.BlobHeader,
}
if len(inverseMap[operatorID]) < blobIndex+1 {
inverseMap[operatorID] = append(inverseMap[operatorID], &corev2.BlobShard{
BlobHeader: headers[blobIndex],
Chunks: make(map[corev2.QuorumID][]*encoding.Frame),
BlobCertificate: headers[blobIndex],
Chunks: make(map[corev2.QuorumID][]*encoding.Frame),
})
}
if len(frames) == 0 {
Expand Down Expand Up @@ -244,7 +246,7 @@ func TestValidationSucceeds(t *testing.T) {
for _, operatorCount := range operatorCounts {

// batch can only be tested per operatorCount, because the assignment would be wrong otherwise
headers := make([]corev2.BlobHeader, 0)
headers := make([]corev2.BlobCertificate, 0)
blobs := make([][]byte, 0)
for _, blobLength := range blobLengths {
for i := 0; i < numBlob; i++ {
Expand Down
21 changes: 14 additions & 7 deletions core/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ type BlobHeader struct {
// QuorumInfos contains the quorum specific parameters for the blob
QuorumNumbers []uint8

// ReferenceBlockNumber is the block number of the block at which the operator state will be referenced
ReferenceBlockNumber uint64
// PaymentHeader contains the payment information for the blob
PaymentHeader

// AuthenticationData is the signature of the blob header by the account ID
AuthenticationData []byte `json:"authentication_data"`
}

func (b *BlobHeader) GetEncodingParams() (encoding.EncodingParams, error) {
Expand All @@ -61,19 +64,23 @@ func (b *BlobHeader) GetEncodingParams() (encoding.EncodingParams, error) {
}

type PaymentHeader struct {
// BlobKey is the hash of the blob header
BlobKey [32]byte

// AccountID is the account that is paying for the blob to be stored. AccountID is hexadecimal representation of the ECDSA public key
AccountID string

// Cumulative Payment
CumulativePayment uint64

BinIndex uint64
}

// AuthenticationData is the signature of the blob header by the account ID
AuthenticationData []byte `json:"authentication_data"`
type BlobCertificate struct {
BlobHeader

// ReferenceBlockNumber is the block number of the block at which the operator state will be referenced
ReferenceBlockNumber uint64

// RelayKeys
RelayKeys []uint16
}

type BlobVersionParameters struct {
Expand Down
2 changes: 1 addition & 1 deletion core/v2/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
)

type BlobShard struct {
BlobHeader
BlobCertificate
Chunks map[QuorumID][]*encoding.Frame
}

Expand Down

0 comments on commit 39b52d2

Please sign in to comment.