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

Confirm DKG start before triggering off-chain protocol #3468

Merged
merged 8 commits into from
Jan 12, 2023
Merged

Conversation

lukasz-zimnoch
Copy link
Member

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.

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.
The off-chain protocol should be started as close as possible to the current
block or even further. Starting the off-chain protocol with a past block will
likely cause a failure of the first attempt as the start block is used to
synchronize the announcements and the state machine. Here we ensure a proper
start point by delaying the execution by the confirmation period length.
Copy link
Member

@pdyraga pdyraga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test this code given #3460 is not yet finished and I am struggling to set up the environment. If you performed tests locally @lukasz-zimnoch I will trust your verification and merge the PR once the code comments are addressed. We will deploy it to testnet for another verification as well.

pkg/tbtc/dkg.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/dkg.go Outdated Show resolved Hide resolved
pkg/tbtc/dkg.go Show resolved Hide resolved
pkg/tbtc/tbtc.go Show resolved Hide resolved
pkg/tbtc/tbtc.go Show resolved Hide resolved
pkg/tbtc/tbtc.go Show resolved Hide resolved
pkg/tbtc/tbtc.go Show resolved Hide resolved
@lukasz-zimnoch
Copy link
Member Author

I can't test this code given #3460 is not yet finished and I am struggling to set up the environment. If you performed tests locally @lukasz-zimnoch I will trust your verification and merge the PR once the code comments are addressed. We will deploy it to testnet for another verification as well.

I have tested the basic scenario: request a new wallet to trigger DKG, wait until the confirmation period elapses, and check if nodes executed the protocol as expected. The corner cases involving reorgs and event duplicates must be checked on testnet

@pdyraga pdyraga merged commit d6d51e9 into main Jan 12, 2023
@pdyraga pdyraga deleted the confirm-dkg-start branch January 12, 2023 20:10
@pdyraga pdyraga self-assigned this Jan 12, 2023
@pdyraga pdyraga added this to the v2.0.0-m2 milestone Jan 25, 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 this pull request may close these issues.

DKG trigger and chain reorgs
2 participants