Skip to content

Commit 4a29a70

Browse files
authored
fix: node request from PXE crossing MAX_RPC_LIMIT (#19516)
A fix that prevents `PXE` from crossing the `MAX_RPC_LIMIT`. This fix was originally published by @porco-rosso-j [here](#19181) but it never got to `next` because on `next` the issue went away with the introduction of the new log sync algo.
1 parent 087f538 commit 4a29a70

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

yarn-project/pxe/src/contract_function_simulator/pxe_oracle_interface.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,22 @@ export class PXEOracleInterface implements ExecutionDataProvider {
10171017
// TODO(#12656): Make this a public function on the AztecNode interface and remove the original getLogsByTags. This
10181018
// was not done yet as we were unsure about the API and we didn't want to introduce a breaking change.
10191019
async #getPrivateLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
1020-
const allLogs = await this.aztecNode.getLogsByTags(tags);
1020+
// Batch tags to avoid exceeding MAX_RPC_LEN
1021+
const tagBatches = tags.reduce(
1022+
(acc, tag) => {
1023+
if (acc[acc.length - 1].length < MAX_RPC_LEN) {
1024+
acc[acc.length - 1].push(tag);
1025+
} else {
1026+
acc.push([tag]);
1027+
}
1028+
return acc;
1029+
},
1030+
[[]] as Fr[][],
1031+
);
1032+
1033+
const allLogsBatched = await Promise.all(tagBatches.map(batch => this.aztecNode.getLogsByTags(batch)));
1034+
1035+
const allLogs = allLogsBatched.flat();
10211036
return allLogs.map(logs => logs.filter(log => !log.isFromPublic));
10221037
}
10231038

0 commit comments

Comments
 (0)