Skip to content

Commit

Permalink
refactor: get rid of timetraveler from l1-publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 28, 2024
1 parent 49dc5ba commit dc9429f
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 164 deletions.
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x2ee6f8720f80fcc063c1042327b734823d51455e444f72fafc9af975f18ab9c5",
"archive": "0x0f24dbb7e2a507326574582c3f44c08266eb441e926f2d68ca112f358585669f",
"body": "0x00000000",
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
"decodedHeader": {
Expand All @@ -22,10 +22,10 @@
"blockNumber": 1,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000033",
"chainId": 31337,
"timestamp": 1724858655,
"timestamp": 1724861610,
"version": 1,
"coinbase": "0xf6ed6ac83b91e8a719e552711e90249ae6fb95e0",
"feeRecipient": "0x28e8cab987a2f3b89fcb16878a71c2076c2b73a6fb26505d8d8db8cf80bb82f0",
"coinbase": "0x872bd7c2a38898f9fc254b86f0fd95475f7eec20",
"feeRecipient": "0x2d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
Expand Down Expand Up @@ -56,8 +56,8 @@
}
}
},
"header": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e00000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000100b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000008019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000330000000000000000000000000000000000000000000000000000000066cf411ff6ed6ac83b91e8a719e552711e90249ae6fb95e028e8cab987a2f3b89fcb16878a71c2076c2b73a6fb26505d8d8db8cf80bb82f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00bc2933646ffc5ac63d957ffb345230d5fc0bfc14359cd13f3a77b60c5d1e1a",
"header": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e00000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000100b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000008019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000330000000000000000000000000000000000000000000000000000000066cf4caa872bd7c2a38898f9fc254b86f0fd95475f7eec202d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00a46e722d885c3bf479f8cf2a786adfde7a8c43740214163f7f9846914cbe6f",
"numTxs": 0
}
}
14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/empty_block_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x0d67087b909c777b9b4c429d421047608d3b5113d6525f024403ba72f0e8c039",
"archive": "0x25126f40ad58d24006e6db629c2efb1e0868a50d5c21aa342894137b2b08bc0b",
"body": "0x00000000",
"txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6",
"decodedHeader": {
Expand All @@ -22,18 +22,18 @@
"blockNumber": 2,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000035",
"chainId": 31337,
"timestamp": 1724858679,
"timestamp": 1724861634,
"version": 1,
"coinbase": "0xf6ed6ac83b91e8a719e552711e90249ae6fb95e0",
"feeRecipient": "0x28e8cab987a2f3b89fcb16878a71c2076c2b73a6fb26505d8d8db8cf80bb82f0",
"coinbase": "0x872bd7c2a38898f9fc254b86f0fd95475f7eec20",
"feeRecipient": "0x2d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x2ee6f8720f80fcc063c1042327b734823d51455e444f72fafc9af975f18ab9c5"
"root": "0x0f24dbb7e2a507326574582c3f44c08266eb441e926f2d68ca112f358585669f"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -56,8 +56,8 @@
}
}
},
"header": "0x2ee6f8720f80fcc063c1042327b734823d51455e444f72fafc9af975f18ab9c500000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000200b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000010019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000350000000000000000000000000000000000000000000000000000000066cf4137f6ed6ac83b91e8a719e552711e90249ae6fb95e028e8cab987a2f3b89fcb16878a71c2076c2b73a6fb26505d8d8db8cf80bb82f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00d1b60b5c9c83f637568ce4355e0127dc27d65edd9f632ab7fb3b00c9fd2199",
"header": "0x0f24dbb7e2a507326574582c3f44c08266eb441e926f2d68ca112f358585669f00000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000200b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000010019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000350000000000000000000000000000000000000000000000000000000066cf4cc2872bd7c2a38898f9fc254b86f0fd95475f7eec202d78818b03bcaf7034fca9d658f1212c6b2aecd6839e03cc21e2846fc061202d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00de3870b035eca1a73e8adf24b738db855a034548805b300d8dbecfd2a6e66b",
"numTxs": 0
}
}
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/mixed_block_1.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/mixed_block_2.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions yarn-project/end-to-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src \"!src/web/main.js\" && run -T eslint ./src",
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
"test": "TIME_TRAVELER=${TIME_TRAVELER:-true} LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test:profile": "TIME_TRAVELER=${TIME_TRAVELER:-true} LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 0x --output-dir \"flame_graph/{pid}.0x\" -- node --experimental-vm-modules ../node_modules/jest/bin/jest.js --runInBand --testTimeout=300000 --forceExit",
"test": "LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test:profile": "LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 0x --output-dir \"flame_graph/{pid}.0x\" -- node --experimental-vm-modules ../node_modules/jest/bin/jest.js --runInBand --testTimeout=300000 --forceExit",
"serve:flames": "python3 -m http.server --directory \"flame_graph\" 8000",
"test:debug": "TIME_TRAVELER=${TIME_TRAVELER:-true} LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --inspect --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test:integration": "TIME_TRAVELER=${TIME_TRAVELER:-true} concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
"test:integration:run": "TIME_TRAVELER=${TIME_TRAVELER:-true} NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --no-cache --runInBand --config jest.integration.config.json",
"test:debug": "LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --inspect --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --no-cache --runInBand --config jest.integration.config.json",
"test:unit": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/package.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"scripts": {
"build": "yarn clean && tsc -b && webpack",
"formatting": "run -T prettier --check ./src \"!src/web/main.js\" && run -T eslint ./src",
"test": "TIME_TRAVELER=${TIME_TRAVELER:-true} LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test": "LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test:unit": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ describe('L1Publisher integration', () => {
publisherPrivateKey: sequencerPK,
l1PublishRetryIntervalMS: 100,
l1ChainId: 31337,
timeTraveler: true,
},
new NoopTelemetryClient(),
);
Expand Down
1 change: 1 addition & 0 deletions yarn-project/end-to-end/src/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './fixtures.js';
export * from './logging.js';
export * from './utils.js';
export * from './watcher.js';
19 changes: 19 additions & 0 deletions yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { getACVMConfig } from './get_acvm_config.js';
import { getBBConfig } from './get_bb_config.js';
import { setupL1Contracts } from './setup_l1_contracts.js';
import { deployCanonicalAuthRegistry, deployCanonicalKeyRegistry, getPrivateKeyFromIndex } from './utils.js';
import { Watcher } from './watcher.js';

export type SubsystemsContext = {
anvil: Anvil;
Expand All @@ -51,6 +52,7 @@ export type SubsystemsContext = {
pxe: PXEService;
deployL1ContractsValues: DeployL1Contracts;
proverNode: ProverNode;
watcher: Watcher;
};

type SnapshotEntry = {
Expand Down Expand Up @@ -229,6 +231,7 @@ async function teardown(context: SubsystemsContext | undefined) {
await context.pxe.stop();
await context.acvmConfig?.cleanup();
await context.anvil.stop();
await context.watcher.stop();
}

export async function createAndSyncProverNode(
Expand Down Expand Up @@ -338,6 +341,13 @@ async function setupFromFresh(
aztecNode,
);

const watcher = new Watcher(
new EthCheatCodes(aztecNodeConfig.l1RpcUrl),
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
deployL1ContractsValues.publicClient,
);
watcher.start();

logger.verbose('Creating pxe...');
const pxeConfig = getPXEServiceConfig();
pxeConfig.dataDirectory = statePath;
Expand Down Expand Up @@ -365,6 +375,7 @@ async function setupFromFresh(
bbConfig,
deployL1ContractsValues,
proverNode,
watcher,
};
}

Expand Down Expand Up @@ -408,6 +419,13 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
logger.verbose('Creating ETH clients...');
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrl, mnemonicToAccount(MNEMONIC));

const watcher = new Watcher(
new EthCheatCodes(aztecNodeConfig.l1RpcUrl),
aztecNodeConfig.l1Contracts.rollupAddress,
publicClient,
);
watcher.start();

logger.verbose('Creating aztec node...');
const telemetry = await createAndStartTelemetryClient(getTelemetryConfig());
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, telemetry);
Expand Down Expand Up @@ -440,6 +458,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
publicClient,
l1ContractAddresses: aztecNodeConfig.l1Contracts,
},
watcher,
};
}

Expand Down
9 changes: 9 additions & 0 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import { MNEMONIC } from './fixtures.js';
import { getACVMConfig } from './get_acvm_config.js';
import { getBBConfig } from './get_bb_config.js';
import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
import { Watcher } from './watcher.js';

export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';

Expand Down Expand Up @@ -451,6 +452,13 @@ export async function setup(
}
}

const watcher = new Watcher(
new EthCheatCodes(config.l1RpcUrl),
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
deployL1ContractsValues.publicClient,
);
watcher.start();

const wallets = numberOfAccounts > 0 ? await createAccounts(pxe, numberOfAccounts) : [];
const cheatCodes = CheatCodes.create(config.l1RpcUrl, pxe!);

Expand All @@ -469,6 +477,7 @@ export async function setup(
}

await anvil?.stop();
await watcher.stop();
};

return {
Expand Down
64 changes: 64 additions & 0 deletions yarn-project/end-to-end/src/fixtures/watcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { type DebugLogger, type EthCheatCodes, createDebugLogger } from '@aztec/aztec.js';
import { type EthAddress } from '@aztec/circuits.js';
import { RunningPromise } from '@aztec/foundation/running-promise';
import { RollupAbi } from '@aztec/l1-artifacts';

import { type GetContractReturnType, type HttpTransport, type PublicClient, getAddress, getContract } from 'viem';
import type * as chains from 'viem/chains';

export class Watcher {
private rollup: GetContractReturnType<typeof RollupAbi, PublicClient<HttpTransport, chains.Chain>>;

private filledRunningPromise?: RunningPromise;

private logger: DebugLogger = createDebugLogger(`aztec:utils:watcher`);

constructor(
private cheatcodes: EthCheatCodes,
rollupAddress: EthAddress,
publicClient: PublicClient<HttpTransport, chains.Chain>,
) {
this.rollup = getContract({
address: getAddress(rollupAddress.toString()),
abi: RollupAbi,
client: publicClient,
});

this.logger.info(`Watcher created for rollup at ${rollupAddress}`);
}

start() {
if (this.filledRunningPromise) {
throw new Error('Watcher already watching for filled slot');
}
this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), 1000);
this.filledRunningPromise.start();
this.logger.info(`Watcher started`);
}

async stop() {
await this.filledRunningPromise?.stop();
}

async mineIfSlotFilled() {
try {
const currentSlot = await this.rollup.read.getCurrentSlot();
const pendingBlockNumber = BigInt(await this.rollup.read.pendingBlockCount()) - 1n;
const [, , lastSlotNumber] = await this.rollup.read.blocks([pendingBlockNumber]);

if (currentSlot === lastSlotNumber) {
// We should jump to the next slot
const timestamp = await this.rollup.read.getTimestampForSlot([currentSlot + 1n]);
try {
await this.cheatcodes.warp(Number(timestamp));
} catch (e) {
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
}

this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
}
} catch (err) {
this.logger.error('mineIfSlotFilled failed', err);
}
}
}
1 change: 0 additions & 1 deletion yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export type EnvVar =
| 'SEQ_PUBLISHER_PRIVATE_KEY'
| 'SEQ_REQUIRED_CONFIRMATIONS'
| 'SEQ_PUBLISH_RETRY_INTERVAL_MS'
| 'TIME_TRAVELER'
| 'VERSION'
| 'SEQ_DISABLED'
| 'PROVER_DISABLED'
Expand Down
12 changes: 1 addition & 11 deletions yarn-project/sequencer-client/src/publisher/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type L1ReaderConfig, NULL_KEY } from '@aztec/ethereum';
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';

/**
* The configuration of the rollup transaction publisher.
Expand All @@ -24,11 +24,6 @@ export interface PublisherConfig {
* The interval to wait between publish retries.
*/
l1PublishRetryIntervalMS: number;
/**
* Whether the publisher is a time traveler and can warp the underlying chain
* @todo #8153 - Remove this flag once the time traveler is removed
*/
timeTraveler: boolean;
}

export const getTxSenderConfigMappings: (
Expand Down Expand Up @@ -69,11 +64,6 @@ export const getPublisherConfigMappings: (scope: 'PROVER' | 'SEQ') => ConfigMapp
defaultValue: 1000,
description: 'The interval to wait between publish retries.',
},
timeTraveler: {
env: `TIME_TRAVELER`,
description: 'Whether the publisher is a time traveler and can warp the underlying chain',
...booleanConfigHelper(),
},
});

export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
Expand Down
Loading

0 comments on commit dc9429f

Please sign in to comment.