From a9c7f349d10b136529ab588b4679ec22d6074225 Mon Sep 17 00:00:00 2001 From: Karl Bartel Date: Fri, 27 Sep 2024 04:01:38 +0200 Subject: [PATCH] Use DA /put path from spec (#12081) * Accept /put path as described in spec In addition to the currently used `/put/` path to ease the migration. See https://github.com/ethereum-optimism/optimism/issues/11499. * alt-DA: write to /put path as described in spec The spec mandates using `/put` and not `/put/`, so that is what we should do. Warning: This will break DA solutions that only accept `/put/` at the moment. It is recommended that DA solutions support both paths for a while, so that updating OP-stack can happen independently of the exact DA implementation version. Closes https://github.com/ethereum-optimism/optimism/issues/11499. --- op-alt-da/daclient.go | 2 +- op-alt-da/damock.go | 2 +- op-alt-da/daserver.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/op-alt-da/daclient.go b/op-alt-da/daclient.go index 269b71f3c104..9f0bdab11fbd 100644 --- a/op-alt-da/daclient.go +++ b/op-alt-da/daclient.go @@ -119,7 +119,7 @@ func (c *DAClient) setInput(ctx context.Context, img []byte) (CommitmentData, er } body := bytes.NewReader(img) - url := fmt.Sprintf("%s/put/", c.url) + url := fmt.Sprintf("%s/put", c.url) req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, body) if err != nil { return nil, fmt.Errorf("failed to create HTTP request: %w", err) diff --git a/op-alt-da/damock.go b/op-alt-da/damock.go index 0db129171a82..ad388d0b2653 100644 --- a/op-alt-da/damock.go +++ b/op-alt-da/damock.go @@ -141,7 +141,7 @@ func (s *FakeDAServer) Start() error { // Override the HandleGet/Put method registrations mux := http.NewServeMux() mux.HandleFunc("/get/", s.HandleGet) - mux.HandleFunc("/put/", s.HandlePut) + mux.HandleFunc("/put", s.HandlePut) s.httpServer.Handler = mux return nil } diff --git a/op-alt-da/daserver.go b/op-alt-da/daserver.go index 94446944b543..ccdc2a0cb4d3 100644 --- a/op-alt-da/daserver.go +++ b/op-alt-da/daserver.go @@ -54,6 +54,7 @@ func (d *DAServer) Start() error { mux.HandleFunc("/get/", d.HandleGet) mux.HandleFunc("/put/", d.HandlePut) + mux.HandleFunc("/put", d.HandlePut) d.httpServer.Handler = mux @@ -128,7 +129,7 @@ func (d *DAServer) HandlePut(w http.ResponseWriter, r *http.Request) { d.log.Info("PUT", "url", r.URL) route := path.Dir(r.URL.Path) - if route != "/put" { + if route != "/put" && r.URL.Path != "/put" { w.WriteHeader(http.StatusBadRequest) return }