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

store: TrieAccountingCache is pretty iffy part of our codebase #13008

Open
nagisa opened this issue Feb 27, 2025 · 0 comments
Open

store: TrieAccountingCache is pretty iffy part of our codebase #13008

nagisa opened this issue Feb 27, 2025 · 0 comments

Comments

@nagisa
Copy link
Collaborator

nagisa commented Feb 27, 2025

TrieAccountingCache (hereon TAC) is pretty iffy part of our codebase.

First, it is currently mostly unused for the purpose of caching, but rather is chiefly a tool for discriminating first and subsequent store accesses from contracts for the purposes of charging different amounts of gas. Since the accesses now always go to the memtrie, it is up for debate if these fees have any reason to be any different at all, since all accesses now cost the same. But at the same time we can't exactly get rid of TAC as it is necessary for support of older protocol versions (replayability.)

There is point to be made to replace TAC with just a mechanism that tracks whether access to a key happens for the first time or not, and just maintain the access type counters. In making this change the cache would stop storing the values and only store the keys that have been accessed.

Second, the current enable_switch mechanism that's part of TAC (and relatedly the Trie::charge_gas_for_trie_node_access field) is super iffy especially as we look towards sharing this type across multiple threads. #12981 made the switch somewhat more palatable by making the switch track state on a thread-local basis, but ideally each access should be passing an argument to describe whether an access should increment the TAC counters (mostly enabled just from the context in which contract execution occurs,) whether an access should incur a side effect of recording it to state witness (subsuming get_no_side_effect), etc. Passing an argument describing the effects makes the whole store concept much more friendly to it being used in a multi-threaded context.

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

No branches or pull requests

1 participant