fix: check the cycles balance and charge executed instructions on DTS resume - #11039
Draft
mraszyk wants to merge 1 commit into
Draft
fix: check the cycles balance and charge executed instructions on DTS resume#11039mraszyk wants to merge 1 commit into
mraszyk wants to merge 1 commit into
Conversation
… resume `InstallCodeHelper` records the cycles balance of the clean canister state it was built from and compares it when resuming a paused `install_code` execution, analogously to `ResponseHelper` and `CallOrTaskHelper`. Moreover, if resuming a paused execution fails, then the instructions already executed by the paused Wasm execution are charged now: those instructions consumed round instructions, but the instruction limits are only updated when the Wasm execution finishes and hence such instructions used to be free. For `install_code`, only the instructions of the steps preceding the paused Wasm execution (e.g., compilation) used to be charged; for update calls, replicated queries, canister tasks, and response callbacks, no instructions used to be charged at all; for cleanup callbacks, the instructions of the preceding response callback used to be charged, but not those of the cleanup callback itself. Finally, `dts_replicated_execution_resume_fails_due_to_cycles_change` moves to the general execution tests as `dts_resume_fails_due_to_cycles_decrease`, decreases the cycles balance using `remove_cycles`, and covers response and cleanup callbacks and the heartbeat in addition to update calls and replicated queries; the new test `dts_install_code_resume_fails_due_to_cycles_decrease` covers `install_code`. The tests assert that the instructions reported by the failed execution match the round instructions consumed by its slices and that the canister is charged exactly the cost of those instructions, for which `ExecutionTest` tracks the round instructions consumed per canister. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InstallCodeHelperrecords the cycles balance of the clean canister state it was built from and compares it when resuming a pausedinstall_codeexecution, analogously toResponseHelperandCallOrTaskHelper.Moreover, if resuming a paused execution fails, then the instructions already executed by the paused Wasm execution are charged now: those instructions consumed round instructions, but the instruction limits are only updated when the Wasm execution finishes and hence such instructions used to be free. For
install_code, only the instructions of the steps preceding the paused Wasm execution (e.g., compilation) used to be charged; for update calls, replicated queries, canister tasks, and response callbacks, no instructions used to be charged at all; for cleanup callbacks, the instructions of the preceding response callback used to be charged, but not those of the cleanup callback itself.Finally,
dts_replicated_execution_resume_fails_due_to_cycles_changemoves to the general execution tests asdts_resume_fails_due_to_cycles_decrease, decreases the cycles balance usingremove_cycles, and covers response and cleanup callbacks and the heartbeat in addition to update calls and replicated queries; the new testdts_install_code_resume_fails_due_to_cycles_decreasecoversinstall_code. The tests assert that the instructions reported by the failed execution match the round instructions consumed by its slices and that the canister is charged exactly the cost of those instructions, for whichExecutionTesttracks the round instructions consumed per canister.