Skip to content

Commit

Permalink
x/auth: fetch one account after another
Browse files Browse the repository at this point in the history
- Don't read all accounts in one go as signature verification
  could fail before last signature is checked.

- TestAnteHandlerFees now checks whether fees were actually
  deducted from the account as well as the fee keeper collected
  them.

Thanks: @ValarDragon for pointing this out
Closes: #3093
  • Loading branch information
Alessio Treglia committed Dec 18, 2018
1 parent badae30 commit e4ac290
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions x/auth/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,11 @@ func NewAnteHandler(am AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler {
}

// GetSignerAcc a signers for a given address that is expected to sign a transaction.
func GetSignerAcc(ctx sdk.Context, am AccountKeeper, addr sdk.AccAddress) (acc Account, res sdk.Result) {
acc = am.GetAccount(ctx, addr)
if acc == nil {
res = sdk.ErrUnknownAddress(addr.String()).Result()
return
func GetSignerAcc(ctx sdk.Context, am AccountKeeper, addr sdk.AccAddress) (Account, sdk.Result) {
if acc := am.GetAccount(ctx, addr); acc != nil {
return acc, sdk.Result{}
}
return
return nil, sdk.ErrUnknownAddress(addr.String()).Result()
}

// verify the signature and increment the sequence. If the account doesn't have
Expand Down Expand Up @@ -301,13 +299,12 @@ func SetGasMeter(simulate bool, ctx sdk.Context, stdTx StdTx) sdk.Context {

// GetSignBytes returns a slice of bytes to sign over for a given transaction
// and an account.
func GetSignBytes(chainID string, stdTx StdTx, acc Account, genesis bool) (signBytes []byte) {
func GetSignBytes(chainID string, stdTx StdTx, acc Account, genesis bool) []byte {
accNum := acc.GetAccountNumber()
if genesis {
accNum = 0
}
signBytes = StdSignBytes(chainID,
return StdSignBytes(chainID,
accNum, acc.GetSequence(),
stdTx.Fee, stdTx.Msgs, stdTx.Memo)
return
}

0 comments on commit e4ac290

Please sign in to comment.