Skip to content

Commit

Permalink
add checkpointed event to interface and ForceMove
Browse files Browse the repository at this point in the history
  • Loading branch information
nksazonov committed Oct 13, 2023
1 parent ebb5130 commit 9d3a669
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
26 changes: 12 additions & 14 deletions packages/nitro-protocol/contracts/ForceMove.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,19 @@ contract ForceMove is IForceMove, StatusManager {
(supported, reason) = _stateIsSupported(fixedPart, proof, candidate);
require(supported, reason);

ChannelMode currMode = _mode(channelId);

// effects
_clearChallenge(channelId, candidateTurnNum);
statusOf[channelId] = _generateStatus(
ChannelData(candidateTurnNum, 0, bytes32(0), bytes32(0))
);

if (currMode == ChannelMode.Open) {
emit Checkpointed(channelId, candidateTurnNum);
} else {
// `Finalized` was ruled out by the require above
emit ChallengeCleared(channelId, candidateTurnNum);
}
}

/**
Expand Down Expand Up @@ -272,19 +283,6 @@ contract ForceMove is IForceMove, StatusManager {
return rvp;
}

/**
* @notice Clears a challenge by updating the turnNumRecord and resetting the remaining channel storage fields, and emits a ChallengeCleared event.
* @dev Clears a challenge by updating the turnNumRecord and resetting the remaining channel storage fields, and emits a ChallengeCleared event.
* @param channelId Unique identifier for a channel.
* @param newTurnNumRecord New turnNumRecord to overwrite existing value
*/
function _clearChallenge(bytes32 channelId, uint48 newTurnNumRecord) internal {
statusOf[channelId] = _generateStatus(
ChannelData(newTurnNumRecord, 0, bytes32(0), bytes32(0))
);
emit ChallengeCleared(channelId, newTurnNumRecord);
}

/**
* @notice Checks that the submitted turnNumRecord is strictly greater than the turnNumRecord stored on chain.
* @dev Checks that the submitted turnNumRecord is strictly greater than the turnNumRecord stored on chain.
Expand Down
7 changes: 7 additions & 0 deletions packages/nitro-protocol/contracts/interfaces/IForceMove.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ interface IForceMove is INitroTypes {
*/
event ChallengeCleared(bytes32 indexed channelId, uint48 newTurnNumRecord);

/**
* @dev Indicates that an on-chain channel data was successfully updated and now has `newTurnNumRecord` as the latest turn number.
* @param channelId Unique identifier for a state channel.
* @param newTurnNumRecord A latest turnNum that (the adjudicator knows) is supported by adhering to channel application rules.
*/
event Checkpointed(bytes32 indexed channelId, uint48 newTurnNumRecord);

/**
* @dev Indicates that a challenge has been registered against `channelId`.
* @param channelId Unique identifier for a state channel.
Expand Down

0 comments on commit 9d3a669

Please sign in to comment.