Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ run:
timeout: 5m

linters:
enable:
- protogetter # reports direct reads from proto message fields when getters should be used.
# Right now revive raises 50+ issues, whereas golint didn't have any.
# despite revive being recommended as a replacement for golint.
# TODO: should we turn on revive and fix the issues?
# enable:
# - revive # drop-in replacement for golint
exclusions:
rules:
Expand Down
8 changes: 4 additions & 4 deletions api/clients/disperser_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ func (c *disperserClient) DisperseBlobAuthenticated(ctx context.Context, data []
if err != nil {
return nil, nil, fmt.Errorf("error while receiving: %w", err)
}
authHeaderReply, ok := reply.Payload.(*disperser_rpc.AuthenticatedReply_BlobAuthHeader)
authHeaderReply, ok := reply.GetPayload().(*disperser_rpc.AuthenticatedReply_BlobAuthHeader)
if !ok {
return nil, nil, api.NewErrorInternal(fmt.Sprintf("client expected challenge from disperser, instead received: %v", reply))
}

authHeader := core.BlobAuthHeader{
BlobCommitments: encoding.BlobCommitments{},
AccountID: "",
Nonce: authHeaderReply.BlobAuthHeader.ChallengeParameter,
Nonce: authHeaderReply.BlobAuthHeader.GetChallengeParameter(),
}
authData, err := c.signer.SignBlobRequest(authHeader)
if err != nil {
Expand All @@ -271,7 +271,7 @@ func (c *disperserClient) DisperseBlobAuthenticated(ctx context.Context, data []
if err != nil {
return nil, nil, fmt.Errorf("error while receiving final reply: %w", err)
}
disperseReply, ok := reply.Payload.(*disperser_rpc.AuthenticatedReply_DisperseReply) // Process the final disperse_reply
disperseReply, ok := reply.GetPayload().(*disperser_rpc.AuthenticatedReply_DisperseReply) // Process the final disperse_reply
if !ok {
return nil, nil, api.NewErrorInternal(fmt.Sprintf("client expected DisperseReply from disperser, instead received: %v", reply))
}
Expand Down Expand Up @@ -321,7 +321,7 @@ func (c *disperserClient) RetrieveBlob(ctx context.Context, batchHeaderHash []by
if err != nil {
return nil, err
}
return reply.Data, nil
return reply.GetData(), nil
}

// initOnceGrpcConnection initializes the grpc connection and client if they are not already initialized.
Expand Down
14 changes: 7 additions & 7 deletions api/clients/eigenda_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ func (m *EigenDAClient) putBlob(ctxFinality context.Context, rawData []byte, res
m.Log.Warn("Unable to retrieve blob dispersal status, will retry", "requestID", base64RequestID, "err", err)
continue
}
latestBlobStatus = statusRes.Status
switch statusRes.Status {
latestBlobStatus = statusRes.GetStatus()
switch statusRes.GetStatus() {
case grpcdisperser.BlobStatus_PROCESSING, grpcdisperser.BlobStatus_DISPERSING:
// to prevent log clutter, we only log at info level once
if alreadyWaitingForDispersal {
Expand Down Expand Up @@ -338,14 +338,14 @@ func (m *EigenDAClient) putBlob(ctxFinality context.Context, rawData []byte, res
alreadyWaitingForConfirmationOrFinality = true
}
} else {
batchId := statusRes.Info.BlobVerificationProof.GetBatchId()
batchId := statusRes.GetInfo().GetBlobVerificationProof().GetBatchId()
batchConfirmed, err := m.batchIdConfirmedAtDepth(ctxFinality, batchId, m.Config.WaitForConfirmationDepth)
if err != nil {
m.Log.Warn("Error checking if batch ID is confirmed at depth. Will retry...", "requestID", base64RequestID, "err", err)
}
if batchConfirmed {
m.Log.Info("EigenDA blob confirmed", "requestID", base64RequestID, "confirmationDepth", m.Config.WaitForConfirmationDepth)
resultChan <- statusRes.Info
resultChan <- statusRes.GetInfo()
return
}
// to prevent log clutter, we only log at info level once
Expand All @@ -357,15 +357,15 @@ func (m *EigenDAClient) putBlob(ctxFinality context.Context, rawData []byte, res
}
}
case grpcdisperser.BlobStatus_FINALIZED:
batchHeaderHashHex := fmt.Sprintf("0x%s", hex.EncodeToString(statusRes.Info.BlobVerificationProof.BatchMetadata.BatchHeaderHash))
batchHeaderHashHex := fmt.Sprintf("0x%s", hex.EncodeToString(statusRes.GetInfo().GetBlobVerificationProof().GetBatchMetadata().GetBatchHeaderHash()))
m.Log.Info("EigenDA blob finalized", "requestID", base64RequestID, "batchHeaderHash", batchHeaderHashHex)
resultChan <- statusRes.Info
resultChan <- statusRes.GetInfo()
return
default:
// This should never happen. If it does, the blob is in a heisenberg state... it could either eventually get confirmed or fail.
// However, this doesn't mean there's a major outage with EigenDA, so we return a 500 error to let the caller redisperse the blob,
// rather than an api.ErrorFailover to failover to EthDA.
errChan <- api.NewErrorInternal(fmt.Sprintf("unknown reply status %d. ask for assistance from EigenDA team, using requestID %s", statusRes.Status, base64RequestID))
errChan <- api.NewErrorInternal(fmt.Sprintf("unknown reply status %d. ask for assistance from EigenDA team, using requestID %s", statusRes.GetStatus(), base64RequestID))
return
}
}
Expand Down
10 changes: 5 additions & 5 deletions api/clients/eigenda_client_e2e_live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func TestClientUsingTestnet(t *testing.T) {
testData := "hello world!"
blobInfo, err := client.PutBlob(context.Background(), []byte(testData))
assert.NoError(t, err)
batchHeaderHash := blobInfo.BlobVerificationProof.BatchMetadata.BatchHeaderHash
blobIndex := blobInfo.BlobVerificationProof.BlobIndex
batchHeaderHash := blobInfo.GetBlobVerificationProof().GetBatchMetadata().GetBatchHeaderHash()
blobIndex := blobInfo.GetBlobVerificationProof().GetBlobIndex()
blob, err := client.GetBlob(context.Background(), batchHeaderHash, blobIndex)
assert.NoError(t, err)
assert.Equal(t, testData, string(blob))
Expand Down Expand Up @@ -90,8 +90,8 @@ func TestClientUsingTestnet(t *testing.T) {
assert.NoError(t, err)
blobInfo, err := client.PutBlob(context.Background(), []byte(data))
assert.NoError(t, err)
batchHeaderHash := blobInfo.BlobVerificationProof.BatchMetadata.BatchHeaderHash
blobIndex := blobInfo.BlobVerificationProof.BlobIndex
batchHeaderHash := blobInfo.GetBlobVerificationProof().GetBatchMetadata().GetBatchHeaderHash()
blobIndex := blobInfo.GetBlobVerificationProof().GetBlobIndex()
blob, err := client.GetBlob(context.Background(), batchHeaderHash, blobIndex)
assert.NoError(t, err)
assert.Equal(t, data, string(blob))
Expand All @@ -101,7 +101,7 @@ func TestClientUsingTestnet(t *testing.T) {
blockNumCur, err := client.ethClient.BlockNumber(context.Background())
assert.NoError(t, err)
blockNumAtDepth := new(big.Int).SetUint64(blockNumCur - confDepth)
batchId := blobInfo.BlobVerificationProof.GetBatchId()
batchId := blobInfo.GetBlobVerificationProof().GetBatchId()
onchainBatchMetadataHash, err := client.edasmCaller.BatchIdToBatchMetadataHash(&bind.CallOpts{BlockNumber: blockNumAtDepth}, batchId)
assert.NoError(t, err)
assert.NotEqual(t, onchainBatchMetadataHash, make([]byte, 32))
Expand Down
4 changes: 2 additions & 2 deletions api/clients/mock/disperser_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (c *MockDisperserClient) GetBlobStatus(ctx context.Context, key []byte) (*d
var reply *disperser_rpc.BlobStatusReply
if args.Get(0) != nil {
reply = (args.Get(0)).(*disperser_rpc.BlobStatusReply)
if reply.Status == disperser_rpc.BlobStatus_FINALIZED {
retrievalKey := fmt.Sprintf("%s-%d", base64.StdEncoding.EncodeToString(reply.Info.BlobVerificationProof.BatchMetadata.BatchHeaderHash), reply.Info.BlobVerificationProof.BlobIndex)
if reply.GetStatus() == disperser_rpc.BlobStatus_FINALIZED {
retrievalKey := fmt.Sprintf("%s-%d", base64.StdEncoding.EncodeToString(reply.GetInfo().GetBlobVerificationProof().GetBatchMetadata().GetBatchHeaderHash()), reply.GetInfo().GetBlobVerificationProof().GetBlobIndex())
requestIDKey := base64.StdEncoding.EncodeToString(key)
c.mockRetrievalStore[retrievalKey] = c.mockRequestIDStore[requestIDKey]
}
Expand Down
4 changes: 2 additions & 2 deletions api/clients/v2/accountant.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ func (a *Accountant) SetPaymentState(paymentState *disperser_rpc.GetPaymentState
periodRecords[i] = PeriodRecord{Index: 0, Usage: 0}
} else {
periodRecords[i] = PeriodRecord{
Index: record.Index,
Usage: record.Usage,
Index: record.GetIndex(),
Usage: record.GetUsage(),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions api/clients/v2/coretypes/conversion_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func BatchHeaderProtoToIEigenDATypesBinding(inputHeader *commonv2.BatchHeader) (
}

func attestationProtoToBinding(inputAttestation *disperserv2.Attestation) (*contractEigenDACertVerifier.EigenDATypesV2Attestation, error) {
if len(inputAttestation.QuorumApks) != len(inputAttestation.QuorumNumbers) {
if len(inputAttestation.GetQuorumApks()) != len(inputAttestation.GetQuorumNumbers()) {
return nil, fmt.Errorf(
"quorum apks and quorum numbers must have the same length (apks: %d, numbers: %d)",
len(inputAttestation.QuorumApks),
len(inputAttestation.QuorumNumbers))
len(inputAttestation.GetQuorumApks()),
len(inputAttestation.GetQuorumNumbers()))
}
nonSignerPubkeys, err := repeatedBytesToBN254G1Points(inputAttestation.GetNonSignerPubkeys())
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/clients/v2/dispersal_request_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestRequestSigning(t *testing.T) {
signature, err := signer.SignStoreChunksRequest(context.Background(), request)
require.NoError(t, err)

require.Nil(t, request.Signature)
require.Nil(t, request.GetSignature())
request.Signature = signature
hash, err := auth.VerifyStoreChunksRequest(publicAddress, request)
require.NoError(t, err)
Expand All @@ -126,7 +126,7 @@ func TestRequestSigning(t *testing.T) {
require.Nil(t, hash)

// Changing a byte in the middle of the request should make the verification fail
request.DisperserID = request.DisperserID + 1
request.DisperserID = request.GetDisperserID() + 1
request.Signature = signature
hash, err = auth.VerifyStoreChunksRequest(publicAddress, request)
require.Error(t, err)
Expand Down
6 changes: 3 additions & 3 deletions api/clients/v2/payloaddispersal/payload_disperser.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ func (pd *PayloadDisperser) SendPayload(
// generic function or helper to enhance DRY
timeoutCtx, cancel = context.WithTimeout(ctx, pd.config.ContractCallTimeout)
defer cancel()
err = pd.blockMonitor.WaitForBlockNumber(timeoutCtx, blobStatusReply.SignedBatch.Header.ReferenceBlockNumber)
err = pd.blockMonitor.WaitForBlockNumber(timeoutCtx, blobStatusReply.GetSignedBatch().GetHeader().GetReferenceBlockNumber())
if err != nil {
return nil, fmt.Errorf("wait for block number: %w", err)
}

certVersion, err := pd.certVerifier.GetCertVersion(ctx, blobStatusReply.SignedBatch.Header.ReferenceBlockNumber)
certVersion, err := pd.certVerifier.GetCertVersion(ctx, blobStatusReply.GetSignedBatch().GetHeader().GetReferenceBlockNumber())
if err != nil {
return nil, fmt.Errorf("get certificate version: %w", err)
}
Expand Down Expand Up @@ -251,7 +251,7 @@ func (pd *PayloadDisperser) pollBlobStatusUntilSigned(
continue
}

newStatus := blobStatusReply.Status
newStatus := blobStatusReply.GetStatus()
if newStatus != previousStatus {
pd.logger.Debug(
"Blob status changed",
Expand Down
12 changes: 6 additions & 6 deletions api/clients/v2/validator/validator_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func TestBasicWorkflow(t *testing.T) {
verificationSet.Store(operatorID, struct{}{})

// make sure the chunks are the ones we expect for this operator
require.Equal(t, len(chunks), len(getChunksReply.Chunks))
for i, chunk := range getChunksReply.Chunks {
require.Equal(t, len(chunks), len(getChunksReply.GetChunks()))
for i, chunk := range getChunksReply.GetChunks() {
require.Equal(t, chunks[i], chunk)
}

Expand Down Expand Up @@ -396,8 +396,8 @@ func TestDownloadTimeout(t *testing.T) {
verificationSet.Store(operatorID, struct{}{})

// make sure the chunks are the ones we expect for this operator
require.Equal(t, len(chunks), len(getChunksReply.Chunks))
for i, chunk := range getChunksReply.Chunks {
require.Equal(t, len(chunks), len(getChunksReply.GetChunks()))
for i, chunk := range getChunksReply.GetChunks() {
require.Equal(t, chunks[i], chunk)
}

Expand Down Expand Up @@ -653,8 +653,8 @@ func TestFailedVerification(t *testing.T) {
verificationSet.Store(operatorID, struct{}{})

// make sure the chunks are the ones we expect for this operator
require.Equal(t, len(chunks), len(getChunksReply.Chunks))
for i, chunk := range getChunksReply.Chunks {
require.Equal(t, len(chunks), len(getChunksReply.GetChunks()))
for i, chunk := range getChunksReply.GetChunks() {
require.Equal(t, chunks[i], chunk)
}

Expand Down
38 changes: 19 additions & 19 deletions api/proxy/store/generated_key/eigenda/verify/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func (c *Certificate) NoNilFields() error {
return fmt.Errorf("BlobVerificationProof is nil")
}

if c.BlobVerificationProof.BatchMetadata == nil {
if c.BlobVerificationProof.GetBatchMetadata() == nil {
return fmt.Errorf("BlobVerificationProof.BatchMetadata is nil")
}

if c.BlobVerificationProof.BatchMetadata.BatchHeader == nil {
if c.BlobVerificationProof.GetBatchMetadata().GetBatchHeader() == nil {
return fmt.Errorf("BlobVerificationProof.BatchMetadata.BatchHeader is nil")
}

if c.BlobHeader == nil {
return fmt.Errorf("BlobHeader is nil")
}

if c.BlobHeader.Commitment == nil {
if c.BlobHeader.GetCommitment() == nil {
return fmt.Errorf("BlobHeader.Commitment is nil")
}

Expand All @@ -69,62 +69,62 @@ func (c *Certificate) ValidFieldLengths() error {

// 1.a necessary since only first 32 bytes of header hash are checked
// in verification equivalence check which could allow data padding at end
if hashLen := len(bvp.BatchMetadata.BatchHeaderHash); hashLen != 32 {
if hashLen := len(bvp.GetBatchMetadata().GetBatchHeaderHash()); hashLen != 32 {
return fmt.Errorf("BlobVerification.BatchMetadata.BatchHeaderHash is not 32 bytes, got %d", hashLen)
}

// 1.b necessary since commitment verification parses the byte field byte arrays
// into a field element representation which disregards 0x0 padded bytes
if xLen := len(bh.Commitment.X); xLen != 32 {
if xLen := len(bh.GetCommitment().GetX()); xLen != 32 {
return fmt.Errorf("BlobHeader.Commitment.X is not 32 bytes, got %d", xLen)
}

if yLen := len(bh.Commitment.Y); yLen != 32 {
if yLen := len(bh.GetCommitment().GetY()); yLen != 32 {
return fmt.Errorf("BlobHeader.Commitment.Y is not 32 bytes, got %d", yLen)
}

// 2 - unnecessary but preemptive checks that would trigger failure in downstream
// verification since these values are used as input for batch metadata hash
// recomputation. Capturing here is more efficient!

if hashLen := len(bvp.BatchMetadata.SignatoryRecordHash); hashLen != 32 {
if hashLen := len(bvp.GetBatchMetadata().GetSignatoryRecordHash()); hashLen != 32 {
return fmt.Errorf("BlobVerification.BatchMetadata.SignatoryRecordHash is not 32 bytes, got %d", hashLen)
}

if hashLen := len(bvp.BatchMetadata.BatchHeader.BatchRoot); hashLen != 32 {
if hashLen := len(bvp.GetBatchMetadata().GetBatchHeader().GetBatchRoot()); hashLen != 32 {
return fmt.Errorf("BlobVerification.BatchMetadata.BatchHeader.BatchRoot is not 32 bytes, got %d", hashLen)
}

return nil
}

func (c *Certificate) BlobIndex() uint32 {
return c.BlobVerificationProof.BlobIndex
return c.BlobVerificationProof.GetBlobIndex()
}

func (c *Certificate) BatchHeaderRoot() []byte {
return c.BlobVerificationProof.BatchMetadata.BatchHeader.BatchRoot
return c.BlobVerificationProof.GetBatchMetadata().GetBatchHeader().GetBatchRoot()
}

func (c *Certificate) ReadBlobHeader() BlobHeader {
// parse quorum params

qps := make([]QuorumBlobParam, len(c.BlobHeader.BlobQuorumParams))
for i, qp := range c.BlobHeader.BlobQuorumParams {
qps := make([]QuorumBlobParam, len(c.BlobHeader.GetBlobQuorumParams()))
for i, qp := range c.BlobHeader.GetBlobQuorumParams() {
qps[i] = QuorumBlobParam{
QuorumNumber: uint8(qp.QuorumNumber), // #nosec G115
AdversaryThresholdPercentage: uint8(qp.AdversaryThresholdPercentage), // #nosec G115
ConfirmationThresholdPercentage: uint8(qp.ConfirmationThresholdPercentage), // #nosec G115
ChunkLength: qp.ChunkLength,
QuorumNumber: uint8(qp.GetQuorumNumber()), // #nosec G115
AdversaryThresholdPercentage: uint8(qp.GetAdversaryThresholdPercentage()), // #nosec G115
ConfirmationThresholdPercentage: uint8(qp.GetConfirmationThresholdPercentage()), // #nosec G115
ChunkLength: qp.GetChunkLength(),
}
}

return BlobHeader{
Commitment: G1Point{
X: new(big.Int).SetBytes(c.BlobHeader.Commitment.X),
Y: new(big.Int).SetBytes(c.BlobHeader.Commitment.Y),
X: new(big.Int).SetBytes(c.BlobHeader.GetCommitment().GetX()),
Y: new(big.Int).SetBytes(c.BlobHeader.GetCommitment().GetY()),
},
DataLength: c.BlobHeader.DataLength,
DataLength: c.BlobHeader.GetDataLength(),
QuorumBlobParams: qps,
}
}
Expand Down
12 changes: 6 additions & 6 deletions api/proxy/store/generated_key/eigenda/verify/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ func (v *Verifier) VerifyCommitment(certCommitment *grpccommon.G1Commitment, blo
}

certCommitmentX := &fp.Element{}
certCommitmentX.Unmarshal(certCommitment.X)
certCommitmentX.Unmarshal(certCommitment.GetX())
certCommitmentY := &fp.Element{}
certCommitmentY.Unmarshal(certCommitment.Y)
certCommitmentY.Unmarshal(certCommitment.GetY())

certCommitmentAffine := bn254.G1Affine{
X: *certCommitmentX,
Expand Down Expand Up @@ -191,10 +191,10 @@ func (v *Verifier) verifySecurityParams(blobHeader BlobHeader, batchHeader *disp

// require that the security param in each blob is met
for i := 0; i < len(blobHeader.QuorumBlobParams); i++ {
if batchHeader.QuorumNumbers[i] != blobHeader.QuorumBlobParams[i].QuorumNumber {
if batchHeader.GetQuorumNumbers()[i] != blobHeader.QuorumBlobParams[i].QuorumNumber {
return fmt.Errorf(
"quorum number mismatch, expected: %d, got: %d",
batchHeader.QuorumNumbers[i],
batchHeader.GetQuorumNumbers()[i],
blobHeader.QuorumBlobParams[i].QuorumNumber)
}

Expand All @@ -218,7 +218,7 @@ func (v *Verifier) verifySecurityParams(blobHeader BlobHeader, batchHeader *disp
return fmt.Errorf("adversary threshold percentage must be >= quorum adversary threshold percentage")
}

if batchHeader.QuorumSignedPercentages[i] < blobHeader.QuorumBlobParams[i].ConfirmationThresholdPercentage {
if batchHeader.GetQuorumSignedPercentages()[i] < blobHeader.QuorumBlobParams[i].ConfirmationThresholdPercentage {
return fmt.Errorf(
"signed stake for quorum must be >= to confirmation threshold percentage",
)
Expand All @@ -228,7 +228,7 @@ func (v *Verifier) verifySecurityParams(blobHeader BlobHeader, batchHeader *disp
}

// ensure that required quorums are present in the confirmed ones
for _, quorum := range requiredQuorum(batchHeader.ReferenceBlockNumber, v) {
for _, quorum := range requiredQuorum(batchHeader.GetReferenceBlockNumber(), v) {
if !confirmedQuorums[quorum] {
return fmt.Errorf("quorum %d is required but not present in confirmed quorums", quorum)
}
Expand Down
2 changes: 1 addition & 1 deletion api/proxy/store/generated_key/memstore/memstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (e *MemStore) generateRandomCert(blobValue []byte) (*verify.Certificate, er
// this is necessary since EigenDA x Arbitrum reconstructs
// the batch header hash before querying proxy since hash field
// isn't persisted via the onchain cert posted to the inbox
bh := cert.BlobVerificationProof.BatchMetadata.BatchHeader
bh := cert.BlobVerificationProof.GetBatchMetadata().GetBatchHeader()

reducedHeader := core.BatchHeader{
BatchRoot: [32]byte(bh.GetBatchRoot()),
Expand Down
Loading
Loading