Skip to content

Commit 9d66dbd

Browse files
majectyjoojis
authored andcommitted
Make sure a regular account is not automatically changed to its owner
1 parent eb42780 commit 9d66dbd

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

state/src/impls/top_level.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -608,21 +608,6 @@ impl TopLevelState {
608608
/// First searches for account in the local, then the shared cache.
609609
/// Populates local cache if nothing found.
610610
fn ensure_account_cached<F, U>(&self, a: &Address, f: F) -> TrieResult<U>
611-
where
612-
F: Fn(Option<&Account>) -> U, {
613-
let a = if self.regular_account_exists_and_not_null(a)? {
614-
let regular_account = self.require_regular_account_from_address(a)?;
615-
public_to_address(&regular_account.owner_public())
616-
} else {
617-
a.clone()
618-
};
619-
620-
self.ensure_master_account_cached(&a, f)
621-
}
622-
623-
/// Same with ensure_master_account.
624-
/// But do not pass regular_account redirection
625-
fn ensure_master_account_cached<F, U>(&self, a: &Address, f: F) -> TrieResult<U>
626611
where
627612
F: Fn(Option<&Account>) -> U, {
628613
let db = TrieFactory::readonly(self.db.as_hashdb(), &self.root)?;
@@ -736,10 +721,6 @@ impl TopState<StateDB> for TopLevelState {
736721
self.ensure_account_cached(a, |a| a.map_or(false, |a| !a.nonce().is_zero()))
737722
}
738723

739-
fn master_account_exists_and_not_null(&self, a: &Address) -> TrieResult<bool> {
740-
self.ensure_master_account_cached(a, |a| a.map_or(false, |a| !a.is_null()))
741-
}
742-
743724
fn regular_account_exists_and_not_null(&self, a: &Address) -> TrieResult<bool> {
744725
self.ensure_regular_account_cached(a, |a| a.map_or(false, |a| !a.is_null()))
745726
}
@@ -800,7 +781,7 @@ impl TopState<StateDB> for TopLevelState {
800781
return Err(ParcelError::RegularKeyAlreadyInUse.into())
801782
}
802783

803-
if self.master_account_exists_and_not_null(&regular_address)? {
784+
if self.account_exists_and_not_null(&regular_address)? {
804785
return Err(ParcelError::RegularKeyAlreadyInUseAsMaster.into())
805786
}
806787

state/src/traits.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ where
9090
fn account_exists_and_not_null(&self, a: &Address) -> TrieResult<bool>;
9191
fn account_exists_and_has_nonce(&self, a: &Address) -> TrieResult<bool>;
9292

93-
fn master_account_exists_and_not_null(&self, a: &Address) -> TrieResult<bool>;
9493
fn regular_account_exists_and_not_null(&self, a: &Address) -> TrieResult<bool>;
9594

9695
/// Add `incr` to the balance of account `a`.

0 commit comments

Comments
 (0)