How To Track Pos Mining - Purchases, Votes, And Revokes

Discussion in 'Proof-of-stake Mining' started by David, Mar 29, 2016.

  1. 2017/12/15 - Decred v1.1.2 released! → Release Notes  → Downloads
  1. David

    David Sr. Member

    Jan 22, 2016
    362
    207
    Male
    USA
    #1 David, Mar 29, 2016
    Last edited: Mar 29, 2016
    I'd like to share a method I've been using for awhile now to keep track of my PoS activity. I have this working on both Windows and Ubuntu Server with only slight variations in details between the two. This is written for any machines that are solo stake mining but I'm sure it can be adapted for those of you who use the stake pools. Let's jump in!


    The first thing we need to do is change the way you launch dcrwallet. If you're on Windows or Linux, launch your wallet with the redirect operator ">>" to send all command output into a text file. Make sure you use the double ">>" operator and not the single ">". Using the single ">" operator will overwrite your log file every time you restart dcrwallet. Using the ">>" operator will add any new output onto the end of the old file, and that is what we want. Here is an example, assuming you have config files setup (which at this point, I hope you do!):
    Code:
    Windows: dcrwallet.exe >> dcrwalletlog.txt
    Linux: ./dcrwallet >> dcrwalletlog.txt
    Go ahead and do this now, and don't forget to unlock your wallet afterwards.

    Note: Dcrwallet logs all output by default to the AppData\local\dcrwallet\logs\mainnet directory, so you can simply point mTail/tail to that file instead of creating a new one as demonstrated above.

    This is where the guide will split up by operating system, as the steps from here on out slightly vary.

    Starting mTail/tail
    Windows
    1. download mTail.
    2. Place mTail.exe into the directory with your dcrd/dcrwallet/dcrctl/dcrwalletlog.txt files.
    3. Open a new command prompt window in this directory with the above mentioned files.
    4. Start mTail with the command:
      Code:
      mTail dcrwalletlog.txt /start
    5. This command prompt window will launch mTail and tell it to start following dcrwalletlog.txt and displaying live updates. Leave this command prompt window running.
    Linux
    1. Open a new terminal window (or a new screen if you're accessing your system via SSH) and type:
      Code:
      tail -f dcrwalletlog.txt
    2. This terminal window will show you a live update of your dcrwalletlog.txt file. You can close this window if you want, but I prefer to leave it open to keep the live updates coming.

    Using mTail/tail
    Windows
    1. The default mTail colors are hideous. You can change them by clicking the hammer icon and going to the colors tab.
    2. With that out of the way, let's look at what mTail can do. If you check the "Filter" box and add a keyword in the text box immediately to the right, mTail will show you all the relevant lines that contain that keyword. You may need to increase the "Read buf (ko)" to scan your log file further back. Typing in "Voted" (capital V...case sensitive) will show you all your votes. Example:
    [​IMG]

    Linux
    1. tail does not have a nice GUI (afaik) like Windows does, but the command line is still just as powerful. You can use any search functions (grep, awk, etc). Here is how to search your log file for certain terms:
    Using grep:
    Code:
    more dcrwalletlog.txt | grep Voted | more 
    Using awk:
    Code:
     awk '/Voted/' dcrwalletlog.txt | more 
    Both will do the exact same thing. Here is a list of search parameters for you to reference (case sensitive)

    Ticket purchases: SStx
    Votes: Voted
    Revoked tickets: Revoked
    Deposits/Withdraws: Inserting

    This system can also be expanded to tracking deposits, withdraws, and any other wallet functions that output specific keywords to the log. The best part is, you will be able to see back in time with the log after a power outage, a system crash, or a long day at work when you're away from your PoS node. I personally run this sytem on Windows and a Ubuntu Server on AWS using the screen utility. Let me know your thoughts/improvements/comments!
     
  2. dave

    dave New Member

    Jan 11, 2016
    27
    10
    In windows, i have just been using notepad++ to search through the log in \AppData\Local\Dcrwallet\logs\mainnet
     
  3. drunkenmugsy

    drunkenmugsy Sr. Member
    Advocate (Reddit)

    Dec 28, 2015
    405
    218
    Male
    On linux mine goes back to block 400. Way before PoS was even enabled.

    I was actually thinking along these lines yesterday and deleted a post as I didnt have enough time to finish it. Personally I dont really care when I voted. I want to know when the funds will be back so I can stake them again! Getting a simple script or log interpreter to do that would be nice.
     
    David likes this.
  4. David

    David Sr. Member

    Jan 22, 2016
    362
    207
    Male
    USA
    I made this post very quickly and forgot to realize I re-imported my wallet and started with a fresh copy of the blockchain. I found the default logs I backed up in another folder prior to reimporting, so the wallet log file is totally fine! Thanks!

    I was actually also working on a spreadsheet to automatically sort and perform all kinds of calculations and analysis on my transaction history with a simple copy and paste of the log, but it sorta fell off the radar.
     
  5. drunkenmugsy

    drunkenmugsy Sr. Member
    Advocate (Reddit)

    Dec 28, 2015
    405
    218
    Male
    Yes I think a lot of us use the getstakeinfo. It is quite useful. What I am talking about is the DCR 'in flight'. When I vote i get the reward next block, easy enough. But is it 8dcr I staked or 13dcr or ? When is it going to show in spendable so I can stake it again? If you have one vote incoming it is pretty easy to track. If you have several incoming per day you have less than easy numbers to count coins in flight.
     
  6. root

    root Member

    Feb 3, 2016
    381
    76
    Noah likes this.
  7. drunkenmugsy

    drunkenmugsy Sr. Member
    Advocate (Reddit)

    Dec 28, 2015
    405
    218
    Male
    Sure you do. It would take some effort but I think you would be able to track it all via the block chain. Just a thought...
     
  8. brencelj

    brencelj New Member

    Jan 10, 2016
    49
    17
    Well I think this is quite similar to my "report" script but you just type what you want to see and you get a bit more information from leaving it alone. Otherwise I think it is useful for windows user since my script is just for Linux user. :)
     
  9. karamble

    karamble Member
    Developer

    Feb 19, 2016
    57
    71
    Code:
    cat dcrwallet.log | grep -a Voted  | cut -d "(" -f2 | cut -d ")" -f1 | sed -e 's/height / /g' | tr -d "\n" |{
      read line;
      for i in $line; do
      payblock="$((i +256))";
      if [ $payblock -gt $blockcount ]; then
      echo -n "$payblock ";
      fi
      done;
      echo
    }
     
  10. root

    root Member

    Feb 3, 2016
    381
    76
  11. jyap

    jyap New Member

    Feb 18, 2016
    27
    18
    Parsing the log file will come up with some errors, mostly to do with orphaned blocks that you have voted on. The ticket then goes back in the pool so there can be some double counting.

    I've been looking to write a utility. It would work like this.

    Gather all Tx's
    listtransactions - Gather all txid's. Gather more details such as block hash and block number.

    Process raw TX's
    Check if it was a OP_SSTX (note fee).
    Check if it was a OP_SSGEN (note current stake reward) with x confirmations.

    I'll probably post the final product as open source on Github for others to use. But basically it will be accurate rather than relying on the log file.
     
    sambiohazard likes this.
  12. sambiohazard

    sambiohazard Sr. Member

    Jan 21, 2016
    844
    372
  13. maxfunky

    maxfunky New Member

    Feb 9, 2016
    7
    0
    Male
    I always start my dcrwallet with a bat file :
    dcrwallet --username ... --password ... --dcrdusername= ... --dcrdpassword= ... --walletpass ... --enablestakemining --balancetomaintain=0.0 --ticketmaxprice=12.0

    What mod I need to do for mtail to work ?
     
  14. David

    David Sr. Member

    Jan 22, 2016
    362
    207
    Male
    USA
    You can start mtail with a batch file too. It would work like this.

    Start_mtail.bat:
    Code:
    mtail C:\Users\YOURUSERNAME\AppData\Local\Dcrwallet\logs\mainnet\dcrwallet.log /start
    And of course, mtail will have to be in the same directory as the mtail batch file, unless you add mtail to your path environment variable.
     
  15. maxfunky

    maxfunky New Member

    Feb 9, 2016
    7
    0
    Male
    Tanks!
     

Share This Page