This commit modifies the recently added logic to the ChainNotifier to:
1. Fix the off-by-one confirmation error that was missed due a flaky
test
2. Ensure that partial historical confirmations are properly handled.
The partial hostile confirmation case arises when a transaction already
a non-zero number of confirmations when the notification is registered,
but less than what would trigger the confirmation notification. To fix
this, transaction which have a partial number of confirmation are now
properly inserted into the confHeap, skipping first first phase for
notifications.
This commit modifies the encoding of signatures on the wire to use
a fixed-size 64-byte format. This change is required as the current spec
draft dictates that all signatures be encoded as `R` and `S` as 32-byte
big-endian integers. With this, signatures are now always a _fixed_ size
slice of bytes on the wire, which is nice to have.
Fixes#83.
Without these checks, “zombie” notification requests that would never
be dispatched could be registered. This would occur if notification
requests were made for events (transaction confirmation and output
spent) that had already been recorded on the blockchain.
This commit introduces a new capability to the database: storage of an
on-disk directed channel graph. The on-disk representation of the graph
within boltdb is essentially a modified adjacency list which separates
the storage of the edge’s existence and the storage of the edge
information itself.
The new objects provided within he ChannelGraph carry an API which
facilitates easy graph traversal via their ForEach* methods. As a
result, path finding algorithms will be able to be expressed in a
natural way using the range methods as a for-range language extension
within Go.
Additionally caching will likely be added either at this layer or the
layer above (the RoutingManager) in order keep queries and outgoing
payments speedy. In a future commit a new set of RPC’s to query the
state of a particular edge or node will also be added.
This commit modifies the channel closing logic to remove the hard coded
bools indicating which side is attempting the closure. With the recent
changes, the initiator must always pay the channel closure fees.
This information is recently stored on disk, therefore we can use the
boolean to ensure that the closure transaction is created properly no
matter who initiates the close.
This fixes a bug.
This commit introduces a new sub-system into the daemon whose job it is
to vigilantly watch for any potential channel breaches throughout the
up-time of the daemon. The logic which was moved from the utxoNursery
in a prior commit now resides within the breachArbiter.
Upon start-up the breachArbiter will query the database for all active
channels, launching a goroutine for each channel in order to be able to
take action if a channel breach is detected. The breachArbiter is also
responsible for notifying the htlcSwitch about channel breaches in
order to black-list the breached linked during any multi-hop forwarding
decisions.
This commit removes the previously added contract breach retribution
duties from the utxoNursery. Much of the code removed will instead be
moved to a new sub-system which continuously monitors the state of ALL
active contracts for their entire life time.
This commit adds support for dispatching the same spend notification to
multiple clients. This is now required by the ChainNotiifer interface
documentation and will be needed within the daemon in order to support
some upcoming refactors.
This commit updates the documentation for the ChainNotifier interface
to specify that all implementation MUST be able to support dispatching
the same notification to multiple clients.
This commit adds a new method to the `OpenChannel` struct:
CommitmentHeight(). This method allows multiple callers holding the
same instance of an OpenChannel struct tied to the same on-disk channel
to consistently query the current commitment height for a channel. Such
a modification will prove useful later as sections of the code-base are
separated in order to allow more vigilant watching of channel breaches.
This commit performs a slight refactoring of the internals (and API) of
the [Fetch|Put]Meta methods. The changes are rather minor and simply
eliminate the conditional branching structure with usage of an internal
function. This new form is much easier to follow.
This commit modifies the composition of the boltdb pointer within the
DB struct to use embedding.
The rationale for this change is that the daemon may soon store some
semi-transient items within the database which requires us to expose
the boltdb’s transaction API. The logic for serialization of this data
will likely lie outside of the channeldb package as the items that may
be stored in the future will be specific to the current sub-systems
within the daemon and not generic channel related data.
Use [33]byte for graph vertex representation.
Delete unneeded stuff:
1. DeepEqual for graph comparison
2. EdgePath
3. 2-thread BFS
4. Table transfer messages and neighborhood radius
5. Beacons
Refactor:
1. Change ID to Vertex
2. Test use table driven approach
3. Add comments
4. Make graph internal representation private
5. Use wire.OutPoint as EdgeId
6. Decouple routing messages from routing implementation
7. Delete Async methods
8. Delete unneeded channels and priority buffer from manager
9. Delete unneeded interfaces in internal graph realisation
10. Renamed ID to Vertex
This commit unexports the SyncVerions PR, in favor of making it private
and moving it into the .Open() method. With this change, callers no
longer need worry about ensuring the database version is up to sync
before usage, as it will happen automatically once the database is
opened.
This commit also unexports some additional variables within the package
that don’t need be consumed by the public, and exports the
DbVersionNumber attribute on the meta struct. Finally some minor
formatting fixes have neen carried out to ensure the new code more
closely matches the style of the rest of the codebase.
In this commit the upgrade mechanism for database was added which makes he current schema rigid and upgradeable. Additional bucket 'metaBucket' was added which stores
key that house meta-data related to the current/version state of the database. 'createChannelDB' was modified to create this new bucket+key during initializing. Also
backup logic was added which makes a complete copy of the current database during migration process and restore the previous version of database if migration failed.
This commit adds persistence for a channel’s
TotalSatoshis[Sent|Received] fields. Also, the functions that perform
this persistence were renamed from [put|delete|fetch]ChanTotalFlow to
[put|delete|fetch]ChanAmountsTransferred.
This commit modifies the invoices generated during the
testRevokedCloseRetribution integration test to ensure that the
invoices are globally unique within the context of the integration
tests.
This commit adds a new rather extensive integration tests to excerise
uncooperative channel breaches triggered by a counter-party
broadcasting a previously revoked commitment state.
In order to programmatically script such logic using the integration
testing framework, the test manually manipulates the database files of
one of the nodes within the test network in order to force Bob to
travel back in time to a revoked commitment state. With this
manipulation, we then force Bob to broadcast the revoked state,
triggering Alice’s retribution logic which sweeps ALL the funds within
the channel.
This commit adds a callback to the RestartNode method on the network
harness in order to allow test authors to execute arbitrary logic
in-between the restart process for the node.
This commit adds the necessary logic a peer’s htlcManger goroutine to
dispatch justice (sweeping all the funds in a channel) after it has
been detected that the counter-party has broadcast a prior revoked
commitment state.
The task to generate the justice transaction is handed off to the
utxoNursery. Once the nursery has finished its duty, the peer launches
a new goroutine which will delete the state of the channel once the
justice transaction has been confirmed within a block.
This commit expands the duties of the utxoNursery (which should maybe
be renamed), to handle carrying out retribution against a counter-party
who breaches the channel contract by broadcasting a prior revoked state
on-chain.
As part of the retribution, once the breach transaction (the revoked
commitment transaction) has been confirmed within a block, the nursery
then sweep ALL funds pending within the channel to the daemon’s wallet.
This new section of the code has been implemented without full
persistence logic similar to time-locked output sweeping workflow of
the nursery. In a later commit, this section will gain full persistence
logic so the workflows can survive restarts of the daemon.
This commit adds detection of contract breaches within the commitment
state-machine for a channel. A contract breach is defined as the event
wherein a channel counter-party broadcasts a previously revoked
commitment transaction. Such an event immediately closes a channel as
the funds are now in a state of dispute.
Once a breach is detected, a snapshot of the breached state is
retrieved from the database’s revocation log. This snapshot is then
used to generate the revocation leaf used within this particular state
along with all the other information ncessary to sweep ALL active funds
within the channel. This information is encapsulated within the
BreachRetribution struct which is sent over a new channel dedicated to
sending/receiving BreachRetributions.
This commit modifies the logic within the state machine to properly
populate the new field of `OutputIndex` which the HTLC stored within a
channel delta.
With this change, in the future we’ll be able to quickly locate a
particular HTLC output in the scenario that the commitment transaction
has been broadcast on-chain and we need to sweep it. Allocating a few
extra bytes on-disk saves us from the guess-and-check logic+code
required otherwise.
This commit adds some necessary locking to ensure that all updates to
the internal state of the commitment state machine are fully serial and
thread-safe. This change is required to ensure future actions w.r.t
taking action once a revoked commitment transaction has been broadcast
are not carried out while the channel’s state is being updated.
This commit extends the SignDescriptor with a single attribute, the
‘PrivateTweak’. The duties of the Signer interface have also been
augmented to properly derive a private key using the specified tweak,
iff it’s non-nil.
As currently defined in order to generate the proper private key based
off of a PrivateTweak, the signer is to add the tweak value to the
private key for the specified public key. This generated value is to be
used for signing within the specified context.
This change paves the way for automatic revoked output sweeping with
signatures generated directly by the Signer interface, maintaining the
structure of the abstraction.
A test has been added at the interface level in order to excerise each
WalletController’s implementation of the key derivation as currently
defined.
This commit converts the rearming two commitment spend functions to use
the lnwallet.Signer interface directly rather than manually manage
private keys during the signing process. This commit is in preparation
for implementation of fully automated revoked uncooperative closure
detection and retribution.
This commit finalizes the implementation of #58 by integrating passing
around the obfuscate state hints into the funding workflow of the
wallet, and also the daemon’s funding manager.
In order to amend the tests, the functions to set and receive the state
hints are now publicly exported.
This commit modifies the channel state machine slightly to encode the
current state number using 30-bits of the sequence number within the
commitment transaction’s only input.
Such a modification reduces up the processing time required to punish
the counter party for breaching the contract established within the
channel by broadcasting an older revoked state.
This fixes#58 with a minor modification to what was originally
suggested.
This commit removes the prior test for the node restart method as it
can be very flaky due to process not always relinquishing ports they
were blinded to.
The solution for this problem is to have the lnd processes obtain ports
to listen on based on their process ID.