Latest develop build incorrectly(?) handles sub qualifiers
kralverde opened this issue · 6 comments
Describe the issue
https://rvnt.cryptoscope.io/tx/?txid=39f584821bfaeb6472969f008d219d6886a9ea430ac948858530a2e252f7ba58
A restricted asset is sent to mnzcdtNKpTY7kpuaW7Th88HPnzxes3BLEd. This h160 is not qualified for the associated tag, but is qualified by the sub qualifier.
>>> address_to_h160('mnzcdtNKpTY7kpuaW7Th88HPnzxes3BLEd')
"52041e2126f9afb70f082caf28cbc0ea4568c682"
>>> send_custom_script('blockchain.asset.validator_string', '$RENEWABLOX')
{
"height": 1124545,
"qualifying_tx_pos": 3,
"restricted_tx_pos": 4,
"string": "KYCTEST",
"tx_hash": "a2791de8bfca034f9801ac3a6411d6a8302d9e08a8064abe8e83c2a206e317cc"
}
>>> send_custom_script('blockchain.asset.all_tags', '52041e2126f9afb70f082caf28cbc0ea4568c682')
{
"#KYCTEST": {
"flag": false,
"height": 1124625,
"tx_hash": "ccebd395b263817f2f1ccf6e9a76a287332b1a5ed98d7fcd29ca1970739b3540",
"tx_pos": 2
},
"#KYCTEST/#RNBX1_TEST": {
"flag": true,
"height": 1124809,
"tx_hash": "744ae2f262efdab76d2398430cd9fe5213ee06e1925d709435d684e2e5afed23",
"tx_pos": 2
}
}
On nodes running 4.7.0-test3, this is valid. On nodes running the latest develop build (7f27d35), this fails (it works occasionally after some time for some reason). The error is: ERROR: ContextualCheckVerifierString: The address mnzcdtNKpTY7kpuaW7Th88HPnzxes3BLEd failed to verify against: KYCTEST. Is null 1
.
As I understand, h160's tagged with a sub qualifier are treated as though they were tagged with the parent qualifier, correct?
It looks like fdov's test3 is the latest that is able to sync from scratch https://github.com/fdoving/Ravencoin/releases/tag/v4.7.0test3-fdov
This is causing an issue on test3 as well now... unsure of what the issue could be
edit: invalidating the best chain at block 1126000 and reconsidering fixes the issue. Could it be that data from the chain is not brought into memory in time or something?
The invalidateblock reconsiderblock spam works on all versions
It does appear to be a fast fail from the cache:
Printout: ADD 2 false #KYCTEST mnzcdtNKpTY7kpuaW7Th88HPnzxes3BLEd
From
setIterator = passets->setNewQualifierAddressToAdd.find(cachedQualifierAddress);
if (setIterator != passets->setNewQualifierAddressToAdd.end()) {
// Return true if we are adding the qualifier, and false if we are removing it
bool b = setIterator->type == QualifierType::ADD_QUALIFIER;
std::cout << "ADD 2 " << (b ? "true " : "false ") << qualifier_name << " " << address << "\n";
return b;
}
Modified from
Ravencoin/src/assets/assets.cpp
Line 4693 in 7f27d35
Returns false without checking the sub-qualifier tag for the address. It appears to me that this is accounted for later when pulling from the db which is why the reconsider works.
Actually this isn't quite correct; another sync resulted in ADD 2 true #KYCTEST mnzcdtNKpTY7kpuaW7Th88HPnzxes3BLEd
... there error must lie in how the cache is populated...
PR #1189 was written today specifically to fix this Issue
The bug is related to the use of SubQualifiers for Restricted Assets and exists in all previous versions of core which support Restricted Assets. Since it is a failure in reading cache properly, it does not occur once the cache flushes to database, making it dependent on node speed, compile types, and other things which affect timing.