Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/vitwit/avail-da-module into…
Browse files Browse the repository at this point in the history
… teja/interfaces
  • Loading branch information
Teja2045 committed Sep 19, 2024
2 parents 61da59d + 6ab0a6d commit e34060f
Show file tree
Hide file tree
Showing 40 changed files with 3,314 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linters:
# - copyloopvar
- goconst
- gocritic
- gci
# - gci
- gofumpt
# - gosec
- gosimple
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Cada (Cosmos Avail DA module)
# CADA (Cosmos Avail DA module)

CADA is a module designed to connect Cosmos sovereign chains with the Avail network, making it easier for any Cosmos chain or rollapp to use Avail as their Data Availability (DA) layer. With CADA, developers can improve the scalability and security of their decentralized applications within the Cosmos ecosystem. It enables better data handling and availability, allowing Cosmos-based chains to tap into the strengths of Avail and build a more connected and resilient blockchain network.

# How It Works
For example:
Let blobInterval = 10,

- At height `11`, blocks from `1` to `10` are posted.
- At height `21`, blocks from `11` to `20` are posted.

Refer to the module specification available [here](./specs/README.md) for more detailed information.
For more detailed information, refer to the `CADA` module specification [here](./specs/README.md).

Note: Use the latest maintained [Go](https://go.dev/dl/) version to work with this module.
# Integration Guide

Ensure that the Avail light client URL is correctly configured for the module to function as expected. For instructions on running Avail locally, refer to [this documentation](https://github.com/rollkit/avail-da?tab=readme-ov-file#avail-da).
To integrate the CADA module into your application, follow the steps outlined in the [integration guide](./integration_docs/README.md)

Note: Ensure that the Avail light client URL is correctly configured for the module to function as expected. For instructions on setup Avail locally, please refer to [this documentation](https://github.com/rollkit/avail-da?tab=readme-ov-file#avail-da).
128 changes: 128 additions & 0 deletions client/cli/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package cli_test

import (
"fmt"
"testing"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
"github.com/vitwit/avail-da-module/client/cli"
network "github.com/vitwit/avail-da-module/network"

app "simapp/app"

clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
)

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}

type IntegrationTestSuite struct {
suite.Suite

cfg network.Config
network *network.Network
addresses []string
}

const aliceMnemonic = "all soap kiwi cushion federal skirt tip shock exist tragic verify lunar shine rely torch please view future lizard garbage humble medal leisure mimic"

func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")

var err error

// Setup network config
cfg := network.DefaultConfig(app.NewTestNetworkFixture)
cfg.NumValidators = 1
s.cfg = cfg

// Initialize the network
s.network, err = network.New(s.T(), s.T().TempDir(), cfg)
s.Require().NoError(err)

kb := s.network.Validators[0].ClientCtx.Keyring
path := sdk.GetConfig().GetFullBIP44Path()
info, err := kb.NewAccount("alice", aliceMnemonic, "", path, hd.Secp256k1)
s.Require().NoError(err)

add, err := info.GetAddress()
s.Require().NoError(err)
s.addresses = append(s.addresses, add.String())

_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
}

func (s *IntegrationTestSuite) TearDownSuite() {
s.T().Log("tearing down integration suite")
s.network.Cleanup()
}

func (s *IntegrationTestSuite) TestNewUpdateBlobStatusCmd() {
val := s.network.Validators[0]

testCases := []struct {
name string
args []string
expectErr bool
}{
{
"update blob status - success",
[]string{
"1",
"10",
"success",
"120",
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
},
false,
},
{
"update blob status - failure",
[]string{
"1",
"10",
"failure",
"120",
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
},
false,
},
{
"update blob status - invalid status",
[]string{
"1",
"10",
"invalid",
"120",
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
},
false,
},
}

for _, tc := range testCases {
s.Run(tc.name, func() {
cmd := cli.NewUpdateBlobStatusCmd()
res, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, tc.args)
if tc.expectErr {
if err != nil {
s.Require().Error(err)
}
}

s.Require().NoError(nil)
s.Require().NotNil(res)
})
}
}
19 changes: 19 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package client

const (
KeyringBackendTest = "test"
)

// ChainClient is client to interact with SPN.
type ChainClient struct {
Address string `json:"address"`
AddressPrefix string `json:"account_address_prefix"`
RPC string `json:"rpc"`
Key string `json:"key"`
Mnemonic string `json:"mnemonic"`
KeyringServiceName string `json:"keyring_service_name"`
HDPath string `json:"hd_path"`
Enabled bool `json:"enabled"`
ChainName string `json:"chain_name"`
Denom string `json:"denom"`
}
25 changes: 0 additions & 25 deletions docs/config.md

This file was deleted.

74 changes: 64 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ go 1.22.5

replace (
cosmossdk.io/core => cosmossdk.io/core v0.11.0
cosmossdk.io/x/evidence => cosmossdk.io/x/evidence v0.1.0
cosmossdk.io/x/upgrade => cosmossdk.io/x/upgrade v0.1.1 // Remove once cosmos-sdk fork has been updated to latest v0.50.6
github.com/cosmos/cosmos-sdk => github.com/vitwit/cosmos-sdk v0.50.6-0.20240905105834-9a5babf69986
github.com/cosmos/ibc-go/v8 => github.com/cosmos/ibc-go/v8 v8.2.1
//github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.18.0 // Remove once cosmos-sdk fork has been updated to latest v0.50.6
// github.com/prometheus/client_model => github.com/prometheus/client_model v0.6.0 // Remove once cosmos-sdk fork has been updated to latest v0.50.6
// github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v1.1.0
// github.com/prometheus/common => github.com/prometheus/common v0.47.0
//github.com/prometheus/common => github.com/prometheus/common v0.47.0
github.com/spf13/viper => github.com/spf13/viper v1.17.0 // v1.18+ breaks app overrides
)

Expand All @@ -17,7 +23,7 @@ require (
cosmossdk.io/log v1.3.1
cosmossdk.io/store v1.1.0
cosmossdk.io/x/upgrade v0.1.4
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12
github.com/centrifuge/go-substrate-rpc-client/v4 v4.2.1
github.com/cometbft/cometbft v0.38.10
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.8
Expand All @@ -27,22 +33,70 @@ require (
github.com/spf13/cobra v1.8.1
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157
google.golang.org/grpc v1.65.0
simapp v0.0.0-00010101000000-000000000000
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.4 // indirect
cosmossdk.io/x/circuit v0.1.1 // indirect
cosmossdk.io/x/evidence v0.1.1 // indirect
cosmossdk.io/x/feegrant v0.1.1 // indirect
cosmossdk.io/x/nft v0.1.1 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/aws/aws-sdk-go v1.44.224 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bits-and-blooms/bitset v1.8.0 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 // indirect
github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect
github.com/cosmos/ibc-go/v8 v8.3.2 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.171.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/math v1.3.0
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand All @@ -62,7 +116,7 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.1.4 // indirect
Expand Down Expand Up @@ -140,10 +194,6 @@ require (
github.com/pierrec/xxHash v0.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.8.3 // indirect
Expand All @@ -155,7 +205,7 @@ require (
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/stretchr/testify v1.9.0
github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand All @@ -168,7 +218,7 @@ require (
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sync v0.7.0
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
Expand All @@ -185,3 +235,7 @@ require (
)

replace github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/availproject/go-substrate-rpc-client/v4 v4.1.0-avail-2.1.5-rc1

// replace github.com/vitwit/avail-da-module/simapp => /home/vitwit/avail-setup/avail-da-module/simapp

replace simapp => ./simapp
Loading

0 comments on commit e34060f

Please sign in to comment.