Skip to content

Commit b87dc85

Browse files
pepyakinrphmeier
authored andcommitted
chore: README and rollkit adapter docs
You can check the updated docs by running `go doc` or `godoc` in the adapter/rollkit directory.
1 parent 3114fb9 commit b87dc85

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sugondat
22

3-
Project structure:
3+
## Project Structure
44

55
<pre>
66
<a href=".">sugondat</a>: The sugondat monorepo.
@@ -15,7 +15,7 @@ Project structure:
1515
├──<a href="./sugondat-subxt">sugondat-subxt</a>: Bindings to Sugondat RPC.
1616
</pre>
1717

18-
## Running demos
18+
## Running Demos
1919

2020
### Prerequisites
2121

adapters/rollkit/sugondat.go

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
// Rollkit DA layer client for Sugondat.
2+
//
3+
// This adapter implements the `DataAvailabilityLayerClient` and `BlockRetriever` interfaces. It
4+
// connects to a running sugondat-shim RPC server and uses it to submit and retrieve blocks.
5+
//
6+
// The intended usage is to add this module to your application and call `Register()`. This will
7+
// make the sugondat adapter available to Rollkit.
8+
//
9+
// To start your rollkit rollup with this adapter, you will need to run your blockchain with the
10+
// following arguments (assuming `gmd`).
11+
//
12+
// ```
13+
//
14+
// gmd \
15+
// --rollkit.da_layer sugondat
16+
// --rollkit.da_config='{"base_url":"http://localhost:10995","namespace":"0102030405060708"}'
17+
//
18+
// ```
119
package sugondat
220

321
import (
@@ -12,12 +30,15 @@ import (
1230
"github.com/rollkit/rollkit/types"
1331
)
1432

33+
// A data package that contains the rollup specific data.
1534
type Blob struct {
16-
Data []byte `json:"data"`
35+
Data []byte `json:"data"` // base64 encoded blob data.
1736
}
1837

38+
// Declaration of JSON-RPC API for sugondat-shim.
1939
type SugondatAPI struct {
2040
// Retrieves the blobs at the given height from the data availability layer at the given namespace.
41+
// Returns the blobs.
2142
Retrieve func(string, uint64) ([]*Blob, error)
2243
// Submits the given blobs to the data availability layer at the given namespace.
2344
// Returns the height of the block that contains the blobs.
@@ -29,6 +50,7 @@ type RpcClient struct {
2950
api SugondatAPI
3051
}
3152

53+
// Main adapter struct.
3254
type DataAvailabilityLayerClient struct {
3355
logger log.Logger
3456
config Config
@@ -38,11 +60,14 @@ type DataAvailabilityLayerClient struct {
3860
var _ da.DataAvailabilityLayerClient = &DataAvailabilityLayerClient{}
3961
var _ da.BlockRetriever = &DataAvailabilityLayerClient{}
4062

63+
// Configuration of the Sugondat adapter.
4164
type Config struct {
42-
BaseURL string `json:"base_url"`
43-
Namespace string `json:"namespace"`
65+
BaseURL string `json:"base_url"` // The base URL of the sugondat-shim RPC server.
66+
Namespace string `json:"namespace"` // HEX encoded namespace ID. Cannot be empty.
4467
}
4568

69+
// Register the `sugondat` adapter with the da adapter registry. Must be called to make the adapter
70+
// available via `--da.layer sugondat`.
4671
func Register() error {
4772
return registry.Register("sugondat", func() da.DataAvailabilityLayerClient {
4873
return &DataAvailabilityLayerClient{}
@@ -60,6 +85,9 @@ func (c *DataAvailabilityLayerClient) Init(namespaceID types.NamespaceID, config
6085
return nil
6186
}
6287

88+
// Starts the RPC client.
89+
//
90+
// Expected to be called before `SubmitBlocks` or `RetrieveBlocks`.
6391
func (c *DataAvailabilityLayerClient) Start() error {
6492
c.logger.Info("starting Sugondat Data Availability Layer Client", "baseURL", c.config.BaseURL)
6593
closer, err := jsonrpc.NewClient(context.Background(), c.config.BaseURL, "Rollkit", &c.rpc.api, nil)
@@ -70,6 +98,7 @@ func (c *DataAvailabilityLayerClient) Start() error {
7098
return nil
7199
}
72100

101+
// Tears down the RPC client.
73102
func (c *DataAvailabilityLayerClient) Stop() error {
74103
c.logger.Info("stopping Sugondat Data Availability Layer Client")
75104
c.rpc.closer()

0 commit comments

Comments
 (0)