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

IBC alpha #5277

Merged
merged 243 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
243 commits
Select commit Hold shift + click to select a range
cffb1f3
IBC alpha
fedekunze Nov 5, 2019
d5a9437
ICS 23 Implementation (#4515)
mossid Nov 5, 2019
ec747fc
ICS 02 Implementation (#4516)
mossid Nov 5, 2019
2ae542a
ICS 03 Implementation (#4517)
mossid Nov 5, 2019
4282412
ICS 05 implementation (#5193)
fedekunze Nov 5, 2019
87d09fd
ICS 04 Implementation (#4548)
mossid Nov 5, 2019
bd85998
IBC v1.0.0 (#5245)
fedekunze Nov 5, 2019
4dda39e
IBC demo fixes (#5267)
cwgoes Nov 5, 2019
7a97b78
Add unit tests for ICS03 (#5275)
chengwenxi Nov 7, 2019
0c268c2
Add unit tests for ICS04 (#5286)
chengwenxi Nov 7, 2019
fa0839f
fix conflicts with master
fedekunze Nov 8, 2019
51ecc98
IBC alpha general cleanup (#5291)
fedekunze Nov 11, 2019
2ebee6a
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Nov 11, 2019
be5be81
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Nov 12, 2019
ee8bde2
Fix codec issue in ics23
jackzampolin Nov 12, 2019
ae8ea8f
Modify codec registration style to match previous working state
jackzampolin Nov 12, 2019
e12d247
write port tests
AdityaSripal Nov 12, 2019
2de199f
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
AdityaSripal Nov 12, 2019
6cd6d4f
ICS-02: Keeper Tests (#5329)
AdityaSripal Nov 19, 2019
3a8f469
Fix proof verification; remove store key prefixes; add additional pat…
chengwenxi Nov 20, 2019
7c987fe
Add ICS20 tests (#5308)
chengwenxi Nov 21, 2019
321463f
Add IBC REST endpoints (#5310)
chengwenxi Dec 2, 2019
e20e687
fix IBC proofs (#5351)
fedekunze Dec 2, 2019
0015c8b
fix conflicts with master
fedekunze Dec 3, 2019
8ca3c28
fix build; comment handshakes
fedekunze Dec 3, 2019
2e1e0e3
ICS-2 Implement Misbehavior (#5321)
AdityaSripal Dec 5, 2019
ea11bd0
Merge branch 'master' into ibc-alpha
fedekunze Dec 5, 2019
791579f
Merge branch 'master' into ibc-alpha
fedekunze Dec 5, 2019
b330c8e
Misc ibc fixes (#5357)
fedekunze Dec 10, 2019
eaea024
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Dec 10, 2019
5f65aaa
Implement Query Committer methods in ICS-02 (#5402)
AdityaSripal Dec 13, 2019
c32a94a
merge master
fedekunze Dec 13, 2019
5947f83
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Dec 13, 2019
0d9bfd4
fix test
fedekunze Dec 13, 2019
fb2dd9a
IBC UX improvements (#5364)
fedekunze Dec 16, 2019
64a38f6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Dec 17, 2019
4c77df0
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Dec 18, 2019
6e94d37
Merge branch 'master' into ibc-alpha
fedekunze Dec 18, 2019
c896467
fix ICS02 queries (#5425)
fedekunze Dec 18, 2019
ed3e3f0
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Dec 19, 2019
9ec532c
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Dec 19, 2019
73a7e5d
fix CLI JSON param unmarshaling (#5431)
fedekunze Jan 2, 2020
e06d6a9
Fix inconsistent string lookup functions (#5437)
fedekunze Jan 2, 2020
221ce96
Update x/ibc error handling (#5462)
fedekunze Jan 2, 2020
560a2fb
Merge branch 'master' into ibc-alpha
fedekunze Jan 2, 2020
682c8ad
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Jan 6, 2020
1e22171
ADR 015 Implementation (#5401)
mossid Jan 14, 2020
50a3f51
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Jan 14, 2020
cf135c2
Merge branch 'master' into ibc-alpha
fedekunze Jan 14, 2020
2ecbfe9
IBC alpha
fedekunze Nov 5, 2019
220a482
ICS 23 Implementation (#4515)
mossid Nov 5, 2019
35e0428
ICS 02 Implementation (#4516)
mossid Nov 5, 2019
e9f3385
ICS 03 Implementation (#4517)
mossid Nov 5, 2019
a654fca
ICS 05 implementation (#5193)
fedekunze Nov 5, 2019
017be7f
ICS 04 Implementation (#4548)
mossid Nov 5, 2019
5bdff3c
IBC v1.0.0 (#5245)
fedekunze Nov 5, 2019
c378fb6
IBC demo fixes (#5267)
cwgoes Nov 5, 2019
d8cf351
Add unit tests for ICS03 (#5275)
chengwenxi Nov 7, 2019
97c3613
Add unit tests for ICS04 (#5286)
chengwenxi Nov 7, 2019
20950b7
IBC alpha general cleanup (#5291)
fedekunze Nov 11, 2019
c617d89
Fix codec issue in ics23
jackzampolin Nov 12, 2019
3fb0c56
Modify codec registration style to match previous working state
jackzampolin Nov 12, 2019
61b1b59
write port tests
AdityaSripal Nov 12, 2019
e54cd1f
ICS-02: Keeper Tests (#5329)
AdityaSripal Nov 19, 2019
0c6ea22
Fix proof verification; remove store key prefixes; add additional pat…
chengwenxi Nov 20, 2019
2966286
Add ICS20 tests (#5308)
chengwenxi Nov 21, 2019
77718c1
Add IBC REST endpoints (#5310)
chengwenxi Dec 2, 2019
a35c79e
fix IBC proofs (#5351)
fedekunze Dec 2, 2019
48a853b
fix build; comment handshakes
fedekunze Dec 3, 2019
4bc70d6
ICS-2 Implement Misbehavior (#5321)
AdityaSripal Dec 5, 2019
6c2232e
Misc ibc fixes (#5357)
fedekunze Dec 10, 2019
883c23d
Implement Query Committer methods in ICS-02 (#5402)
AdityaSripal Dec 13, 2019
29b82d9
fix test
fedekunze Dec 13, 2019
e11aca6
IBC UX improvements (#5364)
fedekunze Dec 16, 2019
300892a
fix ICS02 queries (#5425)
fedekunze Dec 18, 2019
3ecb819
fix CLI JSON param unmarshaling (#5431)
fedekunze Jan 2, 2020
045b021
Fix inconsistent string lookup functions (#5437)
fedekunze Jan 2, 2020
1e10e1f
Update x/ibc error handling (#5462)
fedekunze Jan 2, 2020
134551e
ADR 015 Implementation (#5401)
mossid Jan 14, 2020
a593e7a
Merge ibc-alpha upstream
jackzampolin Jan 15, 2020
15fde5b
Fix build errors
jackzampolin Jan 15, 2020
46cbfd9
Merge branch 'master' into ibc-alpha
jackzampolin Jan 16, 2020
939b2a5
remove tmcmn instance
jackzampolin Jan 17, 2020
559db33
remove tmcmn instance
jackzampolin Jan 17, 2020
92f3069
Fix compliation errors
jackzampolin Jan 17, 2020
8f1a9a9
Merge branch 'master' into ibc-alpha
jackzampolin Jan 17, 2020
b6008d0
Merge branch 'master' into ibc-alpha
jackzampolin Jan 22, 2020
2c22e52
Fix build errors
jackzampolin Jan 22, 2020
ee258f0
Fix build errors
jackzampolin Jan 22, 2020
3df016e
ICS07 Tendermint Client implementation (#5485)
fedekunze Jan 27, 2020
1774687
merge master
fedekunze Jan 27, 2020
c2b874b
fix build
fedekunze Jan 27, 2020
4d5c2d1
IBC historical info support (#5475)
fedekunze Jan 29, 2020
bf906aa
cleanup ibc-alpha diff with master
fedekunze Jan 29, 2020
e46ec7d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Jan 29, 2020
863662e
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Jan 29, 2020
b4a5d60
add ADR04 changes
fedekunze Jan 31, 2020
9fbd7cc
Merge branch 'master' into ibc-alpha
jackzampolin Jan 31, 2020
5e7a39b
Add bank alias for gaia
jackzampolin Jan 31, 2020
b52c07a
Moar bank alias gaia
jackzampolin Jan 31, 2020
81e1497
Moar bank alias gaia
jackzampolin Jan 31, 2020
43706c8
merge master
fedekunze Feb 3, 2020
b85c8f5
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Feb 3, 2020
b822566
Merge branch 'master' into ibc-alpha
jackzampolin Feb 5, 2020
34e6a87
Fix query all clients
jackzampolin Feb 6, 2020
cd61769
update to current Tendermint master
melekes Feb 7, 2020
8fd8950
TxSearchMock: add orderBy field to TxSearch method
melekes Feb 7, 2020
396eed4
Merge branch 'master' into ibc-alpha
jackzampolin Feb 11, 2020
b411199
fix build errors
jackzampolin Feb 11, 2020
c342166
Small changes for compilation of gaia
jackzampolin Feb 11, 2020
55d1aea
Small changes for compilation of gaia
jackzampolin Feb 11, 2020
38d87b4
Add 07-tm.Header.ConsensusState() to make conversions easy
jackzampolin Feb 14, 2020
d8a693d
merge master
fedekunze Feb 17, 2020
c0b7ed2
pull branch
fedekunze Feb 17, 2020
e73caba
Add additional IBC Channel Tests (#5578)
jackzampolin Feb 18, 2020
f123d8a
merge master
fedekunze Feb 18, 2020
5875a96
merge master
fedekunze Feb 18, 2020
efb28d7
ICS07 follow up changes (#5606)
fedekunze Feb 18, 2020
d25f3d3
IBC SDK specification (#5426)
fedekunze Feb 18, 2020
a8b6c67
fix build
fedekunze Feb 18, 2020
cc748c3
Merge branch 'master' into ibc-alpha
jackzampolin Feb 18, 2020
1b5bc90
Merge PR #5670: Fix Packet Timeout Bug
AdityaSripal Feb 18, 2020
a705c56
Merge branch 'master' into ibc-alpha
jackzampolin Feb 18, 2020
5c8f4f9
Merge branch 'master' into ibc-alpha
jackzampolin Feb 19, 2020
ff7c881
Add defensive checks before setting param keytables in keeprs
jackzampolin Feb 19, 2020
54b64d0
Merge branch 'master' into ibc-alpha
jackzampolin Feb 19, 2020
6f42d82
ICS 20 Cleanup and Tests (#5577)
jackzampolin Feb 20, 2020
e2d5d83
conflicts from master
fedekunze Feb 20, 2020
c3bb696
Merge PR #5666: Use Tendermint lite client verification
AdityaSripal Feb 21, 2020
143ccf7
Merge branch 'master' into ibc-alpha
jackzampolin Feb 21, 2020
ace2a98
Disambiguate error codes
cwgoes Feb 21, 2020
bb7e803
Fix binary marshalling for state storage
jackzampolin Feb 24, 2020
5e378a5
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ib…
fedekunze Feb 26, 2020
4d1fb7c
Merge branch 'master' into ibc-alpha
fedekunze Feb 26, 2020
ac0e739
readd MsgSubmitClientMisbehaviour
fedekunze Feb 26, 2020
1176fb6
Merge branch 'master' into ibc-alpha
jackzampolin Feb 26, 2020
68f6700
Fix double flag registration
jackzampolin Feb 26, 2020
69d089c
ICS23 refactor (#5710)
fedekunze Feb 27, 2020
04a1f6f
merge master
fedekunze Mar 5, 2020
89e4597
Merge branch 'master' into ibc-alpha
jackzampolin Mar 7, 2020
1818d98
Merge PR #5711: Switch mock proofs to real proofs
cwgoes Mar 7, 2020
c035957
Try to fix store decoding issue
jackzampolin Mar 7, 2020
fdd8f7f
Sim issue update
jackzampolin Mar 7, 2020
3818571
add error in msg
AdityaSripal Mar 7, 2020
18acea1
remove next validator set from ibctmtypes.Header
AdityaSripal Mar 8, 2020
5a01435
remove warning msg
AdityaSripal Mar 8, 2020
4b683e5
Make IBC updating more robust
AdityaSripal Mar 8, 2020
1ee0b7e
blh
AdityaSripal Mar 8, 2020
9dae837
bump tm dependency
AdityaSripal Mar 9, 2020
69be1cf
remove redundant clockdrift correction
AdityaSripal Mar 9, 2020
aed047d
Merge pull request #5764 from cosmos/aditya/robust-timing
AdityaSripal Mar 9, 2020
4a3b03a
remove blh commit
AdityaSripal Mar 9, 2020
4692d2d
fix test build failures
AdityaSripal Mar 9, 2020
2310bee
Change time from PST to UTC
jackzampolin Mar 9, 2020
382e78d
Merge PR #5770: Update error message in connection keeper
jackzampolin Mar 9, 2020
85a86eb
Merge branch 'master' into ibc-alpha
jackzampolin Mar 9, 2020
01ccc21
Merge PR #5774: Debug timestamp issues
cwgoes Mar 10, 2020
455c712
Merge PR #5786: Fix MsgTransfer routing
AdityaSripal Mar 11, 2020
b412797
Fix test-case
cwgoes Mar 11, 2020
6244b00
Merge branch 'master' into ibc-alpha
jackzampolin Mar 11, 2020
5795324
register MsgPacket
AdityaSripal Mar 12, 2020
c06d4cc
Flip boolean
cwgoes Mar 16, 2020
8b2db11
emit packet event on SendPacket
AdityaSripal Mar 17, 2020
53b9ca4
Merge pull request #5821 from cosmos/aditya/emit-packet
AdityaSripal Mar 17, 2020
b829550
Fix attribute setting
jackzampolin Mar 18, 2020
af10e05
Implement in-memory KVStore
alexanderbez Mar 18, 2020
29d68cf
Start keeper and types
alexanderbez Mar 18, 2020
191df59
Add codec
alexanderbez Mar 19, 2020
cb6fc18
Add keys logic
alexanderbez Mar 19, 2020
447221b
Update types
alexanderbez Mar 19, 2020
970e786
Update keeper
alexanderbez Mar 19, 2020
0f950e1
Implement NewCapability
alexanderbez Mar 19, 2020
2a3dde9
Implement InitializeAndSeal
alexanderbez Mar 20, 2020
4d40d4d
Update simapp
alexanderbez Mar 20, 2020
4c3e8ef
Implement GetCapability
alexanderbez Mar 20, 2020
772d0f6
Add logging for new and claimed caps
alexanderbez Mar 20, 2020
d8f0ee2
Call InitializeAndSeal in SimApp
alexanderbez Mar 20, 2020
e989574
Update keeper semantics + unit tests
alexanderbez Mar 20, 2020
e929832
Use big endian
alexanderbez Mar 20, 2020
3a95ff8
More unit tests
alexanderbez Mar 20, 2020
9e46368
Increase keeper test coverage
alexanderbez Mar 20, 2020
abc15d8
Remove TODO
alexanderbez Mar 20, 2020
74d09b9
Add module doc
alexanderbez Mar 20, 2020
083494c
Update doc
alexanderbez Mar 20, 2020
d6b5f5b
Apply suggestions from code review
cwgoes Mar 23, 2020
c5e9c60
Update NewCapability godoc
alexanderbez Mar 23, 2020
0fa3522
Clarify owner
alexanderbez Mar 23, 2020
f3a514a
Add forgery test case to TestAuthenticateCapability
alexanderbez Mar 23, 2020
1db27ad
Format doc
alexanderbez Mar 23, 2020
6f2a9dd
Update to tm@v0.33.2
jackzampolin Mar 23, 2020
290344c
Update ADR
alexanderbez Mar 23, 2020
76a5c3e
Explicitly take pointer in FwdCapabilityKey
alexanderbez Mar 23, 2020
82afa7d
Update set to be logn
alexanderbez Mar 23, 2020
84707a8
Merge branch 'ibc-alpha' into bez/adr-003-dynamic-cap
alexanderbez Mar 23, 2020
a8efe0f
Update app module
alexanderbez Mar 23, 2020
9b4f448
Lint
alexanderbez Mar 23, 2020
dc737f5
Merge PR #5828: ADR-003: Dynamic Capabilities
alexanderbez Mar 24, 2020
0ed9ed6
merge master changes
fedekunze Mar 24, 2020
4a04faa
Fix broken test after packet format changed
jackzampolin Mar 25, 2020
94f5d6f
Merge branch 'master' into ibc-alpha
jackzampolin Mar 25, 2020
087c102
Add stub and unit tests for ReleaseCapability
alexanderbez Mar 26, 2020
19a8cb1
Finish implementation
alexanderbez Mar 27, 2020
24bd82e
Add test case to TestAuthenticateCapability for releasing a cap
alexanderbez Mar 27, 2020
3b48464
Merge PR #5877: x/capability: ReleaseCapability
alexanderbez Mar 27, 2020
b6e977d
remove swagger files from ibc module (#5893)
fedekunze Mar 31, 2020
d456271
Move IBC packet data interpretation to the application module (#5890)
michaelfig Apr 1, 2020
4a3e8e6
Merge branch 'master' into ibc-alpha
jackzampolin Apr 1, 2020
8d26b7f
fix ibc-alpha sims (#5909)
fedekunze Apr 2, 2020
eb0930e
fix HistoricalInfo sim decoders
fedekunze Apr 2, 2020
70a0e30
add staking sim decoder test case for HistInfo
fedekunze Apr 2, 2020
b7dea19
Merge branch 'master' into ibc-alpha
fedekunze Apr 2, 2020
fa2ea30
Merge PR #5901: Add & update IBC queriers for relayer use
cwgoes Apr 2, 2020
cb485e0
fix test
fedekunze Apr 2, 2020
419f545
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Apr 2, 2020
0d39e00
Merge PR #5914: x/capability: Fix Object Capability Model
alexanderbez Apr 2, 2020
ebdd0a6
Merge PR #5918: Remove source field from ICS 20 packet & message type…
cwgoes Apr 3, 2020
8927822
fix ics20 client args (#5924)
SegueII Apr 3, 2020
6c28954
Merge PR #5930: Add GetChainID to ClientState interface
jackzampolin Apr 3, 2020
d7a9d6e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ibc-alpha
fedekunze Apr 3, 2020
60bf21f
Merge PR #5925: Add additional events to x/ibc
cwgoes Apr 6, 2020
52206f4
Migrate x/capability to Protobuf (#5926)
fedekunze Apr 6, 2020
df5bada
Merge PR #5939: Unmarshal packets as JSON
cwgoes Apr 6, 2020
9448610
Merge PR #5888: Dynamic Capabilities with Routing
AdityaSripal Apr 7, 2020
d0053c5
cleanup ibc-alpha (#5945)
fedekunze Apr 7, 2020
174dfa0
Merge branch 'master' into ibc-alpha
fedekunze Apr 7, 2020
53e135f
x/staking: import and export HistoricalInfo
fedekunze Apr 7, 2020
5eb2878
staking/types: add HistoricalInfo to GenesisState
fedekunze Apr 7, 2020
46d805c
changelog
fedekunze Apr 7, 2020
d252c78
Merge branch 'master' into export-hist-info
fedekunze Apr 7, 2020
5c3df55
add staking module to app BeginBlockers
fedekunze Apr 7, 2020
32a3557
remove JSON files
fedekunze Apr 7, 2020
eb3eca9
address comments from review
fedekunze Apr 7, 2020
90875aa
Merge branch 'export-hist-info' of github.com:cosmos/cosmos-sdk into …
fedekunze Apr 7, 2020
2eeae2b
Merge branch 'master' into export-hist-info
fedekunze Apr 7, 2020
0182438
Merge branch 'export-hist-info' of github.com:cosmos/cosmos-sdk into …
fedekunze Apr 7, 2020
168ea78
merge master changes
fedekunze Apr 7, 2020
383a00a
cleanup ibc-alpha
fedekunze Apr 7, 2020
3986dd3
Merge branch 'master' into ibc-alpha
fedekunze Apr 8, 2020
b0cb3af
Merge branch 'master' into ibc-alpha
cwgoes Apr 8, 2020
f4609bb
Merge branch 'master' into ibc-alpha
jackzampolin Apr 8, 2020
b9c0d3a
fix ibc-alpha lint (#5959)
fedekunze Apr 8, 2020
6d6c832
x/ibc: changelog (#5960)
fedekunze Apr 8, 2020
b85f82e
Merge PR #5954: Bind Transfer Port on InitChain
AdityaSripal Apr 8, 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
47 changes: 47 additions & 0 deletions client/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,53 @@ func NewCLIContextWithFrom(from string) CLIContext {
return ctx.WithVerifier(verifier)
}

// NewCLIContextIBC takes additional arguements
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
func NewCLIContextIBC(from string, chainID string, nodeURI string) CLIContext {
var rpc rpcclient.Client

genOnly := viper.GetBool(flags.FlagGenerateOnly)
fromAddress, fromName, err := GetFromFields(from, genOnly)
if err != nil {
fmt.Printf("failed to get from fields: %v", err)
os.Exit(1)
}

if !genOnly {
if nodeURI != "" {
rpc = rpcclient.NewHTTP(nodeURI, "/websocket")
}
}

ctx := CLIContext{
Client: rpc,
ChainID: chainID,
Output: os.Stdout,
NodeURI: nodeURI,
From: from,
OutputFormat: viper.GetString(cli.OutputFlag),
Height: viper.GetInt64(flags.FlagHeight),
HomeDir: viper.GetString(flags.FlagHome),
TrustNode: viper.GetBool(flags.FlagTrustNode),
UseLedger: viper.GetBool(flags.FlagUseLedger),
BroadcastMode: viper.GetString(flags.FlagBroadcastMode),
Simulate: viper.GetBool(flags.FlagDryRun),
GenerateOnly: genOnly,
FromAddress: fromAddress,
FromName: fromName,
Indent: viper.GetBool(flags.FlagIndentResponse),
SkipConfirm: viper.GetBool(flags.FlagSkipConfirmation),
}

// create a verifier for the specific chain ID and RPC client
verifier, err := CreateVerifier(ctx, DefaultVerifierCacheSize)
if err != nil && viper.IsSet(flags.FlagTrustNode) {
fmt.Printf("failed to create verifier: %s\n", err)
os.Exit(1)
}

return ctx.WithVerifier(verifier)
}

// NewCLIContext returns a new initialized CLIContext with parameters from the
// command line using Viper.
func NewCLIContext() CLIContext { return NewCLIContextWithFrom(viper.GetString(flags.FlagFrom)) }
Expand Down
113 changes: 97 additions & 16 deletions client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package context
import (
"fmt"
"strings"
"time"

"github.com/pkg/errors"

Expand All @@ -12,6 +13,7 @@ import (
tmliteErr "github.com/tendermint/tendermint/lite/errors"
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/store/rootmulti"
Expand All @@ -28,6 +30,55 @@ func (ctx CLIContext) GetNode() (rpcclient.Client, error) {
return ctx.Client, nil
}

// WaitForNBlocks blocks until the node defined on the context has advanced N blocks
func (ctx CLIContext) WaitForNBlocks(n int64) {
node, err := ctx.GetNode()
if err != nil {
panic(err)
}

resBlock, err := node.Block(nil)
var height int64
if err != nil || resBlock.Block == nil {
// wait for the first block to exist
ctx.waitForHeight(1)
height = 1 + n
} else {
height = resBlock.Block.Height + n
}
ctx.waitForHeight(height)
}

func (ctx CLIContext) waitForHeight(height int64) {
node, err := ctx.GetNode()
if err != nil {
panic(err)
}

for {
// get url, try a few times
var resBlock *ctypes.ResultBlock
var err error
INNER:
for i := 0; i < 5; i++ {
resBlock, err = node.Block(nil)
if err == nil {
break INNER
}
time.Sleep(time.Millisecond * 200)
}
if err != nil {
panic(err)
}

if resBlock.Block != nil && resBlock.Block.Height >= height {
return
}

time.Sleep(time.Millisecond * 100)
}
}

// Query performs a query to a Tendermint node with the provided path.
// It returns the result and height of the query upon success or an error if
// the query fails.
Expand All @@ -49,6 +100,12 @@ func (ctx CLIContext) QueryStore(key cmn.HexBytes, storeName string) ([]byte, in
return ctx.queryStore(key, storeName, "key")
}

// QueryABCI performs a query to a Tendermint node with the provide RequestQuery.
// It returns the ResultQuery obtained from the query.
func (ctx CLIContext) QueryABCI(req abci.RequestQuery) (abci.ResponseQuery, error) {
return ctx.queryABCI(req)
}

// QuerySubspace performs a query to a Tendermint node with the provided
// store name and subspace. It returns key value pair and height of the query
// upon success or an error if the query fails.
Expand All @@ -72,40 +129,64 @@ func (ctx CLIContext) GetFromName() string {
return ctx.FromName
}

// query performs a query to a Tendermint node with the provided store name
// and path. It returns the result and height of the query upon success
// or an error if the query fails. In addition, it will verify the returned
// proof if TrustNode is disabled. If proof verification fails or the query
// height is invalid, an error will be returned.
func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, height int64, err error) {
func (ctx CLIContext) queryABCI(req abci.RequestQuery) (resp abci.ResponseQuery, err error) {

node, err := ctx.GetNode()
if err != nil {
return res, height, err
return resp, err
}

// When a client did not provide a query height, manually query for it so it can
// be injected downstream into responses.
if ctx.Height == 0 {
status, err := node.Status()
if err != nil {
return resp, err
}
ctx = ctx.WithHeight(status.SyncInfo.LatestBlockHeight)
}

opts := rpcclient.ABCIQueryOptions{
Height: ctx.Height,
Prove: !ctx.TrustNode,
Prove: req.Prove || !ctx.TrustNode,
}

result, err := node.ABCIQueryWithOptions(path, key, opts)
result, err := node.ABCIQueryWithOptions(req.Path, req.Data, opts)
if err != nil {
return res, height, err
return
}

resp := result.Response
resp = result.Response
if !resp.IsOK() {
return res, resp.Height, errors.New(resp.Log)
err = errors.New(resp.Log)
return
}

// data from trusted node or subspace query doesn't need verification
if ctx.TrustNode || !isQueryStoreWithProof(path) {
return resp.Value, resp.Height, nil
if ctx.TrustNode || !isQueryStoreWithProof(req.Path) {
return resp, nil
}

err = ctx.verifyProof(path, resp)
err = ctx.verifyProof(req.Path, resp)
if err != nil {
return
}

return
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}

// query performs a query to a Tendermint node with the provided store name
// and path. It returns the result and height of the query upon success
// or an error if the query fails. In addition, it will verify the returned
// proof if TrustNode is disabled. If proof verification fails or the query
// height is invalid, an error will be returned.
func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, height int64, err error) {
resp, err := ctx.queryABCI(abci.RequestQuery{
Path: path,
Data: key,
})
if err != nil {
return res, resp.Height, err
return
}

return resp.Value, resp.Height, nil
Expand Down
1 change: 1 addition & 0 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (
FlagRPCWriteTimeout = "write-timeout"
FlagOutputDocument = "output-document" // inspired by wget -O
FlagSkipConfirmation = "yes"
FlagProve = "prove"
)

// LineBreak can be included in a command list to provide a blank line
Expand Down
85 changes: 85 additions & 0 deletions x/ibc/02-client/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package client

// nolint
// autogenerated code using github.com/rigelrozanski/multitool
// aliases generated for the following subdirectories:
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/02-client/types

import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types/errors"
)

const (
DefaultCodespace = errors.DefaultCodespace
CodeClientExists = errors.CodeClientExists
CodeClientNotFound = errors.CodeClientNotFound
CodeClientFrozen = errors.CodeClientFrozen
CodeConsensusStateNotFound = errors.CodeConsensusStateNotFound
CodeInvalidConsensusState = errors.CodeInvalidConsensusState
CodeClientTypeNotFound = errors.CodeClientTypeNotFound
CodeInvalidClientType = errors.CodeInvalidClientType
CodeRootNotFound = errors.CodeRootNotFound
CodeInvalidHeader = errors.CodeInvalidHeader
CodeInvalidEvidence = errors.CodeInvalidEvidence
AttributeKeyClientID = types.AttributeKeyClientID
SubModuleName = types.SubModuleName
StoreKey = types.StoreKey
RouterKey = types.RouterKey
QuerierRoute = types.QuerierRoute
QueryClientState = types.QueryClientState
QueryConsensusState = types.QueryConsensusState
QueryVerifiedRoot = types.QueryVerifiedRoot
)

var (
// functions aliases
NewKeeper = keeper.NewKeeper
QuerierClientState = keeper.QuerierClientState
QuerierConsensusState = keeper.QuerierConsensusState
QuerierVerifiedRoot = keeper.QuerierVerifiedRoot
RegisterCodec = types.RegisterCodec
ErrClientExists = errors.ErrClientExists
ErrClientNotFound = errors.ErrClientNotFound
ErrClientFrozen = errors.ErrClientFrozen
ErrConsensusStateNotFound = errors.ErrConsensusStateNotFound
ErrInvalidConsensus = errors.ErrInvalidConsensus
ErrClientTypeNotFound = errors.ErrClientTypeNotFound
ErrInvalidClientType = errors.ErrInvalidClientType
ErrRootNotFound = errors.ErrRootNotFound
ErrInvalidHeader = errors.ErrInvalidHeader
ErrInvalidEvidence = errors.ErrInvalidEvidence
ClientStatePath = types.ClientStatePath
ClientTypePath = types.ClientTypePath
ConsensusStatePath = types.ConsensusStatePath
RootPath = types.RootPath
KeyClientState = types.KeyClientState
KeyClientType = types.KeyClientType
KeyConsensusState = types.KeyConsensusState
KeyRoot = types.KeyRoot
NewMsgCreateClient = types.NewMsgCreateClient
NewMsgUpdateClient = types.NewMsgUpdateClient
NewMsgSubmitMisbehaviour = types.NewMsgSubmitMisbehaviour
NewQueryClientStateParams = types.NewQueryClientStateParams
NewQueryCommitmentRootParams = types.NewQueryCommitmentRootParams
NewClientState = types.NewClientState

// variable aliases
SubModuleCdc = types.SubModuleCdc
EventTypeCreateClient = types.EventTypeCreateClient
EventTypeUpdateClient = types.EventTypeUpdateClient
EventTypeSubmitMisbehaviour = types.EventTypeSubmitMisbehaviour
AttributeValueCategory = types.AttributeValueCategory
)

type (
Keeper = keeper.Keeper
MsgCreateClient = types.MsgCreateClient
MsgUpdateClient = types.MsgUpdateClient
MsgSubmitMisbehaviour = types.MsgSubmitMisbehaviour
QueryClientStateParams = types.QueryClientStateParams
QueryCommitmentRootParams = types.QueryCommitmentRootParams
State = types.State
)
Loading