How to get a snapshot of eosDAC members and voters as of a specific time

in #eosdac5 years ago

Though I should be finishing up packing for my early morning flight tomorrow to Anarchapulco, I got challenged with trying to get a snapshot of all the eosDAC voters and members as of a specific time. The TelosDAC community decided to airdrop tokens on eosDAC members who voted for custodians as of 2019-02-11 at 13:00 UTC.

Because the voter status and token balances are stored in EOS RAM tables, this can be a tricky thing to do. It's not easy to now what the values were at a specific moment in time. You either have to set up a watcher to scrape through the chain looking for specific actions which might update the values you're interested in starting at a specific block for a specific account up to the block you want or you have to get a little creative. I decided to get a little creative.

First I had to find out which block number I was aiming for. I did this by just playing with block numbers until I found the right one based on the timestamp (jq is a nice command line JSON parser. Super helpful):

Looks like block 42219295 gives me what I want:

curl -s https://proxy.eosnode.tools/v1/chain/get_block -d '{"block_num_or_id":42219295}' | jq '.timestamp' 
"2019-02-11T13:00:00.000"

Next I get a snapshot from EOS Node Tools: https://eosnode.tools/snapshots

wget https://s3.wasabisys.com/eosnode.tools/snapshots/snap_2019-02-11-12-00.tar.gz
tar xvzf snap_2019-02-11-12-00.tar.gz

This is one hour before the time I want which allows me to walk into the time I'm looking for (I guess I could have just gone with the 13-00 snapshot, but what fun would that be?)

Next I start things up and sync my node:

./start.sh --snapshot "$(ls -t ./data-dir/snapshots/*.bin | head -n1)" --reversible-blocks-db-size-mb 1048 --chain-state-db-size-mb 9024 --validation-mode light --read-mode read-only --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --p2p-peer-address eu.eosdac.io:49876 --p2p-peer-address p2p.eossweden.se:9876 --p2p-peer-address node1.eosnewyork.io:6987 --p2p-peer-address peering.mainnet.eoscanada.com:9876 --p2p-peer-address seed1.eos42.io:9876 --p2p-peer-address bp.cryptolions.io:9876

This is where you have to be patient. Tailing eos.log will look like nothing is happening. Just wait a few minutes.

Next we run get info continually every 0.1 seconds in a window to watch and shut down the node as quickly as we can when we reach the LIB we want:

watch -n .1 "curl -s http://127.0.0.1:8888/v1/chain/get_info | jq '.last_irreversible_block_num'"

We have our cursor in the right window with ./stop.sh ready and we hit enter as soon as we get to the block we want.

Finally we restart our node without any peers so the LIB won't move forward:

./start.sh --reversible-blocks-db-size-mb 1048 --chain-state-db-size-mb 9024 --validation-mode light --read-mode read-only --plugin eosio::chain_api_plugin --plugin eosio::http_plugin

We can run this to see what block we got:

curl -s http://127.0.0.1:8888/v1/chain/get_info | jq '.last_irreversible_block_num'

In my case I got 42219306 which is only 5 seconds after our target and close enough for me:

curl -s https://proxy.eosnode.tools/v1/chain/get_block -d '{"block_num_or_id":42219306}' | jq '.timestamp' 
"2019-02-11T13:00:05.500"

Next we use the memberstats tools in the eosDAC github repo here: https://github.com/eosdac/DACtools/tree/master/memberstats

Just change the httpEndpoint to your local 127.0.0.1:8888 node and you'll get just what you want in members.csv and voters.csv:

And that's it!

Why is this important?

The eosDAC community has worked hard to provide these open-source DAC enabling tools for free. As a way to reward our members and voters who make this all happen, we encourage DACs who use our technology to airdrop some of their tokens on our active members. This provides a nice reward for loyal DAC supporters and also serves as some very targeted advertising for the new DAC to a community of people who already understand and love DACs. With these step-by-step instructions, anyone can now run their own snapshots of the eosDAC members pretty close to a specific timestamp or block number.

There may be easier ways to do this (if there are, please let me know in the comments!), but this at least seems to work for what we need.

Sort:  

You mean you also will be travelling to mexico also like aggroed

Oh sweet! I see his post now. Heck yeah. Yep, I get in tonight. Currently on my way in Miami.

Coin Marketplace

STEEM 0.29
TRX 0.11
JST 0.033
BTC 63901.15
ETH 3133.40
USDT 1.00
SBD 4.05