Skip to content

Commit

Permalink
accountSequence zero on genesis transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Villaquiranm committed Nov 24, 2024
1 parent 5e2ca66 commit d25215a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 2 additions & 5 deletions gno.land/pkg/gnoland/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,14 @@ func LoadPackagesFromDir(dir string, creatorMnemonic string, chainID string, fee
nonDraftPkgs := sortedPkgs.GetNonDraftPkgs()
txs := make([]TxWithMetadata, 0, len(nonDraftPkgs))

baseAccount := std.NewBaseAccountWithAddress(info.GetAddress())

for _, pkg := range nonDraftPkgs {
accountSequence := baseAccount.GetSequence()
tx, err := LoadPackage(pkg, info.GetAddress(), fee, nil)
if err != nil {
return nil, fmt.Errorf("unable to load package %q: %w", pkg.Dir, err)
}

txData, err := tx.GetSignBytes(chainID, 0, accountSequence)
// Both account number and account sequence are 0 on genesis transactions
txData, err := tx.GetSignBytes(chainID, 0, 0)
if err != nil {
return nil, fmt.Errorf("unable to generate mnemonic, %w", err)
}
Expand All @@ -189,7 +187,6 @@ func LoadPackagesFromDir(dir string, creatorMnemonic string, chainID string, fee
txs = append(txs, TxWithMetadata{
Tx: tx,
})
baseAccount.SetSequence(accountSequence + 1)
}

return txs, nil
Expand Down
4 changes: 3 additions & 1 deletion tm2/pkg/sdk/auth/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,17 @@ func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit int64) sdk.Context {
// and an account.
func GetSignBytes(chainID string, tx std.Tx, acc std.Account, genesis bool) ([]byte, error) {
var accNum uint64
var accSequence uint64
if !genesis {
accNum = acc.GetAccountNumber()
accSequence = acc.GetSequence()
}

return std.GetSignaturePayload(
std.SignDoc{
ChainID: chainID,
AccountNumber: accNum,
Sequence: acc.GetSequence(),
Sequence: accSequence,
Fee: tx.Fee,
Msgs: tx.Msgs,
Memo: tx.Memo,
Expand Down

0 comments on commit d25215a

Please sign in to comment.