Skip to content

Commit a10cbc6

Browse files
chore: update to 0.52.0-rc.1 (#180)
* update: sdk 0.52.0-rc.1 * fix: ci & tests * lint :) * CHANGELOG * fix: remove arm arch
1 parent a17f92b commit a10cbc6

14 files changed

+306
-558
lines changed

Diff for: .github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
go-arch: ["amd64", "arm", "arm64"]
22+
go-arch: ["amd64", "arm64"]
2323
steps:
2424
- uses: actions/checkout@v4
2525
- uses: actions/setup-go@v5
2626
with:
27-
go-version: "1.22"
27+
go-version: "1.23.4"
2828
check-latest: true
2929
- uses: technote-space/[email protected]
3030
id: git_diff

Diff for: .github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-go@v5
1818
with:
19-
go-version: "1.22"
19+
go-version: "1.23.4"
2020
check-latest: true
2121
- uses: technote-space/[email protected]
2222
id: git_diff

Diff for: .github/workflows/rosetta-cli-test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions/checkout@v4
1919
- uses: actions/setup-go@v5
2020
with:
21-
go-version: '^1.22'
21+
go-version: '^1.23.4'
2222
- name: Run make test-rosetta-ci
2323
run:
2424
COSMOS_SDK_VERSION=v0.50.3

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@v4
2222
- uses: actions/setup-go@v5
2323
with:
24-
go-version: "1.22"
24+
go-version: "1.23.4"
2525
check-latest: true
2626
cache: true
2727
cache-dependency-path: go.sum

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
## [Unreleased]
3838

39+
### Improvements
40+
41+
* [180](https://github.com/cosmos/rosetta/pull/180) Update to cosmos-sdk v0.52.0-rc.1.
42+
* [180](https://github.com/cosmos/rosetta/pull/180) Added bech32 prefix flag.
43+
3944
## [v0.50.11](https://github.com/cosmos/rosetta/releases/tag/v0.50.11) 2024-12-19
4045

4146
### Improvements

Diff for: client_online.go

+15-6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import (
1818
"google.golang.org/grpc/credentials/insecure"
1919
"google.golang.org/grpc/metadata"
2020

21+
bank "cosmossdk.io/x/bank/types"
22+
23+
"github.com/cosmos/cosmos-sdk/codec/address"
2124
sdk "github.com/cosmos/cosmos-sdk/types"
2225
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
2326
"github.com/cosmos/cosmos-sdk/types/query"
2427
"github.com/cosmos/cosmos-sdk/version"
2528
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
2629
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
27-
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
2830

2931
crgerrs "github.com/cosmos/rosetta/lib/errors"
3032
crgtypes "github.com/cosmos/rosetta/lib/types"
@@ -35,7 +37,6 @@ var _ crgtypes.Client = (*Client)(nil)
3537

3638
const (
3739
defaultNodeTimeout = time.Minute
38-
tmWebsocketPath = "/websocket"
3940
)
4041

4142
// Client implements a single network client to interact with cosmos based chains
@@ -61,8 +62,16 @@ func NewClient(cfg *Config) (*Client, error) {
6162
if v == "" {
6263
v = "unknown"
6364
}
65+
ac, err := address.NewCachedBech32Codec(cfg.Bech32Prefix, address.CachedCodecOptions{})
66+
if err != nil {
67+
return nil, err
68+
}
69+
vc, err := address.NewCachedBech32Codec(sdk.GetBech32PrefixValAddr(cfg.Bech32Prefix), address.CachedCodecOptions{})
70+
if err != nil {
71+
return nil, err
72+
}
6473

65-
txConfig := authtx.NewTxConfig(cfg.Codec, authtx.DefaultSignModes)
74+
txConfig := authtx.NewTxConfig(cfg.Codec, ac, vc, authtx.DefaultSignModes)
6675

6776
var supportedOperations []string
6877
for _, ii := range cfg.InterfaceRegistry.ListImplementations(sdk.MsgInterfaceProtoName) {
@@ -101,7 +110,7 @@ func (c *Client) Bootstrap() error {
101110
return crgerrs.WrapError(crgerrs.ErrOnlineClient, fmt.Sprintf("dialing grpc endpoint %s", err.Error()))
102111
}
103112

104-
tmRPC, err := http.New(c.config.TendermintRPC, tmWebsocketPath)
113+
tmRPC, err := http.New(c.config.TendermintRPC)
105114
if err != nil {
106115
return crgerrs.WrapError(crgerrs.ErrOnlineClient, fmt.Sprintf("getting rpc path %s", err.Error()))
107116
}
@@ -488,7 +497,7 @@ func (c *Client) blockTxs(ctx context.Context, height *int64) (crgtypes.BlockTra
488497
return crgtypes.BlockTransactionsResponse{}, crgerrs.WrapError(crgerrs.ErrOnlineClient, fmt.Sprintf("getting rpc block results %s", err.Error()))
489498
}
490499

491-
if len(blockResults.TxsResults) != len(blockInfo.Block.Txs) {
500+
if len(blockResults.TxResults) != len(blockInfo.Block.Txs) {
492501
return crgtypes.BlockTransactionsResponse{}, crgerrs.WrapError(crgerrs.ErrOnlineClient, "block results transactions do now match block transactions")
493502
}
494503
// process begin and end block txs
@@ -503,7 +512,7 @@ func (c *Client) blockTxs(ctx context.Context, height *int64) (crgtypes.BlockTra
503512
deliverTx := make([]*rosettatypes.Transaction, len(blockInfo.Block.Txs))
504513
// process normal txs
505514
for i, tx := range blockInfo.Block.Txs {
506-
rosTx, err := c.converter.ToRosetta().Tx(tx, blockResults.TxsResults[i])
515+
rosTx, err := c.converter.ToRosetta().Tx(tx, blockResults.TxResults[i])
507516
if err != nil {
508517
return crgtypes.BlockTransactionsResponse{}, crgerrs.WrapError(crgerrs.ErrOnlineClient, fmt.Sprintf("getting rosetta tx %s", err.Error()))
509518
}

Diff for: codec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package rosetta
33
import (
44
"github.com/cosmos/gogoproto/proto"
55

6+
bankcodec "cosmossdk.io/x/bank/types"
67
"cosmossdk.io/x/tx/signing"
78

89
"github.com/cosmos/cosmos-sdk/codec"
@@ -12,7 +13,6 @@ import (
1213
sdk "github.com/cosmos/cosmos-sdk/types"
1314
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
1415
authcodec "github.com/cosmos/cosmos-sdk/x/auth/types"
15-
bankcodec "github.com/cosmos/cosmos-sdk/x/bank/types"
1616
)
1717

1818
// MakeCodec generates the codec required to interact

Diff for: config.go

+9
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const (
6666
FlagDenomToSuggest = "denom-to-suggest"
6767
FlagPricesToSuggest = "prices-to-suggest"
6868
FlagPlugin = "plugin"
69+
FlagBech32Prefix = "bech32-prefix"
6970
)
7071

7172
// Config defines the configuration of the rosetta server
@@ -102,6 +103,8 @@ type Config struct {
102103
Codec *codec.ProtoCodec
103104
// InterfaceRegistry overrides the default data and construction api interface registry
104105
InterfaceRegistry codectypes.InterfaceRegistry
106+
// Bech32Prefix defines the prefix used for bech32 addresses in the network.
107+
Bech32Prefix string
105108
}
106109

107110
// NetworkIdentifier returns the network identifier given the configuration
@@ -234,6 +237,10 @@ func FromFlags(flags *pflag.FlagSet) (*Config, error) {
234237
if err != nil {
235238
return nil, crgerrs.WrapError(crgerrs.ErrConfig, fmt.Sprintf("while getting denomToSuggest flag %s", err.Error()))
236239
}
240+
bech32Prefix, err := flags.GetString(FlagBech32Prefix)
241+
if err != nil {
242+
return nil, crgerrs.WrapError(crgerrs.ErrConfig, fmt.Sprintf("while getting bech32Prefix flag %s", err.Error()))
243+
}
237244

238245
var prices sdk.DecCoins
239246
if enableDefaultFeeSuggestion {
@@ -259,6 +266,7 @@ func FromFlags(flags *pflag.FlagSet) (*Config, error) {
259266
GasToSuggest: gasToSuggest,
260267
DenomToSuggest: denomToSuggest,
261268
GasPrices: prices,
269+
Bech32Prefix: bech32Prefix,
262270
}
263271
err = conf.validate()
264272
if err != nil {
@@ -305,4 +313,5 @@ func SetFlags(flags *pflag.FlagSet) {
305313
flags.String(FlagDenomToSuggest, DenomToSuggest, "default denom for fee suggestion")
306314
flags.String(FlagPricesToSuggest, DefaultPrices, "default prices for fee suggestion")
307315
flags.String(FlagPlugin, "", "plugin folder name")
316+
flags.String(FlagBech32Prefix, "cosmos", "address bech32 prefix")
308317
}

Diff for: converter.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
1919
sdkmath "cosmossdk.io/math"
20+
banktypes "cosmossdk.io/x/bank/types"
2021

2122
sdkclient "github.com/cosmos/cosmos-sdk/client"
2223
"github.com/cosmos/cosmos-sdk/codec"
@@ -26,7 +27,6 @@ import (
2627
sdk "github.com/cosmos/cosmos-sdk/types"
2728
"github.com/cosmos/cosmos-sdk/types/tx/signing"
2829
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
29-
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
3030

3131
crgerrs "github.com/cosmos/rosetta/lib/errors"
3232
crgtypes "github.com/cosmos/rosetta/lib/types"
@@ -161,7 +161,7 @@ func (c converter) UnsignedTx(ops []*rosettatypes.Operation) (tx authsigning.Tx,
161161
return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error())
162162
}
163163

164-
signers, _, err := c.cdc.GetMsgV1Signers(msg)
164+
signers, _, err := c.cdc.GetMsgSigners(msg)
165165
if err != nil {
166166
return nil, crgerrs.WrapError(crgerrs.ErrConverter, fmt.Sprintf("while getting msg signers %s", err.Error()))
167167
}
@@ -241,7 +241,7 @@ func (c converter) Ops(status string, msg sdk.Msg) ([]*rosettatypes.Operation, e
241241
return nil, crgerrs.WrapError(crgerrs.ErrConverter, fmt.Sprintf("while getting meta from message %s", err.Error()))
242242
}
243243

244-
signers, _, err := c.cdc.GetMsgV1Signers(msg)
244+
signers, _, err := c.cdc.GetMsgSigners(msg)
245245
if err != nil {
246246
return nil, crgerrs.WrapError(crgerrs.ErrConverter, fmt.Sprintf("while getting msg signers in Ops %s", err.Error()))
247247
}

Diff for: converter_test.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import (
99
abci "github.com/cometbft/cometbft/abci/types"
1010
"github.com/stretchr/testify/suite"
1111

12+
bank "cosmossdk.io/x/bank/types"
13+
1214
"github.com/cosmos/cosmos-sdk/client"
1315
"github.com/cosmos/cosmos-sdk/codec"
16+
"github.com/cosmos/cosmos-sdk/codec/address"
1417
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
1518
sdk "github.com/cosmos/cosmos-sdk/types"
1619
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
1720
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
18-
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
1921

2022
"github.com/cosmos/rosetta"
2123
crgerrs "github.com/cosmos/rosetta/lib/errors"
@@ -41,7 +43,7 @@ func (s *ConverterTestSuite) SetupTest() {
4143
s.unsignedTxBytes = unsignedTxBytes
4244
// instantiate converter
4345
cdc, ir := rosetta.MakeCodec()
44-
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
46+
txConfig := authtx.NewTxConfig(cdc, address.NewBech32Codec("cosmos"), address.NewBech32Codec("cosmosvaloper"), authtx.DefaultSignModes)
4547
s.c = rosetta.NewConverter(cdc, ir, txConfig)
4648
// add utils
4749
s.ir = ir
@@ -132,7 +134,7 @@ func (s *ConverterTestSuite) TestMsgToMetaMetaToMsg() {
132134
func (s *ConverterTestSuite) TestSignedTx() {
133135
s.Run("success", func() {
134136
const payloadsJSON = `[{"hex_bytes":"82ccce81a3e4a7272249f0e25c3037a316ee2acce76eb0c25db00ef6634a4d57303b2420edfdb4c9a635ad8851fe5c7a9379b7bc2baadc7d74f7e76ac97459b5","signing_payload":{"address":"cosmos147klh7th5jkjy3aajsj2rqvhtvh9mfde37wq5g","hex_bytes":"ed574d84b095250280de38bf8c254e4a1f8755e5bd300b1f6ca2671688136ecc","account_identifier":{"address":"cosmos147klh7th5jkjy3aajsj2rqvhtvh9mfde37wq5g"},"signature_type":"ecdsa"},"public_key":{"hex_bytes":"034c92046950c876f4a5cb6c7797d6eeb9ef80d67ced4d45fb62b1e859240ba9ad","curve_type":"secp256k1"},"signature_type":"ecdsa"}]`
135-
const expectedSignedTxHex = "0a8e010a8b010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126b0a2d636f736d6f733134376b6c68377468356a6b6a793361616a736a3272717668747668396d666465333777713567122d636f736d6f73316d6e7670386c786b616679346c787777617175356561653764787630647a36687767797436331a0b0a057374616b651202313612620a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034c92046950c876f4a5cb6c7797d6eeb9ef80d67ced4d45fb62b1e859240ba9ad12040a02087f12100a0a0a057374616b651201311090a10f1a4082ccce81a3e4a7272249f0e25c3037a316ee2acce76eb0c25db00ef6634a4d57303b2420edfdb4c9a635ad8851fe5c7a9379b7bc2baadc7d74f7e76ac97459b5"
137+
const expectedSignedTxHex = "0a9b010a8b010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126b0a2d636f736d6f733134376b6c68377468356a6b6a793361616a736a3272717668747668396d666465333777713567122d636f736d6f73316d6e7670386c786b616679346c787777617175356561653764787630647a36687767797436331a0b0a057374616b65120231362a0b088092b8c398feffffff011291010a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034c92046950c876f4a5cb6c7797d6eeb9ef80d67ced4d45fb62b1e859240ba9ad12040a02087f123f0a0a0a057374616b651201311090a10f1a2d636f736d6f733134376b6c68377468356a6b6a793361616a736a3272717668747668396d6664653337777135671a4082ccce81a3e4a7272249f0e25c3037a316ee2acce76eb0c25db00ef6634a4d57303b2420edfdb4c9a635ad8851fe5c7a9379b7bc2baadc7d74f7e76ac97459b5"
136138

137139
var payloads []*rosettatypes.Signature
138140
s.Require().NoError(json.Unmarshal([]byte(payloadsJSON), &payloads))
@@ -288,14 +290,16 @@ func (s *ConverterTestSuite) TestBalanceOps() {
288290

289291
// TODO - Investigate / fix sdk update discrepancies
290292
s.Run("multiple balance ops from 2 multicoins event", func() {
291-
subBalanceOp := bank.NewCoinSpentEvent(
292-
sdk.AccAddress("test"),
293-
sdk.NewCoins(sdk.NewInt64Coin("test", 10), sdk.NewInt64Coin("utxo", 10)),
293+
subBalanceOp := sdk.NewEvent(
294+
bank.EventTypeCoinSpent,
295+
sdk.NewAttribute(bank.AttributeKeySpender, sdk.AccAddress("test").String()), // TODO remove string address
296+
sdk.NewAttribute(sdk.AttributeKeyAmount, sdk.NewCoins(sdk.NewInt64Coin("test", 10), sdk.NewInt64Coin("utxo", 10)).String()),
294297
)
295298

296-
addBalanceOp := bank.NewCoinReceivedEvent(
297-
sdk.AccAddress("test"),
298-
sdk.NewCoins(sdk.NewInt64Coin("test", 10), sdk.NewInt64Coin("utxo", 10)),
299+
addBalanceOp := sdk.NewEvent(
300+
bank.EventTypeCoinReceived,
301+
sdk.NewAttribute(bank.AttributeKeyReceiver, sdk.AccAddress("test").String()), // TODO: remove string address
302+
sdk.NewAttribute(sdk.AttributeKeyAmount, sdk.NewCoins(sdk.NewInt64Coin("test", 10), sdk.NewInt64Coin("utxo", 10)).String()),
299303
)
300304

301305
ops := s.c.ToRosetta().BalanceOps("", []abci.Event{(abci.Event)(subBalanceOp), (abci.Event)(addBalanceOp)})

0 commit comments

Comments
 (0)