Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonShiesty committed Nov 9, 2023
1 parent 8492b7d commit bcec185
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions contracts/src/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ interface IRollup {
/// @dev Thrown when an attempt is made to grant a role to an account that already possesses the role.
error NoRoleToRevoke();

/// @dev Thrown when assertionData has incorrect encoding
/// @dev Thrown when underflow occurs reading assertion data
error AssertionDataUnderflow();

/// @dev Thrown when a assertion data has an incorrect version
/// @dev Thrown when assertion data has an incorrect version
error AssertionVersionIncorrect();

struct Staker {
Expand All @@ -140,7 +140,7 @@ interface IRollup {
}

struct Assertion {
bytes assertionData; // Hash of execution state associated with assertion. Currently equiv to `vmHash`.
bytes assertionData; // Versioned execution state associated with assertion. Currently equiv to `vmHash`.
uint256 blockNum; // Block number this assertion advanced to
uint256 parent; // Parent assertion ID
uint256 deadline; // Dispute deadline (L1 block number)
Expand Down
7 changes: 3 additions & 4 deletions contracts/src/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ abstract contract RollupBase is

struct AssertionState {
mapping(address => bool) stakers; // all stakers that have ever staked on this assertion.
mapping(bytes => bool) childStateHashes; // child assertion vm hashes
mapping(bytes => bool) childAssertionData; // child assertion data
}

struct Zombie {
Expand Down Expand Up @@ -597,10 +597,10 @@ contract Rollup is RollupBase {
parentAssertion.blockNum = blockNum;
} else if (blockNum != parentBlockNum) {
revert InvalidInboxSize();
} else if (parentAssertionState.childStateHashes[assertionData]) {
} else if (parentAssertionState.childAssertionData[assertionData]) {
revert DuplicateAssertion();
}
parentAssertionState.childStateHashes[assertionData] = true;
parentAssertionState.childAssertionData[assertionData] = true;
assertions[assertionID] = Assertion(
assertionData,
blockNum,
Expand All @@ -612,7 +612,6 @@ contract Rollup is RollupBase {
);
}


/**
* @notice Decode the vm hash from assertion data
* @param assertionData assertion data to decode
Expand Down
22 changes: 11 additions & 11 deletions contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ contract RollupTest is RollupBaseSetup {
_appendTxBatch();

bytes memory mockVmHash = bytes(hex"00");
uint256 mockInboxSize = 1;
uint256 mockBlockNum = 1;

// To avoid the MinimumAssertionPeriodNotPassed error, increase block.number
vm.roll(block.number + rollup.minimumAssertionPeriod());
Expand All @@ -733,7 +733,7 @@ contract RollupTest is RollupBaseSetup {
assertEq(assertionIDInitial, 0);

vm.prank(alice);
rollup.createAssertion(mockInboxSize, mockVmHash);
rollup.createAssertion(mockBlockNum, mockVmHash);

// The assertionID of alice should change after she called `createAssertion`
(,, uint256 assertionIDFinal,) = rollup.stakers(address(alice));
Expand Down Expand Up @@ -890,10 +890,10 @@ contract RollupTest is RollupBaseSetup {
_appendTxBatch();

bytes memory mockVmHash = bytes(hex"00");
uint256 mockInboxSize = 1;
uint256 mockBlockNum = 1;

vm.prank(alice);
rollup.createAssertion(mockInboxSize, mockVmHash);
rollup.createAssertion(mockBlockNum, mockVmHash);

// The assertionID of alice should change after she called `createAssertion`
(,, uint256 assertionIDFinal,) = rollup.stakers(address(alice));
Expand Down Expand Up @@ -982,15 +982,15 @@ contract RollupTest is RollupBaseSetup {
_appendTxBatch();

bytes memory mockVmHash = bytes(hex"00");
uint256 mockInboxSize = 1;
uint256 mockBlockNum = 1;

// To avoid the MinimumAssertionPeriodNotPassed error, increase block.number
vm.roll(block.number + rollup.minimumAssertionPeriod());

assertEq(rollup.lastCreatedAssertionID(), 0, "The lastCreatedAssertionID should be 0 (genesis)");

vm.prank(alice);
rollup.createAssertion(mockInboxSize, mockVmHash);
rollup.createAssertion(mockBlockNum, mockVmHash);

// A successful assertion should bump the lastCreatedAssertionID to 1.
assertEq(rollup.lastCreatedAssertionID(), 1, "LastCreatedAssertionID not updated correctly");
Expand Down Expand Up @@ -1048,7 +1048,7 @@ contract RollupTest is RollupBaseSetup {
_appendTxBatch();

bytes memory mockVmHash = bytes(hex"00");
uint256 mockInboxSize = 1;
uint256 mockBlockNum = 1;

// To avoid the MinimumAssertionPeriodNotPassed error, increase block.number
vm.roll(block.number + rollup.minimumAssertionPeriod());
Expand All @@ -1062,15 +1062,15 @@ contract RollupTest is RollupBaseSetup {
// try as alice
vm.expectRevert("Pausable: paused");
vm.prank(alice);
rollup.createAssertion(mockInboxSize, mockVmHash);
rollup.createAssertion(mockBlockNum, mockVmHash);

// unpause and continue setup
vm.prank(deployer);
rollup.unpause();

// try again now that pause is over
vm.prank(alice);
rollup.createAssertion(mockInboxSize, mockVmHash);
rollup.createAssertion(mockBlockNum, mockVmHash);

// A successful assertion should bump the lastCreatedAssertionID to 1.
assertEq(rollup.lastCreatedAssertionID(), 1, "LastCreatedAssertionID not updated correctly");
Expand Down Expand Up @@ -1195,13 +1195,13 @@ contract RollupTest is RollupBaseSetup {
_appendTxBatch();

bytes memory mockVmHash = bytes(hex"00");
uint256 mockInboxSize = 1;
uint256 mockBlockNum = 1;

// To avoid the MinimumAssertionPeriodNotPassed error, increase block.number
vm.roll(block.number + rollup.minimumAssertionPeriod());

vm.prank(alice);
rollup.createAssertion(mockInboxSize, mockVmHash);
rollup.createAssertion(mockBlockNum, mockVmHash);
}

uint256 defenderAssertionID = lastConfirmedAssertionID; //would be 0 in this case. cannot assign anything lower
Expand Down

0 comments on commit bcec185

Please sign in to comment.