Skip to content

Commit

Permalink
chore: CEI pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Sep 19, 2024
1 parent 504153b commit f64616e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bolt-contracts/src/contracts/BoltChallenger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ contract BoltChallenger is IBoltChallenger {
}

// If the challenge has expired without being resolved, it is considered lost.
emit ChallengeLost(challengeID);
_transferFullBond(challenge.challenger);
challenge.status = ChallengeStatus.Lost;
_transferFullBond(challenge.challenger);
emit ChallengeLost(challengeID);
}

/// @notice Resolve a challenge by providing proofs of the inclusion of the committed transaction.
Expand All @@ -214,9 +214,9 @@ contract BoltChallenger is IBoltChallenger {

if (challenge.openedAt + MAX_CHALLENGE_DURATION < Time.timestamp()) {
// If the challenge has expired without being resolved, it is considered lost.
emit ChallengeLost(challengeID);
_transferFullBond(challenge.challenger);
challenge.status = ChallengeStatus.Lost;
_transferFullBond(challenge.challenger);
emit ChallengeLost(challengeID);
return;
}

Expand Down Expand Up @@ -246,10 +246,10 @@ contract BoltChallenger is IBoltChallenger {
// The sender (accountToProve) has sent a transaction with a higher nonce than the committed
// transaction, before the proposer could include it. Consider the challenge defended, as the
// proposer is not at fault. The bond will be shared between the resolver and commitment signer.
emit ChallengeDefended(challengeID);
challenge.status = ChallengeStatus.Defended;
_transferHalfBond(msg.sender);
_transferHalfBond(challenge.target);
challenge.status = ChallengeStatus.Defended;
emit ChallengeDefended(challengeID);
return;
} else if (account.nonce < decodedTx.nonce) {
// Q: is this a valid case? technically the proposer would be at fault for accepting a commitment of an
Expand All @@ -260,10 +260,10 @@ contract BoltChallenger is IBoltChallenger {
// The account does not have enough balance to pay for the worst-case base fee of the committed transaction.
// Consider the challenge defended, as the proposer is not at fault. The bond will be shared between the
// resolver and commitment signer.
emit ChallengeDefended(challengeID);
challenge.status = ChallengeStatus.Defended;
_transferHalfBond(msg.sender);
_transferHalfBond(challenge.target);
challenge.status = ChallengeStatus.Defended;
emit ChallengeDefended(challengeID);
return;
}

Expand All @@ -287,10 +287,10 @@ contract BoltChallenger is IBoltChallenger {

// If all checks pass, the challenge is considered defended as the proposer defended with valid proofs.
// The bond will be shared between the resolver and commitment signer.
emit ChallengeDefended(challengeID);
challenge.status = ChallengeStatus.Defended;
_transferHalfBond(msg.sender);
_transferHalfBond(challenge.target);
challenge.status = ChallengeStatus.Defended;
emit ChallengeDefended(challengeID);
}

// ========= HELPERS =========
Expand Down

0 comments on commit f64616e

Please sign in to comment.