- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.6k
 
Description
Background
In the TRON FullNode API suite, a variety of endpoints are provided for reading on-chain state. These include methods such as getaccount, getdelegatedresourcev2, getcontract, triggerconstantcontract, and many others. These interfaces are extensively used by wallets, DApps, indexers, explorers, and backend services to query the current blockchain state.
At present, most read operations are performed against the node's latest in-memory state, which can vary depending on block propagation, mempool contents, and internal node synchronization. While this is sufficient for real-time interaction, it can introduce subtle inconsistencies or non-determinism when:
- State changes between consecutive reads
 - State is queried during reorg or finalization windows
 - Downstream systems need to reproduce state as it was at a particular block height
 
To support more robust and reproducible behavior, this proposal introduces deterministic state query capability that allows callers to specify a recent block height to be used as the state root for read operations.
Motivation
Adding deterministic context to state queries can improve:
- Snapshot consistency for voting, airdrops, and retroactive logic
 - Test suite repeatability and CI validation for smart contract developers
 - UI rendering stability across polling intervals in frontend applications
 - Historical verification tools and audit pipelines
 - Off-chain computation engines relying on exact state simulation
 
Feature Specification
Affected APIs
This feature applies to all read-only state access methods in FullNode, including but not limited to:
getaccountgetaccountresourcegetdelegatedresourcev2getcontracttriggerconstantcontract- ...
 
Any API that reflects blockchain state is a candidate for deterministic extension.
New Parameters
Each of these APIs will support the following optional parameters:
| Parameter | Type | Description | 
|---|---|---|
block_number | 
int | 
Target block height to query against. Must be within the node's recent memory window. | 
deterministic | 
boolean | 
If true, query is resolved strictly against state at block_number. | 
Behavior
When deterministic is set to true and block_number is provided:
- The node resolves state using only the data from the specified in-memory block height.
 - Dynamic values like 
block.timestampandblock.numberreflect the queried block. - No pending transactions or newer block state is included.
 - If the requested block has already been finalized and removed from memory, an error such as 
BLOCK_STATE_UNAVAILABLEwill be returned. 
Example Payloads
getaccount
{
  "address": "T...",
  "block_number": 71234567,
  "deterministic": true
}triggerconstantcontract
{
  "owner_address": "T...",
  "contract_address": "T...",
  "function_selector": "balanceOf(address)",
  "parameter": "00000000000000000000000041xxxxxxxx...",
  "visible": true,
  "block_number": 71234567,
  "deterministic": true
}Response Extensions (Optional)
To clarify the execution context, responses MAY include:
{
  "execution_mode": "deterministic",
  "executed_at_block": 71234567,
  "result": { ... }
}Error Handling
If the block specified by block_number is:
- Too old and no longer in memory: return 
BLOCK_STATE_UNAVAILABLE - Not yet received by the node: return 
BLOCK_NOT_FOUND - Valid but 
deterministicis false or omitted: fallback to current behavior 
Node Requirements
- Nodes must maintain recent block states in memory for a sliding window (e.g., 512 or 1024 blocks)
 - No changes to consensus logic or state mutation logic are needed
 - Query cost and latency should remain similar to current behavior for recent blocks
 
Compatibility
- Fully backward-compatible (new parameters are optional)
 - Applies only to a recent window of block state
 - Clients not using 
block_numberordeterministicwill see no change in behavior 
Future Considerations
- Support for finalized blocks or archive-state access beyond in-memory window (e.g., through full archive mode)
 - Support for deterministic filters and paginated state views (e.g., account list snapshots)
 - Integration with light clients or trustless proof systems
 
Request for Comments
We welcome feedback from:
- Smart contract developers: Would this capability improve testing or off-chain simulation?
 - Wallet and frontend developers: Does this help in offering consistent UI snapshots?
 - Node operators: Are there challenges in managing a sliding window of in-memory block state?
 - Analytics and indexer providers: Would deterministic reads simplify your pipelines?
 
Metadata
Metadata
Assignees
Labels
Type
Projects
Status