diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 602cb2a1bbae..0f246740805b 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -255,11 +255,11 @@ describe('Archiver', () => { expect(publicLogs.length).toEqual(expectedTotalNumPublicLogs); } - blockNumbers.forEach(async x => { + for (const x of blockNumbers) { const expectedTotalNumContractClassLogs = 4; const contractClassLogs = await archiver.getContractClassLogs({ fromBlock: x, toBlock: x + 1 }); expect(contractClassLogs.logs.length).toEqual(expectedTotalNumContractClassLogs); - }); + } // Check last proven block number const provenBlockNumber = await archiver.getProvenBlockNumber(); diff --git a/yarn-project/aztec-faucet/src/http.ts b/yarn-project/aztec-faucet/src/http.ts index 7e2e10723d6b..fad380ddbf55 100644 --- a/yarn-project/aztec-faucet/src/http.ts +++ b/yarn-project/aztec-faucet/src/http.ts @@ -70,6 +70,7 @@ export function createFaucetHttpServer(faucet: Faucet, apiPrefix = '', logger = app.use(router.routes()); app.use(router.allowedMethods()); + // eslint-disable-next-line @typescript-eslint/no-misused-promises return createServer(app.callback()); } diff --git a/yarn-project/aztec-node/src/bin/index.ts b/yarn-project/aztec-node/src/bin/index.ts index 36ab58b7e30a..f8a695be3ac6 100644 --- a/yarn-project/aztec-node/src/bin/index.ts +++ b/yarn-project/aztec-node/src/bin/index.ts @@ -32,12 +32,15 @@ async function main() { process.exit(0); }; + // eslint-disable-next-line @typescript-eslint/no-misused-promises process.once('SIGINT', shutdown); + // eslint-disable-next-line @typescript-eslint/no-misused-promises process.once('SIGTERM', shutdown); const rpcServer = createAztecNodeRpcServer(aztecNode); const app = rpcServer.getApp(API_PREFIX); + // eslint-disable-next-line @typescript-eslint/no-misused-promises const httpServer = http.createServer(app.callback()); httpServer.listen(+AZTEC_NODE_PORT); logger.info(`Aztec Node JSON-RPC Server listening on port ${AZTEC_NODE_PORT}`); diff --git a/yarn-project/aztec.js/src/account_manager/index.ts b/yarn-project/aztec.js/src/account_manager/index.ts index 6b2114cf4058..092e66020b3f 100644 --- a/yarn-project/aztec.js/src/account_manager/index.ts +++ b/yarn-project/aztec.js/src/account_manager/index.ts @@ -129,7 +129,7 @@ export class AccountManager { * @returns A DeployMethod instance that deploys this account contract. */ public async getDeployMethod() { - if (!this.isDeployable()) { + if (!(await this.isDeployable())) { throw new Error( `Account contract ${this.accountContract.getContractArtifact().name} does not require deployment.`, ); diff --git a/yarn-project/aztec.js/src/utils/chain_monitor.ts b/yarn-project/aztec.js/src/utils/chain_monitor.ts index 7e2acf19b34e..b047a9653daa 100644 --- a/yarn-project/aztec.js/src/utils/chain_monitor.ts +++ b/yarn-project/aztec.js/src/utils/chain_monitor.ts @@ -27,7 +27,7 @@ export class ChainMonitor { if (this.handle) { throw new Error('Chain monitor already started'); } - this.handle = setInterval(() => this.run(), this.intervalMs); + this.handle = setInterval(this.safeRun.bind(this), this.intervalMs); } stop() { @@ -37,6 +37,12 @@ export class ChainMonitor { } } + private safeRun() { + void this.run().catch(error => { + this.logger.error('Error in chain monitor loop', error); + }); + } + async run() { const newL1BlockNumber = Number(await this.l1Client.getBlockNumber({ cacheTime: 0 })); if (this.l1BlockNumber === newL1BlockNumber) { diff --git a/yarn-project/aztec/src/cli/util.ts b/yarn-project/aztec/src/cli/util.ts index 118044ebd107..fe53de8042e4 100644 --- a/yarn-project/aztec/src/cli/util.ts +++ b/yarn-project/aztec/src/cli/util.ts @@ -18,7 +18,9 @@ export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise false); const avmInputsPath = join(workingDirectory, 'avm_public_inputs.bin'); await fs.writeFile(avmInputsPath, inputsBuffer); - if (!filePresent(avmInputsPath)) { + if (!(await filePresent(avmInputsPath))) { return { status: BB_RESULT.FAILURE, reason: `Could not write avm inputs to ${avmInputsPath}` }; } diff --git a/yarn-project/blob-sink/src/server/run.ts b/yarn-project/blob-sink/src/server/run.ts index 3c0239d5c9c4..6d59238fcd46 100644 --- a/yarn-project/blob-sink/src/server/run.ts +++ b/yarn-project/blob-sink/src/server/run.ts @@ -19,7 +19,9 @@ async function main() { logger.info('Node stopped'); process.exit(0); }; + // eslint-disable-next-line @typescript-eslint/no-misused-promises process.on('SIGTERM', stop); + // eslint-disable-next-line @typescript-eslint/no-misused-promises process.on('SIGINT', stop); } diff --git a/yarn-project/blob-sink/src/server/server.ts b/yarn-project/blob-sink/src/server/server.ts index a4fe4177afd1..27382c4773eb 100644 --- a/yarn-project/blob-sink/src/server/server.ts +++ b/yarn-project/blob-sink/src/server/server.ts @@ -50,7 +50,9 @@ export class BlobSinkServer { private setupRoutes() { // TODO(md): needed? this.app.get('/eth/v1/beacon/headers/:block_id', this.handleGetBlockHeader.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-misused-promises this.app.get('/eth/v1/beacon/blob_sidecars/:block_id', this.handleGetBlobSidecar.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-misused-promises this.app.post('/blob_sidecar', this.handlePostBlobSidecar.bind(this)); } diff --git a/yarn-project/cli-wallet/src/cmds/bridge_fee_juice.ts b/yarn-project/cli-wallet/src/cmds/bridge_fee_juice.ts index 105f9c5b2611..71537d581167 100644 --- a/yarn-project/cli-wallet/src/cmds/bridge_fee_juice.ts +++ b/yarn-project/cli-wallet/src/cmds/bridge_fee_juice.ts @@ -64,14 +64,12 @@ export async function bridgeL1FeeJuice( if (wait) { const delayedCheck = (delay: number) => { - return new Promise(resolve => { - setTimeout(async () => { - const witness = await pxe.getL1ToL2MembershipWitness( - feeJuiceAddress, - Fr.fromHexString(messageHash), - claimSecret, - ); - resolve(witness); + return new Promise((resolve, reject) => { + setTimeout(() => { + void pxe + .getL1ToL2MembershipWitness(feeJuiceAddress, Fr.fromHexString(messageHash), claimSecret) + .then(witness => resolve(witness)) + .catch(err => reject(err)); }, delay); }); }; diff --git a/yarn-project/cli-wallet/src/cmds/create_account.ts b/yarn-project/cli-wallet/src/cmds/create_account.ts index 42fef035d78e..73dd97d0ce1c 100644 --- a/yarn-project/cli-wallet/src/cmds/create_account.ts +++ b/yarn-project/cli-wallet/src/cmds/create_account.ts @@ -66,7 +66,7 @@ export async function createAccount( } else { const wallet = await account.getWallet(); const sendOpts: DeployAccountOptions = { - ...feeOpts.toSendOpts(wallet), + ...(await feeOpts.toSendOpts(wallet)), skipClassRegistration: !publicDeploy, skipPublicDeployment: !publicDeploy, skipInitialization: skipInitialization, diff --git a/yarn-project/cli-wallet/src/cmds/deploy.ts b/yarn-project/cli-wallet/src/cmds/deploy.ts index 7b53e5831a39..342015c7e339 100644 --- a/yarn-project/cli-wallet/src/cmds/deploy.ts +++ b/yarn-project/cli-wallet/src/cmds/deploy.ts @@ -51,7 +51,7 @@ export async function deploy( const deploy = deployer.deploy(...args); const deployOpts: Parameters[0] = { - ...feeOpts.toSendOpts(wallet), + ...(await feeOpts.toSendOpts(wallet)), contractAddressSalt: salt, universalDeploy, skipClassRegistration, diff --git a/yarn-project/cli-wallet/src/cmds/deploy_account.ts b/yarn-project/cli-wallet/src/cmds/deploy_account.ts index 3ecbd48bd3ea..98cc73e1eeeb 100644 --- a/yarn-project/cli-wallet/src/cmds/deploy_account.ts +++ b/yarn-project/cli-wallet/src/cmds/deploy_account.ts @@ -41,7 +41,7 @@ export async function deployAccount( let txReceipt; const sendOpts: DeployAccountOptions = { - ...feeOpts.toSendOpts(wallet), + ...(await feeOpts.toSendOpts(wallet)), skipInitialization: false, }; if (feeOpts.estimateOnly) { diff --git a/yarn-project/cli/src/cmds/contracts/inspect_contract.ts b/yarn-project/cli/src/cmds/contracts/inspect_contract.ts index c85fce5d2940..6bd002b464b7 100644 --- a/yarn-project/cli/src/cmds/contracts/inspect_contract.ts +++ b/yarn-project/cli/src/cmds/contracts/inspect_contract.ts @@ -29,7 +29,7 @@ export async function inspectContract(contractArtifactFile: string, debugLogger: const externalFunctions = contractFns.filter(f => !f.isInternal); if (externalFunctions.length > 0) { log(`\nExternal functions:`); - externalFunctions.forEach(f => logFunction(f, log)); + await Promise.all(externalFunctions.map(f => logFunction(f, log))); } const internalFunctions = contractFns.filter(f => f.isInternal); diff --git a/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts b/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts index 2ccb74332b44..93c0c4898104 100644 --- a/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts +++ b/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts @@ -138,8 +138,8 @@ export class P2PNetworkTest { * Start a loop to sync the mock system time with the L1 block time */ public startSyncMockSystemTimeInterval() { - this.cleanupInterval = setInterval(async () => { - await this.syncMockSystemTime(); + this.cleanupInterval = setInterval(() => { + void this.syncMockSystemTime().catch(err => this.logger.error('Error syncing mock system time', err)); }, l1ContractsConfig.aztecSlotDuration * 1000); } diff --git a/yarn-project/end-to-end/src/e2e_synching.test.ts b/yarn-project/end-to-end/src/e2e_synching.test.ts index 25714248b058..1d80762f8d6d 100644 --- a/yarn-project/end-to-end/src/e2e_synching.test.ts +++ b/yarn-project/end-to-end/src/e2e_synching.test.ts @@ -530,10 +530,10 @@ describe('e2e_synching', () => { const txHash = blockTip.body.txEffects[0].txHash; const contractClassIds = await archiver.getContractClassIds(); - contracts.forEach(async c => { + for (const c of contracts) { expect(contractClassIds.includes(c.instance.contractClassId)).toBeTrue; expect(await archiver.getContract(c.address)).not.toBeUndefined; - }); + } expect(await archiver.getTxEffect(txHash)).not.toBeUndefined; expect(await archiver.getPrivateLogs(blockTip.number, 1)).not.toEqual([]); diff --git a/yarn-project/end-to-end/src/spartan/4epochs.test.ts b/yarn-project/end-to-end/src/spartan/4epochs.test.ts index 4aa433070715..f63b56a6f61b 100644 --- a/yarn-project/end-to-end/src/spartan/4epochs.test.ts +++ b/yarn-project/end-to-end/src/spartan/4epochs.test.ts @@ -68,9 +68,9 @@ describe('token transfer test', () => { const recipient = testWallets.recipientWallet.getAddress(); const transferAmount = 1n; - testWallets.wallets.forEach(async w => { + for (const w of testWallets.wallets) { expect(MINT_AMOUNT).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate()); - }); + } expect(0n).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate()); @@ -98,11 +98,11 @@ describe('token transfer test', () => { ); } - testWallets.wallets.forEach(async w => { + for (const w of testWallets.wallets) { expect(MINT_AMOUNT - ROUNDS * transferAmount).toBe( await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate(), ); - }); + } expect(ROUNDS * transferAmount * BigInt(testWallets.wallets.length)).toBe( await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate(), diff --git a/yarn-project/end-to-end/src/spartan/reorg.test.ts b/yarn-project/end-to-end/src/spartan/reorg.test.ts index 78d0c3942323..a69b90d98d89 100644 --- a/yarn-project/end-to-end/src/spartan/reorg.test.ts +++ b/yarn-project/end-to-end/src/spartan/reorg.test.ts @@ -24,11 +24,11 @@ const { NAMESPACE, HOST_PXE_PORT, HOST_ETHEREUM_PORT, CONTAINER_PXE_PORT, CONTAI const debugLogger = createLogger('e2e:spartan-test:reorg'); async function checkBalances(testWallets: TestWallets, mintAmount: bigint, totalAmountTransferred: bigint) { - testWallets.wallets.forEach(async w => { + for (const w of testWallets.wallets) { expect(await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate()).toBe( mintAmount - totalAmountTransferred, ); - }); + } expect( await testWallets.tokenAdminWallet.methods.balance_of_public(testWallets.recipientWallet.getAddress()).simulate(), diff --git a/yarn-project/end-to-end/src/spartan/transfer.test.ts b/yarn-project/end-to-end/src/spartan/transfer.test.ts index 71dd666c5baa..4f2fd251115b 100644 --- a/yarn-project/end-to-end/src/spartan/transfer.test.ts +++ b/yarn-project/end-to-end/src/spartan/transfer.test.ts @@ -45,9 +45,9 @@ describe('token transfer test', () => { const recipient = testWallets.recipientWallet.getAddress(); const transferAmount = 1n; - testWallets.wallets.forEach(async w => { + for (const w of testWallets.wallets) { expect(MINT_AMOUNT).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate()); - }); + } expect(0n).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate()); @@ -66,11 +66,11 @@ describe('token transfer test', () => { await Promise.all(txs.map(t => t.send().wait({ timeout: 600 }))); } - testWallets.wallets.forEach(async w => { + for (const w of testWallets.wallets) { expect(MINT_AMOUNT - ROUNDS * transferAmount).toBe( await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate(), ); - }); + } expect(ROUNDS * transferAmount * BigInt(testWallets.wallets.length)).toBe( await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate(), diff --git a/yarn-project/foundation/.eslintrc.cjs b/yarn-project/foundation/.eslintrc.cjs index 09a002a79dbd..2cb0d790949e 100644 --- a/yarn-project/foundation/.eslintrc.cjs +++ b/yarn-project/foundation/.eslintrc.cjs @@ -40,6 +40,7 @@ module.exports = { '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/await-thenable': 'error', '@typescript-eslint/no-floating-promises': 2, + '@typescript-eslint/no-misused-promises': 2, '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], '@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }], 'require-await': 2, diff --git a/yarn-project/foundation/src/json-rpc/server/safe_json_rpc_server.ts b/yarn-project/foundation/src/json-rpc/server/safe_json_rpc_server.ts index 941f5436568e..603d88b29ec5 100644 --- a/yarn-project/foundation/src/json-rpc/server/safe_json_rpc_server.ts +++ b/yarn-project/foundation/src/json-rpc/server/safe_json_rpc_server.ts @@ -151,6 +151,7 @@ export class SafeJsonRpcServer { throw new Error('Server is already listening'); } + // eslint-disable-next-line @typescript-eslint/no-misused-promises this.httpServer = http.createServer(this.getApp(prefix).callback()); this.httpServer.listen(port); } @@ -355,6 +356,7 @@ export async function startHttpRpcServer( const statusRouter = createStatusRouter(rpcServer.isHealthy.bind(rpcServer), options.apiPrefix); app.use(statusRouter.routes()).use(statusRouter.allowedMethods()); + // eslint-disable-next-line @typescript-eslint/no-misused-promises const httpServer = http.createServer(app.callback()); if (options.timeoutMs) { httpServer.timeout = options.timeoutMs; diff --git a/yarn-project/foundation/src/mutex/index.ts b/yarn-project/foundation/src/mutex/index.ts index e7b7fcac9685..6042ff32b167 100644 --- a/yarn-project/foundation/src/mutex/index.ts +++ b/yarn-project/foundation/src/mutex/index.ts @@ -72,12 +72,13 @@ export class Mutex { * * @param id - The id of the current lock instance. */ - private async ping(id: number) { + private ping(id: number) { if (id !== this.id) { return; } - - await this.db.extendLock(this.name, this.timeout); - this.pingTimeout = setTimeout(() => this.ping(id), this.pingInterval); + void (async () => { + await this.db.extendLock(this.name, this.timeout); + this.pingTimeout = setTimeout(() => this.ping(id), this.pingInterval); + })(); } } diff --git a/yarn-project/foundation/src/worker/browser/start_web_module.ts b/yarn-project/foundation/src/worker/browser/start_web_module.ts index 06a59e22c3df..4297ffb56585 100644 --- a/yarn-project/foundation/src/worker/browser/start_web_module.ts +++ b/yarn-project/foundation/src/worker/browser/start_web_module.ts @@ -18,6 +18,7 @@ export function startWebModule(module: WasmModule) { }; const transportListener = new WorkerListener(self); const transportServer = new TransportServer(transportListener, dispatch); + // eslint-disable-next-line @typescript-eslint/no-misused-promises module.addLogger((...args: any[]) => transportServer.broadcast({ fn: 'emit', args: ['log', ...args] })); transportServer.start(); } diff --git a/yarn-project/foundation/src/worker/browser/web_worker.ts b/yarn-project/foundation/src/worker/browser/web_worker.ts index 7560c60852ef..8a6f6f52943e 100644 --- a/yarn-project/foundation/src/worker/browser/web_worker.ts +++ b/yarn-project/foundation/src/worker/browser/web_worker.ts @@ -15,6 +15,7 @@ export async function createWebWorker(url: string, initialMem?: number, maxMem?: const transportClient = new TransportClient(transportConnect); await transportClient.open(); const remoteModule = createDispatchProxy(WasmModule, transportClient) as WasmWorker; + // eslint-disable-next-line @typescript-eslint/no-misused-promises remoteModule.destroyWorker = async () => { await transportClient.request({ fn: '__destroyWorker__', args: [] }); transportClient.close(); diff --git a/yarn-project/foundation/src/worker/node/node_worker.ts b/yarn-project/foundation/src/worker/node/node_worker.ts index bd4c8b096f3e..8bf1516b772c 100644 --- a/yarn-project/foundation/src/worker/node/node_worker.ts +++ b/yarn-project/foundation/src/worker/node/node_worker.ts @@ -13,6 +13,7 @@ export async function createNodeWorker(filepath: string, initialMem?: number, ma const transportClient = new TransportClient(transportConnect); await transportClient.open(); const remoteModule = createDispatchProxy(WasmModule, transportClient) as WasmWorker; + // eslint-disable-next-line @typescript-eslint/no-misused-promises remoteModule.destroyWorker = async () => { await transportClient.request({ fn: '__destroyWorker__', args: [] }); transportClient.close(); diff --git a/yarn-project/foundation/src/worker/node/start_node_module.ts b/yarn-project/foundation/src/worker/node/start_node_module.ts index ac445de19264..024868515dda 100644 --- a/yarn-project/foundation/src/worker/node/start_node_module.ts +++ b/yarn-project/foundation/src/worker/node/start_node_module.ts @@ -24,6 +24,7 @@ export function startNodeModule(module: WasmModule) { }; const transportListener = new NodeListener(); const transportServer = new TransportServer(transportListener, dispatch); + // eslint-disable-next-line @typescript-eslint/no-misused-promises module.addLogger((...args: any[]) => transportServer.broadcast({ fn: 'emit', args: ['log', ...args] })); transportServer.start(); } diff --git a/yarn-project/ivc-integration/src/serve.ts b/yarn-project/ivc-integration/src/serve.ts index 3f12245e1716..e8fc91158c19 100644 --- a/yarn-project/ivc-integration/src/serve.ts +++ b/yarn-project/ivc-integration/src/serve.ts @@ -84,6 +84,7 @@ document.addEventListener('DOMContentLoaded', function () { const button = document.createElement('button'); button.innerText = 'Run Test'; + // eslint-disable-next-line @typescript-eslint/no-misused-promises button.addEventListener('click', async () => { logger(`generating circuit and witness...`); const [bytecodes, witnessStack] = await generate3FunctionTestingIVCStack(); diff --git a/yarn-project/noir-bb-bench/src/serve.ts b/yarn-project/noir-bb-bench/src/serve.ts index 754be460f6d7..7af9779e24dc 100644 --- a/yarn-project/noir-bb-bench/src/serve.ts +++ b/yarn-project/noir-bb-bench/src/serve.ts @@ -117,8 +117,6 @@ document.addEventListener('DOMContentLoaded', function () { const button = document.createElement('button'); button.innerText = 'Run Test'; - button.addEventListener('click', async () => { - const _ = await proveThenVerifyStack(); - }); + button.addEventListener('click', () => void proveThenVerifyStack()); document.body.appendChild(button); }); diff --git a/yarn-project/p2p-bootstrap/src/index.ts b/yarn-project/p2p-bootstrap/src/index.ts index c3af829a460b..104a396960e8 100644 --- a/yarn-project/p2p-bootstrap/src/index.ts +++ b/yarn-project/p2p-bootstrap/src/index.ts @@ -41,7 +41,9 @@ async function main( logger.info('Node stopped'); process.exit(0); }; + // eslint-disable-next-line @typescript-eslint/no-misused-promises process.on('SIGTERM', stop); + // eslint-disable-next-line @typescript-eslint/no-misused-promises process.on('SIGINT', stop); } diff --git a/yarn-project/p2p/src/services/libp2p/libp2p_service.ts b/yarn-project/p2p/src/services/libp2p/libp2p_service.ts index 50fe10796537..b2b2066f523a 100644 --- a/yarn-project/p2p/src/services/libp2p/libp2p_service.ts +++ b/yarn-project/p2p/src/services/libp2p/libp2p_service.ts @@ -376,11 +376,13 @@ export class LibP2PService extends WithTracer implement return this.peerManager.getPeers(includePending); } - private async handleGossipSubEvent(e: CustomEvent) { + private handleGossipSubEvent(e: CustomEvent) { const { msg } = e.detail; this.logger.trace(`Received PUBSUB message.`); - await this.jobQueue.put(() => this.handleNewGossipMessage(msg)); + void this.jobQueue + .put(() => this.handleNewGossipMessage(msg)) + .catch(err => this.logger.error(`Error processing gossip message`, err)); } /** diff --git a/yarn-project/p2p/src/services/peer-manager/peer_manager.ts b/yarn-project/p2p/src/services/peer-manager/peer_manager.ts index 6b5b9ba45706..4c4c9eb5993d 100644 --- a/yarn-project/p2p/src/services/peer-manager/peer_manager.ts +++ b/yarn-project/p2p/src/services/peer-manager/peer_manager.ts @@ -42,6 +42,7 @@ export class PeerManager { private timedOutPeers: Map = new Map(); private metrics: PeerManagerMetrics; + private discoveredPeerHandler; constructor( private libP2PNode: PubSubLibp2p, @@ -60,7 +61,10 @@ export class PeerManager { this.libP2PNode.addEventListener(PeerEvent.DISCONNECTED, this.handleDisconnectedPeerEvent.bind(this)); // Handle Discovered peers - this.peerDiscoveryService.on(PeerEvent.DISCOVERED, this.handleDiscoveredPeer.bind(this)); + this.discoveredPeerHandler = (enr: ENR) => + this.handleDiscoveredPeer(enr).catch(e => this.logger.error('Error handling discovered peer', e)); + // eslint-disable-next-line @typescript-eslint/no-misused-promises + this.peerDiscoveryService.on(PeerEvent.DISCOVERED, this.discoveredPeerHandler); // Display peer counts every 60 seconds this.displayPeerCountsPeerHeartbeat = Math.floor(60_000 / this.config.peerCheckIntervalMS); @@ -411,7 +415,8 @@ export class PeerManager { * Removing all event listeners. */ public async stop() { - this.peerDiscoveryService.off(PeerEvent.DISCOVERED, this.handleDiscoveredPeer); + // eslint-disable-next-line @typescript-eslint/no-misused-promises + this.peerDiscoveryService.off(PeerEvent.DISCOVERED, this.discoveredPeerHandler); // Send goodbyes to all peers await Promise.all( diff --git a/yarn-project/p2p/src/services/reqresp/reqresp.ts b/yarn-project/p2p/src/services/reqresp/reqresp.ts index 0f428493c4ed..b3ebc30f97ac 100644 --- a/yarn-project/p2p/src/services/reqresp/reqresp.ts +++ b/yarn-project/p2p/src/services/reqresp/reqresp.ts @@ -95,7 +95,13 @@ export class ReqResp { // Register all protocol handlers for (const subProtocol of Object.keys(this.subProtocolHandlers)) { - await this.libp2p.handle(subProtocol, this.streamHandler.bind(this, subProtocol as ReqRespSubProtocol)); + await this.libp2p.handle( + subProtocol, + (data: IncomingStreamData) => + void this.streamHandler(subProtocol as ReqRespSubProtocol, data).catch(err => + this.logger.error(`Error on libp2p subprotocol ${subProtocol} handler`, err), + ), + ); } this.rateLimiter.start(); } diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator.ts b/yarn-project/prover-client/src/orchestrator/orchestrator.ts index b1f5e2cb6610..1d8a0b855dc9 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator.ts @@ -247,7 +247,7 @@ export class ProvingOrchestrator implements EpochProver { const tubeInputs = new TubeInputs(tx.clientIvcProof); const tubeProof = promiseWithResolvers>(); logger.debug(`Starting tube circuit for tx ${txHash}`); - this.doEnqueueTube(txHash, tubeInputs, proof => tubeProof.resolve(proof)); + this.doEnqueueTube(txHash, tubeInputs, proof => Promise.resolve(tubeProof.resolve(proof))); this.provingState?.cachedTubeProofs.set(txHash, tubeProof.promise); } } @@ -448,7 +448,7 @@ export class ProvingOrchestrator implements EpochProver { }; // let the callstack unwind before adding the job to the queue - setImmediate(safeJob); + setImmediate(() => void safeJob()); } private async prepareBaseParityInputs(l1ToL2Messages: Fr[], db: MerkleTreeWriteOperations) { @@ -593,7 +593,7 @@ export class ProvingOrchestrator implements EpochProver { private doEnqueueTube( txHash: string, inputs: TubeInputs, - handler: (result: ProofAndVerificationKey) => void, + handler: (result: ProofAndVerificationKey) => Promise, provingState: EpochProvingState | BlockProvingState = this.provingState!, ) { if (!provingState?.verifyState()) { diff --git a/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts b/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts index 833979906d17..d6630038171b 100644 --- a/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts +++ b/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts @@ -55,7 +55,7 @@ type ProvingJob = { type: ProvingRequestType; inputsUri: ProofUri; promise: PromiseWithResolvers; - abortFn?: () => Promise; + abortFn?: () => void; signal?: AbortSignal; }; @@ -117,9 +117,9 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver { // Create a promise for this job id, regardless of whether it was enqueued at the broker // The running promise will monitor for the job to be completed and resolve it either way const promise = promiseWithResolvers(); - const abortFn = async () => { + const abortFn = () => { signal?.removeEventListener('abort', abortFn); - await this.broker.cancelProvingJob(id); + void this.broker.cancelProvingJob(id).catch(err => this.log.warn(`Error cancelling job id=${id}`, err)); }; const job: ProvingJob = { id, diff --git a/yarn-project/pxe/src/database/kv_pxe_database.ts b/yarn-project/pxe/src/database/kv_pxe_database.ts index 7966fec8b536..05c7faa4b0d7 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -314,7 +314,7 @@ export class KVPxeDatabase implements PxeDatabase { for (const scope of new Set(filter.scopes)) { const formattedScopeString = scope.toString(); - if (!this.#scopes.hasAsync(formattedScopeString)) { + if (!(await this.#scopes.hasAsync(formattedScopeString))) { throw new Error('Trying to get incoming notes of an scope that is not in the PXE database'); } @@ -568,7 +568,7 @@ export class KVPxeDatabase implements PxeDatabase { } async removeSenderAddress(address: AztecAddress): Promise { - if (!this.#addressBook.hasAsync(address.toString())) { + if (!(await this.#addressBook.hasAsync(address.toString()))) { return false; } diff --git a/yarn-project/pxe/src/pxe_http/pxe_http_server.ts b/yarn-project/pxe/src/pxe_http/pxe_http_server.ts index 03d9309fdf48..7d0f38c66400 100644 --- a/yarn-project/pxe/src/pxe_http/pxe_http_server.ts +++ b/yarn-project/pxe/src/pxe_http/pxe_http_server.ts @@ -21,6 +21,7 @@ export function startPXEHttpServer(pxeService: PXE, port: string | number): http const rpcServer = createNamespacedSafeJsonRpcServer({ pxe: [pxeService, PXESchema] }); const app = rpcServer.getApp(); + // eslint-disable-next-line @typescript-eslint/no-misused-promises const httpServer = http.createServer(app.callback()); httpServer.listen(port); diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index 8998440e7a4a..695df7c040f8 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -493,6 +493,7 @@ export class Sequencer { // We create a fresh processor each time to reset any cached state (eg storage writes) // We wait a bit to close the forks since the processor may still be working on a dangling tx // which was interrupted due to the processingDeadline being hit. + // eslint-disable-next-line @typescript-eslint/no-misused-promises setTimeout(async () => { try { await publicProcessorFork.close(); diff --git a/yarn-project/telemetry-client/src/otel_propagation.ts b/yarn-project/telemetry-client/src/otel_propagation.ts index 99f766769c7d..dad50b793829 100644 --- a/yarn-project/telemetry-client/src/otel_propagation.ts +++ b/yarn-project/telemetry-client/src/otel_propagation.ts @@ -11,7 +11,7 @@ import { export function getOtelJsonRpcPropagationMiddleware( scope = 'JsonRpcServer', -): (ctx: Koa.Context, next: () => Promise) => void { +): (ctx: Koa.Context, next: () => Promise) => Promise { return function otelJsonRpcPropagation(ctx: Koa.Context, next: () => Promise) { const tracer = getTelemetryClient().getTracer(scope); const context = propagation.extract(ROOT_CONTEXT, ctx.request.headers);