Skip to content

Commit

Permalink
Use DA /put path from spec (#12081)
Browse files Browse the repository at this point in the history
* Accept /put path as described in spec

In addition to the currently used `/put/` path to ease the migration.
See #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 #11499.
  • Loading branch information
karlb authored Sep 27, 2024
1 parent 8be1550 commit a9c7f34
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion op-alt-da/daclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion op-alt-da/damock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion op-alt-da/daserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a9c7f34

Please sign in to comment.