Commit a9c7f349 authored by Karl Bartel's avatar Karl Bartel Committed by GitHub

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.
parent 8be15505
......@@ -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)
......
......@@ -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
}
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment