-
Notifications
You must be signed in to change notification settings - Fork 138
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
Consumer handles expired client to provider #452
Consumer handles expired client to provider #452
Conversation
@sainoe This PR removes the SlashRequests from the genesis state. Instead, we need to add the pending data packets, but it's a bit more involved. See #264 (comment) for more details. |
x/ccv/consumer/keeper/relay.go
Outdated
// IBC client expired: | ||
if i != 0 { | ||
// this should never happen | ||
panic(fmt.Errorf("client expired while sending pending packets: %w", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an edgecase also handled in #448.
I'm wondering if this should invoke a panic?
We could simply delete packets that were sent so we don't resend them when a new client is established?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never happen. The client cannot expired in the middle of a block as the time doesn't change. Also, it cannot expire in the middle of a loop as the SDK is sequential. I guess we could remove this check to save space :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code structure here is very hard to follow IMO. As one example, the call to SendPendingDataPackets
on line 89 of relay.go can return false
for its clientExpired
return value, even if the client is expired, if the queue is empty. This is then checked again lower down in the function, leading to a pretty circuitous logic path. There are other examples as well.
I believe that all of this could be made much simpler if the functions SendVSCMaturedPackets
and SendSlashPacket
would only ever append to the PendingDataPacket
queue. Then, another endblock method would deal with sending everything in the PendingDataPacket
queue and dealing with expired clients etc.
I agree this would simplify the logic. The only downside is that we'll do a read and write to the store for every packet (even when the client is not expired). |
Maybe I missed sthg but sending the pending packet in |
The idea is that all packets to be send are added to the queue and then in |
Okay I got it! Thanks for the correction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did read through and I like the semantic changes but I agree with other comments that it could do with some substantial refactoring. I'd accept a merge as long as it was followed up with refactoring immediately afterwards.
Nit: I think DataPackets
as a term is a bit weird: all packets have data so it's not informative. Just Packets
is fine
By the way, will the changes here affect the fact that currently pending consumer slash requests are sent in reverse order? |
Yes. That was just a stupid optimization. Was not necessary for safety. |
92f569b
to
7f918c2
Compare
Merged into |
6e9c1df
to
c46c0f0
Compare
Closing in favor of #448 which has all changes in a single PR. |
Partial fix for #435 (see #448 for the other part). The consumer collects the IBC packets that cannot be sent to the provider due to the client being expired. Once the client is upgraded, these packets are sent in the next block.