|
| 1 | +--- |
| 2 | +simd: '0298' |
| 3 | +title: Add Parent Bank Hash to Block Header |
| 4 | +authors: |
| 5 | + - Max Resnick |
| 6 | +category: Standard |
| 7 | +type: Core |
| 8 | +status: Idea |
| 9 | +created: 2024-03-26 |
| 10 | +--- |
| 11 | + |
| 12 | +## Summary |
| 13 | + |
| 14 | +This proposal adds the parent bank hash to the block header and introduces validity |
| 15 | +constraints to ensure the parent bank hash matches the expected value. This change |
| 16 | +enhances the security and integrity of the blockchain by providing an additional |
| 17 | +verification layer for block validity. |
| 18 | + |
| 19 | +## Motivation |
| 20 | + |
| 21 | +The current block header structure does not include the parent bank hash, which |
| 22 | +means validators cannot verify that the parent block's bank state matches their |
| 23 | +expectations. By adding this field and enforcing its validity, we can: |
| 24 | + |
| 25 | +1. Provide stronger guarantees about the chain's state consistency |
| 26 | +2. Enable more robust fork detection |
| 27 | +3. Improve the security of the consensus mechanism |
| 28 | +4. Help validators detect potential state divergence earlier |
| 29 | + |
| 30 | +## New Terminology |
| 31 | + |
| 32 | +- **Parent Bank Hash**: The hash of the bank state from the parent block |
| 33 | +- **Bank State**: The complete state of all accounts, programs, and system state |
| 34 | + at a given slot |
| 35 | + |
| 36 | +## Detailed Design |
| 37 | + |
| 38 | +### Block Header Changes |
| 39 | + |
| 40 | +The block header structure will be extended to include a new field: |
| 41 | + |
| 42 | +```rust |
| 43 | +pub struct BlockHeader { |
| 44 | + // ... existing fields ... |
| 45 | + pub parent_bank_hash: Hash, // Hash of the parent block's bank state |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +### Validity Constraints |
| 50 | + |
| 51 | +A block will be considered invalid if: |
| 52 | + |
| 53 | +1. The parent_bank_hash does not match the hash of the parent block's bank state |
| 54 | +2. The parent_bank_hash is missing (for blocks after the feature is activated) |
| 55 | + |
| 56 | +### Implementation Details |
| 57 | + |
| 58 | +1. The bank hash will be computed at the end of processing each block |
| 59 | +2. The hash will be stored in the block metadata |
| 60 | +3. Validators will verify the parent_bank_hash matches their computed hash of the |
| 61 | + parent block's state |
| 62 | +4. The feature will be gated behind a feature flag for smooth activation |
| 63 | + |
| 64 | +### Feature Activation |
| 65 | + |
| 66 | +This change will be implemented behind a feature flag and activated through the |
| 67 | +feature activation program. The activation will require: |
| 68 | + |
| 69 | +1. Implementation of the new block header structure |
| 70 | +2. Updates to block validation logic |
| 71 | +3. Updates to block production logic |
| 72 | +4. Updates to block replay logic |
| 73 | + |
| 74 | +## Alternatives Considered |
| 75 | + |
| 76 | +1. **Full State Hash**: Instead of just the parent bank hash, we could include a |
| 77 | + full state hash. This was rejected as it would be more computationally |
| 78 | + expensive and the parent bank hash provides sufficient security guarantees. |
| 79 | + |
| 80 | +2. **Optional Field**: Making the parent_bank_hash optional was considered but |
| 81 | + rejected as it would weaken the security guarantees we're trying to achieve. |
| 82 | + |
| 83 | +3. **Delayed Verification**: Verifying the parent bank hash after block |
| 84 | + processing was considered but rejected as it would allow invalid blocks to be |
| 85 | + processed before being rejected. |
| 86 | + |
| 87 | +## Impact |
| 88 | + |
| 89 | +### Validators |
| 90 | + |
| 91 | +- Will need to compute and store bank hashes |
| 92 | +- Will need to verify parent bank hashes |
| 93 | +- May see slightly increased computational overhead |
| 94 | + |
| 95 | +### Core Contributors |
| 96 | + |
| 97 | +- Need to implement the new block header structure |
| 98 | +- Need to update block validation logic |
| 99 | +- Need to implement feature activation |
| 100 | + |
| 101 | +### DApp Developers |
| 102 | + |
| 103 | +- No direct impact on dapp developers |
| 104 | +- May benefit from increased chain security |
| 105 | + |
| 106 | +## Security Considerations |
| 107 | + |
| 108 | +1. The parent bank hash provides an additional layer of security by ensuring |
| 109 | + state consistency |
| 110 | +2. Malicious validators cannot produce blocks with incorrect parent bank hashes |
| 111 | +3. The change helps detect state divergence earlier in the consensus process |
| 112 | +4. The feature should be activated carefully to ensure smooth transition |
| 113 | + |
| 114 | +## Backwards Compatibility |
| 115 | + |
| 116 | +This change is not backwards compatible and requires a feature flag for |
| 117 | +activation. All validators must upgrade to support the new block header format |
| 118 | +and validation rules before the feature is activated. |
| 119 | + |
| 120 | +## Implementation Plan |
| 121 | + |
| 122 | +1. Create feature flag for parent bank hash |
| 123 | +2. Implement block header changes |
| 124 | +3. Update block validation logic |
| 125 | +4. Update block production logic |
| 126 | +5. Add tests for new validation rules |
| 127 | +6. Deploy to testnet |
| 128 | +7. Activate feature on mainnet-beta |
0 commit comments