Repository navigation
executor: stop contract code that runs outside a method's time limit - #10
Merged
Merged
Conversation
The reserved token name check calls the contract's getName()/getSymbol() at deploy, and the state is deserialized and serialized around every call (the readObject/writeObject/ hashCode of the contract's classes), all on the Thrift thread and with no limit. Contract code that never returns there keeps a CPU busy for the life of the executor, once per transaction that reaches it. That code now runs on a thread of its own. What it returns or throws is passed on unchanged, so a call that ends gets the answer build 1518 gives. Code still running after max(execution time, 120 s) is stopped and the answer is held back 10 min before a failure is returned: the node has stopped waiting long before (executor_receive_timeout, 4 s by default), as it does with build 1518, which never answers such a call.
2 of 3 tasks
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.
Summary
Build 1518 runs some contract code on the Thrift thread with no time limit: the reserved token name check (the contract's
getName()/getSymbol()at deploy) and the serialization and deserialization of the state around every call (thewriteObject/readObject/hashCodeof the contract's classes). Contract code that never returns there keeps a CPU busy for the life of the executor, once per transaction that reaches it, on every node that executes it; the call never gets an answer (the node gives up afterexecutor_receive_timeout, 4 s by default).ContractCodeLimitruns that code on a thread of its own:max(execution time, 120 s)is stopped, and the answer is held back 10 min before a failure is returned: the node has stopped waiting long before, as it does with build 1518, which never answers. The node records the same result (TimeExpired) either way, so a network mixing this executor with 1518 agrees.Wrapped: the name check (
Deployer), the state serialization after deploy and after a call and the deserialization before a call (ContractExecutorServiceImpl), the deserialization per getter ofexecuteByteCodeMultiple(LimitTimeThreadMethodExecutor), andgetContractVariables. Code inside a contract method (already under the method's limit, running with the contract's permissions) is unchanged.Limits:
-Dcontract.executor.unbounded.code.limit.ms(default 120000),-Dcontract.executor.unbounded.code.hold.ms(default 600000).Test plan
ci/contracts/executor_harness.py, ci: token smart contract tests (executor harness and private testnet) node#127) on the release executor and this branch, every token scenario: identical status, return values, state hashes and emitted transactions on every step; the two scenarios with code that never returns (a token whosegetName()loops, a state whosewriteObjectloops) get no answer from 1518 and a failure from this branch after limit + hold (5 s + 20 s in the run), with the looping thread stoppedContractExecutorTestas on the base branch, nothing new🤖 Generated with Claude Code