Skip to content

Commit

Permalink
Merge pull request #1751 from matter-labs/fix-forced-exit
Browse files Browse the repository at this point in the history
Fix forced exit
  • Loading branch information
Deniallugo authored Jul 14, 2021
2 parents 812dc00 + eebbe59 commit 4b86e84
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion core/bin/zksync_core/src/eth_watch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ impl<W: EthClient> EthWatch<W> {
new_tokens,
register_nft_factory_events,
);

self.set_new_state(new_state);
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions core/lib/state/src/handler/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub enum ForcedExitOpError {
InvalidTokenId,
#[error("Target account is not locked; forced exit is forbidden")]
TargetAccountNotLocked,
#[error("Target account is invalid")]
InvalidTargetAccount,
#[error("Nonce mismatch")]
NonceMismatch,
#[error("Initiator account: Not enough balance to cover fees")]
Expand Down
8 changes: 7 additions & 1 deletion core/lib/state/src/handler/forced_exit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::time::Instant;
use zksync_crypto::params;
use zksync_types::{AccountUpdate, AccountUpdates, ForcedExit, ForcedExitOp, PubKeyHash, ZkSyncOp};
use zksync_types::{
AccountUpdate, AccountUpdates, Address, ForcedExit, ForcedExitOp, PubKeyHash, ZkSyncOp,
};
use zksync_utils::BigUintSerdeWrapper;

use crate::{
Expand Down Expand Up @@ -54,6 +56,10 @@ impl TxHandler<ForcedExit> for ZkSyncState {
account.pub_key_hash == PubKeyHash::default(),
ForcedExitOpError::TargetAccountNotLocked
);
invariant!(
account.address != Address::default(),
ForcedExitOpError::InvalidTargetAccount
);

// Obtain the token balance to be withdrawn.
let account_balance = self
Expand Down

0 comments on commit 4b86e84

Please sign in to comment.