Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(l1): abstract request logic into PeerHandler #1845

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

fmoletta
Copy link
Contributor

@fmoletta fmoletta commented Jan 29, 2025

Motivation
sync code should not be aware of how peers are handled and only care about what they ask the peer and what it returns to them. This PR aims to abstract peer handling logic into a PeerHandler so that sync code no longer has to care about finding a suitable peer and managing retries for failing requests. The PeerHandler api will provide request methods that return a suitable peer response unless there was no suitable peer or none of them returned a suitable response. This will also allow us to refactor peer code without affecting sync code & add other behaviors such as punishing peers that return invalid responses in the future

Description

  • Add PeerHandler abstraction (which will take over the request methods of PeerChannels)
  • Peer request methods now also find a suitable peer for the request and retry it if it fails
  • Removed peer selection & request retry logic from sync code

Closes #issue_number

Copy link

github-actions bot commented Jan 29, 2025

| File                                                                                            | Lines | Diff |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ef_tests/levm/runner/revm_runner.rs                         | 462   | +2   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/blockchain.rs                                 | 183   | -2   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/payload.rs                                    | 517   | +36  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/p2p/kademlia.rs                               | 492   | +24  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/p2p/sync.rs                                   | 757   | -38  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/rpc/types/payload.rs                          | 247   | -2   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/bench/revm_comparison/src/levm_factorial.rs      | 11    | +11  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/bench/revm_comparison/src/levm_fibonacci.rs      | 11    | +11  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/bench/revm_comparison/src/lib.rs                 | 58    | -27  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/bench/revm_comparison/src/revm_factorial.rs      | 11    | +11  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/bench/revm_comparison/src/revm_fibonacci.rs      | 11    | +11  |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/call_frame.rs                                | 124   | +6   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/errors.rs                                    | 247   | +8   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/lib.rs                                       | 17    | -1   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/opcode_handlers/arithmetic.rs                | 222   | +6   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/opcode_handlers/bitwise_comparison.rs        | 235   | +3   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/opcode_handlers/push.rs                      | 62    | -2   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/opcode_handlers/stack_memory_storage_flow.rs | 273   | +2   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/opcode_handlers/system.rs                    | 665   | +3   |
+-------------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/vm.rs                                        | 928   | +209 |
+-------------------------------------------------------------------------------------------------+-------+------+

Total lines added: +343
Total lines removed: 72
Total lines changed: 415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant