From 5f3223c13a96666437d522b041d2ac8a78e6f3fc Mon Sep 17 00:00:00 2001 From: Antonio Viggiano Date: Thu, 8 Aug 2024 12:25:41 -0300 Subject: [PATCH] Update DataConsumerWithSequencerCheck.sol (#1995) * 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 * Restore example and update startedAt description * Edit --------- Co-authored-by: Dwight Lyle Co-authored-by: Crystal Gomes --- src/content/data-feeds/l2-sequencer-feeds.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/content/data-feeds/l2-sequencer-feeds.mdx b/src/content/data-feeds/l2-sequencer-feeds.mdx index fbdcb9e1f1c..16d1169ec76 100644 --- a/src/content/data-feeds/l2-sequencer-feeds.mdx +++ b/src/content/data-feeds/l2-sequencer-feeds.mdx @@ -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.