Closed cdamian closed 4 weeks ago
Regarding the tests, I think we should simplify them and/or factorize them. 5k lines are too many lines to refactor tomorrow because something has changed π .
I think by using two messages and 2 routers in the test cases, we can have all the safety we're looking for.
At least, at this stage, where we actually only support 1 router π
Regarding the tests, I think we should simplify them and/or factorize them. 5k lines are too many lines to refactor tomorrow because something has changed π .
I think by using two messages and 2 routers in the test cases, we can have all the safety we're looking for.
At least, at this stage, where we actually only support 1 router π
Might seem a bit of an overkill but when I initially dealt with the message processing logic, these tests helped me stay on the correct path. I would definitely keep the ones for two_routers
all the way up to the four_messages
ones since those confirm that multiple identical entries are processed accordingly. For the ones with the three_routers
, I would only keep the three_message
ones, since that covers the case where we process maximum one message.
I'm all for simplifying these and hopefully have some logic that generates messages + expected test results, but then again, that logic would also have to be tested and I'm not sure if we have time to deal with that given the remaining things that we have to do for the audit.
Maybe we can live with having ultra-verbose tests for the time being since IMO, it's a bit clear of what's tested and what's expected.
Maybe we can live with having ultra-verbose tests for the time being since IMO, it's a bit clear of what's tested and what's expected.
Agree @cdamian, let's keep it as tech-debt. Testing is not under audit.
Gonna add the fixes for ITs on a different branch to reduce the noise here.
Attention: Patch coverage is 76.73469%
with 57 lines
in your changes missing coverage. Please review.
Project coverage is 48.87%. Comparing base (
e8f1efd
) to head (89ffd0e
). Report is 1 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Description
This PR adds support for multiple routers in the LP gateway.
LP Gateway Pallet Changes
Extrinsics
set_routers
extrinsic that sets the set of valid routers for both inbound and outbound messages.Routers
storage, a new session ID is created to keep track of incoming messages or proofs.execute_message_recovery
extrinsic that is used to manually increase the proof count for a particular message proof and router ID, and execute the message if the required proof count is met.Message Processing
Inbound
For every inbound message that is received via the
MessageReceiver
implementation, we check theAllowlist
storage to confirm that the origin is allowed to submit message, if successful, we queue an inbound gateway message that contains the necessary information for processing i.e. origin address, message and router identifier.For every inbound gateway message we create an
InboundEntry
that specifies whether the message is a message type or proof type.After validation, this
InboundEntry
is then added to storage, if a previous entry of this type is found, the expected counts are updated accordingly - for a message type, the total expected proof count is increased by the value required for that domain, similarly, for a proof type, the proof count is increased by 1.If the
PendingInboundEntries
storage contains one message entry from the first router, and the required proof entries from each of the remaining routers, the counts are decreased and the message is forwarded to theInboundMessageHandler
for execution.Outbound
For every outbound message received from the called of the
OutboundMessageHandler::handle
we retrieve all routers for the destinationDomain
.The queueing is done using the
LP Gateway Queue
as follows:Upon eventual receipt of the queued messages/proofs from the
LP Gateway Queue
, they are sent for further processing to theMessageSender
.Other Notable Changes
LPEncoding
trait now has 2 more methods for retrieving a message proof and converting a message type to a proof type.RouterSupport
trait was slightly adjusted to better fit with the requirement of providing a statically defined list ofRouterId
s for a specific domain.Checklist: