From da53b3d4feb297d149f2d1388640ea942d404f69 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 2 Oct 2024 11:27:00 -0400 Subject: [PATCH 1/2] Redundant write on EigenDA failure --- store/manager.go | 13 +++++++++++++ store/secondary.go | 20 +++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/store/manager.go b/store/manager.go index 93721d89..75e171de 100644 --- a/store/manager.go +++ b/store/manager.go @@ -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" ) @@ -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 } diff --git a/store/secondary.go b/store/secondary.go index 9814095c..2b42aa3a 100644 --- a/store/secondary.go +++ b/store/secondary.go @@ -1,6 +1,7 @@ package store import ( + "bytes" "context" "errors" "net/http" @@ -8,8 +9,10 @@ import ( "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" ) @@ -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) @@ -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()) From c0633b576d218fef5f087d57fd4ab66208255a05 Mon Sep 17 00:00:00 2001 From: King Date: Mon, 20 Jan 2025 16:15:39 +0100 Subject: [PATCH 2/2] Typo fix server.go --- server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 10b7e073..d73b1fb4 100644 --- a/server/server.go +++ b/server/server.go @@ -116,7 +116,7 @@ func (svr *Server) Port() int { func parseVersionByte(w http.ResponseWriter, r *http.Request) (byte, error) { vars := mux.Vars(r) // only GET routes use gorilla parsed vars to separate header bytes from the raw commitment bytes. - // POST routes parse them by hand because they neeed to send the entire + // POST routes parse them by hand because they need to send the entire // request (including the type/version header bytes) to the server. // TODO: perhaps for consistency we should also use gorilla vars for POST routes, // and then just reconstruct the full commitment in the handlers?