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

Enforce ProofSpecs in 23-Commitment #6374

Merged
merged 26 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3d2795c
enforce spec ordering
AdityaSripal Jun 8, 2020
a716e20
modify clients to pass in specs to verify functions
AdityaSripal Jun 9, 2020
3a5bc6a
start fixing tests
AdityaSripal Jun 9, 2020
1723648
Apply suggestions from code review
fedekunze Jun 9, 2020
e0d574d
Merge branch 'aditya/ibc-commitment' of github.com:cosmos/cosmos-sdk …
AdityaSripal Jun 9, 2020
74dd904
enforce spec length and proof length match
AdityaSripal Jun 9, 2020
e2f3537
fix all tests
AdityaSripal Jun 9, 2020
57e0a84
add argument to constructor:
AdityaSripal Jun 9, 2020
5a9782d
Merge branch 'master' into aditya/ibc-commitment
AdityaSripal Jun 9, 2020
6d759cf
fixed msg client and tests
AdityaSripal Jun 9, 2020
8e8bfd8
appease linter
AdityaSripal Jun 9, 2020
761fa7b
Apply suggestions from code review
AdityaSripal Jun 10, 2020
4bb1e56
finish fixes from review
AdityaSripal Jun 10, 2020
bd71a76
add back proof-specific checks
AdityaSripal Jun 10, 2020
99c8700
fix merge
AdityaSripal Jun 10, 2020
10c978a
Apply suggestions from code review
fedekunze Jun 10, 2020
3e5b687
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aditya/ibc…
AdityaSripal Jun 10, 2020
f170cf9
more robust proof spec checks
AdityaSripal Jun 10, 2020
f414ad8
Merge branch 'aditya/ibc-commitment' of github.com:cosmos/cosmos-sdk …
AdityaSripal Jun 10, 2020
236ab96
add CHANGELOG entries
AdityaSripal Jun 10, 2020
92e8315
Merge branch 'master' into aditya/ibc-commitment
fedekunze Jun 11, 2020
f441fb1
do not hardcode proofspecs in 23-commitment
AdityaSripal Jun 11, 2020
3731d8a
fix client modules
AdityaSripal Jun 11, 2020
3241a2d
fix tests
AdityaSripal Jun 11, 2020
f6749b5
fix merge
AdityaSripal Jun 11, 2020
0737e09
appease linter
AdityaSripal Jun 11, 2020
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
4 changes: 2 additions & 2 deletions x/ibc-transfer/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error {
ctxTarget := chain.GetContext()

// create client
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header)
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down Expand Up @@ -259,7 +259,7 @@ func (chain *TestChain) updateClient(client *TestChain) {
ctxTarget, client.ClientID, uint64(client.Header.SignedHeader.Header.Height), consensusState,
)
chain.App.IBCKeeper.ClientKeeper.SetClientState(
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header),
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs()),
)

// _, _, err := simapp.SignCheckDeliver(
Expand Down
4 changes: 2 additions & 2 deletions x/ibc-transfer/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error {
ctxTarget := chain.GetContext()

// create client
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header)
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down Expand Up @@ -234,7 +234,7 @@ func (chain *TestChain) updateClient(client *TestChain) {
ctxTarget, client.ClientID, client.Header.GetHeight(), consensusState,
)
chain.App.IBCKeeper.ClientKeeper.SetClientState(
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header),
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs()),
)

// _, _, err := simapp.SignCheckDeliver(
Expand Down
1 change: 1 addition & 0 deletions x/ibc/02-client/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ClientState interface {
GetLatestHeight() uint64
IsFrozen() bool
Validate() error
GetProofSpecs() []string

// State verification functions

Expand Down
14 changes: 7 additions & 7 deletions x/ibc/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func (suite *KeeperTestSuite) TestCreateClient() {
i := i
if tc.expPanic {
suite.Require().Panics(func() {
clientState, err := ibctmtypes.Initialize(tc.clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(tc.clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
suite.Require().NoError(err, "err on client state initialization")
suite.keeper.CreateClient(suite.ctx, clientState, suite.consensusState)
}, "Msg %d didn't panic: %s", i, tc.msg)
} else {
clientState, err := ibctmtypes.Initialize(tc.clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(tc.clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
if tc.expPass {
suite.Require().NoError(err, "errored on initialization")
suite.Require().NotNil(clientState, "valid test case %d failed: %s", i, tc.msg)
Expand Down Expand Up @@ -80,7 +80,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
expPass bool
}{
{"valid update", func() error {
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down Expand Up @@ -114,7 +114,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
return nil
}, false},
{"invalid header", func() error {
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down Expand Up @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
},
func() error {
suite.consensusState.ValidatorSet = bothValSet
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand All @@ -249,7 +249,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
},
func() error {
suite.consensusState.ValidatorSet = bothValSet
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
ClientID: testClientID,
},
func() error {
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions x/ibc/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

const (
testClientID = "gaia"
testClientID = "gaiachain"
testClientID2 = "ethbridge"
testClientID3 = "ethermint"

Expand Down Expand Up @@ -90,7 +90,7 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (suite *KeeperTestSuite) TestSetClientState() {
clientState := ibctmtypes.NewClientState(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{})
clientState := ibctmtypes.NewClientState(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}, commitmenttypes.GetSDKSpecs())
suite.keeper.SetClientState(suite.ctx, clientState)

retrievedState, found := suite.keeper.GetClientState(suite.ctx, testClientID)
Expand Down Expand Up @@ -121,9 +121,9 @@ func (suite *KeeperTestSuite) TestSetClientConsensusState() {

func (suite KeeperTestSuite) TestGetAllClients() {
expClients := []exported.ClientState{
ibctmtypes.NewClientState(testClientID2, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}),
ibctmtypes.NewClientState(testClientID3, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}),
ibctmtypes.NewClientState(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}),
ibctmtypes.NewClientState(testClientID2, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}, commitmenttypes.GetSDKSpecs()),
ibctmtypes.NewClientState(testClientID3, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}, commitmenttypes.GetSDKSpecs()),
ibctmtypes.NewClientState(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}, commitmenttypes.GetSDKSpecs()),
}

for i := range expClients {
Expand Down Expand Up @@ -168,7 +168,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() {

func (suite KeeperTestSuite) TestConsensusStateHelpers() {
// initial setup
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header)
clientState, err := ibctmtypes.Initialize(testClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs())
suite.Require().NoError(err)

suite.keeper.SetClientState(suite.ctx, clientState)
Expand Down
12 changes: 8 additions & 4 deletions x/ibc/02-client/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (

"github.com/stretchr/testify/require"

"github.com/tendermint/tendermint/crypto/merkle"
lite "github.com/tendermint/tendermint/lite2"
tmtypes "github.com/tendermint/tendermint/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
Expand All @@ -24,6 +26,8 @@ const (
maxClockDrift time.Duration = time.Second * 10
)

var specs = []string{storetypes.ProofOpIAVLCommitment, merkle.ProofOpSimpleValue}

func TestValidateGenesis(t *testing.T) {
privVal := tmtypes.NewMockPV()
pubKey, err := privVal.GetPubKey()
Expand All @@ -50,7 +54,7 @@ func TestValidateGenesis(t *testing.T) {
name: "valid genesis",
genState: types.NewGenesisState(
[]exported.ClientState{
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header),
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header, specs),
localhosttypes.NewClientState("chaindID", 10),
},
[]types.ClientConsensusStates{
Expand All @@ -71,7 +75,7 @@ func TestValidateGenesis(t *testing.T) {
name: "invalid client",
genState: types.NewGenesisState(
[]exported.ClientState{
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header),
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header, specs),
localhosttypes.NewClientState("chaindID", 0),
},
nil,
Expand All @@ -83,7 +87,7 @@ func TestValidateGenesis(t *testing.T) {
name: "invalid consensus state",
genState: types.NewGenesisState(
[]exported.ClientState{
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header),
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header, specs),
localhosttypes.NewClientState("chaindID", 10),
},
[]types.ClientConsensusStates{
Expand All @@ -104,7 +108,7 @@ func TestValidateGenesis(t *testing.T) {
name: "invalid consensus state",
genState: types.NewGenesisState(
[]exported.ClientState{
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header),
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, header, specs),
localhosttypes.NewClientState("chaindID", 10),
},
[]types.ClientConsensusStates{
Expand Down
10 changes: 5 additions & 5 deletions x/ibc/03-connection/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ func (suite KeeperTestSuite) TestGetAllConnections() {

func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() {
clients := []clientexported.ClientState{
ibctmtypes.NewClientState(testClientIDA, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}),
ibctmtypes.NewClientState(testClientIDB, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}),
ibctmtypes.NewClientState(testClientID3, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}),
ibctmtypes.NewClientState(testClientIDA, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}, commitmenttypes.GetSDKSpecs()),
ibctmtypes.NewClientState(testClientIDB, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}, commitmenttypes.GetSDKSpecs()),
ibctmtypes.NewClientState(testClientID3, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}, commitmenttypes.GetSDKSpecs()),
}

for i := range clients {
Expand Down Expand Up @@ -262,7 +262,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error {
ctxTarget := chain.GetContext()

// create client
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header)
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func (chain *TestChain) updateClient(client *TestChain) {
ctxTarget, client.ClientID, client.Header.GetHeight(), consensusState,
)
chain.App.IBCKeeper.ClientKeeper.SetClientState(
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header),
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs()),
)

// _, _, err := simapp.SignCheckDeliver(
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/04-channel/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error {
ctxTarget := chain.GetContext()

// create client
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header)
clientState, err := ibctmtypes.Initialize(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs())
if err != nil {
return err
}
Expand Down Expand Up @@ -447,7 +447,7 @@ func (chain *TestChain) updateClient(client *TestChain) {
ctxTarget, client.ClientID, client.Header.GetHeight(), consensusState,
)
chain.App.IBCKeeper.ClientKeeper.SetClientState(
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header),
ctxTarget, ibctmtypes.NewClientState(client.ClientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, client.Header, commitmenttypes.GetSDKSpecs()),
)

// _, _, err := simapp.SignCheckDeliver(
Expand Down
26 changes: 21 additions & 5 deletions x/ibc/07-tendermint/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,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'`,
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand All @@ -59,6 +65,7 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {

var (
trustLevel tmmath.Fraction
specs []string
err error
)

Expand Down Expand Up @@ -88,8 +95,16 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {
return err
}

spc := viper.GetString(flagProofSpecs)

if spc == "default" {
specs = commitmenttypes.GetSDKSpecs()
} else {
specs = strings.Split(spc, ",")
}

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 {
Expand All @@ -100,6 +115,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
}

Expand Down
1 change: 1 addition & 0 deletions x/ibc/07-tendermint/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type CreateClientReq struct {
TrustingPeriod time.Duration `json:"trusting_period" yaml:"trusting_period"`
UnbondingPeriod time.Duration `json:"unbonding_period" yaml:"unbonding_period"`
MaxClockDrift time.Duration `json:"max_clock_drift" yaml:"max_clock_drift"`
ProofSpecs []string `json:"proof_specs" yaml:"proof_specs"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want there to be a way for the client creator to provide the full ics23.ProofSpec?

If we don't have that, then we're limited to whatever specs the SDK has hard-coded "by name".

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm.. for now this is not that useful. Since we're still using merkle.Proof and ProofRuntime to verify proofs, we cannot actually verify a proof that isn't registered and hard-coded into the proofruntime anyway.

Think this is something to revisit once we pull out ProofRuntime from ics23 verification

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh but I suppose we can change the interfaces now, so we don't have to change them again

Copy link
Member Author

@AdityaSripal AdityaSripal Jun 10, 2020

Choose a reason for hiding this comment

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

Hmm after thinking about it, realized there isn't a simple way to do this without completely pulling out merkle.ProofRuntime from the `23-commitment package.

I can do this if there's consensus that this is preferable, but it does involve more work since I have to manually verify the proof with passed in specs, rather than just calling into ProofRuntime. Not too hard tho

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is probably worthwhile, since it will allow SDK chains to support new ProofSpecs without manual upgrades

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, so now 23-commitment no longer uses ProofRuntime. Instead we use the ics23 Verify functions directly with the ProofSpecs passed in from the client.

Now, ibc can verify Commitment proofs even if the chain does not have them hardcoded into its proof runtime

}

// UpdateClientReq defines the properties of a update client request's body.
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/07-tendermint/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func createClientHandlerFn(clientCtx client.Context) http.HandlerFunc {
msg := ibctmtypes.NewMsgCreateClient(
req.ClientID, req.Header, req.TrustLevel,
req.TrustingPeriod, req.UnbondingPeriod, req.MaxClockDrift,
fromAddr,
req.ProofSpecs, fromAddr,
)

if err := msg.ValidateBasic(); err != nil {
Expand Down
Loading