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

fix: Allow txs on block zero #7928

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 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
Loading