Skip to content

Commit

Permalink
chore: Fix intermittent failures for block-building e2e test (#3404)
Browse files Browse the repository at this point in the history
Fixes #3358
  • Loading branch information
spalladino authored Nov 22, 2023
1 parent 6a7ebb6 commit e76e2d4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 19 deletions.
6 changes: 6 additions & 0 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
LogFilter,
LogType,
MerkleTreeId,
SequencerConfig,
SiblingPath,
Tx,
TxHash,
Expand Down Expand Up @@ -434,6 +435,11 @@ export class AztecNodeService implements AztecNode {
this.log.info(`Simulated tx ${await tx.getTxHash()} succeeds`);
}

public setConfig(config: Partial<SequencerConfig>): Promise<void> {
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
Expand Down
8 changes: 8 additions & 0 deletions yarn-project/end-to-end/src/e2e_block_building.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AztecNode,
BatchCall,
ContractDeployer,
ContractFunctionInteraction,
Expand All @@ -22,6 +23,7 @@ describe('e2e_block_building', () => {
let logger: DebugLogger;
let owner: Wallet;
let minter: Wallet;
let aztecNode: AztecNode;
let teardown: () => Promise<void>;

describe('multi-txs block', () => {
Expand All @@ -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());

Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ type SetupOptions = { /** State load */ stateLoad?: string } & Partial<AztecNode
/** Context for an end-to-end test as returned by the `setup` function */
export type EndToEndContext = {
/** The Aztec Node service or client a connected to it. */
aztecNode: AztecNode | undefined;
/** A client to the sequencer service */
aztecNode: AztecNode;
/** A client to the sequencer service (undefined if connected to remote sandbox) */
sequencer: SequencerClient | undefined;
/** The Private eXecution Environment (PXE). */
pxe: PXE;
Expand Down
18 changes: 1 addition & 17 deletions yarn-project/sequencer-client/src/sequencer/config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
/**
* 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;
}
export { SequencerConfig } from '@aztec/types';
7 changes: 7 additions & 0 deletions yarn-project/types/src/interfaces/aztec-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
LogFilter,
LogType,
MerkleTreeId,
SequencerConfig,
StateInfoProvider,
Tx,
TxHash,
Expand Down Expand Up @@ -156,4 +157,10 @@ export interface AztecNode extends StateInfoProvider {
* @param tx - The transaction to simulate.
**/
simulatePublicCalls(tx: Tx): Promise<void>;

/**
* Updates the configuration of this node.
* @param config - Updated configuration to be merged with the current one.
*/
setConfig(config: Partial<SequencerConfig>): Promise<void>;
}
17 changes: 17 additions & 0 deletions yarn-project/types/src/interfaces/configs.ts
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 1 addition & 0 deletions yarn-project/types/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit e76e2d4

Please sign in to comment.