|
| 1 | +--- |
| 2 | +title: AIP-88 - Block Epilogue Transactions |
| 3 | +--- |
| 4 | + |
| 5 | +# AIP-88: Block Epilogue Transactions |
| 6 | + |
| 7 | +[AIP-88](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-88.md) covers |
| 8 | +block epilogue transactions, which are a new type of transaction that give |
| 9 | +information about the block after it has been executed. These transactions can |
| 10 | +only be created by the consensus and are not user-initiated. They contain |
| 11 | +information about gas usage in the block and will contain more information in |
| 12 | +the future. |
| 13 | + |
| 14 | +It replaces the previous `StateCheckpoint` transaction type, which was used to |
| 15 | +"sometimes" signal the end of a block. The new `BlockEpilogue` transaction is |
| 16 | +now sometimes created at the end of a block instead, and it is guaranteed to be |
| 17 | +the last transaction in the block. The only case this does not apply is the |
| 18 | +last block of an epoch, which will have no `BlockEpilogue` transaction. |
| 19 | + |
| 20 | +## General FAQ |
| 21 | +### What is in the Block Epilogue Transaction? |
| 22 | + |
| 23 | +The block epilogue transaction contains a `BlockEndInfo` enum. It is purposely |
| 24 | +designed to be an enum so that it can be extended in the future without breaking |
| 25 | +existing code. The current version is `V0` and contains the following fields: |
| 26 | + |
| 27 | +```move |
| 28 | +module 0x1::epilogue { |
| 29 | + enum BlockEndInfo { |
| 30 | + V0 { |
| 31 | + /// Whether block gas limit was reached |
| 32 | + block_gas_limit_reached: bool, |
| 33 | + /// Whether block output limit was reached |
| 34 | + block_output_limit_reached: bool, |
| 35 | + /// Total gas_units block consumed |
| 36 | + block_effective_block_gas_units: u64, |
| 37 | + /// Total output size block produced |
| 38 | + block_approx_output_size: u64, |
| 39 | + }, |
| 40 | + } |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +These mainly contain information about the gas usage in the block for debugging |
| 45 | +purposes. |
| 46 | + |
| 47 | +The JSON output will look like this: |
| 48 | + |
| 49 | +```json |
| 50 | +{ |
| 51 | + "version":"1912", |
| 52 | + "hash":"0x54a8efc93fc94f5b545dadb63da3d4dc192125c717b336dc446d55a5b553913f", |
| 53 | + "state_change_hash":"0xafb6e14fe47d850fd0a7395bcfb997ffacf4715e0f895cc162c218e4a7564bc6", |
| 54 | + "event_root_hash":"0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000", |
| 55 | + "state_checkpoint_hash":"0x841a43956ca09a02b1c1cdadc65f24c390170aa666015a2e8f7ec5c9d6a3875f", |
| 56 | + "gas_used":"0", |
| 57 | + "success":true, |
| 58 | + "vm_status":"Executed successfully", |
| 59 | + "accumulator_root_hash":"0x6561976b4560ff25239dffc6cada70e7008dd42fc4d3df2eca6a86b6d2ec384d", |
| 60 | + "changes":[], |
| 61 | + "timestamp":"1719263322836578", |
| 62 | + "block_end_info": { |
| 63 | + "block_gas_limit_reached":false, |
| 64 | + "block_output_limit_reached":false, |
| 65 | + "block_effective_block_gas_units":0, |
| 66 | + "block_approx_output_size":1163 |
| 67 | + }, |
| 68 | + "type":"block_epilogue_transaction" |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +## Compatibility FAQ |
| 73 | +### What does this mean for my dApp? |
| 74 | + |
| 75 | +If you process transactions in your dApp, and expect the last transaction in a |
| 76 | +block to be a `StateCheckpoint`, you will need to update your code to handle the |
| 77 | +`BlockEpilogue` transaction instead. |
| 78 | + |
| 79 | +Note that, the `BlockEpilogue` transaction is guaranteed to be the last |
| 80 | +transaction of a block except for the last block of an epoch, which will not |
| 81 | +have a `BlockEpilogue` transaction. |
| 82 | + |
| 83 | +### What apps are likely to be affected? |
| 84 | + |
| 85 | +Apps that index all transactions such as block explorers and centralized |
| 86 | +exchange indexer processors may be affected. However, most of these are |
| 87 | +informational and do not affect the core functionality of the dApp. |
| 88 | + |
| 89 | +### What can I do to process the new transaction type? |
| 90 | + |
| 91 | +If you're using the Aptos Go SDK or the Aptos TypeScript SDK, you can update to |
| 92 | +the latest version, which will automatically handle the new transaction type. |
0 commit comments