Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.11 fixes #30

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a573d20
update submodules to fix lint
zoedberg Jan 13, 2025
eb58209
change tapret_wlt_receiving_opret in parametrized test
zoedberg Dec 4, 2024
2ce2441
remove support for alt layers
zoedberg Dec 4, 2024
dd79a45
make contract commit to a close method
zoedberg Dec 4, 2024
458feab
handle RGB reorgs
zoedberg Jan 7, 2025
c6ff9c2
fix validation: detect double spend
zoedberg Jan 11, 2025
046c664
fix same blinded transfer twice
zoedberg Jan 11, 2025
4fbce1b
add altered submodules to show double spend fix works
zoedberg Jan 14, 2025
1de8d74
udpate bp-core based on review
zoedberg Jan 16, 2025
a2b4f81
update after bp-std review
zoedberg Jan 16, 2025
d2e60b8
update after rgb-core review
zoedberg Jan 16, 2025
1d07b5d
use altered submodule branch from RGB-WG
zoedberg Jan 17, 2025
5fa4db1
update rgb-schemata based on review
zoedberg Jan 17, 2025
1d6f84b
remove pedersen commitments
zoedberg Jan 17, 2025
678a59d
add WitnessOrd::Ignored
zoedberg Jan 21, 2025
5d22984
update esplora with upstream
zoedberg Jan 23, 2025
876fed1
update rgb-std submodule (add layer1 to ContractInfo)
zoedberg Jan 24, 2025
af54236
remove XChain
zoedberg Jan 23, 2025
006bdf1
unified seals
zoedberg Jan 24, 2025
d6148e4
fix start_services.sh: always try to stop esplora
zoedberg Jan 29, 2025
ed28cc3
chain net in genesis + resolver check
zoedberg Jan 30, 2025
9500c15
allow sync on mainnet after esplora fix
zoedberg Feb 5, 2025
d7025f8
add sync_from_scratch
zoedberg Feb 5, 2025
b765461
remove useless conversion to GenesisSeal
zoedberg Feb 10, 2025
e9bb235
update docker services version
zoedberg Feb 10, 2025
aab00a2
remove bp-std dep from rgb-core
zoedberg Feb 12, 2025
28777df
improve issue_on_different_layers after bp-std udpate
zoedberg Feb 12, 2025
187be15
update bp-(core|std) to 0.11.1-alpha.1 + patches
zoedberg Feb 12, 2025
b707cc4
rename add_terminals to add_consignment_txes
zoedberg Feb 13, 2025
8711b35
fix coverage.sh for CI
zoedberg Feb 13, 2025
3db2fca
remove concealed states
zoedberg Feb 14, 2025
5b723f0
update bp/rgb deps to 0.11.1-alpha.1
zoedberg Feb 19, 2025
98dcd84
avoid address reuse
zoedberg Feb 26, 2025
811e9dd
remove blank_tapret_opret test (became useless after unified seals)
zoedberg Feb 26, 2025
ed9375c
add tapret_opret_same_utxo test
zoedberg Feb 26, 2025
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
Prev Previous commit
Next Next commit
add WitnessOrd::Ignored
  • Loading branch information
zoedberg committed Feb 19, 2025
commit 678a59d4e1ce553962f527ab5354e75738b0333c
2 changes: 1 addition & 1 deletion rgb
Submodule rgb updated 1 files
+1 −1 cli/src/args.rs
2 changes: 1 addition & 1 deletion rgb-core
110 changes: 90 additions & 20 deletions tests/transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ fn accept_0conf() {
#[cfg(not(feature = "altered"))]
#[rstest]
#[case(false)]
#[ignore = "fix needed"] // https://github.com/RGB-WG/rgb-std/issues/292
#[case(true)]
fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
initialize();
Expand All @@ -745,21 +744,39 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
let wlt_2 = get_wallet(&DescriptorType::Wpkh);
let pre_funding_height = get_height();

let utxo = wlt_1.get_utxo(Some(10_000));
let (contract_id, iface_type_name) = wlt_1.issue_nia(600, wlt_1.close_method(), Some(&utxo));
let utxo_1 = wlt_1.get_utxo(Some(10_000));
let utxo_2 = wlt_1.get_utxo(Some(20_000));
let amounts = vec![600, 600];
let outpoints = vec![Some(utxo_1), Some(utxo_2)];
let asset_info = AssetInfo::default_nia(amounts.clone());
let (contract_id, iface_type_name) =
wlt_1.issue_with_info(asset_info, wlt_1.close_method(), outpoints);

struct LNFasciaResolver {}
impl ResolveWitness for LNFasciaResolver {
fn resolve_pub_witness(&self, _: XWitnessId) -> Result<XWitnessTx, WitnessResolverError> {
unreachable!()
}
fn resolve_pub_witness_ord(
&self,
_: XWitnessId,
) -> Result<WitnessOrd, WitnessResolverError> {
Ok(WitnessOrd::Ignored)
}
}

println!("\n1. fake commitment TX (no HTLCs)");
let beneficiaries = vec![
(wlt_2.get_address(), Some(2000)),
(wlt_1.get_address(), None),
];
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None);
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo_1], beneficiaries, None);
let coloring_info = ColoringInfo {
asset_info_map: HashMap::from([(
contract_id,
AssetColoringInfo {
iface: iface_type_name.clone(),
input_outpoints: vec![utxo],
input_outpoints: vec![utxo_1],
output_map: HashMap::from([(0, 100), (1, 500)]),
static_blinding: Some(666),
},
Expand All @@ -768,7 +785,7 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
nonce: Some(u64::MAX - 1),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info.clone());
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

let htlc_vout = 2;
Expand All @@ -785,13 +802,13 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
(wlt_1.get_address(), None),
(htlc_derived_addr.addr, Some(htlc_btc_amt)),
];
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None);
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo_1], beneficiaries, None);
let coloring_info = ColoringInfo {
asset_info_map: HashMap::from([(
contract_id,
AssetColoringInfo {
iface: iface_type_name.clone(),
input_outpoints: vec![utxo],
input_outpoints: vec![utxo_1],
output_map: HashMap::from([(0, 100), (1, 300), (htlc_vout, htlc_rgb_amt)]),
static_blinding: Some(666),
},
Expand All @@ -800,7 +817,7 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
nonce: Some(u64::MAX - 1),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info);
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

if update_witnesses_before_htlc {
Expand Down Expand Up @@ -831,21 +848,21 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
nonce: Some(u64::MAX),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info);
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

println!("\n4. fake commitment TX (no HTLCs)");
let beneficiaries = vec![
(wlt_2.get_address(), Some(3000)),
(wlt_1.get_address(), None),
];
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None);
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo_1], beneficiaries, None);
let coloring_info = ColoringInfo {
asset_info_map: HashMap::from([(
contract_id,
AssetColoringInfo {
iface: iface_type_name.clone(),
input_outpoints: vec![utxo],
input_outpoints: vec![utxo_1],
output_map: HashMap::from([(0, 100), (1, 500)]),
static_blinding: Some(666),
},
Expand All @@ -854,7 +871,7 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
nonce: Some(u64::MAX - 1),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info);
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);
let mut old_psbt = psbt.clone();

Expand All @@ -865,13 +882,13 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
(wlt_1.get_address(), None),
(htlc_derived_addr.addr, Some(htlc_btc_amt)),
];
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None);
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo_1], beneficiaries, None);
let coloring_info = ColoringInfo {
asset_info_map: HashMap::from([(
contract_id,
AssetColoringInfo {
iface: iface_type_name.clone(),
input_outpoints: vec![utxo],
input_outpoints: vec![utxo_1],
output_map: HashMap::from([(0, 122), (1, 298), (htlc_vout, htlc_rgb_amt)]),
static_blinding: Some(666),
},
Expand All @@ -880,7 +897,7 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
nonce: Some(u64::MAX - 1),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info.clone());
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

if update_witnesses_before_htlc {
Expand Down Expand Up @@ -911,17 +928,43 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
nonce: Some(u64::MAX),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info);
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

// no problem: since the force-close tx will be updated to mined soon
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));

println!("\n7. broadcast old PSBT");
println!("\n7. fake commitment TX (1 HTLC) on 2nd channel");
let beneficiaries = vec![
(wlt_2.get_address(), Some(2000)),
(wlt_1.get_address(), None),
(htlc_derived_addr.addr, Some(htlc_btc_amt)),
];
let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo_2], beneficiaries, None);
let coloring_info = ColoringInfo {
asset_info_map: HashMap::from([(
contract_id,
AssetColoringInfo {
iface: iface_type_name.clone(),
input_outpoints: vec![utxo_2],
output_map: HashMap::from([(0, 100), (1, 300), (htlc_vout, htlc_rgb_amt)]),
static_blinding: Some(666),
},
)]),
static_blinding: Some(666),
nonce: Some(u64::MAX - 1),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info);
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

println!("\n8. broadcast old PSBT");
let tx = wlt_1.sign_finalize_extract(&mut old_psbt);
wlt_1.broadcast_tx(&tx);
wlt_1.mine_tx(&tx.txid(), false);
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));
let txid = tx.txid();
wlt_1.mine_tx(&txid, false);
wlt_1.sync();
wlt_1.update_witnesses(pre_funding_height, vec![XChain::Bitcoin(txid)]);
let mut wlt_3 = get_wallet(&DescriptorType::Wpkh);
wlt_1.send(
&mut wlt_3,
Expand All @@ -932,6 +975,33 @@ fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
1000,
None,
);

println!("\n9. fake HTLC TX on 2nd channel");
let witness_id = fascia.witness_id();
let txid = witness_id.as_reduced_unsafe();
let input_outpoint = Outpoint::new(*txid, htlc_vout);
let beneficiaries = vec![(wlt_1.get_address(), None)];
let (mut psbt, _meta) = wlt_1.construct_psbt_offchain(
vec![(input_outpoint, htlc_btc_amt, htlc_derived_addr.terminal)],
beneficiaries,
None,
);
let coloring_info = ColoringInfo {
asset_info_map: HashMap::from([(
contract_id,
AssetColoringInfo {
iface: iface_type_name.clone(),
input_outpoints: vec![input_outpoint],
output_map: HashMap::from([(0, htlc_rgb_amt)]),
static_blinding: Some(666),
},
)]),
static_blinding: Some(666),
nonce: Some(u64::MAX),
};
let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info);
wlt_1.consume_fascia_custom_resolver(fascia.clone(), LNFasciaResolver {});
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);
}

#[cfg(not(feature = "altered"))]
Expand Down
14 changes: 11 additions & 3 deletions tests/utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ impl TestWallet {

pub fn sync_and_update_witnesses(&mut self, after_height: Option<u32>) {
self.sync();
self.update_witnesses(after_height.unwrap_or(1));
self.update_witnesses(after_height.unwrap_or(1), vec![]);
}

pub fn switch_to_instance(&mut self, instance: u8) {
Expand Down Expand Up @@ -1643,17 +1643,25 @@ impl TestWallet {
witness_id: XChain::Bitcoin(witness_txid),
};

self.consume_fascia_custom_resolver(fascia, resolver);
}

pub fn consume_fascia_custom_resolver(
&mut self,
fascia: Fascia,
resolver: impl ResolveWitness,
) {
self.wallet
.stock_mut()
.consume_fascia(fascia, resolver)
.unwrap();
}

pub fn update_witnesses(&mut self, after_height: u32) {
pub fn update_witnesses(&mut self, after_height: u32, force_witnesses: Vec<XWitnessId>) {
let resolver = self.get_resolver();
self.wallet
.stock_mut()
.update_witnesses(resolver, after_height)
.update_witnesses(resolver, after_height, force_witnesses)
.unwrap();
}

Expand Down