From ac3b8c1c571ea6bc4c1aaee5f3c43d1129accdff Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 22 Nov 2023 14:29:11 -0300 Subject: [PATCH 1/2] chore: Fix intermittent failures for block-building e2e test --- yarn-project/end-to-end/src/e2e_block_building.test.ts | 5 +++++ 1 file changed, 5 insertions(+) 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 63f4bd19d1c4..7981020fff82 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 @@ -12,6 +12,7 @@ import { import { pedersenHash } from '@aztec/foundation/crypto'; import { TestContractArtifact } from '@aztec/noir-contracts/artifacts'; import { TestContract, TokenContract } from '@aztec/noir-contracts/types'; +import { SequencerClient } from '@aztec/sequencer-client'; import times from 'lodash.times'; @@ -22,6 +23,7 @@ describe('e2e_block_building', () => { let logger: DebugLogger; let owner: Wallet; let minter: Wallet; + let sequencer: SequencerClient | undefined; let teardown: () => Promise; describe('multi-txs block', () => { @@ -32,16 +34,19 @@ describe('e2e_block_building', () => { teardown, pxe, logger, + sequencer, wallets: [owner, minter], } = await setup(2)); }, 100_000); + afterEach(() => sequencer?.updateSequencerConfig({ minTxsPerBlock: 1 })); afterAll(() => teardown()); it('assembles a block with multiple txs', async () => { // Assemble N contract deployment txs // We need to create them sequentially since we cannot have parallel calls to a circuit const TX_COUNT = 8; + sequencer!.updateSequencerConfig({ minTxsPerBlock: TX_COUNT }); const deployer = new ContractDeployer(artifact, owner); const methods = times(TX_COUNT, () => deployer.deploy()); From fe01fda3423148012747cb7469fade91bbc7e178 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 22 Nov 2023 15:30:24 -0300 Subject: [PATCH 2/2] Expose new API for updating config in node --- .../aztec-node/src/aztec-node/server.ts | 6 ++++++ .../end-to-end/src/e2e_block_building.test.ts | 13 ++++++++----- yarn-project/end-to-end/src/fixtures/utils.ts | 4 ++-- .../sequencer-client/src/sequencer/config.ts | 18 +----------------- .../types/src/interfaces/aztec-node.ts | 7 +++++++ yarn-project/types/src/interfaces/configs.ts | 17 +++++++++++++++++ yarn-project/types/src/interfaces/index.ts | 1 + 7 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 yarn-project/types/src/interfaces/configs.ts diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index cd0908cdc9ff..b528a699343d 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -34,6 +34,7 @@ import { LogFilter, LogType, MerkleTreeId, + SequencerConfig, SiblingPath, Tx, TxHash, @@ -434,6 +435,11 @@ export class AztecNodeService implements AztecNode { this.log.info(`Simulated tx ${await tx.getTxHash()} succeeds`); } + public setConfig(config: Partial): Promise { + this.sequencer?.updateSequencerConfig(config); + return Promise.resolve(); + } + /** * Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched * @returns An instance of a committed MerkleTreeOperations 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 7981020fff82..9dd4e9beb79b 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 @@ -1,4 +1,5 @@ import { + AztecNode, BatchCall, ContractDeployer, ContractFunctionInteraction, @@ -12,7 +13,6 @@ import { import { pedersenHash } from '@aztec/foundation/crypto'; import { TestContractArtifact } from '@aztec/noir-contracts/artifacts'; import { TestContract, TokenContract } from '@aztec/noir-contracts/types'; -import { SequencerClient } from '@aztec/sequencer-client'; import times from 'lodash.times'; @@ -23,7 +23,7 @@ describe('e2e_block_building', () => { let logger: DebugLogger; let owner: Wallet; let minter: Wallet; - let sequencer: SequencerClient | undefined; + let aztecNode: AztecNode; let teardown: () => Promise; describe('multi-txs block', () => { @@ -34,19 +34,19 @@ describe('e2e_block_building', () => { teardown, pxe, logger, - sequencer, + aztecNode, wallets: [owner, minter], } = await setup(2)); }, 100_000); - afterEach(() => sequencer?.updateSequencerConfig({ minTxsPerBlock: 1 })); + afterEach(() => aztecNode.setConfig({ minTxsPerBlock: 1 })); afterAll(() => teardown()); it('assembles a block with multiple txs', async () => { // Assemble N contract deployment txs // We need to create them sequentially since we cannot have parallel calls to a circuit const TX_COUNT = 8; - sequencer!.updateSequencerConfig({ minTxsPerBlock: TX_COUNT }); + await aztecNode.setConfig({ minTxsPerBlock: TX_COUNT }); const deployer = new ContractDeployer(artifact, owner); const methods = times(TX_COUNT, () => deployer.deploy()); @@ -73,6 +73,9 @@ describe('e2e_block_building', () => { }, 60_000); it('can call public function from different tx in same block', async () => { + // Ensure both txs will land on the same block + await aztecNode.setConfig({ minTxsPerBlock: 2 }); + // Deploy a contract in the first transaction // In the same block, call a public method on the contract const deployer = TokenContract.deploy(owner, owner.getCompleteAddress()); diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 3ebea90d383b..978147ab5e05 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -232,8 +232,8 @@ type SetupOptions = { /** State load */ stateLoad?: string } & Partial; + + /** + * Updates the configuration of this node. + * @param config - Updated configuration to be merged with the current one. + */ + setConfig(config: Partial): Promise; } diff --git a/yarn-project/types/src/interfaces/configs.ts b/yarn-project/types/src/interfaces/configs.ts new file mode 100644 index 000000000000..82c6e10db168 --- /dev/null +++ b/yarn-project/types/src/interfaces/configs.ts @@ -0,0 +1,17 @@ +/** + * The sequencer configuration. + */ +export interface SequencerConfig { + /** + * The number of ms to wait between polling for pending txs. + */ + transactionPollingIntervalMS?: number; + /** + * The maximum number of txs to include in a block. + */ + maxTxsPerBlock?: number; + /** + * The minimum number of txs to include in a block. + */ + minTxsPerBlock?: number; +} diff --git a/yarn-project/types/src/interfaces/index.ts b/yarn-project/types/src/interfaces/index.ts index 390f25be66b5..ddef4f6b1f8d 100644 --- a/yarn-project/types/src/interfaces/index.ts +++ b/yarn-project/types/src/interfaces/index.ts @@ -5,3 +5,4 @@ export * from './pxe.js'; export * from './deployed-contract.js'; export * from './node-info.js'; export * from './sync-status.js'; +export * from './configs.js';