fix: sequence in sign-batch (#13200)
## Description Closes: #13199 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
parent
d07429425f
commit
04858ea2ea
@ -440,6 +440,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account.
|
||||
* (x/crisis) [#12208](https://github.com/cosmos/cosmos-sdk/pull/12208) Fix progress index of crisis invariant assertion logs.
|
||||
* (types) [#12229](https://github.com/cosmos/cosmos-sdk/pull/12229) Increase sdk.Dec maxApproxRootIterations to 300
|
||||
* (x/auth) [#13200](https://github.com/cosmos/cosmos-sdk/pull/13200) Fix wrong sequences in `sign-batch`
|
||||
|
||||
### State Machine Breaking
|
||||
|
||||
|
||||
@ -95,7 +95,26 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {
|
||||
scanner := authclient.NewBatchScanner(txCfg, infile)
|
||||
|
||||
if !clientCtx.Offline {
|
||||
txFactory = txFactory.WithAccountNumber(0).WithSequence(0)
|
||||
if ms == "" {
|
||||
from, err := cmd.Flags().GetString(flags.FlagFrom)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
addr, _, _, err := client.GetFromFields(clientCtx, txFactory.Keybase(), from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
acc, err := txFactory.AccountRetriever().GetAccount(clientCtx, addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
txFactory = txFactory.WithAccountNumber(acc.GetAccountNumber()).WithSequence(acc.GetSequence())
|
||||
} else {
|
||||
txFactory = txFactory.WithAccountNumber(0).WithSequence(0)
|
||||
}
|
||||
}
|
||||
|
||||
for sequence := txFactory.Sequence(); scanner.Scan(); sequence++ {
|
||||
|
||||
@ -285,6 +285,40 @@ func (s *IntegrationTestSuite) TestCLISignBatch() {
|
||||
// Sign batch malformed tx file signature only.
|
||||
_, err = TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
s.Require().Error(err)
|
||||
|
||||
// make a txn to increase the sequence of sender
|
||||
_, seq, err := val.ClientCtx.AccountRetriever.GetAccountNumberSequence(val.ClientCtx, val.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
account1, err := val.ClientCtx.Keyring.Key("newAccount1")
|
||||
s.Require().NoError(err)
|
||||
|
||||
addr, err := account1.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Send coins from validator to multisig.
|
||||
_, err = s.createBankMsg(
|
||||
val,
|
||||
addr,
|
||||
sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 1000)),
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// fetch the sequence after a tx, should be incremented.
|
||||
_, seq1, err := val.ClientCtx.AccountRetriever.GetAccountNumberSequence(val.ClientCtx, val.Address)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(seq+1, seq1)
|
||||
|
||||
// signing sign-batch should start from the last sequence.
|
||||
signed, err := TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
s.Require().NoError(err)
|
||||
signedTxs := strings.Split(strings.Trim(signed.String(), "\n"), "\n")
|
||||
s.Require().GreaterOrEqual(len(signedTxs), 1)
|
||||
|
||||
sigs, err := s.cfg.TxConfig.UnmarshalSignatureJSON([]byte(signedTxs[0]))
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(sigs[0].Sequence, seq1)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestCliGetAccountAddressByID() {
|
||||
@ -449,9 +483,10 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByHash() {
|
||||
sdk.NewCoins(sendTokens),
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
var txRes sdk.TxResponse
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user