-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing a transaction with a profile results in never-ending balance withdraws #416
Comments
After a lot of investigations, and thanks to @dimiandre and @AmauryM, we found out what was causing this. Apparently, inside Cosmos when a transaction fails the sequence of the account is incremented anyway. This results, on the next block, to make the transaction invalid as the account will have a different sequence from the one used to sign it. Being invalid, the transaction will be removed from the mempool and not be included in the next block. In this case, when a transaction is performed by a
We found out this is caused by the fact that for a // GetAccount returns the underlying account as an authtypes.AccountI instance
func (p *Profile) GetAccount() authtypes.AccountI {
return p.Account.GetCachedValue().(authtypes.AccountI)
}
// SetSequence implements authtypes.AccountI
func (p *Profile) SetSequence(sequence uint64) error {
return p.GetAccount().SetSequence(sequence)
} As you can see, the The problem with this approach is that we're only updating the cached account, and not the real one. To solve this, we need to change all // SetSequence implements authtypes.AccountI
func (p *Profile) SetSequence(sequence uint64) error {
acc := p.GetAccount()
err := acc.SetSequence(sequence)
if err != nil {
return err
}
accAny, err := codectypes.NewAnyWithValue(acc)
if err != nil {
return err
}
p.Account = accAny
return nil
} This will make sure that changes are also stored inside the underlying A test should also be added to make sure that this bug does not happen anymore. |
Bug description
Inside Apollo, if you perform a transaction with a fee after you create a profile, and that transaction fails, your balance will start loosing tokens every block until there are no more funds to get.
Steps to reproduce
amount
greater than the overall balance) and set a feeExpected behavior
After a transaction fails, the balance should not continue to drop.
The text was updated successfully, but these errors were encountered: