Skip to content
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

Error while distributing rewards #622

Closed
DylanVerstraete opened this issue Feb 28, 2023 · 9 comments
Closed

Error while distributing rewards #622

DylanVerstraete opened this issue Feb 28, 2023 · 9 comments
Assignees
Labels
type_bug Something isn't working
Milestone

Comments

@DylanVerstraete
Copy link
Contributor

Seen on testnet

2023-02-28 10:44:36 πŸ’€ Idle (8 peers), best: #7153780 (0xfb24…88ff), finalized #7153777 (0x5f93…433b), ⬇ 9.3kiB/s ⬆ 13.0kiB/s    
2023-02-28 10:44:41 πŸ’€ Idle (8 peers), best: #7153780 (0xfb24…88ff), finalized #7153778 (0x8674…852b), ⬇ 11.4kiB/s ⬆ 12.6kiB/s    
2023-02-28 10:44:42 Transfering: 25 from contract twin  to foundation account     
2023-02-28 10:44:42 error while distributing cultivation rewards <wasm:stripped>
@DylanVerstraete DylanVerstraete added the type_bug Something isn't working label Feb 28, 2023
@renauter
Copy link
Collaborator

renauter commented Mar 1, 2023

Investigation of the case on Testnet

Looking at block #7153778 we can see the failing extrinsic:
https://polkadot.js.org/apps/?rpc=wss%3A%2F%2F/tfchain.test.grid.tf#/explorer/query/7153778

image

It corresponds to a failing transaction from this account: 5G3t9VaCQf5M2PawGz3iENYMwzpbMkaqZ1nxavnEaH2oPa3K
which state at this block is:

image

The error Balances.KeepAlive / Transfer/payment would kill account is triggered because of

  consumers: 1
  providers: 1

which returns false here:

https://github.com/paritytech/substrate/blob/cb4f2491b00af7d7817f3a54209c26b20faa1f51/frame/system/src/lib.rs#L1233

	/// True if the account has no outstanding consumer references or more than one provider.
	pub fn can_dec_provider(who: &T::AccountId) -> bool {
		let a = Account::<T>::get(who);
		a.consumers == 0 || a.providers > 1
	}

while transferring in the transfer() function:

https://github.com/paritytech/substrate/blob/cb4f2491b00af7d7817f3a54209c26b20faa1f51/frame/balances/src/lib.rs#L1546

@renauter
Copy link
Collaborator

renauter commented Mar 1, 2023

But no idea about the account 5G3t9VaCQf5M2PawGz3iENYMwzpbMkaqZ1nxavnEaH2oPa3K, in which context it is billed and how it get in the consumers: 1 / providers: 1 case

Just found it was a billing for contract ID 716 which is a node contract

image

@renauter renauter self-assigned this Mar 1, 2023
@DylanVerstraete
Copy link
Contributor Author

I think this error is because we try to distribute rewards from contracts that are in grace but the balance of the user's twin is not enough to cover the costs. We should actually not try to distribute rewards when a contract is in grace period.

@renauter
Copy link
Collaborator

renauter commented Mar 2, 2023

I think this error is because we try to distribute rewards from contracts that are in grace but the balance of the user's twin is not enough to cover the costs. We should actually not try to distribute rewards when a contract is in grace period.

We distribute rewards inside handle_lock()
And just before we prevent to do it if contract is in grace period
See here:

if matches!(contract.state, types::ContractState::GracePeriod(_)) {

So I am not sure it is the right cause...

@DylanVerstraete
Copy link
Contributor Author

Hmm okay, might need to dig deeper then

@xmonader
Copy link
Contributor

xmonader commented Mar 8, 2023

should this be moved to blocked?

@DylanVerstraete
Copy link
Contributor Author

After some investigation I think this issue will be resolved by: #631

@xmonader xmonader added this to the 2.3.0 milestone Mar 8, 2023
@A-Harby
Copy link

A-Harby commented Mar 19, 2023

Closing as issue was fixed in #631 and haven't reproduce again on the chain.

@A-Harby A-Harby closed this as completed Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type_bug Something isn't working
Projects
No open projects
Status: βœ… Done
Development

No branches or pull requests

4 participants