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

Archiver #41

Merged
merged 31 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b942dec
refactor: renamed data-archiver to rollup-archiver + initial setup
benesjan Mar 8, 2023
d5bb973
chore: updated deps
benesjan Mar 8, 2023
5b0c302
docs: inital RollupSource interface documentation
benesjan Mar 8, 2023
b597efe
feat: setting up RollupArchiver class
benesjan Mar 8, 2023
56b3bbc
feat: Add RollupBlockData
LHerskind Mar 9, 2023
48daf13
temporarily added some deps from Aztec Connect
benesjan Mar 9, 2023
2fa8aca
feat: making sync loop work
benesjan Mar 10, 2023
958eaa9
feat: status interface + implementation
benesjan Mar 10, 2023
81d74ab
chore: updated jest config to avoid depreciation warnings
benesjan Mar 10, 2023
704f857
test: archiver test setup
benesjan Mar 10, 2023
97f9ab1
docs: fixed naming
benesjan Mar 12, 2023
b157911
feat: sync loop using viem
benesjan Mar 13, 2023
ba6ddde
refactor: naming
benesjan Mar 13, 2023
1bd041e
refactor: improved naming 2
benesjan Mar 13, 2023
6c28ca0
cleanup
benesjan Mar 13, 2023
cadbf7b
installed types
benesjan Mar 14, 2023
5e2cf81
refactor: better naming + matching yeets to blocks
benesjan Mar 14, 2023
77d3434
docs: fixes
benesjan Mar 15, 2023
c5f28c6
refactor: renamed Data Archiver to Archiver
benesjan Mar 15, 2023
970d8ae
docs: readme
benesjan Mar 15, 2023
676784d
refactor: block number as number
benesjan Mar 15, 2023
e6b8da1
docs: issues in readme
benesjan Mar 15, 2023
0f91d85
ordering
benesjan Mar 15, 2023
c71f6e2
feat: fetching latest block num from contract
benesjan Mar 15, 2023
c646968
docs: removed redundant space
benesjan Mar 15, 2023
7d2701e
test: Archiver
benesjan Mar 15, 2023
0146455
chore: less noisy logs
benesjan Mar 15, 2023
e144629
Merge branch 'master' into janb/archiver-viem
benesjan Mar 15, 2023
934279c
chore: reenabled `noImplicitAny` rule
benesjan Mar 15, 2023
cc13c64
Update bootstrap.sh
ludamad Mar 15, 2023
c884299
docs: fix
benesjan Mar 15, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
The Aztec 3 system consists of the following sub projects.

- `acir-simulator`
- `archiver`
- `aztec-cli`
- `aztec.js`
- `barretenberg.js`
- `circuit.js`
- `data-archiver`
- `ethereum.js`
- `kernel-simulator`
- `key-store`
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECTS=(
"yarn-project/aztec.js:yarn build"
# "yarn-project/barretenberg.js:yarn build"
# "yarn-project/circuit.js:yarn build"
# "yarn-project/data-archiver:yarn build"
"yarn-project/archiver:yarn build"
# "yarn-project/ethereum.js:yarn build"
# "yarn-project/kernel-simulator:yarn build"
"yarn-project/key-store:yarn build"
Expand Down
14 changes: 7 additions & 7 deletions build_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
"rebuildPatterns": ["^yarn-project/acir-simulator/"],
"dependencies": ["yarn-project-base"]
},
"archiver": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/archiver",
"dockerfile": "archiver/Dockerfile",
"rebuildPatterns": ["^yarn-project/archiver/"],
"dependencies": ["yarn-project-base"]
},
"aztec-cli": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/aztec-cli",
Expand Down Expand Up @@ -73,13 +80,6 @@
"rebuildPatterns": ["^yarn-project/circuit.js/"],
"dependencies": ["yarn-project-base"]
},
"data-archiver": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/data-archiver",
"dockerfile": "data-archiver/Dockerfile",
"rebuildPatterns": ["^yarn-project/data-archiver/"],
"dependencies": ["yarn-project-base"]
},
"end-to-end": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/end-to-end",
Expand Down
2 changes: 1 addition & 1 deletion build_manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ PROJECTS=(
# l1-contracts:l1-contracts
# yarn-project-base:yarn-project
# acir-simulator:yarn-project
# archiver:yarn-project
# aztec-cli:yarn-project
# aztec.js:yarn-project
# barretenberg.js:yarn-project
# circuit.js:yarn-project
# data-archiver:yarn-project
# end-to-end:yarn-project
# ethereum.js:yarn-project
# kernel-simulator:yarn-project
Expand Down
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"]
9 changes: 9 additions & 0 deletions yarn-project/archiver/README.md
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
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
{
"name": "@aztec/data-archiver",
"name": "@aztec/archiver",
"version": "0.0.0",
"type": "module",
"exports": "./dest/index.js",
"typedoc": {
"entryPoint": "./src/index.ts",
"displayName": "Data Archiver",
"displayName": "Archiver",
"tsconfig": "./tsconfig.dest.json"
},
"scripts": {
"build": "yarn clean && yarn formatting && tsc -b tsconfig.dest.json",
"build:dev": "tsc -b tsconfig.dest.json --watch",
"start": "node ./dest",
"start:dev": "tsc-watch -p tsconfig.dest.json --onSuccess 'yarn start'",
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint --max-warnings 0 ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --passWithNoTests"
},
"jest": {
"preset": "ts-jest/presets/default-esm",
"globals": {
"ts-jest": {
"useESM": true
}
},
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"testRegex": "./src/.*\\.test\\.ts$",
"rootDir": "./src"
},
"dependencies": {
"tslib": "^2.4.0"
"debug": "^4.3.4",
"tsc-watch": "^6.0.0",
"tslib": "^2.5.0",
"viem": "^0.1.15",
"ws": "^8.13.0"
},
"devDependencies": {
"@aztec/eslint-config": "workspace:^",
"@jest/globals": "^29.4.3",
"@rushstack/eslint-patch": "^1.1.4",
"@types/jest": "^29.4.0",
"@types/node": "^18.7.23",
"jest": "^28.1.3",
"ts-jest": "^28.0.7",
"@jest/globals": "^29.5.0",
"@rushstack/eslint-patch": "^1.2.0",
"@types/debug": "^4.1.7",
"@types/jest": "^29.4.1",
"@types/node": "^18.15.2",
"@types/ws": "^8.5.4",
"jest": "^29.5.0",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
}
Expand Down
14 changes: 14 additions & 0 deletions yarn-project/archiver/src/abis/rollup.ts
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;
5 changes: 5 additions & 0 deletions yarn-project/archiver/src/abis/yeeter.ts
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;
59 changes: 59 additions & 0 deletions yarn-project/archiver/src/archiver.test.ts
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();
});
});
Loading