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

DKG trigger and chain reorgs #3456

Closed
lukasz-zimnoch opened this issue Dec 28, 2022 · 1 comment · Fixed by #3468
Closed

DKG trigger and chain reorgs #3456

lukasz-zimnoch opened this issue Dec 28, 2022 · 1 comment · Fixed by #3468
Assignees
Milestone

Comments

@lukasz-zimnoch
Copy link
Member

lukasz-zimnoch commented Dec 28, 2022

Currently, the tECDSA DKG is triggered using a simple event listener acting on DKGStarted events. However, small chain reorgs may cause different startBlock to be received by DKG participants. That can lead to invalid signatures over the produced DKG result as the startBlock is one of the signature's components. We need to improve that. See discussion

@pdyraga
Copy link
Member

pdyraga commented Jan 4, 2023

An early idea on how we could approach it...

Things that may happen:

  • The block is mined and DKGStarted event is emitted. Given the chain reorg, the block is dropped and DKG start transaction is not mined again. In this scenario, the client should not start the DKG.
  • The block with DKGStarted event is emitted. The event is emitted twice with the same block number given the specifics of Ethereum gateway deployment. In this scenario, the client should ignore the second event.
  • The block with DKGStarted event is emitted. The event is emitted twice with the same block number given the background event monitoring loop. In this scenario, the client should ignore the second event.
  • The block with DKGStarted event is mined. Given the chain reorg, the block is dropped. A moment later, another block with DKGStarted event is mined. Two events were emitted in this scenario but the client should take into account only the second one.

Here is how can we approach it:

  • DKGStarted event is emitted at block N. We start the monitoring goroutine and wait for 20 blocks.
  • After 20 blocks, we check the DKG state. If it is not in progress, we leave.
  • If DKG is in progress we take the last DKGStarted event emitted.
  • We start the DKG based on the block number from the latest DKGStarted event.

In this approach, it may happen that the latest DKGStarted event has only 15 confirmations, for example. I think this is fine.

If we want to be more restrictive, we could:

  • DKGStarted event is emitted at block N. We start the monitoring goroutine and wait for 20 blocks.
  • After 20 blocks, we check the DKG state. If it is not in progress, we leave.
  • If DKG is in progress we take the last DKGStarted event emitted.
  • We wait until the event has 20 confirmations.
  • Optional: We periodically double-check if DKG is in progress to not wait forever if 20 confirmations never happen because the block with the event was dropped.
  • We start the DKG based on the block number from the latest DKGStarted event.

@lukasz-zimnoch lukasz-zimnoch moved this from Todo to In Progress in Launch 🚀 Jan 6, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Launch 🚀 Jan 12, 2023
pdyraga added a commit that referenced this issue Jan 12, 2023
Closes: #3456 

So far, the tECDSA DKG was triggered using a simple event listener acting on
DKGStarted events. However, small chain reorgs may cause different startBlock to
be received by DKG participants. That can lead to invalid signatures over the
produced DKG result as the startBlock is one of the signature's components.
Here we improve that by adding a confirmation mechanism that delays the start of
the off-chain protocol until the event and DKG on-chain state is confirmed. This
way clients are sure to use a finalized event that will no longer be the subject
of chain reorgs.
@pdyraga pdyraga added this to the v2.0.0-m2 milestone Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants