-
Notifications
You must be signed in to change notification settings - Fork 690
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
protocol_feature_fix_contract_loading_cost tracking issue #5962
Comments
related: #4826 |
Note: we also should charge this cost if contract fails to compile (ie, it is invalid wasm) |
contract_compile
contract_compile
cost
I started working on this. I wonder what the correct place to charge the new
|
Having merged #6772 also, I consider this issue done. |
# Feature to stabilize The gas cost for loading a contract executable used to be charged afterwards. However, the general rule for gas charges is that they should be charged before the cost occurs. This is only noticable when the execution fails during that step. But it is nevertheless important, as an attacker could potentially abuse this to fill up block space without being charged for it. Note that "loading" in this context is a technical term for preparing and populating all memory regions for an executable. Reading the data from the database is NOT included in this. On a side note, the actual gas parameter values have not been updated, yet. We know that `wasm_contract_loading_bytes` in particular is too low. But it is counter balanced by `action_function_call` which is higher than it needs to be. Stabilizing this feature paves the floor to adjust those parameters. Main implementation PR: near#6772 Main issue: near#5962 # Testing and QA ## Tests The original PR (near#6772) includes tests on the VM level that ensure old versions are unaffeceted while new versions charge the cost correctly. Integration tests in near#7169 checks the same again but on the apply-block level. ## Impact on existing smart contracts This change does not affect anything except for function calls that fail during preparation. Since those were already failing, it should not impact anyone if the error type and amount of gas charged changes. # Checklist - [ ] TODO Link to nightly nayduck run (`./scripts/nayduck.py`, [docs](https://github.com/near/nearcore/blob/master/nightly/README.md#scheduling-a-run)): https://nayduck.near.org/ - [x] Update CHANGELOG.md to include this protocol feature in the `Unreleased` section.
# Feature to stabilize The gas cost for loading a contract executable used to be charged afterwards. However, the general rule for gas charges is that they should be charged before the cost occurs. This is only noticeable when the execution fails during that step. But it is nevertheless important, as an attacker could potentially abuse this to fill up block space without being charged for it. Note that "loading" in this context is a technical term for preparing and populating all memory regions for an executable. Reading the data from the database is NOT included in this. On a side note, the actual gas parameter values have not been updated, yet. We know that `wasm_contract_loading_bytes` in particular is too low. But it is counter balanced by `action_function_call` which is higher than it needs to be. Stabilizing this feature paves the floor to adjust those parameters. Main implementation PR: #6772 Main issue: #5962 # Testing and QA ## Tests The original PR (#6772) includes tests on the VM level that ensure old versions are unaffected while new versions charge the cost correctly. Integration tests in #7169 checks the same again but on the apply-block level. ## Impact on existing smart contracts This change does not affect anything except for function calls that fail during preparation. Since those were already failing, it should not impact anyone if the error type and amount of gas charged changes. # Checklist - [x] Link to nightly nayduck: https://nayduck.near.org/#/run/2562 - [x] Update CHANGELOG.md to include this protocol feature in the `Unreleased` section.
contract_compile
cost
We also want to reshuffle costs at some point: #7741 Maybe we should release these things together. But we can continue to treat them separately, as the cost changes probably need some more optimizations before we can really move forward with them. |
Closing this as obsolete. |
protocol_feature_fix_contract_loading_cost
features changes the logic for charging for loading contract. Roughly, this is a per-byte cost which measures the work of "dynamic linker" (loading pre-compiled x86_64 machine code from the database into memory, doing neccesary adjustments and marking the relevant pages as executable).Specifically, the "fix" here covers:
Implementation history:
Blockers:
The text was updated successfully, but these errors were encountered: