Skip to content

Commit 712e0ec

Browse files
Merge pull request #687 from OffchainLabs/remove-0x
Remove 0x from restful
2 parents 7c8bba8 + d3c4e60 commit 712e0ec

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

das/restful_client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"net/http"
1414
"strings"
1515

16-
"github.com/ethereum/go-ethereum/common/hexutil"
1716
"github.com/ethereum/go-ethereum/crypto"
1817
"github.com/offchainlabs/nitro/arbstate"
1918
)
@@ -43,7 +42,7 @@ func (c *RestfulDasClient) GetByHash(ctx context.Context, hash []byte) ([]byte,
4342
if len(hash) != 32 {
4443
return nil, fmt.Errorf("Hash must be 32 bytes long, was %d", len(hash))
4544
}
46-
res, err := http.Get(c.url + getByHashRequestPath + hexutil.Encode(hash))
45+
res, err := http.Get(c.url + getByHashRequestPath + EncodeStorageServiceKey(hash))
4746
if err != nil {
4847
return nil, err
4948
}

das/restful_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"net/http"
1313
"strings"
1414

15-
"github.com/ethereum/go-ethereum/common/hexutil"
1615
"github.com/ethereum/go-ethereum/log"
1716
"github.com/offchainlabs/nitro/arbstate"
1817
"github.com/offchainlabs/nitro/util/pretty"
@@ -120,7 +119,7 @@ func (rds *RestfulDasServer) ExpirationPolicyHandler(w http.ResponseWriter, r *h
120119
func (rds *RestfulDasServer) GetByHashHandler(w http.ResponseWriter, r *http.Request, requestPath string) {
121120
log.Debug("Got request", "requestPath", requestPath)
122121

123-
hashBytes, err := hexutil.Decode(strings.TrimPrefix(requestPath, "/get-by-hash/"))
122+
hashBytes, err := DecodeStorageServiceKey(strings.TrimPrefix(requestPath, "/get-by-hash/"))
124123
if err != nil {
125124
log.Warn("Failed to decode hex-encoded hash", "path", requestPath, "err", err)
126125
w.WriteHeader(http.StatusBadRequest)

das/storage_service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"errors"
99
"fmt"
10+
"strings"
1011

1112
"github.com/ethereum/go-ethereum/common/hexutil"
1213
"github.com/offchainlabs/nitro/arbstate"
@@ -28,5 +29,8 @@ func EncodeStorageServiceKey(b []byte) string {
2829
}
2930

3031
func DecodeStorageServiceKey(input string) ([]byte, error) {
32+
if strings.HasPrefix(input, "0x") {
33+
return hexutil.Decode(input)
34+
}
3135
return hexutil.Decode("0x" + input)
3236
}

docs/das/daserver-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
The Data Availability Server, `daserver`, allows storage and retrieval of transaction data batches for Arbitrum AnyTrust chains. It can be run in two modes: either committee member or mirror. Commitee members accept time-limited requests to store data batches from an Arbitrum AnyTrust sequencer, and if they store the data then they return a signed certificate promising to store that data. Commitee members and mirrors both respond to requests to retrieve the data batches. Mirrors exist to replicate and serve the data so that committee members to provide resiliency to the network in the case committee members going down, and to make it so committee members don't need to serve requests for the data directly. The data batches are addressed by a keccak256 hash of their contents. This document gives sample configurations for `daserver` in committee member and mirror mode.
55

66
### Interfaces
7-
There are two interfaces, a REST interface supporting only GET operations and intended for public use, and an RPC interface intended for use only by the AnyTrust sequencer. Mirrors listen on the REST inferface only and respond to queries on `/get-by-hash/0x<hex encoded data hash>`. The response is always the same for a given hash so it is cacheable; it contains a `cache-control` header specifying the object is immutable and to cache for up to 28 days. The REST interface has a health check on `/health` which will return 200 if the underling storage is working, otherwise 503.
7+
There are two interfaces, a REST interface supporting only GET operations and intended for public use, and an RPC interface intended for use only by the AnyTrust sequencer. Mirrors listen on the REST inferface only and respond to queries on `/get-by-hash/<hex encoded data hash>`. The response is always the same for a given hash so it is cacheable; it contains a `cache-control` header specifying the object is immutable and to cache for up to 28 days. The REST interface has a health check on `/health` which will return 200 if the underling storage is working, otherwise 503.
88

99
Committee members listen on the REST interface and additionally listen on the RPC interface for `das_store` RPC messages from the sequencer. The sequencer signs its requests and the committee member checks the signature. The RPC interface also has a health check that checks the underlying storage that responds requests with RPC method `das_healthCheck`.
1010

@@ -341,7 +341,7 @@ Message: Test-Data
341341
342342
Using curl to check the REST endpoint
343343
```
344-
$ curl https://anytrust-devnet.arbitrum.io/da-mirror-0/get-by-hash/0xdac8a9f2bbcca34aecad0af5a43dcb48c94f0755f7cf4d87bc01925eb390b762
344+
$ curl https://anytrust-devnet.arbitrum.io/da-mirror-0/get-by-hash/dac8a9f2bbcca34aecad0af5a43dcb48c94f0755f7cf4d87bc01925eb390b762
345345
{"data":"VGVzdC1EYXRh"}
346346
```
347347

0 commit comments

Comments
 (0)