-
Notifications
You must be signed in to change notification settings - Fork 386
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5d758eb
init changes
rach-id 7f78c6f
scaffolds basic qgb module
rach-id 0f4f2be
scaffolds basic qgb module
rach-id 3bbe33c
adds comments
rach-id bf5a4e8
adds comments
rach-id ff6c3c8
removes dummy field from data commitment
rach-id File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.