-
Notifications
You must be signed in to change notification settings - Fork 142
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
Gas: Reprice state read/write #1346
Comments
Currently, we charge very little for state reads and address lookups because we expect heavy caching. However, in an environment where users can manually trigger lookups, this is no longer true. Unfortunately, given the current number of actors in the network, I'd expect at least 2 IPLD loads (assuming caching) for actor lookups, and likely 4 for address lookups. This comes out to 0.5M and 1M gas, respectively. That's really expensive. We likely need to find a better approach.
|
Ok, so, some benchmarking. We were hoping that the EVM logic would cost more than the expected address lookup costs. From the EVM, it costs ~21801 gas to lookup a balance by ID. That's:
It's ~45792 gas to lookup a balance by address (which, under the hood, resolves an address then looks up an actor). That's:
The expected cost to, e.g., lookup an address plus an actor is about 6 IPLD loads (or more) which is at least 1M gas (or ~2 orders of magnitude greater). So we definitely need to charge here. |
Benchmark: filecoin-project/fvm-bench#7 |
Benchmarking required:
Determining the cost of an uncached load may be a bit tricky, unfortunately, due to the caching inside the state tree itself. Really, it may be easier to simulate these things by:
|
Results for updates: https://shuttle-10.estuary.tech/gw/ipfs/bafkreia4ywcghoe57tc5mj455ycboosdoezrfzbwzv445hsfqxizd44yyi/ Normal gateway link: https://dweb.link/ipfs/bafkreia4ywcghoe57tc5mj455ycboosdoezrfzbwzv445hsfqxizd44yyi , but I'm getting 429 error right now. |
Let me know if you want an interpolation of the result for a specific number of state updates in a batch, I can interpolate it from the results. |
Frome sentinel, we learned that, on average, we do 262 state updates per epoch.
|
1. We don't intentionally use these anywhere. 2. We _do_ unintentionally use these where we shouldn't (filecoin-project/builtin-actors#1346). fixes #1346
We need to account for the cost of looking actors up in the state-tree, and writing them back.
The text was updated successfully, but these errors were encountered: