From df18eaabbc438016e73deb062625dd2d6edb54d4 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 12 Aug 2024 18:26:06 -0300 Subject: [PATCH] fix: Allow txs on block zero --- .../aztec-node/src/aztec-node/server.ts | 2 +- .../end-to-end/src/e2e_block_building.test.ts | 21 +++++++++++++ yarn-project/end-to-end/src/fixtures/utils.ts | 30 +++++++++++-------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index cd5b8b8b097..168d2662a76 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -805,7 +805,7 @@ export class AztecNodeService implements AztecNode { * @returns An instance of a committed MerkleTreeOperations */ async #getWorldState(blockNumber: L2BlockNumber) { - if (typeof blockNumber === 'number' && blockNumber < INITIAL_L2_BLOCK_NUM) { + if (typeof blockNumber === 'number' && blockNumber < INITIAL_L2_BLOCK_NUM - 1) { throw new Error('Invalid block number to get world state for: ' + blockNumber); } diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index caf6b83f7bc..74696ddeca7 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -5,6 +5,7 @@ import { ContractDeployer, ContractFunctionInteraction, type DebugLogger, + Fq, Fr, L1NotePayload, type PXE, @@ -307,6 +308,26 @@ describe('e2e_block_building', () => { // const decryptedLogs = encryptedLogs.map(l => TaggedNote.decryptAsIncoming(l.data, keys.masterIncomingViewingSecretKey)); }, 60_000); }); + + describe('regressions', () => { + afterEach(async () => { + if (teardown) { + await teardown(); + } + }); + + // Regression for https://github.com/AztecProtocol/aztec-packages/issues/7537 + it('sends a tx on the first block', async () => { + ({ teardown, pxe, logger, aztecNode } = await setup(0, { + minTxsPerBlock: 0, + sequencerSkipSubmitProofs: true, + skipProtocolContracts: true, + })); + + const account = getSchnorrAccount(pxe, Fr.random(), Fq.random(), Fr.random()); + await account.waitSetup(); + }); + }); }); async function sendAndWait(calls: ContractFunctionInteraction[]) { diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index d50b60fcafc..6537f1f18f4 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -281,6 +281,8 @@ type SetupOptions = { stateLoad?: string; /** Previously deployed contracts on L1 */ deployL1ContractsValues?: DeployL1Contracts; + /** Whether to skip deployment of protocol contracts (auth registry, etc) */ + skipProtocolContracts?: boolean; } & Partial; /** Context for an end-to-end test as returned by the `setup` function */ @@ -387,24 +389,26 @@ export async function setup( const { pxe } = await setupPXEService(aztecNode!, pxeOpts, logger); - logger.verbose('Deploying key registry...'); - await deployCanonicalKeyRegistry( - new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(config.l1ChainId, config.version)), - ); - - logger.verbose('Deploying auth registry...'); - await deployCanonicalAuthRegistry( - new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(config.l1ChainId, config.version)), - ); + if (!config.skipProtocolContracts) { + logger.verbose('Deploying key registry...'); + await deployCanonicalKeyRegistry( + new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(config.l1ChainId, config.version)), + ); - if (enableGas) { - logger.verbose('Deploying Fee Juice...'); - await deployCanonicalFeeJuice( + logger.verbose('Deploying auth registry...'); + await deployCanonicalAuthRegistry( new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(config.l1ChainId, config.version)), ); + + if (enableGas) { + logger.verbose('Deploying Fee Juice...'); + await deployCanonicalFeeJuice( + new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(config.l1ChainId, config.version)), + ); + } } - const wallets = await createAccounts(pxe, numberOfAccounts); + const wallets = numberOfAccounts > 0 ? await createAccounts(pxe, numberOfAccounts) : []; const cheatCodes = CheatCodes.create(config.l1RpcUrl, pxe!); const teardown = async () => {