-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Increase the CPU execution time limit in the TVM of the triggerconstantcontract
API
#6288
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
Comments
@yanghang8612 Very good proposal. Regarding your previews comment here:
I wonder what the upper limit of |
@yanghang8612 @Sunny6889 Hi, I found that the eth_call is implemented the same as triggerconstantcontract, do you want to add the |
Sorry previously I thought about you add it to configuration file. If we implement the timeout setting in the request body instead, it would enforce a uniformly agreed-upon timeout across the system. This approach would require a new committee proposal for implementation, as direct modification could potentially cause blockchain forks. |
Yes, perhaps we can limit the number of requests that can be processed at the same time with a |
triggerconstantcontract
interface so that it can override the TVM timeout limittriggerconstantcontract
API
Sure, but what I'm thinking about is whether adding parameters to the |
Adding an new parameter in |
Good advice! Another thing I would like to share is that if the parameter is set to a larger value like |
Hi, I think add a node-level-config is a better way, who want to test this situation they could modify the config of the nodes to support a custom time limitation. |
@abc-x-t I agree with you. Add request parameter |
@abc-x-t @317787106 One risk about adding it to a node-level-config would be it may cause insistence among SRs. |
If a transactional contract transaction calls |
Consensus transaction execution time is inherently an impossible task because of the differences in machine performance between SR nodes and the fact that even the exact same machine performance is not likely to produce the exact same processing market for the same transaction. |
I don't agree with what you call controlling the execution logic of the service. If that's considered, wouldn't the different interface parameters also be considered as controlling the execution logic of the service? As you phrased it, you implicitly think this is a dangerous thing to do, so you have to give specific counter-examples to prove your point. |
@Sunny6889 |
Essentially, whether it's at the node configuration level, or by adding parameters at the interface level, its possible to potentially introduce a ddos attack. For example, unreasonably large node configuration parameters or concurrent interface access with large parameter values. |
So we also mentioned in the previous discussion that for this type of access, regardless of the form of the implementation, it is important to strictly limit the frequency of accesses to this type of call, and to carefully design the valid ranges of specific parameters. |
As per previous design conventions, perhaps we could add a node configuration switch for nodes to enable this new feature. Or in order to avoid differences in understanding while retaining interface compatibility, perhaps we could accomplish the purpose by adding a new interface, adding a |
Background
In the TRON network, the
triggerconstantcontract
interface is widely used for off-chain simulation calls (dry-runs). However, this interface is constrained by the execution time limit of the TVM (mainnet, 80ms). When simulating complex contract logic or intensive state access, this can lead toout_of_time
exceptions, affecting the reliability of development tools and analysis services.While running the FullNode with the
--debug
flag can remove the TVM timeout restriction fortriggerconstantcontract
calls, this setting also removes the timeout limit for transactions within blocks during normal block processing. This can introduce potential instability or denial-of-service risks to the node, making it unsuitable for production environments.Related issues: #6266
Rationale
Why should this feature exist?
Allowing users to configure a custom TVM timeout in dry-run calls would:
Improve the stability of off-chain analysis tools
Prevent false negatives for complex contracts
Reduce misleading error codes that confuse developers
What are the use-cases?
Data services performing bulk state queries via contract calls
Deep cross-contract call simulation
Simulating complex logic (e.g., loops or mappings) that exceed the default execution window
Specification
Introduce a new optional field in the triggerconstantcontract request body:
timeout_ms
: Allows the caller to specify a custom timeout (e.g., 200ms). Default behavior remains unchanged (e.g., 80ms).A maximum cap (e.g., 500ms) should be enforced to prevent abuse.
Test Specification
TODO
Scope Of Impact
Backward-compatible API change
TVM executor must support receiving the custom timeout
SDKs and documentation need to be updated accordingly
Implementation
TODO
Do you have ideas regarding the implementation of this feature?
Extend the interface parser to accept and pass the timeout_ms field
Update the TVM executor to handle the custom timeout logic
Enforce a reasonable upper limit to avoid long blocking operations
Are you willing to implement this feature?
Yeap, happy to do it.
The text was updated successfully, but these errors were encountered: