-
Notifications
You must be signed in to change notification settings - Fork 20
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
ANV Computation #52
ANV Computation #52
Conversation
This version constructs a discrete distribution using the ANVs of the wallets and uses Inverse Transform Sampling to sample from the distribution. A WalletSelected can return N winners by sampling the distribution based on the input hash. The sampling is deterministic and returns the same winners given an input hash. This version samples in memory.
This is solid. I like the flow, generally speaking. It all makes sense. Couple thoughts on my mind, in no specific order:
tl;dr is that this is the right direction. All my open questions will be answered as we continue to implement. |
WIP, this commit does not compile
refdb compiles now. Onward to referrals.
Now we have a tree structure in multiple ways. Next is to add a aggregated ANV tree.
We need to cache ANV so that getting an ANV for a particular key is O(logn) time. Updates also cost O(logn).
1. Renamed wallet to key. 2. Moved KeyANV to anv.h 3. Created Stub function to get all ANVs.
Added a function to ReferralsViewDB to get all ANVs into memory. The vector of KeyANVs is used by the selection algorithm to choose N winners. In the future we should store a heap on disk of KeyANVs and change the selection algorithm to use the disk instead. Alternatively we can store a heap as an mmap file and change the selection algorithm to index using pointer arithmatic.
Iterates through all the activities in the block and debit/credits the key's ANV.
Updating ANV caching code to not rely on addressIndex array. Instead we compute the credits and debits in IndexReferralsAndUpdateANV
Pairing with Max. This is solid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go.
samples.push_back(sampled); | ||
} | ||
|
||
return samples; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my C++ learning, since this method is defined on std::vector<WalletAnv>
, if we call it on that vector, will we mutate it to get back the trimmed vector? Or do we get back a new vector? Trying to understand where the return goes.
src/pog/anv.cpp
Outdated
* wallet_id specified and aggregating each child's ANV. | ||
* | ||
* This is the naive version that computes whole tree every time. We need an | ||
* accumulated version instead where ANV is cached and gets updated for every |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree on the accumulated version. With that said, I think the naive version is fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a crazy thought the other day around actually just computing ANV diffs when blocks get mined. Basically, any txn is an opportunity to crawl up the tree and understand whose ANV went up and whose went down.
In theory, if no new users are added to the network, ANV is a zero sum game.
src/pog/anv.cpp
Outdated
|
||
auto children = GetReferredIds(wallet_id); | ||
for(const auto& child: children) | ||
wallets.push(child); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice thing about this is that this list can be operated against in a flattened way, like you are doing here. Keeps things simple (and impossible to game.)
src/pog/anv.cpp
Outdated
namespace pog | ||
{ | ||
using wallet_stack = std::stack<uint256>; | ||
using wallet_ids = std::vector<uint256>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this represent? All wallet IDs? Or any vector of wallet IDs? Something else?
src/pog/select.cpp
Outdated
{ | ||
assert(m_inverted.empty() == false); | ||
|
||
//TODO: Should we loop over whole hash? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we gain if we do?
Prototype PoG mining.
This PR specifically targets prototyping algorithm and getting ANV to work with actual referrals.
#29