Commit 3c8212c
revive/rpc: Adjust the RPC to utilize the ETH block from storage (#9512)
This PR adjusts the RPC layer of pallet-revive to use Ethereum blocks
from storage via runtime APIs and establishes proper Ethereum ↔
Substrate block hash mappings.
## Key Changes
### Block Hash Mapping Infrastructure
- **New database table**: `eth_to_substrate_blocks` maps Ethereum block
hashes to Substrate block hashes and block numbers
- **Bidirectional lookups**: Support for both ETH→Substrate and
Substrate→ETH hash resolution with backward compatibility fallbacks
- **Block pruning**: Updated to remove stale mappings alongside
transaction and log data
### Pallet Changes
- **Genesis block initialization**: Added
`block_storage::on_finalize_build_eth_block()` call in
`BuildGenesisConfig` to properly build and store block 0
## Testing
- Added comprehensive tests for block hash mapping operations
- Ethereum vs Substrate hash resolution tests
- Fork handling in block pruning tests
- Log filtering with Ethereum block hash tests
- TransactionInfo deserialization from JSON Value tests
## Implementation Details
The implementation uses a **runtime API approach** where the RPC layer
queries the runtime for Ethereum blocks and hashes, which are then
mapped to Substrate block hashes in the local SQLite database. This
provides:
1. **Backward compatibility**: Falls back to treating hashes as
Substrate hashes when no mapping exists
2. **Efficient lookups**: Database indices on both Ethereum and
Substrate block hashes
3. **Automatic cleanup**: Block mappings are pruned alongside
transaction and log data
4. **Genesis block handling**: Block 0 is built during genesis using the
block storage infrastructure
Builds upon: #9418
Part of: paritytech/contract-issues#139
---------
Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: Lukasz Rubaszewski <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: PG Herveou <[email protected]>1 parent 2543325 commit 3c8212c
28 files changed
Lines changed: 1603 additions & 366 deletions
File tree
- prdoc
- substrate/frame/revive
- rpc
- .sqlx
- migrations
- src
- client
- src
- evm
- api
- block_hash
- exec
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 0 additions & 20 deletions
This file was deleted.
0 commit comments