Skip to content
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

New builtin for field map garbage collection #977

Open
anton-trunov opened this issue Apr 5, 2021 · 2 comments
Open

New builtin for field map garbage collection #977

anton-trunov opened this issue Apr 5, 2021 · 2 comments
Labels

Comments

@anton-trunov
Copy link
Contributor

anton-trunov commented Apr 5, 2021

Some contracts tend to accumulate lots of nested empty maps and when the semantics of the contract permits we should have a mechanism to clean the empty maps. @vaivaswatha has suggested to implement this as a new builtin because it's easier to do this at the C++ level.

Example:

A map like this
{
"key1" -> {"key1a" -> 42}
"key2" -> {}
"key3" -> {}
...
"key42" -> {}
}

often times can be simplified to

{
"key1" -> {"key1a" -> 42}
}
@vaivaswatha
Copy link
Contributor

vaivaswatha commented Apr 5, 2021

A common scenario is when in a nested map, all keys of a nested map are deleted (and we have an empty map), but the corresponding key in the outer map (that now holds an empty inner map as its value) lives on.

A builtin can be provided to prune such keys in an outer map that have empty map values.

Implementation: It looks to me that the best way to do this is to have a direct call, via IPC, to the blockchain code that will scan the leveldb database and perform this operation.

Edit: This comment turned out to be redundant given @anton-trunov 's update to the Issue description. I'll let it stay on though.

@anton-trunov
Copy link
Contributor Author

Related issue: #900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants