-
Notifications
You must be signed in to change notification settings - Fork 552
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
fix remove contract #1739
fix remove contract #1739
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 980 to 1011 in e373273
/// Removes an account from Accounts and AccountStorages. | |
pub fn remove_account(address: &EvmAddress) -> DispatchResult { | |
// Deref code, and remove it if ref count is zero. | |
Accounts::<T>::mutate_exists(&address, |maybe_account| { | |
if let Some(account) = maybe_account { | |
if let Some(contract_info) = account.contract_info.clone() { | |
CodeInfos::<T>::mutate_exists(&contract_info.code_hash, |maybe_code_info| { | |
if let Some(code_info) = maybe_code_info.as_mut() { | |
code_info.ref_count = code_info.ref_count.saturating_sub(1); | |
if code_info.ref_count == 0 { | |
Codes::<T>::remove(&contract_info.code_hash); | |
account.contract_info = None; | |
*maybe_code_info = None; | |
} | |
} | |
}); | |
} | |
} | |
}); | |
if let Some(AccountInfo { | |
contract_info: Some(_), .. | |
}) = Accounts::<T>::take(address) | |
{ | |
// remove_account can only be called when account is killed. i.e. providers == 0 | |
// but contract_info should maintain a provider | |
// so this should never happen | |
debug_assert!(false); | |
} | |
Ok(()) | |
} |
remove line L1000-L1008 and add debug_assert!(false);
in mutate_exists
.
this will assert if remove_account is called while contract ref > 1 |
|
current impl is not removing contract_info