From 484ca2770092e7d25d82eb5cfc851a9ac3593338 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 24 Jan 2025 02:57:55 -0500 Subject: [PATCH 1/5] fix(x/auth/tx): add missing timeoutTimestamp in newBuilderFromDecodedTx (#23492) (cherry picked from commit 494389d15a8c8c7030e4e71c44f68006da1006ca) --- CHANGELOG.md | 1 + x/auth/tx/builder.go | 19 ++++++++++++++++++- x/auth/tx/builder_test.go | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5049cb1f1031..a11fc5fabe7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (x/auth/tx) [#23492](https://github.com/cosmos/cosmos-sdk/pull/23492) Add missing timeoutTimestamp in newBuilderFromDecodedTx. * (client/keys) [#24041](https://github.com/cosmos/cosmos-sdk/pull/24041) `keys delete` won't terminate when a key is not found, but will log the error. * (baseapp) [#24027](https://github.com/cosmos/cosmos-sdk/pull/24027) Ensure that `BaseApp.Init` checks that the commit multistore is set to protect against nil dereferences. * (x/group) [GHSA-47ww-ff84-4jrg](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-47ww-ff84-4jrg) Fix x/group can halt when erroring in EndBlocker diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index e211ecf27a5e..5f40ef161567 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -68,7 +68,24 @@ func newBuilder(cdc codec.Codec) *wrapper { }, }, } - return w + + return &builder{ + addressCodec: addrCodec, + decoder: decoder, + codec: codec, + msgs: decoded.Messages, + timeoutHeight: decoded.GetTimeoutHeight(), + granter: decoded.FeeGranter(), + payer: payer, + unordered: decoded.GetUnordered(), + memo: decoded.GetMemo(), + gasLimit: decoded.GetGas(), + fees: decoded.GetFee(), + signerInfos: sigInfos, + signatures: signatures, + extensionOptions: decoded.GetExtensionOptions(), + nonCriticalExtensionOptions: decoded.GetNonCriticalExtensionOptions(), + }, nil } func (w *wrapper) GetMsgs() []sdk.Msg { diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index 2fb88905beb2..edc9fb0d2bc9 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -333,3 +333,21 @@ func TestBuilderFeeGranter(t *testing.T) { txBuilder.SetFeeGranter(addr1) require.Equal(t, addr1.String(), sdk.AccAddress(txBuilder.GetTx().FeeGranter()).String()) } + +func TestBuilderWithTimeoutTimestamp(t *testing.T) { + cdc := codectestutil.CodecOptions{}.NewCodec() + interfaceRegistry := cdc.InterfaceRegistry() + signingCtx := interfaceRegistry.SigningContext() + txConfig := NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), DefaultSignModes) + txBuilder := txConfig.NewTxBuilder() + encodedTx, err := txConfig.TxJSONEncoder()(txBuilder.GetTx()) + require.NoError(t, err) + file := testutil.WriteToNewTempFile(t, string(encodedTx)) + clientCtx := client.Context{InterfaceRegistry: interfaceRegistry, TxConfig: txConfig} + decodedTx, err := authclient.ReadTxFromFile(clientCtx, file.Name()) + require.NoError(t, err) + txBldr, err := txConfig.WrapTxBuilder(decodedTx) + require.NoError(t, err) + b := txBldr.(*builder) + require.False(t, b.timeoutTimestamp.IsZero()) +} From fec0f985c4616bfa60ff43a1a87cabecc771a5f3 Mon Sep 17 00:00:00 2001 From: kdonthi Date: Fri, 21 Mar 2025 01:35:53 -0400 Subject: [PATCH 2/5] change back newBuilder --- x/auth/tx/builder.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index 5f40ef161567..e211ecf27a5e 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -68,24 +68,7 @@ func newBuilder(cdc codec.Codec) *wrapper { }, }, } - - return &builder{ - addressCodec: addrCodec, - decoder: decoder, - codec: codec, - msgs: decoded.Messages, - timeoutHeight: decoded.GetTimeoutHeight(), - granter: decoded.FeeGranter(), - payer: payer, - unordered: decoded.GetUnordered(), - memo: decoded.GetMemo(), - gasLimit: decoded.GetGas(), - fees: decoded.GetFee(), - signerInfos: sigInfos, - signatures: signatures, - extensionOptions: decoded.GetExtensionOptions(), - nonCriticalExtensionOptions: decoded.GetNonCriticalExtensionOptions(), - }, nil + return w } func (w *wrapper) GetMsgs() []sdk.Msg { From 401f39df83f2f92f770bda44d88b675974aac410 Mon Sep 17 00:00:00 2001 From: kdonthi Date: Fri, 21 Mar 2025 21:10:51 -0400 Subject: [PATCH 3/5] fix test to have timeout ts --- x/auth/tx/builder_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index edc9fb0d2bc9..70374ff09c8b 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -1,7 +1,11 @@ package tx import ( + "github.com/cosmos/cosmos-sdk/client" + testutil2 "github.com/cosmos/cosmos-sdk/testutil" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" "testing" + "time" "github.com/stretchr/testify/require" @@ -11,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/testutil" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -337,17 +342,18 @@ func TestBuilderFeeGranter(t *testing.T) { func TestBuilderWithTimeoutTimestamp(t *testing.T) { cdc := codectestutil.CodecOptions{}.NewCodec() interfaceRegistry := cdc.InterfaceRegistry() - signingCtx := interfaceRegistry.SigningContext() - txConfig := NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), DefaultSignModes) + interfaceRegistry.SigningContext() + txConfig := NewTxConfig(cdc, DefaultSignModes) txBuilder := txConfig.NewTxBuilder() + txBuilder.SetTimeoutTimestamp(time.Unix(1, 0)) encodedTx, err := txConfig.TxJSONEncoder()(txBuilder.GetTx()) require.NoError(t, err) - file := testutil.WriteToNewTempFile(t, string(encodedTx)) + file := testutil2.WriteToNewTempFile(t, string(encodedTx)) clientCtx := client.Context{InterfaceRegistry: interfaceRegistry, TxConfig: txConfig} decodedTx, err := authclient.ReadTxFromFile(clientCtx, file.Name()) require.NoError(t, err) txBldr, err := txConfig.WrapTxBuilder(decodedTx) require.NoError(t, err) - b := txBldr.(*builder) - require.False(t, b.timeoutTimestamp.IsZero()) + b := txBldr.(*wrapper) + require.False(t, b.tx.Body.TimeoutTimestamp.IsZero()) } From cf061149d8ac6a90fc9f67a213062ac743bb6d00 Mon Sep 17 00:00:00 2001 From: kdonthi Date: Tue, 25 Mar 2025 13:33:31 -0700 Subject: [PATCH 4/5] remove update to CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a11fc5fabe7d..5049cb1f1031 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,7 +54,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes -* (x/auth/tx) [#23492](https://github.com/cosmos/cosmos-sdk/pull/23492) Add missing timeoutTimestamp in newBuilderFromDecodedTx. * (client/keys) [#24041](https://github.com/cosmos/cosmos-sdk/pull/24041) `keys delete` won't terminate when a key is not found, but will log the error. * (baseapp) [#24027](https://github.com/cosmos/cosmos-sdk/pull/24027) Ensure that `BaseApp.Init` checks that the commit multistore is set to protect against nil dereferences. * (x/group) [GHSA-47ww-ff84-4jrg](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-47ww-ff84-4jrg) Fix x/group can halt when erroring in EndBlocker From 1c059d491a8a96b2c18d3086114c9807397fe171 Mon Sep 17 00:00:00 2001 From: kdonthi Date: Tue, 25 Mar 2025 13:47:43 -0700 Subject: [PATCH 5/5] fix lint errors --- x/auth/tx/builder_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index 70374ff09c8b..d64d920c880c 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -1,9 +1,6 @@ package tx import ( - "github.com/cosmos/cosmos-sdk/client" - testutil2 "github.com/cosmos/cosmos-sdk/testutil" - authclient "github.com/cosmos/cosmos-sdk/x/auth/client" "testing" "time" @@ -12,16 +9,18 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/testutil" - codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + testutil2 "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" txtypes "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" ) func TestTxBuilder(t *testing.T) { @@ -340,7 +339,7 @@ func TestBuilderFeeGranter(t *testing.T) { } func TestBuilderWithTimeoutTimestamp(t *testing.T) { - cdc := codectestutil.CodecOptions{}.NewCodec() + cdc := testutil.CodecOptions{}.NewCodec() interfaceRegistry := cdc.InterfaceRegistry() interfaceRegistry.SigningContext() txConfig := NewTxConfig(cdc, DefaultSignModes)