Repository navigation
fix(examples): derive the automation task's max gas and fee cap from a simulation - #46
Open
isaacdoidge wants to merge 1 commit into
Open
isaacdoidge wants to merge 1 commit into
isaacdoidge wants to merge 1 commit into
Conversation
…a simulation The automation example and the node-backed tests registered a task running 0x1::supra_account::transfer(0x1, 1) with a max gas of 9 and a fee cap of 1 SUPRA. A SUPRA transfer uses about 500 gas units on its first execution, so the automated transaction ran out of gas, and nothing in the example or the tests waited for an automated transaction to notice. `automation_task_limits` in examples/automation.py simulates the automated function as a user transaction from the task's owner and registers the task with twice the gas used. The fee cap is twice the registry's estimate for that max gas (`0x1::automation_registry::estimate_automation_fee`), since the estimate depends on the gas other tasks have committed. The node-backed tests use the same helper. The docstring of `register_automation_task` describes both limits. Measured on localnets: the simulated transfer used 543 gas units on supra_node_v12.0.0.rc7 and 508 on supra_node_v11.7.2. A task registered with the resulting max gas (1086 and 1016) produced automated transactions with status Success on both: the first used 543 and 508 units, the following ones 8 and 9. Co-Authored-By: Claude Opus 5.5 <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.
What
examples/automation.pyand the node-backed automation tests registered a task running0x1::supra_account::transfer(0x1, 1)with a max gas of 9 and a fee cap of 1 SUPRA. The first execution of that transfer uses about 500 gas units, so the automated transaction ran out of gas. Neither the example nor the tests waited for an automated transaction, so nothing noticed.examples/automation.pyhas a new helper,automation_task_limits(supra_client, sender, automated_function). It simulates the automated function as a user transaction from the task's owner and returns:gas_used. The automated transaction runs in a later block, on state that may differ.0x1::automation_registry::estimate_automation_fee. The registry refuses a cap below its estimate, and the estimate rises with the gas other tasks have committed.register_test_automation_taskintests/unit/test_supra_client.pyuses the same helper. Tests already import fromexamples(test_faucet_funder.py).register_automation_taskdocstring says what happens when an automated transaction needs more than the max gas, and that the registry refuses a fee cap below its estimate.No change to SDK behaviour.
Checks
On fresh localnets of
supra_node_v12.0.0.rc7(Devnet's release) andsupra_node_v11.7.2(Mainnet's and Testnet's), gas price 100000:gas_usedgas_usedSuccesson each node.examples/automation.pycompleted on both.SUPRA_RPC_URL=<localnet> make test-unit: 397 tests, OK, 0 skipped, on both.make fmt-check,make lint,make typecheck,make test-unit(offline),make test-specandmake buildpass.🤖 Generated with Claude Code