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

Add basic scaffolding for QGB module #208

Merged
merged 6 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ import (
paymentmodule "github.com/celestiaorg/celestia-app/x/payment"
paymentmodulekeeper "github.com/celestiaorg/celestia-app/x/payment/keeper"
paymentmoduletypes "github.com/celestiaorg/celestia-app/x/payment/types"

qgbmodule "github.com/celestiaorg/celestia-app/x/qgb"
qgbmodulekeeper "github.com/celestiaorg/celestia-app/x/qgb/keeper"
qgbmoduletypes "github.com/celestiaorg/celestia-app/x/qgb/types"
// this line is used by starport scaffolding # stargate/app/moduleImport
)

Expand Down Expand Up @@ -115,6 +119,7 @@ var (
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
paymentmodule.AppModuleBasic{},
qgbmodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -183,6 +188,7 @@ type App struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper

PaymentKeeper paymentmodulekeeper.Keeper
QgbKeeper qgbmodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// the module manager
Expand Down Expand Up @@ -219,6 +225,7 @@ func New(
paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
paymentmoduletypes.StoreKey,
qgbmoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -313,6 +320,13 @@ func New(
)
paymentmodule := paymentmodule.NewAppModule(appCodec, app.PaymentKeeper)

app.QgbKeeper = *qgbmodulekeeper.NewKeeper(
appCodec,
keys[qgbmoduletypes.StoreKey],
keys[qgbmoduletypes.MemStoreKey],
)
qgbmodule := qgbmodule.NewAppModule(appCodec, app.QgbKeeper)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

// Create static IBC router, add transfer route, then set and seal it
Expand Down Expand Up @@ -351,6 +365,7 @@ func New(
params.NewAppModule(app.ParamsKeeper),
transferModule,
paymentmodule,
qgbmodule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -385,6 +400,7 @@ func New(
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
paymentmoduletypes.ModuleName,
qgbmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down Expand Up @@ -568,6 +584,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(paymentmoduletypes.ModuleName)
paramsKeeper.Subspace(qgbmoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
7 changes: 7 additions & 0 deletions proto/qgb/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package qgb;

option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types";

// GenesisState defines the capability module's genesis state.
message GenesisState {}
Copy link
Member

Choose a reason for hiding this comment

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

This is something that we will have to think about in the future, do we want to incorporate the needed validator information in the genesis state, or do we want to add it later.

We're going to have to have some organization around when we actually start the QGB, either at genesis or at a later block height.

tbc, nothing todo in this PR, just talking out loud.

52 changes: 52 additions & 0 deletions proto/qgb/msgs.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";
package qgb;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";

option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types";

// Msg defines the state transitions possible for QGB
service Msg {
// ValsetConfirm allows the validators to submit their signatures over the validator set.
rpc ValsetConfirm(MsgValsetConfirm) returns (MsgValsetConfirmResponse) {
option (google.api.http).post = "/qgb/valset_confirm";
}
// DataCommitmentConfirm allows the validators to submit a confirmation for a data commitment.
rpc DataCommitmentConfirm(MsgDataCommitmentConfirm) returns (MsgDataCommitmentConfirmResponse) {
option (google.api.http).post = "/qgb/data_commitment_confirm";
}
}

// MsgValsetConfirm
// this is the message sent by the validators when they wish to submit their
// signatures over the validator set at a given block height. A validator must
// first call MsgSetEthAddress to set their Ethereum address to be used for
// signing. Then someone (anyone) must make a ValsetRequest, the request is
// essentially a messaging mechanism to determine which block all validators
// should submit signatures over. Finally validators sign the validator set,
// powers, and Ethereum addresses of the entire validator set at the height of a
// ValsetRequest and submit that signature with this message.
//
// If a sufficient number of validators (66% of voting power) (A) have set
// Ethereum addresses and (B) submit ValsetConfirm messages with their
// signatures it is then possible for anyone to view these signatures in the
// chain store and submit them to Ethereum to update the validator set
// -------------
message MsgValsetConfirm {
uint64 nonce = 1;
string orchestrator = 2;
string eth_address = 3;
string signature = 4;
}

// MsgValsetConfirmResponse describes the response returned after the submission
// of a MsgValsetConfirm.
message MsgValsetConfirmResponse {}

// MsgDataCommitmentConfirm describes a data commitment for a set of blocks.
message MsgDataCommitmentConfirm {}

// MsgValsetConfirmResponse describes the response returned after the submission
// of a MsgDataCommitmentConfirm.
message MsgDataCommitmentConfirmResponse {}
15 changes: 15 additions & 0 deletions proto/qgb/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package qgb;

import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
// this line is used by starport scaffolding # 1

option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types";

// Query defines the gRPC querier service.
service Query {
// this line is used by starport scaffolding # 2
}

// this line is used by starport scaffolding # 3
16 changes: 10 additions & 6 deletions x/payment/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions x/qgb/client/cli/datacommitment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cli

import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
)

func CmdGetDataCommitmentConfirm() *cobra.Command {
//nolint: exhaustivestruct
cmd := &cobra.Command{
Use: "datacommitment-confirm // TODO",
Short: "Get data commitment // TODO",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
// TODO
return nil
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
21 changes: 21 additions & 0 deletions x/qgb/client/cli/valsetconfirm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cli

import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
)

func CmdGetValsetConfirm() *cobra.Command {
//nolint: exhaustivestruct
cmd := &cobra.Command{
Use: "valset-confirm [nonce] [bech32 validator address]",
Short: "Get valset confirmation with a particular nonce from a particular validator",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
// TODO
return nil
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
22 changes: 22 additions & 0 deletions x/qgb/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package qgb

import (
"github.com/celestiaorg/celestia-app/x/qgb/keeper"
"github.com/celestiaorg/celestia-app/x/qgb/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// InitGenesis initializes the capability module's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
// this line is used by starport scaffolding # genesis/module/init
}

// ExportGenesis returns the capability module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
genesis := types.DefaultGenesis()

// this line is used by starport scaffolding # genesis/module/export

return genesis
}
30 changes: 30 additions & 0 deletions x/qgb/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package qgb

import (
"fmt"

"github.com/celestiaorg/celestia-app/x/qgb/keeper"
"github.com/celestiaorg/celestia-app/x/qgb/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// NewHandler uses the provided qgb keeper to create an sdk.Handler
func NewHandler(k keeper.Keeper) sdk.Handler {
msgServer := keeper.NewMsgServerImpl(k)

return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())
switch msg := msg.(type) {
case *types.MsgValsetConfirm:
res, err := msgServer.ValsetConfirm(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgDataCommitmentConfirm:
res, err := msgServer.DataCommitmentConfirm(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
default:
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
}
}
}
29 changes: 29 additions & 0 deletions x/qgb/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package keeper

import (
"fmt"

"github.com/tendermint/tendermint/libs/log"

"github.com/celestiaorg/celestia-app/x/qgb/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type Keeper struct {
cdc codec.BinaryCodec
storeKey sdk.StoreKey
memKey sdk.StoreKey
}

func NewKeeper(cdc codec.BinaryCodec, storeKey, memKey sdk.StoreKey) *Keeper {
return &Keeper{
cdc: cdc,
storeKey: storeKey,
memKey: memKey,
}
}

func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}
23 changes: 23 additions & 0 deletions x/qgb/keeper/keeper_data_commitment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package keeper

import (
"github.com/celestiaorg/celestia-app/x/qgb/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// GetDataCommitmentConfirm
func (k Keeper) GetDataCommitmentConfirm(ctx sdk.Context) *types.MsgDataCommitmentConfirm {
// TODO
return nil
}

// SetDataCommitmentConfirm
func (k Keeper) SetDataCommitmentConfirm(ctx sdk.Context, dcConf types.MsgDataCommitmentConfirm) []byte {
// TODO
return nil
}

// DeleteDataCommitmentConfirms
func (k Keeper) DeleteDataCommitmentConfirms(ctx sdk.Context) {
// TODO
}
30 changes: 30 additions & 0 deletions x/qgb/keeper/keeper_valset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package keeper

import (
"github.com/celestiaorg/celestia-app/x/qgb/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// GetValsetConfirm
func (k Keeper) GetValsetConfirm(ctx sdk.Context, nonce uint64, validator sdk.AccAddress) *types.MsgValsetConfirm {
// TODO
return nil
}

// SetValsetConfirm
func (k Keeper) SetValsetConfirm(ctx sdk.Context, valsetConf types.MsgValsetConfirm) []byte {
// TODO
return nil
}

// GetValsetConfirms
func (k Keeper) GetValsetConfirms(ctx sdk.Context, nonce uint64) (confirms []types.MsgValsetConfirm) {
// TODO
return nil
}

// DeleteValsetConfirms
func (k Keeper) DeleteValsetConfirms(ctx sdk.Context, nonce uint64) {
// TODO
}
Loading