-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: renamed data-archiver to rollup-archiver + initial setup * chore: updated deps * docs: inital RollupSource interface documentation * feat: setting up RollupArchiver class * feat: Add RollupBlockData * temporarily added some deps from Aztec Connect * feat: making sync loop work * feat: status interface + implementation * chore: updated jest config to avoid depreciation warnings * test: archiver test setup * docs: fixed naming * feat: sync loop using viem * refactor: naming * refactor: improved naming 2 * cleanup * installed types * refactor: better naming + matching yeets to blocks * docs: fixes * refactor: renamed Data Archiver to Archiver * docs: readme * refactor: block number as number * docs: issues in readme * ordering * feat: fetching latest block num from contract * docs: removed redundant space * test: Archiver * chore: less noisy logs * chore: reenabled `noImplicitAny` rule * Update bootstrap.sh * docs: fix --------- Co-authored-by: LHerskind <lasse.herskind@gmail.com> Co-authored-by: ludamad <adam.domurad@gmail.com>
- Loading branch information
1 parent
3c3ebe0
commit 17d69f1
Showing
31 changed files
with
1,733 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
yarn-project/data-archiver/Dockerfile → yarn-project/archiver/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder | ||
|
||
COPY data-archiver data-archiver | ||
WORKDIR /usr/src/yarn-project/data-archiver | ||
COPY archiver archiver | ||
WORKDIR /usr/src/yarn-project/archiver | ||
RUN yarn build && yarn formatting && yarn test | ||
|
||
# Prune dev dependencies. See comment in base image. | ||
RUN yarn cache clean | ||
RUN yarn workspaces focus --production > /dev/null | ||
|
||
FROM node:18-alpine | ||
COPY --from=builder /usr/src/yarn-project/data-archiver /usr/src/yarn-project/data-archiver | ||
WORKDIR /usr/src/yarn-project/data-archiver | ||
COPY --from=builder /usr/src/yarn-project/archiver /usr/src/yarn-project/archiver | ||
WORKDIR /usr/src/yarn-project/archiver | ||
ENTRYPOINT ["yarn"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Archiver | ||
To run: | ||
1. Run `anvil`, | ||
2. in the aztec3-l1-contracts repo check out my branch `janb/archiver-test-data`, | ||
3. deploy the contracts and generate initial activity with: `forge script --fork-url "http://127.0.0.1:8545/" --ffi GenerateActivityTest --sig "testGenerateActivity()" --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast` | ||
4. in this repository run `yarn start:dev` (Note: this repo is currently messy and eslint will not allow it to be built with `yarn start`) | ||
|
||
Relevant unresolved issues: | ||
https://stackoverflow.com/questions/75739742/why-is-eslint-complaining-about-inheritdoc-tag |
31 changes: 17 additions & 14 deletions
31
yarn-project/data-archiver/package.json → yarn-project/archiver/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const rollupAbi = [ | ||
{ | ||
name: 'L2BlockProcessed', | ||
type: 'event', | ||
inputs: [{ type: 'uint256', name: 'blockNum', indexed: true }], | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'nextBlockNum', | ||
outputs: [{ name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
] as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { parseAbiItem } from 'viem'; | ||
|
||
export const yeeterAbi = [ | ||
parseAbiItem('event Yeet(uint256 indexed blockNum, address indexed sender, bytes blabber)'), | ||
] as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { jest } from '@jest/globals'; | ||
import { getAddress, PublicClient } from 'viem'; | ||
import { Archiver } from './archiver.js'; | ||
|
||
jest.mock('viem'); | ||
|
||
describe('Archiver', () => { | ||
const rollupAddress = getAddress('0x0000000000000000000000000000000000000000'); | ||
const yeeterAddress = getAddress('0x0000000000000000000000000000000000000000'); | ||
let publicClient: PublicClient; | ||
|
||
beforeEach(() => { | ||
publicClient = { | ||
readContract: jest.fn().mockReturnValue(3n), | ||
createEventFilter: jest.fn(), | ||
getFilterLogs: jest.fn().mockReturnValue([ | ||
{ | ||
args: { | ||
blockNum: 0n, | ||
}, | ||
}, | ||
{ | ||
args: { | ||
blockNum: 1n, | ||
}, | ||
}, | ||
{ | ||
args: { | ||
blockNum: 2n, | ||
}, | ||
}, | ||
]), | ||
watchEvent: jest.fn().mockReturnValue(jest.fn()), | ||
} as unknown as PublicClient; | ||
}); | ||
|
||
it('can start, sync and stop', async () => { | ||
const archiver = new Archiver(publicClient, rollupAddress, yeeterAddress); | ||
let syncStatus = await archiver.getSyncStatus(); | ||
let latestBlockNum = archiver.getLatestBlockNum(); | ||
expect(syncStatus).toStrictEqual({ | ||
syncedToBlock: -1, | ||
latestBlock: 2, | ||
}); | ||
expect(latestBlockNum).toBe(syncStatus.syncedToBlock); | ||
|
||
await archiver.start(); | ||
|
||
syncStatus = await archiver.getSyncStatus(); | ||
latestBlockNum = archiver.getLatestBlockNum(); | ||
expect(syncStatus).toStrictEqual({ | ||
syncedToBlock: 2, | ||
latestBlock: 2, | ||
}); | ||
expect(latestBlockNum).toBe(syncStatus.syncedToBlock); | ||
|
||
archiver.stop(); | ||
}); | ||
}); |
Oops, something went wrong.