Git Product home page Git Product logo

Comments (4)

Crypt-iQ avatar Crypt-iQ commented on May 12, 2024

Another case that's unhandled is in contractcourt/chain_watcher.go closeObserver() method. It notifies once on the spend (which requires only 1-confirmation), and then exits out after "handling" the confirmed commit tx. If the commit tx gets re-orged out, the chain_watcher will be unaware, and the contractcourt subsystem will not properly handle this event.

from lnd.

Crypt-iQ avatar Crypt-iQ commented on May 12, 2024

Other call-sites that use RegisterSpendNtfn:

  • breacharbiter.go
  • contractcourt/commit_sweep_resolver.go
  • contractcourt/htlc_outgoing_contest_resolver.go
  • sweep/sweeper.go
    I haven't checked if the ones listed above properly handle re-orgs. I can update this issue once I check.

from lnd.

Crypt-iQ avatar Crypt-iQ commented on May 12, 2024

Sub-systems are not re-org safe:

  • Sub-system grabs current-height after acquiring mutex
  • chainntnfs receives: disconnected block, disconnected block, block (confirm/spend), block, block
  • chainntnfs backend puts the blocks in a buffered channel
  • Sub-system calls RegisterConfirmationsNtfn with the original height.
  • Historical dispatch occurs from [height, height+1]
  • The desired confirmation has occurred at height-1
  • Sub-system grabs the blocks from its BlockEpochRegistration channel, finally updating its height to height+1.

The blocks are received before the call to txnotifier.RegisterConf, so they will not notify on the confirmation. This requires a 2-block re-org. Re-orgs are a global event, so while this race is unlikely, one re-org could affect one very unlucky user out of the thousands on the network.

from lnd.

Crypt-iQ avatar Crypt-iQ commented on May 12, 2024

Additionally, the onus seems to be on the sub-system or caller to handle re-orgs.

from lnd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.