EXPERIMENTAL_FEATURES: enable option_anchor_outputs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-08-14 11:00:42 +09:30
parent 591e8f9663
commit cbd0be5c0e
6 changed files with 62 additions and 9 deletions

View File

@ -733,6 +733,7 @@ static struct feature_set *default_features(const tal_t *ctx)
OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES_EX),
OPTIONAL_FEATURE(OPT_STATIC_REMOTEKEY),
#if EXPERIMENTAL_FEATURES
OPTIONAL_FEATURE(OPT_ANCHOR_OUTPUTS),
OPTIONAL_FEATURE(OPT_ONION_MESSAGES),
#endif
};

View File

@ -8,7 +8,8 @@ from utils import (
DEVELOPER, only_one, wait_for, sync_blockheight, TIMEOUT,
expected_peer_features, expected_node_features,
expected_channel_features,
check_coin_moves, first_channel_id, account_balance, basic_fee
check_coin_moves, first_channel_id, account_balance, basic_fee,
EXPERIMENTAL_FEATURES
)
from bitcoin.core import CMutableTransaction, CMutableTxOut
@ -138,6 +139,7 @@ def test_bad_opening(node_factory):
l2.daemon.wait_for_log('to_self_delay 100 larger than 99')
@unittest.skipIf(EXPERIMENTAL_FEATURES, "FIXME: anchor_outputs changes numbers")
@unittest.skipIf(not DEVELOPER, "gossip without DEVELOPER=1 is slow")
@unittest.skipIf(TEST_NETWORK != 'regtest', "Fee computation and limits are network specific")
@pytest.mark.slow_test
@ -2176,8 +2178,9 @@ def test_feerate_spam(node_factory, chainparams):
# Now change feerates to something l1 can't afford.
l1.set_feerates((100000, 100000, 100000, 100000))
# It will raise as far as it can (48000)
l1.daemon.wait_for_log('Setting REMOTE feerate to 48000')
# It will raise as far as it can (48000) (30000 for option_anchor_outputs)
maxfeerate = 30000 if EXPERIMENTAL_FEATURES else 48000
l1.daemon.wait_for_log('Setting REMOTE feerate to {}'.format(maxfeerate))
l1.daemon.wait_for_log('peer_out WIRE_UPDATE_FEE')
# But it won't do it again once it's at max.

View File

@ -1537,8 +1537,13 @@ def test_feerates(node_factory):
htlc_feerate = feerates["perkw"]["htlc_resolution"]
htlc_timeout_cost = feerates["onchain_fee_estimates"]["htlc_timeout_satoshis"]
htlc_success_cost = feerates["onchain_fee_estimates"]["htlc_success_satoshis"]
assert htlc_timeout_cost == htlc_feerate * 663 // 1000
assert htlc_success_cost == htlc_feerate * 703 // 1000
if EXPERIMENTAL_FEATURES:
# option_anchor_outputs
assert htlc_timeout_cost == htlc_feerate * 666 // 1000
assert htlc_success_cost == htlc_feerate * 706 // 1000
else:
assert htlc_timeout_cost == htlc_feerate * 663 // 1000
assert htlc_success_cost == htlc_feerate * 703 // 1000
def test_logging(node_factory):
@ -1887,6 +1892,7 @@ def test_list_features_only(node_factory):
'option_basic_mpp/odd',
]
if EXPERIMENTAL_FEATURES:
expected += ['option_anchor_outputs/odd']
expected += ['option_unknown_102/odd']
assert features == expected

View File

@ -627,11 +627,30 @@ def test_sendpay_cant_afford(node_factory):
with pytest.raises(RpcError):
l1.pay(l2, 10**9 + 1)
# This is the fee, which needs to be taken into account for l1.
available = 10**9 - 32040000
# Reserve is 1%.
reserve = 10**7
# # This is how we recalc constants (v. v. slow!)
# minimum = 1
# maximum = 10**9
# while maximum - minimum > 1:
# l1, l2 = node_factory.line_graph(2, fundamount=10**6,
# opts={'feerates': (15000, 15000, 15000, 15000)})
# try:
# l1.pay(l2, (minimum + maximum) // 2)
# minimum = (minimum + maximum) // 2
# except RpcError:
# maximum = (minimum + maximum) // 2
# print("{} - {}".format(minimum, maximum))
# assert False
# This is the fee, which needs to be taken into account for l1.
if EXPERIMENTAL_FEATURES:
# option_anchor_outputs
available = 10**9 - 44700000
else:
available = 10**9 - 32040000
# Can't pay past reserve.
with pytest.raises(RpcError):
l1.pay(l2, available)

View File

@ -8,7 +8,7 @@ from utils import (
DEVELOPER, only_one, sync_blockheight, TIMEOUT, wait_for, TEST_NETWORK,
DEPRECATED_APIS, expected_peer_features, expected_node_features,
expected_channel_features, account_balance,
check_coin_moves, first_channel_id, check_coin_moves_idx
check_coin_moves, first_channel_id, check_coin_moves_idx, EXPERIMENTAL_FEATURES
)
from pyln.testing.utils import TailableProc
@ -1438,6 +1438,26 @@ def test_coin_movement_notices(node_factory, bitcoind, chainparams):
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 941045000, 'debit': 0, 'tag': 'deposit'},
]
elif EXPERIMENTAL_FEATURES:
# option_anchor_outputs
l2_l3_mvts = [
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'channel_mvt', 'credit': 0, 'debit': 100000000, 'tag': 'routed'},
{'type': 'channel_mvt', 'credit': 50000501, 'debit': 0, 'tag': 'routed'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 8430501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 941570000, 'tag': 'withdrawal'},
]
l2_wallet_mvts = [
{'type': 'chain_mvt', 'credit': 2000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 0, 'tag': 'spend_track'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 995425000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 1000000000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 4575000, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 995425000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 941570000, 'debit': 0, 'tag': 'deposit'},
]
else:
l2_l3_mvts = [
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},

View File

@ -23,6 +23,8 @@ def expected_peer_features(wumbo_channels=False, extra=[]):
if EXPERIMENTAL_FEATURES:
# OPT_ONION_MESSAGES
features += [103]
# option_anchor_outputs
features += [21]
if wumbo_channels:
features += [19]
return hex_bits(features + extra)
@ -36,6 +38,8 @@ def expected_node_features(wumbo_channels=False, extra=[]):
if EXPERIMENTAL_FEATURES:
# OPT_ONION_MESSAGES
features += [103]
# option_anchor_outputs
features += [21]
if wumbo_channels:
features += [19]
return hex_bits(features + extra)
@ -105,7 +109,7 @@ def first_channel_id(n1, n2):
def basic_fee(feerate):
if False: # FIXME-anchor
if EXPERIMENTAL_FEATURES:
# option_anchor_outputs
weight = 1124
else: