sui move test: hardcoded 10 MB per-package VM arena makes large test suites unrunnable, with no way to raise it
Summary
The Move VM's per-package arena is capped at a hardcoded 10 MB (ARENA_SIZE in
external-crates/move/crates/move-vm-runtime/src/cache/arena.rs). That is generous for a
published package, but a package built for sui move test also contains everything under
tests/, and Move macros expand at every call site — so the JIT'd form of a test build can be
an order of magnitude larger than the same package's on-chain form.
Once a package crosses the line, sui move test becomes unusable for that package: the arena is
exhausted while the package is loaded, before any test runs, so every test fails with
PACKAGE_ARENA_LIMIT_REACHED (code 4031) — including tests that have nothing to do with the code
that pushed it over. There is no flag to raise the limit and no way to work around it at the CLI.
The constant carries a FIXME acknowledging it was never validated:
/// Size of a package arena.
/// This is 10 megabytes, which should be more than enough room for any pacakge on chain.
/// FIXME: Test this limit and validate. See how large packages are in backtesting and double that
/// limit, setting it here.
const ARENA_SIZE: usize = 10_000_000;The reasoning in that comment ("any package on chain") is the gap: test builds are not on-chain packages, and they are what hits this.
Repro
Against a real production package, on a public repo:
git clone https://github.com/kunalabs-io/sui-smart-contracts.git
cd sui-smart-contracts
# passes
sui move test --path kai/leverage/core
# => Test result: OK. Total tests: 294; passed: 294; failed: 0
# add one more test module — a copy of an existing 136-line one under a new name
cd kai/leverage/core/tests/position_core/cetus
sed 's/position_core_cetus_liquidate_tests;/position_core_cetus_liquidate_tests_dup;/' \
liquidate_tests.move > liquidate_tests_dup.move
cd -
sui move test --path kai/leverage/core
# => Test result: FAILED. Total tests: 308; passed: 0; failed: 308
# every one: PACKAGE_ARENA_LIMIT_REACHED (code 4031)136 lines of added test source is enough to take the suite from fully green to fully red. The file is small because it only instantiates macros defined elsewhere; the expansion is what lands in the arena.
sui move build on the same package succeeds — this affects test builds only.
Why the obvious workarounds don't apply
Filtering the test run doesn't help. The whole package is compiled and published into the test VM before the filter selects anything, so selecting two tests exhausts the arena exactly like selecting all of them:
sui move test --path kai/leverage/core pyth_tests
# => Test result: FAILED. Total tests: 2; passed: 0; failed: 2 (PACKAGE_ARENA_LIMIT_REACHED)Moving the tests into a separate package doesn't help either. The arena is per-package, so
this ought to be the natural fix, but dependencies are compiled without test mode — a test-only
package that depends on the package under test can reach only its public API, not
public(package) items and not its #[test_only] helpers. For the package above, 64 of its 207
public(package) functions are exercised by tests; exporting all of them purely to satisfy the
test layout would permanently widen the on-chain API surface of a deployed protocol.
That leaves deleting tests or patching the constant in a private build as the only options.
Suggested fix
Any of these would resolve it:
- Raise
ARENA_SIZE, per the existingFIXME. - Use a separate, larger limit when running in test mode, where the on-chain sizing rationale doesn't apply.
- Expose it as a
sui move testflag, alongside--gas-limit.
A clearer error would also help a lot independently of the limit — the current failure surfaces identically on every test in the package and doesn't mention package size, which makes it non-obvious that the cause is total test-build size rather than the change being tested.
Environment
sui 1.77.2-51d177ad7d65- Also present on current
main—ARENA_SIZEis unchanged since #25838 ("[move] Add and enable the new VM")
Source: MystenLabs/sui