github.com/Finschia/finschia-sdk@v0.49.1/x/upgrade/spec/04_client.md (about) 1 <!-- 2 order: 4 3 --> 4 5 # Client 6 7 ## CLI 8 9 A user can query and interact with the `upgrade` module using the CLI. 10 11 ### Query 12 13 The `query` commands allow users to query `upgrade` state. 14 15 ```bash 16 simd query upgrade --help 17 ``` 18 19 #### applied 20 21 The `applied` command allows users to query the block header for height at which a completed upgrade was applied. 22 23 ```bash 24 simd query upgrade applied [upgrade-name] [flags] 25 ``` 26 27 If upgrade-name was previously executed on the chain, this returns the header for the block at which it was applied. 28 This helps a client determine which binary was valid over a given range of blocks, as well as more context to understand past migrations. 29 30 Example: 31 32 ```bash 33 simd query upgrade applied "test-upgrade" 34 ``` 35 36 Example Output: 37 38 ```bash 39 "block_id": { 40 "hash": "A769136351786B9034A5F196DC53F7E50FCEB53B48FA0786E1BFC45A0BB646B5", 41 "parts": { 42 "total": 1, 43 "hash": "B13CBD23011C7480E6F11BE4594EE316548648E6A666B3575409F8F16EC6939E" 44 } 45 }, 46 "block_size": "7213", 47 "header": { 48 "version": { 49 "block": "11" 50 }, 51 "chain_id": "testnet-2", 52 "height": "455200", 53 "time": "2021-04-10T04:37:57.085493838Z", 54 "last_block_id": { 55 "hash": "0E8AD9309C2DC411DF98217AF59E044A0E1CCEAE7C0338417A70338DF50F4783", 56 "parts": { 57 "total": 1, 58 "hash": "8FE572A48CD10BC2CBB02653CA04CA247A0F6830FF19DC972F64D339A355E77D" 59 } 60 }, 61 "last_commit_hash": "DE890239416A19E6164C2076B837CC1D7F7822FC214F305616725F11D2533140", 62 "data_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", 63 "validators_hash": "A31047ADE54AE9072EE2A12FF260A8990BA4C39F903EAF5636B50D58DBA72582", 64 "next_validators_hash": "A31047ADE54AE9072EE2A12FF260A8990BA4C39F903EAF5636B50D58DBA72582", 65 "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", 66 "app_hash": "28ECC486AFC332BA6CC976706DBDE87E7D32441375E3F10FD084CD4BAF0DA021", 67 "last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", 68 "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", 69 "proposer_address": "2ABC4854B1A1C5AA8403C4EA853A81ACA901CC76" 70 }, 71 "num_txs": "0" 72 } 73 ``` 74 75 #### module versions 76 77 The `module_versions` command gets a list of module names and their respective consensus versions. 78 79 Following the command with a specific module name will return only 80 that module's information. 81 82 ```bash 83 simd query upgrade module_versions [optional module_name] [flags] 84 ``` 85 86 Example: 87 88 ```bash 89 simd query upgrade module_versions 90 ``` 91 92 Example Output: 93 94 ```bash 95 module_versions: 96 - name: auth 97 version: "2" 98 - name: authz 99 version: "1" 100 - name: bank 101 version: "2" 102 - name: capability 103 version: "1" 104 - name: crisis 105 version: "1" 106 - name: distribution 107 version: "2" 108 - name: evidence 109 version: "1" 110 - name: feegrant 111 version: "1" 112 - name: genutil 113 version: "1" 114 - name: gov 115 version: "2" 116 - name: ibc 117 version: "2" 118 - name: mint 119 version: "1" 120 - name: params 121 version: "1" 122 - name: slashing 123 version: "2" 124 - name: staking 125 version: "2" 126 - name: transfer 127 version: "1" 128 - name: upgrade 129 version: "1" 130 - name: vesting 131 version: "1" 132 ``` 133 134 Example: 135 136 ```bash 137 regen query upgrade module_versions ibc 138 ``` 139 140 Example Output: 141 142 ```bash 143 module_versions: 144 - name: ibc 145 version: "2" 146 ``` 147 148 #### plan 149 150 The `plan` command gets the currently scheduled upgrade plan, if one exists. 151 152 ```bash 153 regen query upgrade plan [flags] 154 ``` 155 156 Example: 157 158 ```bash 159 simd query upgrade plan 160 ``` 161 162 Example Output: 163 164 ```bash 165 height: "130" 166 info: "" 167 name: test-upgrade 168 time: "0001-01-01T00:00:00Z" 169 upgraded_client_state: null 170 ``` 171 172 ## REST 173 174 A user can query the `upgrade` module using REST endpoints. 175 176 ### Applied Plan 177 178 `AppliedPlan` queries a previously applied upgrade plan by its name. 179 180 ```bash 181 /cosmos/upgrade/v1beta1/applied_plan/{name} 182 ``` 183 184 Example: 185 186 ```bash 187 curl -X GET "http://localhost:1317/cosmos/upgrade/v1beta1/applied_plan/v2.0-upgrade" -H "accept: application/json" 188 ``` 189 190 Example Output: 191 192 ```bash 193 { 194 "height": "30" 195 } 196 ``` 197 198 ### Current Plan 199 200 `CurrentPlan` queries the current upgrade plan. 201 202 ```bash 203 /cosmos/upgrade/v1beta1/current_plan 204 ``` 205 206 Example: 207 208 ```bash 209 curl -X GET "http://localhost:1317/cosmos/upgrade/v1beta1/current_plan" -H "accept: application/json" 210 ``` 211 212 Example Output: 213 214 ```bash 215 { 216 "plan": "v2.1-upgrade" 217 } 218 ``` 219 220 ### Module versions 221 222 `ModuleVersions` queries the list of module versions from state. 223 224 ```bash 225 /cosmos/upgrade/v1beta1/module_versions 226 ``` 227 228 Example: 229 230 ```bash 231 curl -X GET "http://localhost:1317/cosmos/upgrade/v1beta1/module_versions" -H "accept: application/json" 232 ``` 233 234 Example Output: 235 236 ```bash 237 { 238 "module_versions": [ 239 { 240 "name": "auth", 241 "version": "2" 242 }, 243 { 244 "name": "authz", 245 "version": "1" 246 }, 247 { 248 "name": "bank", 249 "version": "2" 250 }, 251 { 252 "name": "capability", 253 "version": "1" 254 }, 255 { 256 "name": "crisis", 257 "version": "1" 258 }, 259 { 260 "name": "distribution", 261 "version": "2" 262 }, 263 { 264 "name": "evidence", 265 "version": "1" 266 }, 267 { 268 "name": "feegrant", 269 "version": "1" 270 }, 271 { 272 "name": "genutil", 273 "version": "1" 274 }, 275 { 276 "name": "gov", 277 "version": "2" 278 }, 279 { 280 "name": "ibc", 281 "version": "2" 282 }, 283 { 284 "name": "mint", 285 "version": "1" 286 }, 287 { 288 "name": "params", 289 "version": "1" 290 }, 291 { 292 "name": "slashing", 293 "version": "2" 294 }, 295 { 296 "name": "staking", 297 "version": "2" 298 }, 299 { 300 "name": "transfer", 301 "version": "1" 302 }, 303 { 304 "name": "upgrade", 305 "version": "1" 306 }, 307 { 308 "name": "vesting", 309 "version": "1" 310 } 311 ] 312 } 313 ``` 314 315 ## gRPC 316 317 A user can query the `upgrade` module using gRPC endpoints. 318 319 ### Applied Plan 320 321 `AppliedPlan` queries a previously applied upgrade plan by its name. 322 323 ```bash 324 cosmos.upgrade.v1beta1.Query/AppliedPlan 325 ``` 326 327 Example: 328 329 ```bash 330 grpcurl -plaintext \ 331 -d '{"name":"v2.0-upgrade"}' \ 332 localhost:9090 \ 333 cosmos.upgrade.v1beta1.Query/AppliedPlan 334 ``` 335 336 Example Output: 337 338 ```bash 339 { 340 "height": "30" 341 } 342 ``` 343 344 ### Current Plan 345 346 `CurrentPlan` queries the current upgrade plan. 347 348 ```bash 349 cosmos.upgrade.v1beta1.Query/CurrentPlan 350 ``` 351 352 Example: 353 354 ```bash 355 grpcurl -plaintext localhost:9090 cosmos.slashing.v1beta1.Query/CurrentPlan 356 ``` 357 358 Example Output: 359 360 ```bash 361 { 362 "plan": "v2.1-upgrade" 363 } 364 ``` 365 366 ### Module versions 367 368 `ModuleVersions` queries the list of module versions from state. 369 370 ```bash 371 cosmos.upgrade.v1beta1.Query/ModuleVersions 372 ``` 373 374 Example: 375 376 ```bash 377 grpcurl -plaintext localhost:9090 cosmos.slashing.v1beta1.Query/ModuleVersions 378 ``` 379 380 Example Output: 381 382 ```bash 383 { 384 "module_versions": [ 385 { 386 "name": "auth", 387 "version": "2" 388 }, 389 { 390 "name": "authz", 391 "version": "1" 392 }, 393 { 394 "name": "bank", 395 "version": "2" 396 }, 397 { 398 "name": "capability", 399 "version": "1" 400 }, 401 { 402 "name": "crisis", 403 "version": "1" 404 }, 405 { 406 "name": "distribution", 407 "version": "2" 408 }, 409 { 410 "name": "evidence", 411 "version": "1" 412 }, 413 { 414 "name": "feegrant", 415 "version": "1" 416 }, 417 { 418 "name": "genutil", 419 "version": "1" 420 }, 421 { 422 "name": "gov", 423 "version": "2" 424 }, 425 { 426 "name": "ibc", 427 "version": "2" 428 }, 429 { 430 "name": "mint", 431 "version": "1" 432 }, 433 { 434 "name": "params", 435 "version": "1" 436 }, 437 { 438 "name": "slashing", 439 "version": "2" 440 }, 441 { 442 "name": "staking", 443 "version": "2" 444 }, 445 { 446 "name": "transfer", 447 "version": "1" 448 }, 449 { 450 "name": "upgrade", 451 "version": "1" 452 }, 453 { 454 "name": "vesting", 455 "version": "1" 456 } 457 ] 458 } 459 ```