forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'v0.47.5' of https://github.com/cosmos/cosmos-sdk into upgr…
…ade/v0.47.x Release v0.47.5
- Loading branch information
Showing
32 changed files
with
392 additions
and
68 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# Cosmos SDK v0.47.4 Release Notes | ||
# Cosmos SDK v0.47.5 Release Notes | ||
|
||
💬 [**Release Discussion**](https://github.com/orgs/cosmos/discussions/categories/announcements) | ||
|
||
## 🚀 Highlights | ||
|
||
Missed the v0.47.0 announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0). | ||
For this fourth patch release of the `v0.47.x` line, some of the notable changes include: | ||
Get ready for v0.50.0 and start integrating with the next [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.0-rc.0) release. | ||
|
||
* An improvement in `<appd> prune` UX. | ||
* Improving the error handling when there is a snapshot creation failure. | ||
For this 5th patch release of the `v0.47.x` line, some of the notable changes include: | ||
|
||
Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/CHANGELOG.md) for an exhaustive list of changes or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/release/v0.47.3...v0.47.4) from last release. | ||
* A new command for importing private keys encoded in hex. This complements the existing `import` command that supports mnemonic and key files. | ||
Use `<appd> keys import <name> <hex>` to import a private key encoded in hex. | ||
* A new command, `rpc.QueryEventForTxCmd` for querying a transaction by its hash and blocking until the transaction is included in a block. It is useful as an alternative to the legacy `--sync block`. | ||
|
||
Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.47.5/CHANGELOG.md) for an exhaustive list of changes or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/release/v0.47.4...v0.47.5) from last release. | ||
|
||
Refer to the [upgrading guide](https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/UPGRADING.md) when migrating from `v0.46.x` to `v0.47.0`. |
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 |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package rpc | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | ||
coretypes "github.com/cometbft/cometbft/rpc/core/types" | ||
tmtypes "github.com/cometbft/cometbft/types" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
func newTxResponseCheckTx(res *coretypes.ResultBroadcastTxCommit) *sdk.TxResponse { | ||
if res == nil { | ||
return nil | ||
} | ||
|
||
var txHash string | ||
if res.Hash != nil { | ||
txHash = res.Hash.String() | ||
} | ||
|
||
parsedLogs, _ := sdk.ParseABCILogs(res.CheckTx.Log) | ||
|
||
return &sdk.TxResponse{ | ||
Height: res.Height, | ||
TxHash: txHash, | ||
Codespace: res.CheckTx.Codespace, | ||
Code: res.CheckTx.Code, | ||
Data: strings.ToUpper(hex.EncodeToString(res.CheckTx.Data)), | ||
RawLog: res.CheckTx.Log, | ||
Logs: parsedLogs, | ||
Info: res.CheckTx.Info, | ||
GasWanted: res.CheckTx.GasWanted, | ||
GasUsed: res.CheckTx.GasUsed, | ||
Events: res.CheckTx.Events, | ||
} | ||
} | ||
|
||
func newTxResponseDeliverTx(res *coretypes.ResultBroadcastTxCommit) *sdk.TxResponse { | ||
if res == nil { | ||
return nil | ||
} | ||
|
||
var txHash string | ||
if res.Hash != nil { | ||
txHash = res.Hash.String() | ||
} | ||
|
||
parsedLogs, _ := sdk.ParseABCILogs(res.DeliverTx.Log) | ||
|
||
return &sdk.TxResponse{ | ||
Height: res.Height, | ||
TxHash: txHash, | ||
Codespace: res.DeliverTx.Codespace, | ||
Code: res.DeliverTx.Code, | ||
Data: strings.ToUpper(hex.EncodeToString(res.DeliverTx.Data)), | ||
RawLog: res.DeliverTx.Log, | ||
Logs: parsedLogs, | ||
Info: res.DeliverTx.Info, | ||
GasWanted: res.DeliverTx.GasWanted, | ||
GasUsed: res.DeliverTx.GasUsed, | ||
Events: res.DeliverTx.Events, | ||
} | ||
} | ||
|
||
func newResponseFormatBroadcastTxCommit(res *coretypes.ResultBroadcastTxCommit) *sdk.TxResponse { | ||
if res == nil { | ||
return nil | ||
} | ||
|
||
if !res.CheckTx.IsOK() { | ||
return newTxResponseCheckTx(res) | ||
} | ||
|
||
return newTxResponseDeliverTx(res) | ||
} | ||
|
||
// QueryEventForTxCmd returns a CLI command that subscribes to a WebSocket connection and waits for a transaction event with the given hash. | ||
func QueryEventForTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "event-query-tx-for [hash]", | ||
Short: "Query for a transaction by hash", | ||
Long: `Subscribes to a CometBFT WebSocket connection and waits for a transaction event with the given hash.`, | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
c, err := rpchttp.New(clientCtx.NodeURI, "/websocket") | ||
if err != nil { | ||
return err | ||
} | ||
if err := c.Start(); err != nil { | ||
return err | ||
} | ||
defer c.Stop() //nolint:errcheck // ignore stop error | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15) | ||
defer cancel() | ||
|
||
hash := args[0] | ||
query := fmt.Sprintf("%s='%s' AND %s='%s'", tmtypes.EventTypeKey, tmtypes.EventTx, tmtypes.TxHashKey, hash) | ||
const subscriber = "subscriber" | ||
eventCh, err := c.Subscribe(ctx, subscriber, query) | ||
if err != nil { | ||
return fmt.Errorf("failed to subscribe to tx: %w", err) | ||
} | ||
defer c.UnsubscribeAll(context.Background(), subscriber) //nolint:errcheck // ignore unsubscribe error | ||
|
||
select { | ||
case evt := <-eventCh: | ||
if txe, ok := evt.Data.(tmtypes.EventDataTx); ok { | ||
res := &coretypes.ResultBroadcastTxCommit{ | ||
DeliverTx: txe.Result, | ||
Hash: tmtypes.Tx(txe.Tx).Hash(), | ||
Height: txe.Height, | ||
} | ||
return clientCtx.PrintProto(newResponseFormatBroadcastTxCommit(res)) | ||
} | ||
case <-ctx.Done(): | ||
return errors.ErrLogic.Wrapf("timed out waiting for event, the transaction could have already been included or wasn't yet included") | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
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
Oops, something went wrong.