Skip to content

Commit 8fdb81e

Browse files
fix(memory): bump stack memory to permit 30k records
1 parent 7a57ca5 commit 8fdb81e

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

ao-build-config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ao-dev-cli options
2-
stack_size: 65536 # 64KiB
3-
initial_memory: 1048576 # 1MiB stack size is included in initial memory, along with heap
2+
stack_size: 3145728 # 3MiB
3+
initial_memory: 4194304 # 4MiB stack size is included in initial memory, along with heap
44
maximum_memory: 1073741824 # 1GiB
55
target: 32 # wasm32 or wasm 64
66
# extra info

test/json.test.mjs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { createAntAosLoader } from './utils.mjs';
2+
import { describe, it } from 'node:test';
3+
import {
4+
AO_LOADER_HANDLER_ENV,
5+
DEFAULT_HANDLE_OPTIONS,
6+
} from '../tools/constants.mjs';
7+
8+
describe('JSON limits', async () => {
9+
const { handle: originalHandle, memory: startMemory } =
10+
await createAntAosLoader();
11+
12+
async function handle(options = {}, mem = startMemory) {
13+
return originalHandle(
14+
mem,
15+
{
16+
...DEFAULT_HANDLE_OPTIONS,
17+
...options,
18+
},
19+
AO_LOADER_HANDLER_ENV,
20+
);
21+
}
22+
23+
it('should not be able to parse a large json', async () => {
24+
const records = {};
25+
const controllers = [];
26+
const balances = {};
27+
for (let i = 0; i < 15_000; i++) {
28+
records[`${i}-name`] = {
29+
transactionId: ''.padEnd(43, '1'),
30+
ttlSeconds: 900,
31+
};
32+
const controller = ''.padEnd(43, i.toString());
33+
controllers.push(controller);
34+
balances[controller] = 1;
35+
}
36+
const data = JSON.stringify({
37+
records,
38+
controllers,
39+
balances,
40+
});
41+
console.log('parsing data size: ' + data.length);
42+
const result = await handle({
43+
Data: data,
44+
Tags: [{ name: 'Content-Type', value: 'application/json' }],
45+
});
46+
47+
console.dir(result, { depth: null });
48+
});
49+
});

0 commit comments

Comments
 (0)