trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

Maybe move "bufferification" step to `debug_traceTransaction` so that that the result can be chunked and sent to the caller instead of buffered in a JSON object first #3998

Open davidmurdoch opened 1 year ago

davidmurdoch commented 1 year ago

We currently use a function called bufferify to convert "large" JSON objects into small Buffer chunks that can be yielded and serialized for the wire as they are processed. This works around a node limitation with JSON.stringify, as it can't handle strings greater than ~1GB in size (Buffers also have a similar limit). However, this approach is much slower then JSON.stringify, so we try to only do it on "large" traces. The number at which we choose to switch to bufferification is arbitrary and prone to issues where a trace with few steps still has too much data to JSON.stringify, causing the error. Here is an example: https://github.com/trufflesuite/ganache/issues/3924

We could try to JSON.stringify, and then fall back to bufferify, but there is a better way: start sending the data as soon as it is available to send. Example: https://github.com/trufflesuite/ganache/pull/3997

However, this has some new problems:

A similar issue: https://github.com/trufflesuite/ganache/issues/381

davidmurdoch commented 1 year ago

Related: https://banteg.mirror.xyz/3dbuIlaHh30IPITWzfT1MFfSg6fxSssMqJ7TcjaWecM