Skip to content

Commit

Permalink
Update DataConsumerWithSequencerCheck.sol (#1995)
Browse files Browse the repository at this point in the history
* Update DataConsumerWithSequencerCheck.sol

* Add optional code for invalid L2 feed round

* Clarify how to handle startedAt 0

* Update src/content/data-feeds/l2-sequencer-feeds.mdx

Co-authored-by: Crystal Gomes <thedriftofwords@users.noreply.github.com>

* Restore example and update startedAt description

* Edit

---------

Co-authored-by: Dwight Lyle <dwightjl@gmail.com>
Co-authored-by: Crystal Gomes <thedriftofwords@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 8, 2024
1 parent 4209004 commit 5f3223c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/content/data-feeds/l2-sequencer-feeds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ This example code works on the Arbitrum, Optimism, and Metis networks. Create th

The `sequencerUptimeFeed` object returns the following values:

- `answer`: A variable with a value of either `1` or `0`
- `answer`: A variable with a value of either `0` or `1`
- 0: The sequencer is up
- 1: The sequencer is down
- `startedAt`: This timestamp indicates when the sequencer changed status. This timestamp returns `0` if a round is invalid. When the sequencer comes back up after an outage, wait for the `GRACE_PERIOD_TIME` to pass before accepting answers from the data feed. Subtract `startedAt` from `block.timestamp` and revert the request if the result is less than the `GRACE_PERIOD_TIME`.
- `startedAt`: This timestamp indicates when the sequencer feed changed status. When the sequencer comes back up after an outage, wait for the `GRACE_PERIOD_TIME` to pass before accepting answers from the data feed. Subtract `startedAt` from `block.timestamp` and revert the request if the result is less than the `GRACE_PERIOD_TIME`.
- The `startedAt` variable returns `0` only on Arbitrum when the Sequencer Uptime contract is not yet initialized. For L2 chains other than Arbitrum, `startedAt` is set to `block.timestamp` on construction and `startedAt` is never `0`. After the feed begins rounds, the `startedAt` timestamp will always indicate when the sequencer feed last changed status.

If the sequencer is up and the `GRACE_PERIOD_TIME` has passed, the function retrieves the latest answer from the data feed using the `dataFeed` object.

0 comments on commit 5f3223c

Please sign in to comment.