Merge pull request #52 from ziggie1984/channel-age

pull/54/head
rkfg 1 year ago committed by GitHub
commit 9a5116eef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -88,7 +88,7 @@ Common:
-e, --exclude-channel (DEPRECATED) don't use this channel at all (can be specified multiple times) -e, --exclude-channel (DEPRECATED) don't use this channel at all (can be specified multiple times)
-d, --exclude-node (DEPRECATED) don't use this node for routing (can be specified multiple times) -d, --exclude-node (DEPRECATED) don't use this node for routing (can be specified multiple times)
--exclude don't use this node or your channel for routing (can be specified multiple times) --exclude don't use this node or your channel for routing (can be specified multiple times)
--to try only this channel or node as target (should satisfy other constraints too; can be specified multiple times) --exclude-channel-age don't use channels opened less than this number of blocks ago --to try only this channel or node as target (should satisfy other constraints too; can be specified multiple times)
--from try only this channel or node as source (should satisfy other constraints too; can be specified multiple times) --from try only this channel or node as source (should satisfy other constraints too; can be specified multiple times)
--fail-tolerance a payment that differs from the prior attempt by this ppm will be cancelled --fail-tolerance a payment that differs from the prior attempt by this ppm will be cancelled
--allow-unbalance-from (DEPRECATED) let the source channel go below 50% local liquidity, use if you want to drain a channel; you should also set --pfrom to >50 --allow-unbalance-from (DEPRECATED) let the source channel go below 50% local liquidity, use if you want to drain a channel; you should also set --pfrom to >50
@ -199,8 +199,7 @@ continues.
In general its recommanded to run regolancer in a normal environment because it is In general its recommanded to run regolancer in a normal environment because it is
so easy to install as mentioned above. However if you want to run it in a docker so easy to install as mentioned above. However if you want to run it in a docker
we also provide the Dockerfile and a docker-compose.yml so that you can easily we also provide the Dockerfile so that you can easily get started.
get started.
Build the container or pull it: Build the container or pull it:
@ -224,7 +223,6 @@ alias regolancer="docker run --rm --network=umbrel_main_network -it -v /home/umb
For older versions of Umbrel please use `/home/umbrel/umbrel/lnd` instead of `/home/umbrel/umbrel/app-data/lightning/data/lnd` For older versions of Umbrel please use `/home/umbrel/umbrel/lnd` instead of `/home/umbrel/umbrel/app-data/lightning/data/lnd`
# What's wrong with the other rebalancers # What's wrong with the other rebalancers
While I liked probing in `bos`, it has many downsides: gives up quickly on While I liked probing in `bos`, it has many downsides: gives up quickly on
@ -288,6 +286,7 @@ during route construction. You can also disable them (it only happens on your
end so you'll be able to receive liquidity but not send it) but it hurts your end so you'll be able to receive liquidity but not send it) but it hurts your
score on various sites so better not to do it. Increase fees or lower max_htlc and score on various sites so better not to do it. Increase fees or lower max_htlc and
you'll be good. You can set multiple brackets with multiple limits like: you'll be good. You can set multiple brackets with multiple limits like:
- 20% local balance => set max_htlc to 0.1 of channel capacity (so it can - 20% local balance => set max_htlc to 0.1 of channel capacity (so it can
process ≈2 payments max or more smaller payments) process ≈2 payments max or more smaller payments)
- 10% local balance => set max_htlc to 0.01 of channel capacity (small payments - 10% local balance => set max_htlc to 0.01 of channel capacity (small payments
@ -306,6 +305,7 @@ accept contributions and suggestions though! For now I implemented almost
everything I needed, maybe except a couple of timeouts being configurable. But I everything I needed, maybe except a couple of timeouts being configurable. But I
don't see much need for that as of now. The main goals and motivation for this don't see much need for that as of now. The main goals and motivation for this
project were: project were:
- make it reliable and robust so I don't have to babysit it (stop/restart if it - make it reliable and robust so I don't have to babysit it (stop/restart if it
hangs, crashes or gives up early) hangs, crashes or gives up early)
- make it fast and lightweight, don't stress `lnd` too much as it all should run - make it fast and lightweight, don't stress `lnd` too much as it all should run

@ -64,6 +64,10 @@ func (r *regolancer) getChannelCandidates(fromPerc, toPerc, amount int64) error
for _, c := range r.channels { for _, c := range r.channels {
if params.ExcludeChannelAge != 0 && uint64(r.blockHeight)-getChannelAge(c.ChanId) < params.ExcludeChannelAge {
continue
}
if _, ok := r.excludeBoth[c.ChanId]; ok { if _, ok := r.excludeBoth[c.ChanId]; ok {
continue continue
} }
@ -200,6 +204,12 @@ func parseScid(chanId string) int64 {
} }
func getChannelAge(chanId uint64) uint64 {
shortChanId := lnwire.NewShortChanIDFromInt(chanId)
return uint64(shortChanId.BlockHeight)
}
func (r *regolancer) getChannelForPeer(ctx context.Context, node []byte) []*lnrpc.Channel { func (r *regolancer) getChannelForPeer(ctx context.Context, node []byte) []*lnrpc.Channel {
channels, err := r.lnClient.ListChannels(ctx, &lnrpc.ListChannelsRequest{ActiveOnly: true, PublicOnly: true, Peer: node}) channels, err := r.lnClient.ListChannels(ctx, &lnrpc.ListChannelsRequest{ActiveOnly: true, PublicOnly: true, Peer: node})

@ -79,6 +79,9 @@ func (r *regolancer) info(ctx context.Context) error {
} }
} }
fmt.Println() fmt.Println()
if params.ExcludeChannelAge != 0 {
fmt.Printf("Channel age needs to be >= %s blocks\n", hiWhiteColor(params.ExcludeChannelAge))
}
fmt.Printf("Fail tolerance: %s ppm\n", formatAmt(int64(params.FailTolerance))) fmt.Printf("Fail tolerance: %s ppm\n", formatAmt(int64(params.FailTolerance)))
printBooleanOption("Rapid rebalance", params.AllowRapidRebalance) printBooleanOption("Rapid rebalance", params.AllowRapidRebalance)
printBooleanOption("Lost profit accounting", params.LostProfit) printBooleanOption("Lost profit accounting", params.LostProfit)

@ -45,6 +45,7 @@ type configParams struct {
ExcludeChannels []string `short:"e" long:"exclude-channel" description:"(DEPRECATED) don't use this channel at all (can be specified multiple times)" json:"exclude_channels" toml:"exclude_channels"` ExcludeChannels []string `short:"e" long:"exclude-channel" description:"(DEPRECATED) don't use this channel at all (can be specified multiple times)" json:"exclude_channels" toml:"exclude_channels"`
ExcludeNodes []string `short:"d" long:"exclude-node" description:"(DEPRECATED) don't use this node for routing (can be specified multiple times)" json:"exclude_nodes" toml:"exclude_nodes"` ExcludeNodes []string `short:"d" long:"exclude-node" description:"(DEPRECATED) don't use this node for routing (can be specified multiple times)" json:"exclude_nodes" toml:"exclude_nodes"`
Exclude []string `long:"exclude" description:"don't use this node or your channel for routing (can be specified multiple times)" json:"exclude" toml:"exclude"` Exclude []string `long:"exclude" description:"don't use this node or your channel for routing (can be specified multiple times)" json:"exclude" toml:"exclude"`
ExcludeChannelAge uint64 `long:"exclude-channel-age" description:"don't use channels opened less than this number of blocks ago" json:"exclude_channel_age" toml:"exclude_channel_age"`
To []string `long:"to" description:"try only this channel or node as target (should satisfy other constraints too; can be specified multiple times)" json:"to" toml:"to"` To []string `long:"to" description:"try only this channel or node as target (should satisfy other constraints too; can be specified multiple times)" json:"to" toml:"to"`
From []string `long:"from" description:"try only this channel or node as source (should satisfy other constraints too; can be specified multiple times)" json:"from" toml:"from"` From []string `long:"from" description:"try only this channel or node as source (should satisfy other constraints too; can be specified multiple times)" json:"from" toml:"from"`
FailTolerance int64 `long:"fail-tolerance" description:"a payment that differs from the prior attempt by this ppm will be cancelled" json:"fail_tolerance" toml:"fail_tolerance"` FailTolerance int64 `long:"fail-tolerance" description:"a payment that differs from the prior attempt by this ppm will be cancelled" json:"fail_tolerance" toml:"fail_tolerance"`
@ -83,6 +84,7 @@ type regolancer struct {
lnClient lnrpc.LightningClient lnClient lnrpc.LightningClient
routerClient routerrpc.RouterClient routerClient routerrpc.RouterClient
myPK string myPK string
blockHeight uint32
channels []*lnrpc.Channel channels []*lnrpc.Channel
fromChannels []*lnrpc.Channel fromChannels []*lnrpc.Channel
fromChannelId map[uint64]struct{} fromChannelId map[uint64]struct{}
@ -104,7 +106,10 @@ type regolancer struct {
} }
func loadConfig() { func loadConfig() {
flags.NewParser(&cfgParams, flags.None).Parse() _, err := flags.NewParser(&cfgParams, flags.None).Parse()
if err != nil {
log.Fatalf("Error when parsing command line options: %s", err)
}
if cfgParams.Config == "" { if cfgParams.Config == "" {
return return
@ -318,6 +323,7 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
r.myPK = info.IdentityPubkey r.myPK = info.IdentityPubkey
r.blockHeight = info.BlockHeight
err = r.getChannels(infoCtx) err = r.getChannels(infoCtx)
if err != nil { if err != nil {
log.Fatal("Error listing own channels: ", err) log.Fatal("Error listing own channels: ", err)

Loading…
Cancel
Save