Skip to main content

TIP-2 / Contract tracing proposal

Created: 02/08/2024
Status: Active
Implemented: v1.3.0

Motivation

We often as users want to see if a specific contract has been executed and when it was executed. Currently if you want to know if a contract has been successfully executed or not. The only way to figure it out is if the side effects contracts are active, ie. inputs for the contract were deleted and the outputs are added. There are several problems with this.

  • We have no way to see when a contract is executed.
  • We can no longer se if a contract is executed if the outputs are later consumed by another contract.
  • We can't know for certain that the contract is actually the one that has produced the outputs, the same outputs could have been produced by another contract.

Requirements

Using a hirpc method we must be able to lookup a contract using the hash of the contract to see if and when it was executed.
This information stored to achieve this should not be a part of the consensus data.

Proposed solution

Add a new record to the trt with the dart hashkey being the contract hash. The record will include the epoch where it was executed.

The hibon record definition trt contract will look like this.

@recordType("$@contract_trt")
struct TRTContract {
@label("#CONTRACT") Buffer contract_hash; // the contract hash as a name record
long epoch_number; // the epoch number
}

This will allow users to lookup if a contract has been executed with a trt.checkRead method. Or perform a trt.dartRead to see what epoch the contract was executed.

Additional improvements to this system would be to store the contract hashes in the replicator block so the trt can be reconstructed if it's deleted or a new nodes join the network. Another improvement is to combine it with a subscription api, such that a client not only knows if a transaction is executed but can be notified when it's executed.

History

10/12/2025: Removed elements related to subscription logging