Execution Lifecycle

Executors Part 2: Execution Lifecycle

Paul Etscheit
March 20, 2023

Welcome to the second part of our three-part blog series about Executors, a crucial actor in the t3rn ecosystem. In t3rn Executors, Part 1: What are t3rn Executors?, we covered the role of Executors in the t3rn ecosystem, explaining all relevant aspects such as their role and the transaction types they facilitate.

As a quick recap, Executors generate yield by executing transactions on behalf of users, verifying their execution on the target chain, and receiving a side effect reward. They must also balance their funds across multiple chains and compete with each other to incentivize efficient fees for users.

In addition to the Executors, we also covered the various transaction types involved. Such as, there are escrow transactions that depend on an escrow contract deployed on the target blockchain, and optimistic transactions that don't require a smart contract to be available on the target chain. Understanding the different transaction types is crucial to utilizing the Executor system effectively.

Execution Lifecycle

In this new post, we will dive into the Execution Lifecycle, which is essential for anyone looking to become an Executor. Understanding the three stages of an XTX object's life cycle - Bidding, Execution, and Finalization - is vital to successfully execute multichain transactions and generate yield on t3rn. 

Execution Lifecycle

Bidding Stage

When creating an XTX, the user sets the maximum reward they are willing to pay for the execution of each SFX. This is the total reward the user is willing to pay for the execution of the SFX. The reward must cover the cost of assets, transaction fees, and the risk premium for the executor. As it is difficult to estimate how much an SFX (or rather its native transaction on the target chain) will cost to execute, t3rn relies on a reverse bidding mechanism to determine the reward payment. The simple idea here is to rely on an open market system.

Executors can submit bids for a specific SFX they are interested in executing. A bid is accepted if the submitted amount is lower than the previous one. On bid submission, the insurance reward for the side effect is reserved from the Executor's balance. If a new bid is undercutting another Executor, its insurance deposit is unreserved, effectively refunding the Executor.

In bids on optimistic SFXs, the bond is automatically computed and reserved. The bond is the sum of all other optimistic SFXs rewards of the corresponding XTX.

At the end of the bidding stage, the Executor with the lowest bid wins the right to execute the SFX. This means that the Executor must execute the side effect during the execution stage. Executors without a winning bid do not have any obligations and can reclaim the funds reserved during the bidding.

If not all side effects have successfully found an Executor, the execution is reverted, and all involved parties are refunded.

Execution Stage

Next, the execution stage begins. The winning Executors now need to execute the side effects they have bid on. The SFX could be an escrowed transfer, where the Executor would deposit the funds requested into the escrow contract. Once the transaction is finalized, the Executor creates an inclusion proof for the deposit transaction. The Executor waits until the light client on t3rn receives the required block header. Once this is the case, the Executor can submit the proof, confirming the finality of the transaction.

The execution stage contains two execution phases:

  1. All escrowed side effects are grouped, executed and confirmed.
  2. Then, all optimistic side effects are executed and confirmed. The confirmation of optimistic side effects can only start once all escrow transactions have been confirmed.

Within an execution phase, the order of confirmation does not matter. The execution and confirmation of SFX are parallelizable.

It is always possible that an SFXs Executor does not confirm before the timeout. For this situation, a re-execution can be triggered. The non-confirming Executor gets their insurance deposit slashed and added to the reward of the unconfirmed SFX. As a result, the SFX profitability is increased, making it more attractive to be picked up by another Executor. This reduces user frustration and makes a revert more unlikely, which benefits all Executors. Executors must note that this aspect of the protocol will not be part of our initial release and will be incorporated at a later stage.

Once all side effects are confirmed, the execution stage terminates with “commit”. This means the execution was completed, which triggers the payment for the Executor. The reward for the side effect they executed is now claimable by them on the t3rn blockchain.

If not all SFXs are confirmed before reaching the timeout limit, the execution stage terminates with “revert”, triggering the refunding of the Executor and user.

Escrow Refund:

  • User: receives all previously locked max_reward amounts
  • Executor: funds located in escrow contract, unlocked in the finality stage

Optimistic Refund:

  • User: receives all max_reward amounts it has previously locked
  • Offending Executor: slashed, losing the entire bond it posted during bidding
  • Honest Executor: as the bond covers the rewards for all other Executors, receives the expected reward

Finalization Stage

The finalization stage is only relevant for escrowed side effects, as it is required to unlock the funds on the target. The finalization stage could either result in a refund for the Executor or sending funds to the receiver.

To unlock funds from the escrow contract, t3rn needs to trustlessly relay the unlock transactions of an XTX from the t3rn Circuit to the target blockchain. t3rn relies on a group of network participants called Attesters to achieve this. Attesters require a high amount of stake on the t3rn blockchain, enabling them to sign the unlocks of the escrow transaction of the current batch. Initially, we plan to activate around 30-50 Attesters, selected by stake weight, requiring a >2/3 majority to find consensus. Going forward, we want to further increase this set, eventually utilizing zkSNARKS to activate hundreds of Attesters. A signer set of this size will make the relaying more decentralized and resilient to collusion attacks.

These unlock transactions are batched per target and delivered to Executors. Batching significantly reduces the fees required for unlocking. On XTX (cross-chain transaction) submission, a finality fee is charged for each escrowed SFX (side effect). The unlock transaction on the target is paid with this fee. The user also pays this in case of reverts, so the Executors do not face any additional cost.

t3rn’s vision

The future of Web3 is multichain. t3rn has been built to enable this new paradigm in multichain programming, which is trustless, fail-safe and interoperable. We believe in trust-free collaboration, therefore the network will offer open access for anyone to join and play a critical role as Collator, Executor, Attester or Contracts Registry Builder.

Team t3rn will take a phased approach to rolling out the protocol, gradually releasing different features, showcasing and battle testing the network within a Substrate-based environment first  before integrating with some of the foremost ecosystems in the industry.

‍About t3rn

t3rn is a multichain protocol that brings fail-safe, interoperable execution and smart contract composability to the Polkadot ecosystem and beyond.

t3rn’s ultimate goal is to enable trust-free collaboration between blockchains and to create an ecosystem in which anyone can utilize and deploy an interoperable smart contract, in an ecosystem where developers are fairly rewarded for their contributions.

Turn multichain with t3rn.

Glossary

t3rn Circuit - the name of the t3rn blockchain.

XTX - a cross-chain execution containing N side effects on an arbitrary number of different target chains. Every side effect belongs to a specific execution.

Side Effect (SFX) - a single transaction on a target blockchain.

Insurance Deposit - a small deposit paid by the Executor winning the side effect bidding. This deposit incentivizes Executors to execute the side effects they have won the bid for. Failing to submit the execution proof until the execution expiry will result in the deposit being slashed. The user sets the insurance amount on a per-side effect basis.

Side Effect Reward - The reward the user pays to execute a single side effect. This is the total amount paid to Executors. During the bidding stage, Executors can submit execution bids, lowering the reward amount paid out.

Attesters - Stakers on t3rn used to authorize unlock transactions in the target escrow contract. Users can nominate their TRN tokens to receive a proportional share of the inflation paid to them.

Escrow Contract - A smart contract deployed on the blockchains t3rn connects to. The outputs of escrow side effects are temporarily deposited there until the execution has finalized. An Attester majority is needed to unlock transactions from the contract.

👉 Subscribe to our newsletter: Join 15,000 subscribers for exclusive monthly updates and insights, directly from Maciej Baj, founder & CTO of t3rn. - no spam, unsubscribe anytime.

Thank you. We'll be in touch.
Oops! Something went wrong while submitting the form.