Skip to content

Commit

Permalink
Add context inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed Jul 3, 2023
1 parent 9c9af7c commit b69379c
Showing 1 changed file with 105 additions and 13 deletions.
118 changes: 105 additions & 13 deletions tips/TIP-0045/tip-0045.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ The following table describes the entirety of a _Transaction Payload_ in its ser
<td>Payload Type</td>
<td>uint32</td>
<td>
TODO value ??
Set to <strong>value 6</strong> to denote a <i>TIP-45 Transaction Payload</i>.
</td>
</tr>
Expand All @@ -90,7 +89,7 @@ The following table describes the entirety of a _Transaction Payload_ in its ser
<td>Transaction Type</td>
<td>uint8</td>
<td>
Set to <strong>value 1</strong> to denote a <i>TIP-20 Transaction Essence</i>.
Set to <strong>value 2</strong> to denote a <i>TIP-45 Transaction Essence</i>.
</td>
</tr>
<tr>
Expand All @@ -107,6 +106,34 @@ The following table describes the entirety of a _Transaction Payload_ in its ser
The slot index of the block in which the transaction was created.
</td>
</tr>
<tr>
<td>Context Inputs Count</td>
<td>uint16</td>
<td>The number of context input entries.</td>
</tr>
<tr>
<td valign="top">Context Inputs <code>optAnyOf</code></td>
<td colspan="2">
<details>
<summary>Commitment Input</summary>
<blockquote>
Describes an input which references commitment to a certain slot.
</blockquote>
</details>
<details>
<summary>BIC Input</summary>
<blockquote>
Describes an input which denotes an BIC value of an account.
</blockquote>
</details>
<details>
<summary>Reward Input</summary>
<blockquote>
Describes an input which claims the reward.
</blockquote>
</details>
</td>
</tr>
<tr>
<td>Inputs Count</td>
<td>uint16</td>
Expand Down Expand Up @@ -296,30 +323,95 @@ It is a unique value denoting whether the transaction was meant for the IOTA mai
#### Creation Time
Transaction timestamp is now expressed with `Slot Index`, as there is no need for finer granularity. The validity of the transaction timestamp is checked in comparison with the `Block` timestamp. Therefore, it is performed at the level of semantic validation of a block, described in [TIP-0046](../TIP-0046/tip-0046.md).

#### Inputs
#### Context Inputs

The `Inputs` field holds the inputs to consume in order to fund the outputs of the <i>Transaction Payload</i>. Currently, there are three types of input:
- _UTXO Input_
The `Context Inputs` field holds that indicates the different functions related to account, commitment and more. Currently, there are 3 types of context input:
- _Commitment Input_
- _Block Issuance Credits Input_
- _Reward Input_
In the future, more types of inputs may be specified as part of protocol upgrades.

Each input must be accompanied by a corresponding <i>Unlock</i> at the same index in the <i>Unlocks</i> part of the <i>Transaction Payload</i>.

##### UTXO Input

A <i>UTXO Input</i> is an input which references an unspent output of a previous transaction. This UTXO is uniquely identified by its _Output ID_, defined by the _Transaction ID_ of the creating transaction together with corresponding output index. Each <i>UTXO Input</i> must be accompanied by an <i>Unlock</i> that is allowed to unlock the referenced output.

##### Commitment Input
A _Commitment Input_ is an input that allows to reference commitment to a certain slot. It is used to provide the VM with the necessary context information from the node, to prove that the time at the transaction execution is past certain slot in the past, as it indicates that the slot has been already committed. It is expressed as the _CommitmentID_ and can be resolved to the _Commitment_ value before it enters the VM. The _Commitment_ itself provides the `Slot Index` which serves as a time reference.

Serialization Layout:
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>Input Type</td>
<td>uint16</td>
<td>The input type of Commitment Input is 1.</td>
</tr>
<tr>
<td>Commitment ID</td>
<td>ByteArray[40]</td>
<td>The commitment identifier to reference to.</td>
</tr>
</table>

##### Block Issuance Credits Input
A _Block Issuance Credits Input_ is an input that allows to provide the VM with context for the value of the BIC vector for a specific slot. It is necessary information needed for any _Account_ transitions, and account destroying. As any operation on the _Account_ can only be allowed if the BIC balance is not negative at specific point in time. _Block Issuance Credits Input_ is defined as follows. The input commitment will be resolved to hte `AccountID`, `CommitmentID` which contains the SLot Index and the BIC vector value for the given `AccountID` and `Slot Index`.

| Field Name | Type Value |
|--------------|------------|
| Account ID | ByteArray[32] |
| CommitmentID | ByteArray[32] |
Serialization layout:
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>Input Type</td>
<td>uint16</td>
<td>The input type of BIC Input is 2.</td>
</tr>
<tr>
<td>Account ID</td>
<td>ByteArray[32]</td>
<td>The BIC of an account to use.</td>
</tr>
</table>

##### Reward Input

A Reward Input is an input indicates which transaction `Input` is the claiming reward.

<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>Input Type</td>
<td>uint16</td>
<td>The input type of Reward Input is 3.</td>
</tr>
<tr>
<td>Index</td>
<td>uint16</td>
<td>The index of the transaction input for which to claim rewards.</td>
</tr>
</table>

#### Inputs

The `Inputs` field holds the inputs to consume in order to fund the outputs of the <i>Transaction Payload</i>. Currently, there are one type of input:
- _UTXO Input_
In the future, more types of inputs may be specified as part of protocol upgrades.

Each input must be accompanied by a corresponding <i>Unlock</i> at the same index in the <i>Unlocks</i> part of the <i>Transaction Payload</i>.

##### UTXO Input

A <i>UTXO Input</i> is an input which references an unspent output of a previous transaction. This UTXO is uniquely identified by its _Output ID_, defined by the _Transaction ID_ of the creating transaction together with corresponding output index. Each <i>UTXO Input</i> must be accompanied by an <i>Unlock</i> that is allowed to unlock the referenced output.


#### Inputs Commitment

The `Inputs Commitment` field of the _Transaction Essence_ is a cryptographic commitment to the content of the consumed outputs (inputs). It consists of the BLAKE2b-256 hash of the concatenated output hashes.
Expand Down

0 comments on commit b69379c

Please sign in to comment.