2019-09-22 11:37:43 +09:30
|
|
|
#ifndef LIGHTNING_COMMON_GOSSIP_CONSTANTS_H
|
|
|
|
#define LIGHTNING_COMMON_GOSSIP_CONSTANTS_H
|
|
|
|
#include "config.h"
|
2019-09-18 10:35:05 +09:30
|
|
|
#include <common/utils.h>
|
2018-05-17 14:38:11 +09:30
|
|
|
|
2023-04-07 16:06:14 +09:30
|
|
|
/* FIXME: This is a legacy concept, which should be eliminated now we have
|
|
|
|
* only onion tlv payloads. */
|
2018-05-17 14:38:11 +09:30
|
|
|
#define ROUTING_MAX_HOPS 20
|
|
|
|
|
2024-03-18 13:31:06 +10:30
|
|
|
/* BOLT #7:
|
2018-05-17 14:38:11 +09:30
|
|
|
*
|
2019-09-22 11:37:43 +09:30
|
|
|
* The `channel_flags` bitfield...individual bits:
|
2018-05-17 14:38:11 +09:30
|
|
|
*...
|
|
|
|
* | 0 | `direction` | Direction this update refers to. |
|
|
|
|
* | 1 | `disable` | Disable the channel. |
|
|
|
|
*/
|
|
|
|
#define ROUTING_FLAGS_DIRECTION (1 << 0)
|
|
|
|
#define ROUTING_FLAGS_DISABLED (1 << 1)
|
|
|
|
|
2018-09-21 17:34:03 -07:00
|
|
|
/* BOLT #7:
|
|
|
|
*
|
2022-09-14 13:20:31 +09:30
|
|
|
* The `message_flags` bitfield is used to provide additional details about the message:
|
|
|
|
* | Bit Position | Name |
|
|
|
|
* | ------------- | ---------------|
|
|
|
|
* | 0 | `must_be_one` |
|
|
|
|
* | 1 | `dont_forward` |
|
2018-09-21 17:34:03 -07:00
|
|
|
*/
|
2022-09-14 13:20:31 +09:30
|
|
|
/* FIXME: This is the old name */
|
2018-09-21 17:34:03 -07:00
|
|
|
#define ROUTING_OPT_HTLC_MAX_MSAT (1 << 0)
|
2022-09-14 13:20:31 +09:30
|
|
|
#define ROUTING_OPT_DONT_FORWARD (1 << 1)
|
2018-09-21 17:34:03 -07:00
|
|
|
|
2018-05-17 14:38:11 +09:30
|
|
|
/* BOLT #7:
|
|
|
|
*
|
2022-09-10 11:40:31 +09:30
|
|
|
* - MUST NOT send `announcement_signatures` messages until `channel_ready`
|
2019-09-22 11:37:43 +09:30
|
|
|
* has been sent and received AND the funding transaction has at least six
|
|
|
|
* confirmations.
|
2018-05-17 14:38:11 +09:30
|
|
|
*/
|
|
|
|
#define ANNOUNCE_MIN_DEPTH 6
|
|
|
|
|
2024-07-09 22:45:29 +09:30
|
|
|
/* BOLT #7:
|
|
|
|
*
|
|
|
|
* `query_option_flags` is a bitfield represented as a minimally-encoded bigsize.
|
|
|
|
* Bits have the following meaning:
|
|
|
|
*
|
|
|
|
* | Bit Position | Meaning |
|
|
|
|
* | ------------- | ----------------------- |
|
|
|
|
* | 0 | Sender wants timestamps |
|
|
|
|
* | 1 | Sender wants checksums |
|
|
|
|
*/
|
|
|
|
enum query_option_flags {
|
|
|
|
QUERY_ADD_TIMESTAMPS = 0x1,
|
|
|
|
QUERY_ADD_CHECKSUMS = 0x2,
|
|
|
|
};
|
|
|
|
|
2023-09-21 15:06:27 +09:30
|
|
|
/* Gossip timing constants. These can be overridden using --developer
|
|
|
|
* with --dev-fast-gossip */
|
2019-09-18 10:35:05 +09:30
|
|
|
#define DEV_FAST_GOSSIP(dev_fast_gossip_flag, fast, normal) \
|
2023-09-21 15:06:27 +09:30
|
|
|
((dev_fast_gossip_flag) ? (fast) : (normal))
|
2019-09-18 10:35:05 +09:30
|
|
|
|
|
|
|
/* How close we can generate gossip msgs (5 minutes) */
|
|
|
|
#define GOSSIP_MIN_INTERVAL(dev_fast_gossip_flag) \
|
|
|
|
DEV_FAST_GOSSIP(dev_fast_gossip_flag, 5, 300)
|
|
|
|
|
2021-05-28 11:32:08 -05:00
|
|
|
/* How long to wait at start for the plugin to callback with liquidity ad */
|
|
|
|
#define GOSSIP_NANN_STARTUP_DELAY(dev_fast_gossip_flag) \
|
|
|
|
DEV_FAST_GOSSIP(dev_fast_gossip_flag, 8, 60)
|
|
|
|
|
2019-09-18 10:35:05 +09:30
|
|
|
/* BOLT #7:
|
|
|
|
*
|
|
|
|
* - SHOULD flush outgoing gossip messages once every 60 seconds,
|
|
|
|
* independently of the arrival times of the messages.
|
|
|
|
*/
|
|
|
|
#define GOSSIP_FLUSH_INTERVAL(dev_fast_gossip_flag) \
|
|
|
|
DEV_FAST_GOSSIP(dev_fast_gossip_flag, 1, 60)
|
|
|
|
|
|
|
|
/* BOLT #7:
|
|
|
|
*
|
|
|
|
* A node:
|
2022-09-14 12:16:34 +09:30
|
|
|
* - if the `timestamp` of the latest `channel_update` in
|
|
|
|
* either direction is older than two weeks (1209600 seconds):
|
2019-09-18 10:35:05 +09:30
|
|
|
* - MAY prune the channel.
|
|
|
|
* - MAY ignore the channel.
|
|
|
|
*/
|
2019-09-26 11:30:20 +09:30
|
|
|
#define GOSSIP_PRUNE_INTERVAL(dev_fast_gossip_prune_flag) \
|
pytest: fix flake in test_gossip_pruning
We actually pruned before we got all the channels. Extend the pruning time,
which unfortunately makes the test slower.
```
2024-11-18T02:13:11.7013278Z node_factory = <pyln.testing.utils.NodeFactory object at 0x7ff72969e820>
2024-11-18T02:13:11.7014386Z bitcoind = <pyln.testing.utils.BitcoinD object at 0x7ff72968fe20>
2024-11-18T02:13:11.7014996Z
2024-11-18T02:13:11.7015271Z def test_gossip_pruning(node_factory, bitcoind):
2024-11-18T02:13:11.7016222Z """ Create channel and see it being updated in time before pruning
2024-11-18T02:13:11.7017037Z """
2024-11-18T02:13:11.7017871Z l1, l2, l3 = node_factory.get_nodes(3, opts={'dev-fast-gossip-prune': None,
2024-11-18T02:13:11.7018971Z 'allow_bad_gossip': True})
2024-11-18T02:13:11.7019634Z
2024-11-18T02:13:11.7020236Z l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2024-11-18T02:13:11.7021153Z l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
2024-11-18T02:13:11.7021806Z
2024-11-18T02:13:11.7022226Z scid1, _ = l1.fundchannel(l2, 10**6)
2024-11-18T02:13:11.7022886Z scid2, _ = l2.fundchannel(l3, 10**6)
2024-11-18T02:13:11.7023458Z
2024-11-18T02:13:11.7023907Z mine_funding_to_announce(bitcoind, [l1, l2, l3])
2024-11-18T02:13:11.7025183Z l1_initial_cupdate_timestamp = only_one(l1.rpc.listchannels(source=l1.info['id'])['channels'])['last_update']
2024-11-18T02:13:11.7026179Z
2024-11-18T02:13:11.7027358Z # Get timestamps of initial updates, so we can ensure they change.
2024-11-18T02:13:11.7028171Z # Channels should be activated locally
2024-11-18T02:13:11.7029326Z > wait_for(lambda: [c['active'] for c in l1.rpc.listchannels()['channels']] == [True] * 4)
```
We can see in logs, it actually started pruning already:
```
2024-11-18T02:13:11.9622477Z lightningd-1 2024-11-18T01:52:03.570Z DEBUG gossipd: Pruning channel 105x1x0 from network view (ages 1731894723 and 0)
```
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-11-19 15:10:21 +10:30
|
|
|
DEV_FAST_GOSSIP(dev_fast_gossip_prune_flag, 120, 1209600)
|
2019-09-18 10:35:05 +09:30
|
|
|
|
|
|
|
/* How long after seeing lockin until we announce the channel. */
|
|
|
|
#define GOSSIP_ANNOUNCE_DELAY(dev_fast_gossip_flag) \
|
|
|
|
DEV_FAST_GOSSIP(dev_fast_gossip_flag, 1, 60)
|
|
|
|
|
|
|
|
/* How long before deadline should we send refresh update? 1 day normally */
|
2019-09-26 11:30:20 +09:30
|
|
|
#define GOSSIP_BEFORE_DEADLINE(dev_fast_gossip_prune_flag) \
|
|
|
|
DEV_FAST_GOSSIP(dev_fast_gossip_prune_flag, 30, 24*60*60)
|
2019-09-18 10:35:05 +09:30
|
|
|
|
2019-09-18 10:35:10 +09:30
|
|
|
/* How many seconds per token? Normally 1 hour. */
|
|
|
|
#define GOSSIP_TOKEN_TIME(dev_fast_gossip_flag) \
|
|
|
|
DEV_FAST_GOSSIP(dev_fast_gossip_flag, 1, 3600)
|
|
|
|
|
2020-10-20 14:32:00 +10:30
|
|
|
/* This is where we keep our gossip */
|
|
|
|
#define GOSSIP_STORE_FILENAME "gossip_store"
|
|
|
|
|
2019-09-22 11:37:43 +09:30
|
|
|
#endif /* LIGHTNING_COMMON_GOSSIP_CONSTANTS_H */
|