Skip to content

introduced internal call <-> caller relation

Thomas Binétruy-Pic requested to merge feat/index-cross-contract-calls into master

When indexing, it is important to be able to easily navigate between internal call data as it contains precious information that was calculated on chain that we sometimes cannot recalculate precisely offchain due to rounding errors.

An internal call has a foreign key relation to its caller, another TezosTransaction. However, the transaction metadata does not give enough data to reconstruct the call tree when complex cross contract interaction is indexed. Consider the following:

  • A calls B_1 & B_2
  • B_1 calls A
  • A calls B_2

The transaction metadata contained in the block is ordered in the internal call execution order:

  • external call A
  • internal calls: [A->B_1; A->B_2; B_1->A; A->B_2]

Although this is a simple graph, it is already costly to introduce this relation at index time when constructing the tree.

Rather, since cross contract call data is sometimes necessary but nevertheless remains occasional, I propose allowing to retrieve it from the database through a model property, at the cost of a db transaction.

The end goal is to support the following sort of calls:

transfer_out_tx = instance.internal_calls[transfer_out_index]

if instance.args["a_to_b"]:
    token_a_amount = instance.args["tokens_sold"]
    if exchange.token_b.asset_type == AssetType.FA12:
        token_b_amount = transfer_out_tx.args["value"]
    elif exchange.token_b.asset_type == AssetType.XTZ:
        token_b_amount = transfer_out_tx.amount
Edited by Thomas Binétruy-Pic

Merge request reports

Loading