-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Enforce ProofSpecs in 23-Commitment #6374
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3d2795c
enforce spec ordering
AdityaSripal a716e20
modify clients to pass in specs to verify functions
AdityaSripal 3a5bc6a
start fixing tests
AdityaSripal 1723648
Apply suggestions from code review
fedekunze e0d574d
Merge branch 'aditya/ibc-commitment' of github.com:cosmos/cosmos-sdk …
AdityaSripal 74dd904
enforce spec length and proof length match
AdityaSripal e2f3537
fix all tests
AdityaSripal 57e0a84
add argument to constructor:
AdityaSripal 5a9782d
Merge branch 'master' into aditya/ibc-commitment
AdityaSripal 6d759cf
fixed msg client and tests
AdityaSripal 8e8bfd8
appease linter
AdityaSripal 761fa7b
Apply suggestions from code review
AdityaSripal 4bb1e56
finish fixes from review
AdityaSripal bd71a76
add back proof-specific checks
AdityaSripal 99c8700
fix merge
AdityaSripal 10c978a
Apply suggestions from code review
fedekunze 3e5b687
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aditya/ibc…
AdityaSripal f170cf9
more robust proof spec checks
AdityaSripal f414ad8
Merge branch 'aditya/ibc-commitment' of github.com:cosmos/cosmos-sdk …
AdityaSripal 236ab96
add CHANGELOG entries
AdityaSripal 92e8315
Merge branch 'master' into aditya/ibc-commitment
fedekunze f441fb1
do not hardcode proofspecs in 23-commitment
AdityaSripal 3731d8a
fix client modules
AdityaSripal 3241a2d
fix tests
AdityaSripal f6749b5
fix merge
AdityaSripal 0737e09
appease linter
AdityaSripal 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
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
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
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |||||
"strings" | ||||||
"time" | ||||||
|
||||||
ics23 "github.com/confio/ics23/go" | ||||||
"github.com/pkg/errors" | ||||||
|
||||||
"github.com/spf13/cobra" | ||||||
|
@@ -25,17 +26,23 @@ import ( | |||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||||||
evidenceexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" | ||||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" | ||||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" | ||||||
) | ||||||
|
||||||
const flagTrustLevel = "trust-level" | ||||||
const ( | ||||||
flagTrustLevel = "trust-level" | ||||||
flagProofSpecs = "proof-specs" | ||||||
) | ||||||
|
||||||
// GetCmdCreateClient defines the command to create a new IBC Client as defined | ||||||
// in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#create | ||||||
func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command { | ||||||
cmd := &cobra.Command{ | ||||||
Use: "create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift]", | ||||||
Short: "create new tendermint client", | ||||||
Long: "create new tendermint client. Trust level can be a fraction (eg: '1/3') or 'default'", | ||||||
Use: "create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift]", | ||||||
Short: "create new tendermint client", | ||||||
Long: `Create a new tendermint IBC client. | ||||||
- 'trust-level' flag can be a fraction (eg: '1/3') or 'default' | ||||||
- 'proof-specs' flag can be a comma-separated list of strings (eg: 'ics23:simple,ics23:iavl') or 'default'`, | ||||||
Example: fmt.Sprintf("%s tx ibc %s create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift] --trust-level default --from node0 --home ../node0/<app>cli --chain-id $CID", version.ClientName, ibctmtypes.SubModuleName), | ||||||
Args: cobra.ExactArgs(5), | ||||||
RunE: func(cmd *cobra.Command, args []string) error { | ||||||
|
@@ -59,6 +66,7 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command { | |||||
|
||||||
var ( | ||||||
trustLevel tmmath.Fraction | ||||||
specs []*ics23.ProofSpec | ||||||
err error | ||||||
) | ||||||
|
||||||
|
@@ -88,8 +96,20 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command { | |||||
return err | ||||||
} | ||||||
|
||||||
spc := viper.GetString(flagProofSpecs) | ||||||
|
||||||
// Currently supports SDK chain or simple kvstore tendermint chain | ||||||
switch spc { | ||||||
case "default": | ||||||
specs = commitmenttypes.GetSDKSpecs() | ||||||
case "simple": | ||||||
specs = []*ics23.ProofSpec{ics23.TendermintSpec} | ||||||
default: | ||||||
return fmt.Errorf("proof Spec: %s not supported", spc) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
msg := ibctmtypes.NewMsgCreateClient( | ||||||
clientID, header, trustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientCtx.GetFromAddress(), | ||||||
clientID, header, trustLevel, trustingPeriod, ubdPeriod, maxClockDrift, specs, clientCtx.GetFromAddress(), | ||||||
) | ||||||
|
||||||
if err := msg.ValidateBasic(); err != nil { | ||||||
|
@@ -100,6 +120,7 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command { | |||||
}, | ||||||
} | ||||||
cmd.Flags().String(flagTrustLevel, "default", "light client trust level fraction for header updates") | ||||||
cmd.Flags().String(flagProofSpecs, "default", "proof specs format to be used for verification") | ||||||
return cmd | ||||||
} | ||||||
|
||||||
|
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.
Can we support reading a spec from JSON or something?
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 can happen later though