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

[DEPLOY-178]: Adds Scroll L2EP Contracts #11405

Merged
merged 23 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ab23752
Adds scroll L2EP contracts and tests
chris-de-leon-cll Nov 30, 2023
74d7a91
fixes comments, adds fixed solidity compiler version, and adds scroll…
chris-de-leon-cll Dec 1, 2023
2443b2d
renames SCROLL_CROSS_DOMAIN_MESSENGER to i_SCROLL_CROSS_DOMAIN_MESSEN…
chris-de-leon-cll Dec 1, 2023
6ec4f81
removes unnecessary solhint disable rule
chris-de-leon-cll Dec 1, 2023
a6e29b7
moves scroll mocks from tests folder to l2ep folder
chris-de-leon-cll Dec 1, 2023
c26330f
resolve solhint errors for scroll
chris-de-leon-cll Dec 1, 2023
7a849cc
proposed restructure to reduce inheritance
RensR Dec 4, 2023
785fc51
Merge pull request #11471 from smartcontractkit/l2ep-fixes
chris-de-leon-cll Dec 4, 2023
e81403d
Merge branch 'develop' into feat/DEPLOY-178-l2ep-scroll
chris-de-leon-cll Dec 4, 2023
1405c41
removes extraneous comments from scroll contracts and refactors typeA…
chris-de-leon-cll Dec 4, 2023
6786173
use named parameters in mappings for scroll contracts
chris-de-leon-cll Dec 4, 2023
b6df5fe
removes extraneous empty comments from scroll contracts (again)
chris-de-leon-cll Dec 4, 2023
a006199
removes unnecessary comment from scroll cross domain governor
chris-de-leon-cll Dec 4, 2023
9db4bb9
Merge branch 'develop' into feat/DEPLOY-178-l2ep-scroll
chris-de-leon-cll Dec 4, 2023
3c38e37
adds minor formatting updates to scroll mocks
chris-de-leon-cll Dec 4, 2023
ced25df
adds onlyL1Owner modifier back to ScrollCrossDomainGovernor
chris-de-leon-cll Dec 4, 2023
e0076a6
Merge branch 'develop' into feat/DEPLOY-178-l2ep-scroll
chris-de-leon-cll Dec 4, 2023
5f58f39
adds style and formatting improvements
chris-de-leon-cll Dec 6, 2023
f281a4b
adds formatting updates
chris-de-leon-cll Dec 6, 2023
e1402b9
Merge branch 'develop' into feat/DEPLOY-178-l2ep-scroll
chris-de-leon-cll Dec 6, 2023
0a30bc9
Merge branch 'develop' into feat/DEPLOY-178-l2ep-scroll
chris-de-leon-cll Dec 8, 2023
ebbb791
refactors scroll sequencer uptime feed to reduce gas and updates test…
chris-de-leon-cll Dec 10, 2023
1b8c936
Merge branch 'develop' into feat/DEPLOY-178-l2ep-scroll
chris-de-leon-cll Dec 12, 2023
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
43 changes: 17 additions & 26 deletions contracts/src/v0.8/l2ep/dev/scroll/ScrollSequencerUptimeFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ contract ScrollSequencerUptimeFeed is
constructor(address l1SenderAddress, address l2CrossDomainMessengerAddr, bool initialStatus) {
_setL1Sender(l1SenderAddress);
s_l2CrossDomainMessenger = IL2ScrollMessenger(l2CrossDomainMessengerAddr);
uint64 timestamp = uint64(block.timestamp);

// Initialise roundId == 1 as the first round
_recordRound(1, initialStatus, timestamp);
_recordRound(1, initialStatus, uint64(block.timestamp));
}

/// @notice Check if a roundId is valid in this current contract state
Expand Down Expand Up @@ -115,12 +114,8 @@ contract ScrollSequencerUptimeFeed is
/// @param status Sequencer status
/// @param timestamp The L1 block timestamp of status update
function _recordRound(uint80 roundId, bool status, uint64 timestamp) private {
uint64 updatedAt = uint64(block.timestamp);
Round memory nextRound = Round(status, timestamp, updatedAt);
FeedState memory feedState = FeedState(roundId, status, timestamp, updatedAt);

s_rounds[roundId] = nextRound;
s_feedState = feedState;
s_feedState = FeedState(roundId, status, timestamp, uint64(block.timestamp));
s_rounds[roundId] = Round(status, timestamp, s_feedState.updatedAt);

emit NewRound(roundId, msg.sender, timestamp);
emit AnswerUpdated(_getStatusAnswer(status), roundId, timestamp);
Expand All @@ -130,10 +125,9 @@ contract ScrollSequencerUptimeFeed is
/// @param roundId The round ID to update
/// @param status Sequencer status
function _updateRound(uint80 roundId, bool status) private {
uint64 updatedAt = uint64(block.timestamp);
s_rounds[roundId].updatedAt = updatedAt;
s_feedState.updatedAt = updatedAt;
emit RoundUpdated(_getStatusAnswer(status), updatedAt);
s_feedState.updatedAt = uint64(block.timestamp);
s_rounds[roundId].updatedAt = s_feedState.updatedAt;
chris-de-leon-cll marked this conversation as resolved.
Show resolved Hide resolved
emit RoundUpdated(_getStatusAnswer(status), s_feedState.updatedAt);
}

/// @notice Record a new status and timestamp if it has changed since the last round.
Expand All @@ -142,24 +136,23 @@ contract ScrollSequencerUptimeFeed is
/// @param status Sequencer status
/// @param timestamp Block timestamp of status update
function updateStatus(bool status, uint64 timestamp) external override {
FeedState memory feedState = s_feedState;
chris-de-leon-cll marked this conversation as resolved.
Show resolved Hide resolved
if (
msg.sender != address(s_l2CrossDomainMessenger) || s_l2CrossDomainMessenger.xDomainMessageSender() != s_l1Sender
) {
revert InvalidSender();
}

// Ignore if latest recorded timestamp is newer
if (feedState.startedAt > timestamp) {
emit UpdateIgnored(feedState.latestStatus, feedState.startedAt, status, timestamp);
if (s_feedState.startedAt > timestamp) {
emit UpdateIgnored(s_feedState.latestStatus, s_feedState.startedAt, status, timestamp);
return;
}

if (feedState.latestStatus == status) {
_updateRound(feedState.latestRoundId, status);
if (s_feedState.latestStatus == status) {
_updateRound(s_feedState.latestRoundId, status);
} else {
feedState.latestRoundId += 1;
_recordRound(feedState.latestRoundId, status, timestamp);
s_feedState.latestRoundId += 1;
_recordRound(s_feedState.latestRoundId, status, timestamp);
}
}

Expand Down Expand Up @@ -223,14 +216,12 @@ contract ScrollSequencerUptimeFeed is
checkAccess
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
{
FeedState memory feedState = s_feedState;

return (
feedState.latestRoundId,
_getStatusAnswer(feedState.latestStatus),
feedState.startedAt,
feedState.updatedAt,
feedState.latestRoundId
s_feedState.latestRoundId,
chris-de-leon-cll marked this conversation as resolved.
Show resolved Hide resolved
_getStatusAnswer(s_feedState.latestStatus),
s_feedState.startedAt,
s_feedState.updatedAt,
s_feedState.latestRoundId
);
}
}
4 changes: 2 additions & 2 deletions contracts/test/v0.8/dev/ScrollSequencerUptimeFeed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('ScrollSequencerUptimeFeed', () => {
// Assert no update
expect(await scrollUptimeFeed.latestAnswer()).to.equal(0)
expect(noUpdateTx.cumulativeGasUsed.toNumber()).to.be.closeTo(
38594,
38694,
gasUsedDeviation,
)

Expand All @@ -317,7 +317,7 @@ describe('ScrollSequencerUptimeFeed', () => {
// Assert update
expect(await scrollUptimeFeed.latestAnswer()).to.equal(1)
expect(updateTx.cumulativeGasUsed.toNumber()).to.be.closeTo(
60170,
chris-de-leon-cll marked this conversation as resolved.
Show resolved Hide resolved
58995,
gasUsedDeviation,
)
})
Expand Down
Loading