Skip to content

Commit

Permalink
feat(rpc): add da, rollapp params to status query (dymensionxyz#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Jan 14, 2025
1 parent 0140460 commit 5f028e5
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 8 deletions.
2 changes: 2 additions & 0 deletions da/avail/avail.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/avast/retry-go/v4"
"github.com/dymensionxyz/dymint/da/stub"
"github.com/gogo/protobuf/proto"

"github.com/dymensionxyz/dymint/types"
Expand Down Expand Up @@ -58,6 +59,7 @@ type Config struct {
}

type DataAvailabilityLayerClient struct {
stub.Layer
client SubstrateApiI
pubsubServer *pubsub.Server
config Config
Expand Down
5 changes: 4 additions & 1 deletion da/celestia/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.S
return nil
}

func (c DataAvailabilityLayerClient) DAPath() string {
return c.config.NamespaceIDStr
}

func createConfig(bz []byte) (c Config, err error) {
if len(bz) <= 0 {
return c, errors.New("supplied config is empty")
Expand All @@ -104,7 +108,6 @@ func createConfig(bz []byte) (c Config, err error) {
if err != nil {
return c, fmt.Errorf("json unmarshal: %w", err)
}

err = c.InitNamespaceID()
if err != nil {
return c, fmt.Errorf("init namespace id: %w", err)
Expand Down
3 changes: 3 additions & 0 deletions da/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ type DataAvailabilityLayerClient interface {

// GetSignerBalance returns the balance for a specific address
GetSignerBalance() (Balance, error)

// Something third parties can use to identify rollapp activity on the DA
DAPath() string
}

// BatchRetriever is additional interface that can be implemented by Data Availability Layer Client that is able to retrieve
Expand Down
2 changes: 2 additions & 0 deletions da/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"

"cosmossdk.io/math"
"github.com/dymensionxyz/dymint/da/stub"
uretry "github.com/dymensionxyz/dymint/utils/retry"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
Expand All @@ -21,6 +22,7 @@ const maxBlobSize = 2097152 // 2MB (equivalent to avail or celestia)

// DataAvailabilityLayerClient is a generic client that proxies all DA requests via gRPC.
type DataAvailabilityLayerClient struct {
stub.Layer
config Config

conn *grpc.ClientConn
Expand Down
2 changes: 2 additions & 0 deletions da/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"cosmossdk.io/math"
"github.com/dymensionxyz/dymint/da"
"github.com/dymensionxyz/dymint/da/stub"
"github.com/dymensionxyz/dymint/store"
"github.com/dymensionxyz/dymint/types"
"github.com/tendermint/tendermint/libs/pubsub"
Expand All @@ -17,6 +18,7 @@ import (
// DataAvailabilityLayerClient is intended only for usage in tests.
// It does actually ensures DA - it stores data in-memory.
type DataAvailabilityLayerClient struct {
stub.Layer
logger types.Logger
dalcKV store.KV
daHeight atomic.Uint64
Expand Down
52 changes: 52 additions & 0 deletions da/stub/stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package stub

import (
"github.com/dymensionxyz/dymint/da"
"github.com/dymensionxyz/dymint/store"
"github.com/dymensionxyz/dymint/types"
"github.com/tendermint/tendermint/libs/pubsub"
)

var _ da.DataAvailabilityLayerClient = &Layer{}

type Layer struct{}

func (l Layer) Init(config []byte, pubsubServer *pubsub.Server, kvStore store.KV, logger types.Logger, options ...da.Option) error {
panic("implement me")
}

func (l Layer) DAPath() string {
return ""
}

func (l Layer) Start() error {
panic("implement me")
}

func (l Layer) Stop() error {
panic("implement me")
}

func (l Layer) SubmitBatch(batch *types.Batch) da.ResultSubmitBatch {
panic("implement me")
}

func (l Layer) GetClientType() da.Client {
panic("implement me")
}

func (l Layer) CheckBatchAvailability(daMetaData *da.DASubmitMetaData) da.ResultCheckBatch {
panic("implement me")
}

func (l Layer) WaitForSyncing() {
panic("implement me")
}

func (l Layer) GetMaxBlobSizeBytes() uint32 {
panic("implement me")
}

func (l Layer) GetSignerBalance() (da.Balance, error) {
panic("implement me")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -324,5 +324,5 @@ replace (
github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3
github.com/gorilla/rpc => github.com/dymensionxyz/rpc v1.3.1
github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.2
github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241128205759-2a9d5f015da5
github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20250109171128-0ea81b630cbc
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM=
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dymensionxyz/cometbft v0.34.29-0.20241128205759-2a9d5f015da5 h1:DIKsa7EWJRt+pIzzFn3MGYajwqaTmQQ/k255xONciRc=
github.com/dymensionxyz/cometbft v0.34.29-0.20241128205759-2a9d5f015da5/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw=
github.com/dymensionxyz/cometbft v0.34.29-0.20250109171128-0ea81b630cbc h1:ylgD5jzLTNx3NbIHC26QDr63U1lwyEtI/6BAhYc7V1M=
github.com/dymensionxyz/cometbft v0.34.29-0.20250109171128-0ea81b630cbc/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw=
github.com/dymensionxyz/cosmos-sdk v0.46.17-0.20241128210616-e9dfe47b8c73 h1:A0Oqua/AfzhBWvv4jiep48TAaAsh6wSwgCKBAqU/LQ0=
github.com/dymensionxyz/cosmos-sdk v0.46.17-0.20241128210616-e9dfe47b8c73/go.mod h1:VPUuzF+l+ekSGPV7VVB8m0OMQfwp3QdKWNZjvkU3A1U=
github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20241121093220-e0d7ad456fbd h1:V89QyOFM84o9w0iFdctMU6So8SS/Xt32JWAXGqJduT0=
Expand Down
6 changes: 6 additions & 0 deletions rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,16 @@ func (c *Client) Status(_ context.Context) (*ctypes.ResultStatus, error) {
PubKey: proposer.PubKey(),
VotingPower: 1,
},
DymensionStatus: ctypes.DymensionStatus{
DAPath: c.node.BlockManager.DAClient.DAPath(),
RollappParams: types.RollappParamsToABCI(state.RollappParams),
},
}
return result, nil
}

type DAInfo struct{}

// BroadcastEvidence is not yet implemented.
func (c *Client) BroadcastEvidence(ctx context.Context, evidence tmtypes.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
return &ctypes.ResultBroadcastEvidence{
Expand Down
17 changes: 17 additions & 0 deletions types/rollapp_params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package types

import (
"github.com/dymensionxyz/dymint/types/pb/dymint"
abci "github.com/tendermint/tendermint/abci/types"
)

type RollappParams struct {
Params *dymint.RollappParams
}

func RollappParamsToABCI(r dymint.RollappParams) abci.RollappParams {
ret := abci.RollappParams{}
ret.Da = r.Da
ret.DrsVersion = r.DrsVersion
return ret
}
4 changes: 0 additions & 4 deletions types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ func (s *State) IsGenesis() bool {
return s.Height() == 0
}

type RollappParams struct {
Params *dymint.RollappParams
}

// SetHeight sets the height saved in the Store if it is higher than the existing height
// returns OK if the value was updated successfully or did not need to be updated
func (s *State) SetHeight(height uint64) {
Expand Down

0 comments on commit 5f028e5

Please sign in to comment.