Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Mar 15, 2024
1 parent 56b1949 commit 36bc496
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 19 deletions.
2 changes: 0 additions & 2 deletions yarn-project/archiver/src/archiver/archiver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe('Archiver', () => {
publicClient.getBlockNumber.mockResolvedValueOnce(2500n).mockResolvedValueOnce(2600n).mockResolvedValueOnce(2700n);
// logs should be created in order of how archiver syncs.
publicClient.getLogs
.mockResolvedValueOnce([]) // no messages to cancel
.mockResolvedValueOnce([makeLeafInsertedEvent(98n, 1n, 0n), makeLeafInsertedEvent(99n, 1n, 1n)])
.mockResolvedValueOnce([makeTxsPublishedEvent(101n, blocks[0].body.getTxsEffectsHash())])
.mockResolvedValueOnce([makeL2BlockProcessedEvent(101n, 1n)])
Expand Down Expand Up @@ -140,7 +139,6 @@ describe('Archiver', () => {
publicClient.getBlockNumber.mockResolvedValue(102n);
// add all of the L1 to L2 messages to the mock
publicClient.getLogs
.mockResolvedValueOnce([])
.mockResolvedValueOnce([makeLeafInsertedEvent(66n, 1n, 0n), makeLeafInsertedEvent(68n, 1n, 1n)])
.mockResolvedValueOnce([
makeTxsPublishedEvent(70n, blocks[0].body.getTxsEffectsHash()),
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/archiver/src/archiver/archiver_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/types/c
export type ArchiverL1SynchPoint = {
/** The last L1 block that added a new L2 block. */
addedBlock: bigint;
/** The last L1 block that added messages from the new inbox. */
/** The last L1 block that added messages from the inbox. */
// TODO(#4492): Clean this up and fix the naming
newMessages: bigint;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
it('returns 0n if no blocks have been added', async () => {
await expect(store.getL1BlockNumber()).resolves.toEqual({
addedBlock: 0n,
addedMessages: 0n,
cancelledMessages: 0n,
newMessages: 0n,
});
});
Expand All @@ -95,18 +93,14 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
await store.addBlocks(blocks);
await expect(store.getL1BlockNumber()).resolves.toEqual({
addedBlock: blocks.at(-1)!.getL1BlockNumber(),
addedMessages: 0n,
cancelledMessages: 0n,
newMessages: 0n,
});
});

it('returns the L1 block number that most recently added messages from new inbox', async () => {
it('returns the L1 block number that most recently added messages from inbox', async () => {
await store.addNewL1ToL2Messages([new NewInboxLeaf(0n, 0n, Fr.ZERO)], 1n);
await expect(store.getL1BlockNumber()).resolves.toEqual({
addedBlock: 0n,
addedMessages: 0n,
cancelledMessages: 0n,
newMessages: 1n,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export class MemoryArchiverStore implements ArchiverDataStore {
private contractInstances: Map<string, ContractInstanceWithAddress> = new Map();

private lastL1BlockNewMessages: bigint = 0n;
private lastL1BlockAddedMessages: bigint = 0n;
private lastL1BlockCancelledMessages: bigint = 0n;

constructor(
/** The max number of logs that can be obtained in 1 "getUnencryptedLogs" call. */
Expand Down Expand Up @@ -404,14 +402,10 @@ export class MemoryArchiverStore implements ArchiverDataStore {
public getL1BlockNumber() {
const addedBlock = this.l2BlockContexts[this.l2BlockContexts.length - 1]?.block?.getL1BlockNumber() ?? 0n;
const newMessages = this.lastL1BlockNewMessages;
const addedMessages = this.lastL1BlockAddedMessages;
const cancelledMessages = this.lastL1BlockCancelledMessages;

return Promise.resolve({
addedBlock,
newMessages,
addedMessages,
cancelledMessages,
});
}
}
3 changes: 0 additions & 3 deletions yarn-project/sequencer-client/src/sequencer/sequencer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ describe('sequencer', () => {
new GlobalVariables(chainId, version, new Fr(lastBlockNumber + 1), Fr.ZERO, coinbase, feeRecipient),
expectedTxHashes.map(hash => expect.objectContaining({ hash })),
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(new Fr(0n)),
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(new Fr(0n)),
);
expect(publisher.processL2Block).toHaveBeenCalledWith(block);
});
Expand Down Expand Up @@ -149,7 +148,6 @@ describe('sequencer', () => {
new GlobalVariables(chainId, version, new Fr(lastBlockNumber + 1), Fr.ZERO, coinbase, feeRecipient),
expectedTxHashes.map(hash => expect.objectContaining({ hash })),
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(new Fr(0n)),
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(new Fr(0n)),
);
expect(publisher.processL2Block).toHaveBeenCalledWith(block);
expect(p2p.deleteTxs).toHaveBeenCalledWith([doubleSpendTx.getTxHash()]);
Expand Down Expand Up @@ -183,7 +181,6 @@ describe('sequencer', () => {
new GlobalVariables(chainId, version, new Fr(lastBlockNumber + 1), Fr.ZERO, coinbase, feeRecipient),
expectedTxHashes.map(hash => expect.objectContaining({ hash })),
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(new Fr(0n)),
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(new Fr(0n)),
);
expect(publisher.processL2Block).toHaveBeenCalledWith(block);
expect(p2p.deleteTxs).toHaveBeenCalledWith([invalidChainTx.getTxHash()]);
Expand Down

0 comments on commit 36bc496

Please sign in to comment.