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

Fix invalid anchor resolution for seals #160

Merged
merged 1 commit into from
Jun 16, 2023
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
3 changes: 0 additions & 3 deletions src/validation/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ pub enum Warning {
ExcessiveOperation(OpId),
/// terminal witness transaction {0} is not yet mined.
TerminalWitnessNotMined(Txid),
/// anchor for operation {0} is not found in the index. This is possible an
/// internal bug of RGB Core library.
AnchorNotFound(OpId),

/// Custom warning by external services on top of RGB Core.
#[display(inner)]
Expand Down
16 changes: 9 additions & 7 deletions src/validation/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::collections::{BTreeMap, BTreeSet, VecDeque};

use bp::dbc::Anchor;
use bp::seals::txout::Witness;
use bp::seals::txout::{TxPtr, Witness};
use bp::{Tx, Txid};
use commit_verify::mpc;
use single_use_seals::SealWitness;
Expand Down Expand Up @@ -411,15 +411,17 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveTx>
continue
};

match self.anchor_index.get(&op) {
Some(anchor) => {
let seal = match (seal.txid, self.anchor_index.get(&op)) {
(TxPtr::WitnessTx, Some(anchor)) => {
let prev_witness_txid = anchor.txid;
seals.push(seal.resolve(prev_witness_txid))
seal.resolve(prev_witness_txid)
}
None => {
self.status.add_warning(Warning::AnchorNotFound(op));
(TxPtr::WitnessTx, None) => {
panic!("anchor for the operation {op} was not indexed by the validator");
}
}
(TxPtr::Txid(txid), _) => seal.resolve(txid),
};
seals.push(seal)
}

let message = mpc::Message::from(bundle_id);
Expand Down