Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Avail DA to Rollkit #2

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b134701
added da for avail
chandiniv1 Jul 17, 2023
64a7b9b
fix: messages and appID + dependencies
prabal-banerjee Jul 19, 2023
b0382f7
replaced substrate rpc
chandiniv1 Jul 24, 2023
d7d815f
made changes in retrieve blocks
chandiniv1 Jul 26, 2023
5cbc78e
changed naming conventions
chandiniv1 Aug 3, 2023
619de31
taken dalayerheight as blocknumber
chandiniv1 Aug 3, 2023
4ebf625
renamed mock to datasubmit
chandiniv1 Aug 3, 2023
964575d
renamed mock to datasubmit and added desired confidence to config
chandiniv1 Aug 3, 2023
ae3fc03
added baseurl and confidence to config
chandiniv1 Aug 7, 2023
eb7269b
removed size from config and handled errors
chandiniv1 Aug 7, 2023
9ea8b1c
removed rpc in dataavailabilitylayerclient
chandiniv1 Aug 7, 2023
303d5ff
return error when appID is 0
chandiniv1 Aug 9, 2023
7add807
changed imports in go mod
chandiniv1 Aug 9, 2023
8cb14ba
Merge branch 'vitwit/avail-da' into chandini/avail-da
murthyvitwit Aug 9, 2023
8f17072
added block extrincs to blocks
chandiniv1 Aug 10, 2023
d92ead6
Merge branch 'chandini/avail-da' of https://github.com/chandiniv1/rol…
chandiniv1 Aug 10, 2023
773fb54
modified submit block to submit blocks
chandiniv1 Aug 10, 2023
f0ab456
Merge branch 'main' of https://github.com/rollkit/rollkit into chandi…
chandiniv1 Aug 23, 2023
0712600
updated avail.go
chandiniv1 Aug 23, 2023
6243a29
closed the response body
chandiniv1 Aug 23, 2023
86aa124
removed empty fields
chandiniv1 Aug 29, 2023
e840e02
fixed linting
chandiniv1 Sep 4, 2023
b7cd609
changed gsrpc
chandiniv1 Sep 5, 2023
b79c701
Merge branch 'main' of https://github.com/rollkit/rollkit into chandi…
chandiniv1 Sep 5, 2023
e71fcb6
changed go mod
chandiniv1 Sep 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions da/avail/avail.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"

Check failure on line 8 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
"net/http"

ds "github.com/ipfs/go-datastore"

Check failure on line 11 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

File is not `goimports`-ed with -local github.com/rollkit (goimports)
openrpc "github.com/rollkit/celestia-openrpc"
openrpcns "github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/rollkit/rollkit/da"
Expand All @@ -21,14 +21,13 @@
BaseURL string `json:"base_url"`
Seed string `json:"seed"`
ApiURL string `json:"api_url"`
Size int `json:"size"`
AppID int `json:"app_id"`
confidence float64 `json:"confidence"`

Check failure on line 25 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

structtag: struct field confidence has json tag but is not exported (govet)
chandiniv1 marked this conversation as resolved.
Show resolved Hide resolved
}

type DataAvailabilityLayerClient struct {
rpc *openrpc.Client

Check failure on line 29 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

`rpc` is unused (structcheck)
namespace openrpcns.Namespace

Check failure on line 30 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

`namespace` is unused (structcheck)
config Config
logger log.Logger
}
Expand Down Expand Up @@ -87,7 +86,7 @@
}
}

txHash, err := datasubmit.SubmitData(c.config.Size, c.config.ApiURL, c.config.Seed, c.config.AppID, data)
txHash, err := datasubmit.SubmitData(c.config.ApiURL, c.config.Seed, c.config.AppID, data)

if err != nil {
return da.ResultSubmitBlock{
Expand All @@ -113,7 +112,7 @@
blockNumber := dataLayerHeight
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why new variable?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akhilkumarpilli ,datalayerheight and blocknumber are two different fields but currently we are considering datalayerheight as blocknumber that's why I have taken a new variable.If there is no necessity of new variable,I'll remove it. Please suggest

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, you can remove it.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay akhil

confidenceURL := fmt.Sprintf(c.config.BaseURL+"/confidence/%d", blockNumber)

response, err := http.Get(confidenceURL)

Check failure on line 115 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

G107: Potential HTTP request made with variable url (gosec)
chandiniv1 marked this conversation as resolved.
Show resolved Hide resolved

if err != nil {
return da.ResultCheckBlock{
Expand All @@ -135,7 +134,15 @@
}

var confidenceObject Confidence
json.Unmarshal(responseData, &confidenceObject)
err = json.Unmarshal(responseData, &confidenceObject)
if err != nil {
return da.ResultCheckBlock{
BaseResult: da.BaseResult{
Code: da.StatusError,
Message: err.Error(),
},
}
}

return da.ResultCheckBlock{
BaseResult: da.BaseResult{
Expand All @@ -155,7 +162,7 @@

blockNumber := dataLayerHeight
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

appDataURL := fmt.Sprintf(c.config.BaseURL+"/appdata/%d?decode=true", blockNumber)
response, err := http.Get(appDataURL)

Check failure on line 165 in da/avail/avail.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

G107: Potential HTTP request made with variable url (gosec)
chandiniv1 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Expand All @@ -174,8 +181,15 @@
}
}
var appDataObject AppData
json.Unmarshal(responseData, &appDataObject)

err = json.Unmarshal(responseData, &appDataObject)
if err != nil {
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Code: da.StatusError,
Message: err.Error(),
},
}
}
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Code: da.StatusSuccess,
Expand Down
8 changes: 3 additions & 5 deletions da/avail/datasubmit/submitdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// submit data submits the extrinsic through substrate api
func SubmitData(size int, apiURL string, seed string, AppID int, data []byte) (types.Hash, error) {
func SubmitData(apiURL string, seed string, appID int, data []byte) (types.Hash, error) {
api, err := gsrpc.NewSubstrateAPI(apiURL)
if err != nil {
return types.Hash{}, err
Expand All @@ -18,11 +18,9 @@ func SubmitData(size int, apiURL string, seed string, AppID int, data []byte) (t
return types.Hash{}, err
}

var appID int

// if app id is greater than 0 then it must be created before submitting data
if AppID != 0 {
appID = AppID
if appID == 0 {
return types.Hash{}, err
chandiniv1 marked this conversation as resolved.
Show resolved Hide resolved
}

c, err := types.NewCall(meta, "DataAvailability.submit_data", data)
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ require (
golang.org/x/net v0.12.0
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.31.0
// github.com/chandiniv1/go-substrate-rpc-client/v4 dfd1152c8eca19e7090112c105770db21149e3cf
)

require (
Expand Down Expand Up @@ -197,10 +198,8 @@ require (
)

replace (
github.com/centrifuge/go-substrate-rpc-client/v4 => /home/chandini/go/src/github.com/chandiniv1/go-substrate-rpc-client
github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/chandiniv1/go-substrate-rpc-client/v4 v4.0.12-avail-1.5.0-4eb55aaa492.0.20230719142342-dfd1152c8eca

// github.com/vedhavyas/go-subkey => github.com/vedhavyas/go-subkey/v2 v2.0.0
// github.com/vedhavyas/go-subkey/v2 => github.com/vedhavyas/go-subkey/v2 v2.0.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4
// github.com/tendermint/tendermint => github.com/celestiaorg/tendermint v0.34.22-0.20221202214355-3605c597500d
github.com/tendermint/tendermint => github.com/rollkit/cometbft v0.0.0-20230524013001-2968c8b8b121
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chandiniv1/go-substrate-rpc-client/v4 v4.0.12-avail-1.5.0-4eb55aaa492.0.20230719142342-dfd1152c8eca h1:LDXxsQcnmEcf5bE+kh/4C3dihhEt8q21f2A3oor3ljA=
github.com/chandiniv1/go-substrate-rpc-client/v4 v4.0.12-avail-1.5.0-4eb55aaa492.0.20230719142342-dfd1152c8eca/go.mod h1:ci/8ueqySAWWtagThy3d8kwHGYNjl0AXw8aasJfnr20=
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down
Loading