Skip to content

Commit

Permalink
fix: Allow txs on block zero (#7928)
Browse files Browse the repository at this point in the history
Fixes #7537
  • Loading branch information
spalladino authored Aug 13, 2024
1 parent 5e8b4a8 commit 5e25cd6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
21 changes: 21 additions & 0 deletions yarn-project/end-to-end/src/e2e_block_building.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ContractDeployer,
ContractFunctionInteraction,
type DebugLogger,
Fq,
Fr,
L1NotePayload,
type PXE,
Expand Down Expand Up @@ -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[]) {
Expand Down
30 changes: 17 additions & 13 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AztecNodeConfig>;

/** Context for an end-to-end test as returned by the `setup` function */
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit 5e25cd6

Please sign in to comment.