Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant write on EigenDA failure #242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions store/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/Layr-Labs/eigenda-proxy/commitments"
"github.com/Layr-Labs/eigenda-proxy/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
)

Expand Down Expand Up @@ -124,6 +125,18 @@ func (m *Manager) Put(ctx context.Context, cm commitments.CommitmentMode, key, v
}

if err != nil {
log.Error("Failed to write to EigenDA backend", "err", err)
// write to EigenDA failed, which shouldn't happen if the backend is functioning properly
// use the payload as the key to avoid data loss
if m.secondary.Enabled() && !m.secondary.AsyncWriteEntry() {
redundantErr := m.secondary.HandleRedundantWrites(ctx, value, value)
if redundantErr != nil {
log.Error("Failed to write to redundant backends", "err", redundantErr)
return nil, redundantErr
}

return crypto.Keccak256(value), nil
}
return nil, err
}

Expand Down
20 changes: 19 additions & 1 deletion store/secondary.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package store

import (
"bytes"
"context"
"errors"
"net/http"
"sync"

"github.com/Layr-Labs/eigenda-proxy/common"
"github.com/Layr-Labs/eigenda-proxy/metrics"
verifypackage "github.com/Layr-Labs/eigenda-proxy/verify"
"github.com/ethereum-optimism/optimism/op-service/retry"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"

"github.com/ethereum/go-ethereum/log"
)
Expand Down Expand Up @@ -151,6 +154,14 @@ func (sm *SecondaryManager) MultiSourceRead(ctx context.Context, commitment []by
}

key := crypto.Keccak256(commitment)

// check if key is an RLP encoded certificate, if not, assume it's an s3 key
var cert verifypackage.Certificate
err := rlp.DecodeBytes(commitment, &cert)
if err != nil {
key = commitment
}

for _, src := range sources {
cb := sm.m.RecordSecondaryRequest(src.BackendType().String(), http.MethodGet)
data, err := src.Get(ctx, key)
Expand All @@ -168,7 +179,14 @@ func (sm *SecondaryManager) MultiSourceRead(ctx context.Context, commitment []by

// verify cert:data using provided verification function
sm.verifyLock.Lock()
err = verify(ctx, commitment, data)

if bytes.Equal(key, commitment) {
err = src.Verify(ctx, commitment, data)
} else {
// verify cert:data using EigenDA verification checks
err = verify(ctx, commitment, data)
}

if err != nil {
cb(Failed)
log.Warn("Failed to verify blob", "err", err, "backend", src.BackendType())
Expand Down