-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ToJson overload #2671
Add ToJson overload #2671
Conversation
@shargon @Liaojinghui |
I am not sure, but dont you think 4G is too big? By the way, we still have another problem which is user can deploy a smart contract on N3 that keeps calling
|
neo-project/neo-vm#245 and neo-project/neo-vm#369. I'd still like to have more strict constraints (like ~128MB), but we're in 2022 now and every phone around has 4+GB, so maybe it's not worth the trouble? As for GAS cost, btw, 0.15GAS seems to be appropriate, it's mostly about CPU time spent and CPU doesn't have to do a lot of work to allocate 2G. |
But think about that, you have a 4Gb json to process or a 2Gb value to persist. Indeed it is memory, but you gonna deal with this memory. |
Where will it come from? Oracle responses are limited (IIRC, 64K), transaction size is limited too (100K, but script can only be 64K). Sure, you can construct some JSON in memory, but I think this activity will be limited by the maximum Buffer capacity that is 1M.
With StoragePrice of 10000 (or 0.0001) that'd be more than 200K GAS which is ~1M$ at the moment. I think we know all people with enough GAS to try doing that by name and it's not likely they're interested in doing this. |
I agree with everything you mentioned. However, we are not talking about usage cases, we are talking about attacks: This exploit i constructed can generate a 1024 GB json
at
and it could be 2048TB if i deploy a smart contract. Saddly |
Well, it won't after the fix (and appropriate limit of course).
Sure, but this was all started by The way I see it is we have some reasonable limits in the VM, as far as we know they work fine. There are some ways for data to get in/out of the VM and they're all well-known. Stack items can be serialized into binary or into JSON (in two different ways). As long as all these ways are protected we should be fine. If every plugin implements something of its own, that's plugin's problem. |
JArray result = new(); | ||
foreach (var item in stack) | ||
result.Add(ToJson(item, null, ref maxSize)); | ||
if (maxSize < 0) throw new InvalidOperationException("Max size reached."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (maxSize < 0) throw new InvalidOperationException("Max size reached."); |
Co-authored-by: Jinghui Liao <jinghui@wayne.edu>
Co-authored-by: Jinghui Liao <jinghui@wayne.edu>
* Add ToJson overload (#2671) * Add ToJson overload * change * Update src/neo/VM/Helper.cs * Update src/neo/VM/Helper.cs * Update src/neo/VM/Helper.cs * Update src/neo/VM/Helper.cs Co-authored-by: Jinghui Liao <jinghui@wayne.edu> * Update src/neo/VM/Helper.cs Co-authored-by: Jinghui Liao <jinghui@wayne.edu> Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Jinghui Liao <jinghui@wayne.edu> * Fix oom (#2665) * Fix oom * Revert reorder * parameters order Co-authored-by: Erik Zhang <erik@neo.org> * Optimize inventory (#2659) * add `murmur32` to crypto lib (#2604) * 3.2.0 * fix Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Jinghui Liao <jinghui@wayne.edu>
Alternative to #2669