Merge pull request #3177 from halseth/autopilot-targetconf-conf

[autopilot] make confirmation target configurable
This commit is contained in:
Olaoluwa Osuntokun 2019-06-17 16:05:00 -07:00 committed by GitHub
commit df40a9c1e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 7 deletions

@ -9,6 +9,11 @@ import (
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )
// DefaultConfTarget is the default confirmation target for autopilot channels.
// TODO(halseth): possibly make dynamic, going aggressive->lax as more channels
// are opened.
const DefaultConfTarget = 3
// Node node is an interface which represents n abstract vertex within the // Node node is an interface which represents n abstract vertex within the
// channel graph. All nodes should have at least a single edge to/from them // channel graph. All nodes should have at least a single edge to/from them
// within the graph. // within the graph.

@ -21,6 +21,7 @@ import (
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
flags "github.com/jessevdk/go-flags" flags "github.com/jessevdk/go-flags"
"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/chanbackup" "github.com/lightningnetwork/lnd/chanbackup"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
@ -209,6 +210,7 @@ type autoPilotConfig struct {
MaxChannelSize int64 `long:"maxchansize" description:"The largest channel that the autopilot agent should create"` MaxChannelSize int64 `long:"maxchansize" description:"The largest channel that the autopilot agent should create"`
Private bool `long:"private" description:"Whether the channels created by the autopilot agent should be private or not. Private channels won't be announced to the network."` Private bool `long:"private" description:"Whether the channels created by the autopilot agent should be private or not. Private channels won't be announced to the network."`
MinConfs int32 `long:"minconfs" description:"The minimum number of confirmations each of your inputs in funding transactions created by the autopilot agent must have."` MinConfs int32 `long:"minconfs" description:"The minimum number of confirmations each of your inputs in funding transactions created by the autopilot agent must have."`
ConfTarget uint32 `long:"conftarget" description:"The confirmation target (in blocks) for channels opened by autopilot."`
} }
type torConfig struct { type torConfig struct {
@ -389,6 +391,7 @@ func loadConfig() (*config, error) {
Allocation: 0.6, Allocation: 0.6,
MinChannelSize: int64(minChanFundingSize), MinChannelSize: int64(minChanFundingSize),
MaxChannelSize: int64(MaxFundingAmount), MaxChannelSize: int64(MaxFundingAmount),
ConfTarget: autopilot.DefaultConfTarget,
Heuristic: map[string]float64{ Heuristic: map[string]float64{
"preferential": 1.0, "preferential": 1.0,
}, },
@ -559,6 +562,12 @@ func loadConfig() (*config, error) {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return nil, err return nil, err
} }
if cfg.Autopilot.ConfTarget < 1 {
str := "%s: autopilot.conftarget must be positive"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
// Ensure that the specified values for the min and max channel size // Ensure that the specified values for the min and max channel size
// don't are within the bounds of the normal chan size constraints. // don't are within the bounds of the normal chan size constraints.

@ -74,6 +74,7 @@ type chanController struct {
server *server server *server
private bool private bool
minConfs int32 minConfs int32
confTarget uint32
} }
// OpenChannel opens a channel to a target peer, with a capacity of the // OpenChannel opens a channel to a target peer, with a capacity of the
@ -84,7 +85,9 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
// With the connection established, we'll now establish our connection // With the connection established, we'll now establish our connection
// to the target peer, waiting for the first update before we exit. // to the target peer, waiting for the first update before we exit.
feePerKw, err := c.server.cc.feeEstimator.EstimateFeePerKW(3) feePerKw, err := c.server.cc.feeEstimator.EstimateFeePerKW(
c.confTarget,
)
if err != nil { if err != nil {
return err return err
} }
@ -170,6 +173,7 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.ManagerCfg, er
server: svr, server: svr,
private: cfg.Private, private: cfg.Private,
minConfs: cfg.MinConfs, minConfs: cfg.MinConfs,
confTarget: cfg.ConfTarget,
}, },
WalletBalance: func() (btcutil.Amount, error) { WalletBalance: func() (btcutil.Amount, error) {
return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs) return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs)