feat(vm): add node-level vm.constantCallTimeoutMs for constant calls#6719
Open
yanghang8612 wants to merge 2 commits intodevelopfrom
Open
feat(vm): add node-level vm.constantCallTimeoutMs for constant calls#6719yanghang8612 wants to merge 2 commits intodevelopfrom
yanghang8612 wants to merge 2 commits intodevelopfrom
Conversation
New config knob extends the TVM execution window for triggerconstantcontract / eth_call only; pairs with a concurrency cap that engages when the configured timeout exceeds the network's current maxCpuTimeOfOneTx. Issue #6681.
VmTimeoutPolicy: deadline math, max-of semantics (never shrink below network), and cap-engagement gate against the runtime network value. VmConfig: 0 sentinel, [80, 500] range, cap > 0.
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 does this PR do?
Adds a node-level config
vm.constantCallTimeoutMs(range[80, 500]ms; default0= sentinel meaning "use the network'smaxCpuTimeOfOneTx") that extends the TVM execution-time window fortriggerconstantcontractandeth_callonly. Block-processing deadline is unchanged.Pairs with
vm.constantCallMaxConcurrency(default10). The cap engages strictly when the operator's configured timeout exceeds the network's currentmaxCpuTimeOfOneTx; nodes leaving the timeout at0see no behaviour change — no new throttling, no regression on high-throughput RPC paths.Closes #6681.
Why are these changes required?
triggerconstantcontract/eth_callare widely used for state queries and dry-runs but cap out at the same TVM deadline as block-processing (mainnet 80 ms). Operators currently have only--debugto extend this window, which also removes the block-processing timeout — unsafe for any node serving traffic, since it can desync from the network (#6266). This PR gives operators a scoped lever for the constant-call window without that side effect.Design highlights:
isConstantCall, so the new code path is unreachable from block validation — guaranteed by structure, not by convention.VmTimeoutPolicy.computeVmShouldEndInUsusesmax(configured, networkMs)for the budget; setting a value below the currentmaxCpuTimeOfOneTxis a no-op (equivalent to sentinel0).Wallet.callConstantContractreads the livemaxCpuTimeOfOneTxfromDynamicPropertiesStoreand passes it toVmTimeoutPolicy.isCapEngaged. If the network committee raisesmaxCpuTimeOfOneTxlater, the cap-engagement threshold tracks it automatically.Programplumbing (getVmShouldEndInUs()is propagated to internalProgramInvokeinstances), so the override applies to deep call trees — the headline use case.VmConfig.postProcess()rejects values outside[80, 500]. Note: at config-load time the DB isn't open yet, so this>= 80floor is a sanity check, not a comparison against the live network value; the runtimemax(...)keeps semantics correct regardless.org.tron.common.math.StrictMathWrapper(max,multiplyExact,addExact) per the repo's math-check CI policy.This PR has been tested by:
VmTimeoutPolicyTest(11 cases): deadline math, max-of semantics (never shrink below network), block-processing isolation, cap-engagement gate against runtime network value.VmConfigTest(6 new cases): defaults0 / 10; valid override200 / 4; boundary0 / 80 / 500accepted;< 80,> 500, andcap = 0rejected.ArgsTestandWalletTest/WalletMockTeststill green.Follow up
Operators currently running with
--debugpurely to extend the constant-call window should switch tovm.constantCallTimeoutMs=<ms>once this lands.--debugadditionally extends the block-processing timeout, which is unsafe for any node serving traffic (see #6266). Release notes will spell this out at both touchpoints.Extra details
VmTimeoutPolicyhelper lives incommon(notactuator) soVmConfig(also incommon) can reference it without a circular dependency.framework/src/main/resources/config.conf(commented user-facing samples) andcommon/src/main/resources/reference.conf(defaults soConfigBeanFactoryhonours them whenconfig.confis silent).--debugmigration path) for the design rationale.