informalsystems / informalsystems/emerald

make consensus app generic over `ExecutionLayer`

Open
#224 0 comments 0 reactions 1 assignee Claimed by @rnbguy View on GitHub
Dominant language
Rust
Stars
25
Forks
9
PR merge metrics
No merged PRs in 30d

Description

the main refactoring PR. replace every `engine: &Engine` parameter in `app/src/` with `el: &E where E: ExecutionLayer`. move app logic into `crates/consensus/malachite/`.

### what moves + changes

| source | destination | change |
|--------|-------------|--------|
| `app/src/app.rs` | `consensus/malachite/src/app.rs` | `engine: &Engine` -> `el: &E` in all handlers |
| `app/src/state.rs` | `consensus/malachite/src/state.rs` | remove `eth_chain_config`, `get_fork()`, `ValidatedPayloadCache` |
| `app/src/bootstrap.rs` | `consensus/malachite/src/bootstrap.rs` | use trait methods |
| `app/src/sync_handler.rs` | `consensus/malachite/src/sync_handler.rs` | `el.get_block_by_height()` + `el.encode_block()` |
| `app/src/store.rs` | `consensus/malachite/src/store.rs` | unchanged |
| `app/src/streaming.rs` | `consensus/malachite/src/streaming.rs` | unchanged |
| `app/src/node.rs` | `consensus/malachite/src/node.rs` | `App`, Engine construction moves to CLI |
| `app/src/metrics.rs` | `consensus/malachite/src/metrics.rs` | unchanged |

### handler-level changes

| handler | before | after |
|---------|--------|-------|
| `on_consensus_ready` | `engine.check_capabilities()`, `engine.eth.get_block_by_number("earliest")` | `el.genesis_block()` |
| `on_get_value` | `engine.is_syncing()`, `engine.generate_block(...)` | `el.is_syncing()`, `el.build_block(parent, ts)` |
| `on_decided` | `engine.set_latest_forkchoice_state(hash, retry)`, `read_validators_from_contract(url, hash)` | `el.finalize_block(&block)` -> `BlockId`, `el.validator_set()` |
| `on_process_synced_value` | `validate_execution_payload(cache, data, h, r, engine, retry)` | `el.validate_block(&block)` |
| `on_get_decided_value` | `get_decided_value_for_sync(store, engine, h, earliest)` | `get_decided_value_for_sync(store, el, h, earliest)` |
| `on_started_round` | `state.process_complete_proposal_parts(parts, engine, &config.retry_config)` | `state.process_complete_proposal_parts(parts, el)` |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.