You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: yarn-project/archiver/README.md
+25-4Lines changed: 25 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,37 @@
1
1
# Archiver
2
2
3
3
Archiver is a service which is used to fetch data on-chain data and present them in a nice-to-consume form.
4
+
4
5
The on-chain data specifically are the following events:
5
6
6
7
1.`L2BlockProposed` event emitted on Rollup contract,
7
8
2.`MessageAdded` event emitted on Inbox contract,
8
9
9
10
The interfaces defining how the data can be consumed from the archiver are `L2BlockSource`, `L2LogsSource` and `ContractDataSource`.
10
11
11
-
## Usage
12
+
## Sync process
13
+
14
+
The archiver sync process periodically checks its current state against the Rollup contract on L1 and updates its local state.
15
+
16
+
### Handling invalid blocks
17
+
18
+
After the implementation of [delayed attestation verification](https://github.com/AztecProtocol/engineering-designs/pull/69), the Rollup contract on L1 no longer validates committee attestations. Instead, these are posted in calldata, and L2 nodes are expected to verify them as they download blocks. The archiver handles this validation during its sync process.
19
+
20
+
Whenever the archiver detects a block with invalid attestations, it skips it. These blocks are not meant to be part of the chain, so the archiver ignores them and continues processing the next blocks. It is expected that an honest proposer will eventually invalidate these blocks, removing them from the chain on L1, and then resume the sequence of valid blocks.
21
+
22
+
> [!WARNING]
23
+
> If the committee for the epoch is also malicious and attests to a descendant of an invalid block, nodes should also ignore these descendants, unless they become proven. This is currently not implemented. Nodes assume that the majority of the committee is honest.
24
+
25
+
When the current node is elected as proposer, the `sequencer` needs to know whether there is an invalid block in L1 that needs to be purged before posting their own block. To support this, the archiver exposes a `pendingChainValidationStatus`, which is the state of the tip of the pending chain. This status can be valid in the happy path, or invalid if the tip of the pending chain has invalid attestations. If invalid, this status also contains all the data needed for purging the block from L1 via an `invalidate` call to the Rollup contract. Note that, if the head of the chain has more than one invalid consecutive block, this status will reference the earliest one that needs to be purged, since a call to purge an invalid block will automatically purge all descendants. Refer to the [InvalidateLib.sol](`l1-contracts/src/core/libraries/rollup/InvalidateLib.sol`) for more info.
26
+
27
+
> [!TIP]
28
+
> The archiver can be configured to `skipValidateBlockAttestations`, which will make it skip this validation. This cannot be set via environment variables, only via a call to `nodeAdmin_setConfig`. This setting is only meant for testing purposes.
12
29
13
-
To install dependencies and build the package run `yarn install` followed by `yarn build`.
14
-
To run test execute `yarn test`.
30
+
As an example, let's say the chain has been progressing normally up until block 10, and then:
31
+
1. Block 11 is posted with invalid attestations. The archiver will report 10 as the latest block, but the `pendingChainValidationStatus` will point to block 11.
32
+
2. Block 11 is purged, but another block 11 with invalid attestations is posted in its place. The archiver will still report 10 as latest, and the `pendingChainValidationStatus` will point to the new block 11 that needs to be purged.
33
+
3. Block 12 with invalid attestations is posted. No changes in the archiver.
34
+
4. Block 13 is posted with valid attestations, due to a malicious committee. The archiver will try to sync it and fail, since 13 does not follow 10. This scenario is not gracefully handled yet.
35
+
5. Blocks 11 to 13 are purged. The archiver status will not yet be changed: 10 will still be the latest block, and the `pendingChainValidationStatus` will point to 11. This is because the archiver does **not** follow `BlockInvalidated` events.
36
+
6. Block 11 with valid attestations is posted. The archiver pending chain now reports 11 as latest, and its status is valid.
15
37
16
-
To start the service export `ETHEREUM_HOSTS` (defaults to `http://127.0.0.1:8545/`), `ARCHIVER_POLLING_INTERVAL_MS` (defaults to `1000 ms`), `ROLLUP_CONTRACT_ADDRESS`, `INBOX_CONTRACT_ADDRESS` environmental variables and start the service with `yarn start`.
* There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
15
21
* This is the interval between successive calls to eth_blockNumber via viem.
16
22
* Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
17
23
* As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
18
24
*/
19
-
20
-
/**
21
-
* The archiver configuration.
22
-
*/
23
-
exporttypeArchiverConfig={
24
-
/** The polling interval in ms for retrieving new L2 blocks and encrypted logs. */
25
-
archiverPollingIntervalMS?: number;
26
-
27
-
/** The number of L2 blocks the archiver will attempt to download at a time. */
28
-
archiverBatchSize?: number;
29
-
30
-
/** The polling interval viem uses in ms */
31
-
viemPollingIntervalMS?: number;
32
-
33
-
/** The deployed L1 contract addresses */
34
-
l1Contracts: L1ContractAddresses;
35
-
36
-
/** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
37
-
maxLogs?: number;
38
-
39
-
/** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB. */
0 commit comments