Skip to content

Commit

Permalink
Redundant write on EigenDA failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Inkvi authored and Inkvi committed Oct 7, 2024
1 parent 480324a commit 723478e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions store/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"fmt"
"sync"

"github.com/Layr-Labs/eigenda-proxy/verify"
"github.com/ethereum/go-ethereum/rlp"

"github.com/Layr-Labs/eigenda-proxy/commitments"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -130,6 +133,17 @@ func (r *Router) Put(ctx context.Context, cm commitments.CommitmentMode, key, va
}

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 r.cacheEnabled() || r.fallbackEnabled() {
redundantErr := r.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 Expand Up @@ -195,6 +209,14 @@ func (r *Router) multiSourceRead(ctx context.Context, commitment []byte, fallbac
}

key := crypto.Keccak256(commitment)

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

for _, src := range sources {
data, err := src.Get(ctx, key)
if err != nil {
Expand Down

0 comments on commit 723478e

Please sign in to comment.