RGB-WG / rgb-std

RGB standard libs for WASM & low-level integrations (no FS/networking)
https://rgb.tech
Apache License 2.0
66 stars 31 forks source link

State transition bundle to witness transaction relation ambiguity #247

Closed dr-orlovsky closed 1 month ago

dr-orlovsky commented 1 month ago

My research has shown that the assumption that each witness transaction has 1-to-1 relations with anchor and state transition bundle, used in developing Index for standard library, is invalid.

The problem comes from so-called "pay-to-witness" state transitions, which doesn't contain txid in their seal definition. This means that if one does an RBF for a pay-to-witness invoice - or use RGB in lightning channel, when RGB state is not changed (only bitcoin amount in witness transactions output), the resulting bundle for both transactions (pre-RBF or pre-channel-update - and post) will be the same. Thus, multiple witness transactions can be related to the same state transition bundle.

The situation can be "saved" by requiring RBF and LN channels to force-change bundle using "salt" values in state values. However, this is hacky and may also not always work: if a state transition defines just pay-to-witness seals and void state ("state rights"), there is no salt available to change the bundle id.

Thus, the index must be able to contain information about multiple witness transactions for any bundle id. This creates a problem during the consignment construction (of which witness transaction must be selected for the consignment), but this can be solved via newly introduces witness state information managed by the contract state object, which should be implemented as a part of Stock business logic.

Related issues: