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 committed Oct 2, 2024
1 parent 24c4715 commit efb3828
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(key, &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 efb3828

Please sign in to comment.