diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index cd0908cdc9f..b528a699343 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 63f4bd19d1c..9dd4e9beb79 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, @@ -22,6 +23,7 @@ describe('e2e_block_building', () => { let logger: DebugLogger; let owner: Wallet; let minter: Wallet; + let aztecNode: AztecNode; let teardown: () => Promise; describe('multi-txs block', () => { @@ -32,16 +34,19 @@ describe('e2e_block_building', () => { teardown, pxe, logger, + aztecNode, wallets: [owner, minter], } = await setup(2)); }, 100_000); + 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; + await aztecNode.setConfig({ minTxsPerBlock: TX_COUNT }); const deployer = new ContractDeployer(artifact, owner); const methods = times(TX_COUNT, () => deployer.deploy()); @@ -68,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 3ebea90d383..978147ab5e0 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 00000000000..82c6e10db16 --- /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 390f25be66b..ddef4f6b1f8 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';