See this discussion: #2860 (comment)
We should be able to know before decoding a message, which capability it belongs to.
So we should avoid code like this:
|
fn decode(msg_data: &[u8]) -> Result<Self, RLPDecodeError> { |
|
if has_bloom(msg_data)? { |
|
Ok(Receipts::Receipts68(Receipts68::decode(msg_data)?)) |
|
} else { |
|
Ok(Receipts::Receipts69(Receipts69::decode(msg_data)?)) |
|
} |
|
} |
|
} |
Instead, the caller of decode should know which version we are in and call Receipts68::decode or Receipts69::decode
This might need a refactor. This will allow the different versions to be more differenciated.
Acceptance criteria:
- Review the code to make sure we only use the highest version of a capability.
- Ignore a message when it is from a capability that has a lower version
- Refactor: I would proably avoid bundling multiple versions of a type in an enum like
pub(crate) enum Receipts {
Receipts68(Receipts68),
Receipts69(Receipts69),
}
Instead, we could have both implement a common trait. Open to discussion though
See this discussion: #2860 (comment)
We should be able to know before decoding a message, which capability it belongs to.
So we should avoid code like this:
ethrex/crates/networking/p2p/rlpx/eth/receipts.rs
Lines 99 to 106 in 15ef5f8
Instead, the caller of decode should know which version we are in and call
Receipts68::decodeorReceipts69::decodeThis might need a refactor. This will allow the different versions to be more differenciated.
Acceptance criteria:
Instead, we could have both implement a common trait. Open to discussion though