Skip to content

Commit 1014a96

Browse files
authored
HIP-1193: Records to block streams cutover (#1381)
Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
1 parent a4b24ba commit 1014a96

1 file changed

Lines changed: 266 additions & 0 deletions

File tree

HIP/hip-1193.md

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
---
2+
hip: 1193
3+
title: Record Stream to Block Stream Cutover
4+
author: Mark Blackman <mark@hashgraph.com>
5+
working-group: Steven Sheehy <@steven-sheehy>, Joseph Sinclair<@jsync-swirlds>, Dan Alvizu <dan.alvizu@swirldslabs.com>, Jasper Potts <jasper.potts@swirldslabs.com>, Keith Kowal <keith.kowal@swirldslabs.com>
6+
requested-by: Hashgraph
7+
type: Standards Track
8+
category: Mirror
9+
status: Review
10+
discussions-to: https://github.com/hiero-ledger/hiero-improvement-proposals/pull/1193
11+
needs-hiero-approval: Yes
12+
needs-hedera-review: Yes
13+
hedera-review-date:
14+
hedera-acceptance-decision:
15+
requires: 1056
16+
replaces: 679
17+
created: 2025-05-08
18+
updated: 2026-01-21
19+
---
20+
21+
## Abstract
22+
This HIP defines the requirements and implementation details for transitioning the Hedera network from record and event streams to block streams. This transition is a critical step toward enhancing blockchain compatibility, improving data integrity, and enabling future network optimizations such as state proofs. The proposal outlines the coordinated changes required across consensus nodes, mirror nodes, and supporting infrastructure to ensure a clean cutover without service disruption. It specifies new storage paths, file formats, and mechanisms to handle the transition state, including a marker file approach to indicate the final record stream entry before blocks begin.
23+
24+
## Motivation
25+
As highlighted in the Block Streams HIP:1056, the Hedera network currently produces record streams as its primary method of exposing transaction data to mirror nodes and external consumers. While functional, this approach diverges from standard blockchain architectures that organize data into blocks. By transitioning to block streams, Hedera will:
26+
27+
1. Improve blockchain compatibility and interoperability with existing blockchain tools and infrastructure
28+
2. Provide better data integrity through block-level proofs and signatures
29+
3. Reduce storage costs through optimized block organization and eventual deduplication
30+
4. Enable future improvements like block-based state proofs and block node architecture
31+
5. Simplify the developer experience by aligning with familiar blockchain concepts
32+
33+
This transition is a prerequisite for the planned block node architecture and represents an important step in Hedera's technical evolution.
34+
35+
## Rationale
36+
The transition from record streams to block streams requires careful planning to ensure network continuity, data integrity, and backward compatibility. This HIP proposes a clean cutover approach with the following key design decisions:
37+
38+
### Bucket Structure and File Format
39+
40+
The new block stream files will follow a revised path structure that includes network, shard, realm, and node ID components:
41+
42+
```
43+
block/{network}-{YYYYMMDD_HHmm}/{realm}/{shard}/{nodeID}/0000000000000000000000000000000000000.blk.gz
44+
```
45+
46+
This structure provides:
47+
48+
- Clear separation from existing record streams
49+
- Support for sharding
50+
- Node identification to identify source of block
51+
- Block number-based naming for sequential processing
52+
- ISO 8601 date and time format values of last network reset (optional field for resettable networks)
53+
54+
Block files will use the `.blk.gz` extension and GZip compression to maintain better compatibility with current record stream processing.
55+
56+
### Cutover Mechanism
57+
58+
A marker file will be used to denote the last record stream entry, providing mirror nodes with a clear signal to transition processing from records to blocks. This approach:
59+
60+
- Creates a clean demarcation point between systems
61+
- Allows mirror nodes to detect the transition without configuration changes
62+
- Prevents data loss during the transition
63+
- Eases mirror node operations, enabling mirror nodes to update mirror node version before block stream cutover and have seamless service continuity.
64+
- Reduces mirror node costs by not requiring periodically polling for block files.
65+
66+
### Node Requirements
67+
68+
Consensus nodes will:
69+
70+
- Stop producing record and event streams at the designated cutover point
71+
- Generate marker files to signal the end of record streams
72+
- Begin producing block streams with proper continuity from record stream hash to block hash.
73+
- Update uploaders to use new block paths
74+
75+
Mirror nodes will:
76+
77+
- Implement logic to detect marker files and switch processing modes
78+
- Support the new block path structure
79+
- Implement block proof verification using Threshold Signature Scheme (TSS)
80+
- Support retry mechanisms for failed block ingestion
81+
82+
## User stories
83+
1. As a mirror node operator, I want a clear signal when to transition from record stream processing to block stream processing, so that I don't miss any transactions during the cutover.
84+
85+
2. As a mirror node operator, I want to understand the new block file format and paths so that I can adjust my infrastructure to process block streams efficiently.
86+
87+
3. As a developer building on Hedera, I want to understand how the transition affects data availability and processing so that my applications continue to function correctly.
88+
89+
4. As a consensus node operator, I want to know exactly what changes are needed to support block streams so that I can prepare for the upgrade.
90+
91+
5. As a mirror node operator I need to know what version of the mirror node software I need to be running and have sufficient time to upgrade to that version before the cutover
92+
93+
6. As a network user, I want the transition to be seamless with no impact on transaction processing or data availability.
94+
95+
7. As a consumer of mirror node data and associated metrics, I want the transition to be seamless with no impact on how I consume mirror node data.
96+
8. As a consensus node operator, I want to notify stream consumers with an end of record streams marker to signify the last record stream file during an upgrade.
97+
## Specification
98+
### 1\. Cutover Point Definition
99+
100+
The transition from record streams to block streams will occur during a Hedera mainnet update boundary, with the following requirements:
101+
102+
- Occurs after a Hedera Freeze Upgrade transaction during Hedera mainnet update window
103+
- Current round comes to consensus
104+
- The final record stream will be completed and a marker file will be generated
105+
- The first block will contain zero transactions to ensure proper formatting without impacting network usage
106+
- Block continuity will be maintained by carrying forward:
107+
- The correct block number (incremented by one from the last record)
108+
- The last running hash value &mdash; cryptographic continuity of the Hedera blockchain.
109+
110+
### 2\. Consensus Node Requirements
111+
112+
#### 2.1 Record and Event Stream Termination
113+
114+
Consensus nodes will:
115+
116+
- Perform Freeze operation and stop accepting transactions
117+
- Freeze round comes to consensus
118+
- Ensure all signatures are collected and files are properly finalized
119+
- Produce final record file
120+
- Stop producing both record and event streams at the designated cutover point
121+
- Generate marker files to indicate the end of record and event streams
122+
123+
#### 2.2 Block Stream Initialization
124+
125+
Consensus nodes will:
126+
127+
- Construct the first block with zero transactions
128+
- Apply the correct running hash and block number from the final record
129+
- Upload to new block path structure for uploaders
130+
131+
NOTE: All event stream format changes must be completed and active prior to the cutover
132+
133+
#### 2.3 Path Structure Implementation
134+
135+
Consensus nodes will implement the new path structure, for example:
136+
137+
```
138+
block/mainnet/0/0/10/000000000000000000000000000083406349.blk.gz
139+
```
140+
141+
- The network value will identify the network (mainnet, testnet, etc.)
142+
- The shard and realm values will be included in the directory structure
143+
- The nodeID will identify the consensus node that produced the block
144+
- Block files will use a 36-digit zero-padded block number format
145+
- Files will use gzip compression and the `.blk.gz` extension
146+
147+
### 3\. Mirror Node Requirements
148+
149+
#### 3.1 Processing Logic
150+
151+
Mirror nodes will implement logic to:
152+
153+
- Detect marker files indicating the end of record streams
154+
- Switch from record stream processing to block stream processing
155+
- Apply the new bucket directory structure and path conventions
156+
- Store block data in a compatible format with existing database schemas
157+
158+
#### 3.2 Block Verification
159+
160+
Mirror nodes will:
161+
162+
- Implement block proof verification using Threshold Signature Scheme (TSS)
163+
- Implement retry mechanisms to handle cases where block verification fails. Should retry the same block number from other node until correctly processed.
164+
165+
#### 3.3 Bootstrap and Recovery
166+
167+
Mirror nodes will:
168+
169+
- Implement logic to process both block and records files.
170+
- Implement logic to update the timestamp-based startup logic to use blocks rather than timestamps
171+
- Take PostgreSQL snapshots before the transition to enable mirror node bootstrapping
172+
- Support recovery in cases where block processing fails
173+
174+
### 4\. Test Plan and Verification
175+
176+
The end-to-end test plan will include:
177+
178+
1. Verification of logic for writing block streams
179+
2. Verification of block production and correctness
180+
3. Verification of ingestion and cloud storage
181+
4. Verification of block proof creation and verification following node upgrade
182+
5. Verification of Mirror Node transition detection and cutover capability
183+
184+
### 5\. Disaster Recovery Considerations
185+
186+
The following risk scenarios must be addressed:
187+
188+
#### 5.1 Pre-First-Block Risks
189+
190+
- Node failure during cutover
191+
- Uploader misconfiguration (incorrect path, cloud provider, etc.)
192+
- No blocks being produced
193+
- Record or event streams not stopping as intended
194+
195+
#### 5.2 First Block Production Risks
196+
197+
- Incorrect running hash
198+
- Incorrect block number
199+
- Malformed block data or schema
200+
- Invalid block proof
201+
- Node reconnection issues after maintenance window
202+
203+
### Example Specification
204+
NA
205+
206+
## Backwards Compatibility
207+
This transition introduces a fundamental change in how transaction data is exposed by the Hedera network.
208+
209+
To maintain backward compatibility:
210+
211+
Historical record stream data will remain available in its current format and location
212+
Mirror nodes will support both record stream and block stream processing
213+
The first block will maintain cryptographic continuity with the last record
214+
215+
Long-term, as the ecosystem transitions to block nodes, historic record streams and cloud bucket access may eventually be deprecated, but this would require a separate HIP and migration plan.
216+
217+
## Security Implications
218+
The transition to block streams introduces several security considerations:
219+
220+
1. **Data Integrity**: Ensuring the running hash continuity between record streams and block streams is critical to maintain the cryptographic integrity of the ledger.
221+
222+
2. **Block Verification**: Mirror nodes must properly implement the TSS verifier to validate block proofs.
223+
224+
3. **Disaster Recovery**: Proper procedures must be in place to handle node failures or other issues during the cutover.
225+
226+
4. **Data Availability**: Ensuring no transactions are lost during the transition is critical for maintaining network trust.
227+
228+
## How to Teach This
229+
The transition from record streams to block streams represents a significant architectural change for the Hedera network. To help the community understand this change:
230+
231+
1. **For Mirror Node Operators:**
232+
233+
- Provide detailed documentation on the new block file format and paths
234+
- Explain how to detect the transition marker and switch processing modes
235+
- Offer guidance on handling the transition period
236+
237+
2. **For Developers:**
238+
239+
- Explain the conceptual shift from records to blocks
240+
- Document how transaction data will be organized in the new format
241+
- Provide examples of how to process block data
242+
243+
3. **For Node Operators:**
244+
245+
- Detail the changes required to consensus node configuration
246+
- Explain the new uploader paths and configurations
247+
- Provide a timeline and checklist for the upgrade
248+
249+
## Reference Implementation
250+
NA
251+
252+
## Rejected Ideas
253+
None to note
254+
255+
## Open Issues
256+
Block Stream Protobuf Definitions: The block stream protobuf definitions are still under development. Several open items remain.
257+
258+
Block Deduplication Strategy: A decision is needed on whether to implement deduplication of blocks from multiple nodes before block nodes are fully operational, or to accept the additional storage costs during the transition period.
259+
260+
Timestamp to Block Number Mapping: A solution is needed for mirror nodes to map between timestamps and block numbers, particularly for startup and historical data access.
261+
## References
262+
A collection of URLs used as references throughout the HIP.
263+
264+
## Copyright/license
265+
This document is licensed under the Apache License, Version 2.0 —
266+
see [LICENSE](../LICENSE) or <https://www.apache.org/licenses/LICENSE-2.0>.

0 commit comments

Comments
 (0)