-
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
x/ibc: stateful clients #6202
x/ibc: stateful clients #6202
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k Keeper, msg exported.MsgCreateClie | |
} | ||
case exported.Localhost: | ||
// msg client id is always "localhost" | ||
clientState = localhosttypes.NewClientState( | ||
k.ClientStore(ctx, msg.GetClientID()), | ||
ctx.ChainID(), | ||
ctx.BlockHeight(), | ||
) | ||
clientState = localhosttypes.NewClientState(ctx.ChainID(), ctx.BlockHeight()) | ||
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. this looks a lot cleaner 🙌 I think it'll be pretty straight forward to create interfaces funcs for clients to implement so we can remove custom client handling here (see #6064) |
||
default: | ||
return nil, sdkerrors.Wrap(ErrInvalidClientType, msg.GetClientType()) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,12 @@ import ( | |
|
||
"github.com/stretchr/testify/suite" | ||
|
||
abci "github.com/tendermint/tendermint/abci/types" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/simapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" | ||
) | ||
|
||
|
@@ -24,6 +26,7 @@ const ( | |
type TendermintTestSuite struct { | ||
suite.Suite | ||
|
||
ctx sdk.Context | ||
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. what was the purpose of adding this? |
||
aminoCdc *codec.Codec | ||
cdc codec.Marshaler | ||
privVal tmtypes.PrivValidator | ||
|
@@ -48,6 +51,7 @@ func (suite *TendermintTestSuite) SetupTest() { | |
val := tmtypes.NewValidator(pubKey, 10) | ||
suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) | ||
suite.header = ibctmtypes.CreateTestHeader(chainID, height, suite.now, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) | ||
suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1, Time: suite.now}) | ||
} | ||
|
||
func TestTendermintTestSuite(t *testing.T) { | ||
|
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.
replaced
sdk.Context
withKVStore
since the client won't be able to access the store thought the context unless we passed the IBC StoreKey as an argument.This approach is more secure because we can just pass the prefix store for the specific client.