Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: snapshot id internal lib #4060

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ contract RootManager is ProposedOwnable, IRootManager, WatcherClient, DomainInde
return pendingInboundRoots.length();
}

/**
* @notice Get the duration of the snapshot
*
* @return _snapshotDuration The duration of the snapshot
*/
function getSnapshotDuration() external pure returns (uint256 _snapshotDuration) {
_snapshotDuration = SnapshotId.SNAPSHOT_DURATION;
}

// ============ Admin Functions ============

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@ abstract contract SpokeConnector is Connector, ConnectorManager, WatcherClient,
_lastCompletedSnapshotId = SnapshotId.getLastCompletedSnapshotId();
}

/**
* @notice Get the duration of the snapshot
*
* @return _snapshotDuration The duration of the snapshot
*/
function getSnapshotDuration() external pure returns (uint256 _snapshotDuration) {
_snapshotDuration = SnapshotId.SNAPSHOT_DURATION;
}

// ============ Private Functions ============

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library SnapshotId {
* @dev Off-chain agents could change the effective snapshot length by skipping snapshots. This is the
* smallest unit of snapshot duration, not just the only option.
*/
uint256 public constant SNAPSHOT_DURATION = 30 minutes;
uint256 constant SNAPSHOT_DURATION = 30 minutes;

/**
* @notice This function calculates the last completed snapshot id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,3 +1287,9 @@ contract RootManager_FinalizeAndPropagate is Base {
_rootManager.finalizeAndPropagate(_connectors, _fees, _encodedData, aggregateRoot, _endOfDispute);
}
}

contract RootManager_GetSnapshotDuration is Base {
function test_getSnapshotDuration() public {
assertEq(SnapshotId.SNAPSHOT_DURATION, _rootManager.getSnapshotDuration());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,9 @@ contract SpokeConnector_GetLastCompletedSnapshotId is Base {
assertEq(spokeConnector.getLastCompletedSnapshotId(), _snapshotId);
}
}

contract SpokeConnector_GetSnapshotDuration is Base {
function test_getSnapshotDuration() public {
assertEq(SnapshotId.SNAPSHOT_DURATION, spokeConnector.getSnapshotDuration());
}
}