added blockhash input to claimtrie RPC methods plus tests #189
No reviewers
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
Epic
good first issue
hacktoberfest
hard fork
help wanted
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
soft fork
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
work in progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbrycrd#189
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "add_minconf_to_rpc_try2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm marking this as WIP as I'm unsure on the approach and looking for feedback. You'll notice that
getclaimsforname
is done differently (more robustly) than the others. The others could be done like that one but not vice-versa, but I'm less sure on the consequences of that approach and the completeness of what's there.Apparently I need to add those minconf parameters to the client.cpp file for automatic CLI conversion to int. (I was testing them with unit tests rather than the CLI.)
This method existed for CClaimTrie but not for the "cache".
@ -2574,0 +2553,4 @@
else
recursiveFlattenTrie(str, it->second, nodes);
}
}
this method also existed for CClaimTrie but not for the cache; it was mostly duplicated here.
I was making this follow the pattern of
getInfoForName
.@ -27,3 +45,3 @@
{
if (fHelp || params.size() > 0)
if (fHelp || params.size() > 1)
throw std::runtime_error(
This method uses the approach of rolling back the caches to put us in a state where we were some number of blocks back. The caches are never flushed.
This particular line is not using data from the caches. It's hitting the live claimTrie itself. It appears that passing in the maxHeight would give the same result as rolling back the main trie.
In this method we are actually rolling back the real blocks -- not just the caches. We hold the locks and disconnect some number of tips and then rely on our scope-exit handler to put everything back before we leave. I think it's a horrible approach, really, but didn't see a good way to do it otherwise in the current codebase. We lock the entire system for handling this method. That's so wrong. I think Roy's approach of storing all claimtrie (nodes that have ever existed) in LevelDB is much better -- the old nodes would still be there and you could just start a search at a certain time period -- we wouldn't ever have to lock; we could run numerous calls concurrently.
There was no equivalent of
getClaimsForName
in the cache object, and it was not obvious how to achieve this method's "support" outputs using the data in the cache.What is this supposed to do? It doesn't make sense to me.
All (current) claimtrie nodes are stored in leveldb. Storing all changes over time (while nice for analysis) isn't actually that practical of a feature to have. Eeven concurrent performance on lookups isn't needed for just about anything practical (other than analysis), where I'd argue a relational DB is just as well suited, if not better. Horrible or not, all persistent state changes of a blockchain occur via connecting and disconnecting blocks.
Now is all this needed for this particular issue? I'm not sure yet, haven't thought about it enough.
After further discussion, we don't want to do any flushes in RPC calls. We need to move the getClaimsForName method to the cache object. It does already have a method to get support nodes, but it has a different name than that method on the claimtrie.
We need ability read cached claim, it makes sense when we use rollback feature.
use
getNodeForName
here?I've thinking about that, but getNodeForName fallback to base (CClaimTrie) when it's not found in cache.
I plan to standardized JSON objects names, between function they have different names which is ugly and hard to parse in a script.
claimId
txId
txn
value
presentInTrie (in claim trie)
effectiveAmount
validAtHeight
and so on, first word starts with lower letter, second word, if it presents, starts with upper. Most help does not match returned JSON object, Any other suggestions?
We need to do that as a separate pull request. That's a breaking change, whereas adding additional outputs and taking new optional inputs are not breaking changes. I agree that the current mismatches between methods are silly. Do you know where each RPC method is used in the LBRY stack? We should locate each call and write up an epic story that includes updating each method that is necessary.
I understand, you're right.
lbry.go, i think, but @shyba knows better.
Rebase to be ready for merge.
What are all these changes to getEffectiveAmoutnForClaim for? Seems like an unrelated change?
@ -32,2 +50,3 @@
"Arguments:\n"
"None\n"
"1. \"blockhash\" (string, optional) get claims in the trie\n"
" at the block specified\n"
Instead of "Block too deep to regenerate it" , how about just "Block is too deep"
@ -46,3 +68,4 @@
" \"value\" (string) the value of this claim\n"
" }\n"
" ]\n"
" }\n"
instead of "the hash of the block which is the active in the chain. If none is given, the latest block will be used", how about:
"get claims in the trie at the block specified by this block hash. If none is given, the latest active block will be used"
how about:
"get the claim trie at the block specified by this block hash. If none is given, the latest active block will be used"
how about "get the value associated with the name at the block specified by this block hash. If none is given, the latest active block will be used"
how about, "get claims for name at the block specified by this block hash. If none is given, the latest active block will be used"
I added a commit for some unit tests for the new CClaimtrieCache functions in claimtriecache_tests.cpp, by no means extensive but I think it'd be good to have some coverage on those.
https://github.com/lbryio/lbrycrd/pull/189/commits/0159a57765154ca2a09df4fc3845546eb3908a00
When I made a getEffectiveAmountForClaim in CClaimTrieCache notice it has 2 functions in here, so i just want to match them in the 2 classes. I prefer pointer to indicate it's optional or not. In plus now it has overloaded function that takes claimsForNameType if you performed getClaimsForName before to prevent double look-up. Otherwise we end-up with 4 functions
Fixed formatting on the test I added.
Also noting that this will affect calls in https://github.com/lbryio/lbryumx for lbryumx/session.py , this should be the only place where this PR will affect. I will open issue there
How will libryumx be affected? The intent was that all new parameters here were optional.
Update help strings.
@ -32,2 +50,3 @@
"Arguments:\n"
"None\n"
"1. \"blockhash\" (string, optional) get claims in the trie\n"
" at the block specified\n"
getnameproof says "Block too deep to generate proof"
I was just doing some testing by hand and seeing a problem:
Update: it looks like this is an issue of us not using the "" (aka, root) node from the cache.
Noting here that RPC command getclaimbyid does not have a blockhash argument in this PR .
I think it might be a bit involved to implement .. since we'll have to redo the getClaimById function in CClaimTrie ( it relies on leveldb and a cache, but the cache I think does not support decrementing multiple blocks at a time, just one block at at time) . We could probably open a new PR for this instead of doing this here.