Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions smite-scenarios/src/executor/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::executor::*;
use bitcoin::{Amount, Transaction};
use smite::bolt::{AcceptChannelTlvs, ChannelTypeVariant, FromMessage};
use smite::bolt::{AcceptChannelTlvs, ChannelTypeVariant, FromMessage, REGTEST_CHAIN_HASH};
use std::collections::VecDeque;
use std::str::FromStr;

Expand Down Expand Up @@ -254,7 +254,7 @@ pub fn sample_pubkey(byte: u8) -> PublicKey {
pub fn sample_context() -> ProgramContext {
ProgramContext {
target_pubkey: sample_pubkey(1),
chain_hash: [0xcc; 32],
chain_hash: REGTEST_CHAIN_HASH,
block_height: 800_000,
negotiated_features: Features::from_bits(&[
Features::OPTION_STATIC_REMOTEKEY,
Expand Down Expand Up @@ -467,7 +467,7 @@ pub fn sample_funding_negotiation() -> PendingChannel {

PendingChannel {
open_channel: OpenChannel {
chain_hash: [0xcc; 32],
chain_hash: REGTEST_CHAIN_HASH,
temporary_channel_id: TemporaryChannelId::new([0xbb; 32]),
funding_satoshis: 10_000_000,
push_msat: 3_000_000_000,
Expand Down
2 changes: 1 addition & 1 deletion smite-scenarios/src/scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub use encrypted_bytes::EncryptedBytesScenario;
pub use init::InitScenario;
pub use ir::IrScenario;
pub use noise::NoiseScenario;
pub use setup::{PostInitSetup, REGTEST_CHAIN_HASH, SnapshotSetup};
pub use setup::{PostInitSetup, SnapshotSetup};
use smite::scenarios::ScenarioError;

use std::time::Duration;
Expand Down
8 changes: 1 addition & 7 deletions smite-scenarios/src/scenarios/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

use std::time::Duration;

use smite::bolt::{FeatureBit, Features, Init, InitTlvs, Message};
use smite::bolt::{FeatureBit, Features, Init, InitTlvs, Message, REGTEST_CHAIN_HASH};
use smite::noise::NoiseConnection;
use smite::scenarios::ScenarioError;

use super::{handshake_with_target, ping_pong};
use crate::executor::ProgramContext;
use crate::targets::{INITIAL_BLOCKS, Target};

/// Bitcoin regtest genesis hash (in BOLT 2 network byte order).
pub const REGTEST_CHAIN_HASH: [u8; 32] = [
0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b, 0x59, 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb, 0x5b, 0xbf,
0x28, 0xc3, 0x4f, 0x3a, 0x5e, 0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c, 0xf1, 0x88, 0x91, 0x0f,
];

const TIMEOUT: Duration = Duration::from_secs(5);

/// Pre-snapshot setup that establishes a ready-to-use connection and produces
Expand Down
18 changes: 18 additions & 0 deletions smite-scenarios/src/targets/cln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,17 @@ impl Target for ClnTarget {
/// (hardcoded 546) exceeds its own `channel_reserve_satoshis`, which
/// BOLT 2 forbids.
/// See: <https://github.com/ElementsProject/lightning/issues/9515>
///
/// - CLN accepts `open_channel` with `option_scid_alias` in `channel_type`
/// on a channel that is to be announced, which BOLT 2 forbids the opener
/// from sending.
/// See: <https://github.com/ElementsProject/lightning/issues/9444>
///
/// - CLN currently allows an unreasonably large `dust_limit_satoshis`
/// during `open_channel` negotiation, leaving too much of the channel
/// balance unenforceable on-chain. BOLT 2 allows the receiver fail the
/// channel if it considers `dust_limit_satoshis` too large. A fix is in
/// progress upstream.
fn known_violations() -> &'static [&'static [&'static str]] {
&[
&[
Expand All @@ -410,6 +421,13 @@ impl Target for ClnTarget {
"sat cannot cover anchor cost of",
],
&["invalid accept_channel: dust_limit_satoshis 546 exceeds channel_reserve_satoshis"],
&[
"accepted invalid open_channel: option_scid_alias requires the channel to be private",
],
&[
"accepted invalid open_channel: dust_limit_satoshis",
"exceeds the maximum of 10000 sat",
],
]
}
}
8 changes: 8 additions & 0 deletions smite-scenarios/src/targets/eclair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ impl Target for EclairTarget {
/// fee or fund the anchor outputs. This situation should be rejected
/// early, as required by BOLT 2.
/// See: <https://github.com/ACINQ/eclair/issues/3383>
///
/// - Eclair accepts `open_channel` with `option_scid_alias` in
/// `channel_type` on a channel that is to be announced, which BOLT 2
/// forbids the opener from sending.
/// See: <https://github.com/ACINQ/eclair/issues/3374>
fn known_violations() -> &'static [&'static [&'static str]] {
&[
&[
Expand All @@ -269,6 +274,9 @@ impl Target for EclairTarget {
"accepted invalid open_channel: opener balance",
"sat cannot cover anchor cost of",
],
&[
"accepted invalid open_channel: option_scid_alias requires the channel to be private",
],
]
}
}
13 changes: 13 additions & 0 deletions smite-scenarios/src/targets/lnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ impl Target for LndTarget {
/// a wrapping `uint64` and then tested as an `int64`, so any push above
/// roughly 2^63 wraps back into the non-negative range.
/// See: <https://github.com/lightningnetwork/lnd/pull/10765>
///
/// - LND accepts `open_channel` with an empty `channel_type`, which matches
/// none of the channel types defined in BOLT 2, and falls back to opening
/// a legacy channel.
/// See: <https://github.com/lightningnetwork/lnd/issues/11195>
///
/// - LND accepts `open_channel` with `feerate_per_kw` of 0 without
/// `zero_fee_commitments`, as it enforces no lower bound on the feerate.
/// See: <https://github.com/lightningnetwork/lnd/issues/11201>
fn known_violations() -> &'static [&'static [&'static str]] {
&[
&["accepted invalid open_channel: open_channel does not include a channel_type"],
Expand All @@ -356,6 +365,10 @@ impl Target for LndTarget {
"accepted invalid open_channel: push_msat",
"exceeds funding amount",
],
&["accepted invalid open_channel: channel_type is not a known variant"],
&[
"accepted invalid open_channel: feerate_per_kw must be non-zero without zero_fee_commitments",
],
]
}
}
8 changes: 4 additions & 4 deletions smite/src/bolt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ pub use tx_init_rbf::{TxInitRbf, TxInitRbfTlvs};
pub use tx_remove_input::TxRemoveInput;
pub use tx_remove_output::TxRemoveOutput;
pub use types::{
BigSize, CHANNEL_ID_SIZE, COMPACT_SIGNATURE_SIZE, ChannelId, ChannelTypeVariant,
MAX_MESSAGE_SIZE, PAYMENT_ONION_PACKET_SIZE, PER_COMMITMENT_SECRET_SIZE, PUBLIC_KEY_SIZE,
SHA256_HASH_SIZE, SHORT_CHANNEL_ID_SIZE, ShortChannelId, TXID_SIZE, TemporaryChannelId, Tu32,
Tu64,
BigSize, CHAIN_HASH_SIZE, CHANNEL_ID_SIZE, COMPACT_SIGNATURE_SIZE, ChannelId,
ChannelTypeVariant, MAX_MESSAGE_SIZE, PAYMENT_ONION_PACKET_SIZE, PER_COMMITMENT_SECRET_SIZE,
PUBLIC_KEY_SIZE, REGTEST_CHAIN_HASH, SHA256_HASH_SIZE, SHORT_CHANNEL_ID_SIZE, ShortChannelId,
TXID_SIZE, TemporaryChannelId, Tu32, Tu64,
};
pub use update_add_htlc::{UpdateAddHtlc, UpdateAddHtlcTlvs};
pub use update_fail_htlc::{UpdateFailHtlc, UpdateFailHtlcTlvs};
Expand Down
6 changes: 6 additions & 0 deletions smite/src/bolt/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ pub const PAYMENT_ONION_PACKET_SIZE: usize = 1366;
/// Size of a per-commitment secret in bytes.
pub const PER_COMMITMENT_SECRET_SIZE: usize = 32;

/// Bitcoin regtest genesis hash (in BOLT 2 network byte order).
pub const REGTEST_CHAIN_HASH: [u8; CHAIN_HASH_SIZE] = [
0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b, 0x59, 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb, 0x5b, 0xbf,
0x28, 0xc3, 0x4f, 0x3a, 0x5e, 0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c, 0xf1, 0x88, 0x91, 0x0f,
];

/// A 32-byte channel identifier.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash)]
pub struct ChannelId(pub [u8; CHANNEL_ID_SIZE]);
Expand Down
Loading
Loading