Skip to content

Instantly share code, notes, and snippets.

@phm87
Last active January 9, 2021 01:22
Show Gist options
  • Save phm87/fc75d5820d232376a8256874726673b4 to your computer and use it in GitHub Desktop.
Save phm87/fc75d5820d232376a8256874726673b4 to your computer and use it in GitHub Desktop.
Test : ac_aur

ac_aur is a new experimental ac_param for smartchains/assetchains that allows to have active user reward. TAUR stands for Test Active User Reward, it is the name of the blockchain and the name of the token/coin. TAUR tokens are meant to be testcoins with no monetary value.

Please feel free to review https://github.com/KomodoPlatform/komodo/compare/master...phm87:ac_aur

ac_aur testchain AUR parameters

./komodod -ac_name=TAUR -ac_aur=1,10,2,500000000,10 -ac_supply=0 -ac_reward=800000000 -ac_blocktime=10 -ac_decay=50 -ac_halving=525000 -ac_adaptivepow=1 -addnode=91.121.217.73 -addnode=178.32.41.81 &

-ac_aur=1,10,2,500000000,10 will enable active user rewards activated at block 10, min 2 coins to earn AUR, min locktime identical to Komodo (500000000), Percentage per year of 10%

-ac_supply=0 to have no pre-mine

-ac_reward=800000000 to have 8 coins block reward

-ac_blocktime=60 to have one minute blocktime

-ac_decay=50 to reduce coin emission of 50% at each halvening

-ac_halving=525000 one halvening per year

-ac_adaptivepow=1 will enable adaptivepow (the DAA allows to mine with ASIC then mine with CPU without having stalled chain due to too long delay between blocks)

How to test ac_aur ?

Dependencies

sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl libsodium-dev

Download source and build

git clone https://github.com/phm87/komodo -b ac_aur ac_aur
cd ac_aur
./zcutil/fetch-params.sh
./zcutil/build.sh -j$(expr $(nproc) - 1)

Launch and sync TAUR

./komodod -ac_name=TAUR -ac_aur=1,10,2,500000000,10 -ac_supply=0 -ac_reward=800000000 -ac_blocktime=10 -ac_decay=50 -ac_halving=525000 -ac_adaptivepow=1 -addnode=91.121.217.73 -addnode=178.32.41.81 -addnode=5.196.76.230 & Make sure that you see the correct p2p and rpc ports and magic when the chain is starting:

>>>>>>>>>> TAUR: p2p.53646 rpc.53647 magic.051fcaee 85969646 0 coins

When the coin is synced, you can mine few blocks. It is not needed to consolidate to earn AUR because minimum amount of coins to earn AUR is 2 while block reward is 8. But if you want to consolidate, usual scripts should work. ./komodo-cli -ac_name=TAUR setgenerate true 1

TAUR : Claim active user rewards without -pubkey set

Execute getinfo and verify that the interest field contains a positive amount. ./komodo-cli -ac_name=TAUR getinfo "interest": 0.09025772, "balance": 520.02083566

Execute listunspent and verify that each utxo contains an interest field. UTXO recently mined should have 0 as interest. ./komodo-cli -ac_name=TAUR listunspent

Execute a sendtoaddress to claim AUR that will arrive on a change address then verify that your balance increased by AUR minus tx fee:

./komodo-cli -ac_name=TAUR getbalance
520.02083566
./komodo-cli -ac_name=TAUR getnewaddress
RNGiwDsSmVfED792bRrE5FTkh8Ft7fKpuh
./komodo-cli -ac_name=TAUR sendtoaddress RNGiwDsSmVfED792bRrE5FTkh8Ft7fKpuh 520.02083566 "" "" true
6ff084d243da4c7aa338e95dc231728649426bb0a668857a8b6444e7bfb002d7
./komodo-cli -ac_name=TAUR getbalance

You can also try other rpc calls to perform transactions and you can try the usual tools to consolidate or claim AUR (createrawtransaction, sendtoaddress, sendmany, listunspent, getinfo) and please feel free to compare with Komodo current behavior.

ac_aur : test of the ac_aur (not on TAUR)

If you want to test the parameter -ac_aur itself with different values, you should launch a new chain. A chain needs 2 nodes to be launched but using -testnode=1 one single node is enough to launch a chain). Please feel free to try different values of parameters of -ac_aur. You can also try to use -ac_aur with different other ac params (CC, algo, ac_private).

-ac_aur needs several parameters separated by commas: Enable/disable active user rewards (parameters: 1, activationHeight (60000), minCoins (10), LOCKTIME_THRESHOLD (500000000), percentage (5)), default is disable

Example (TAUR): -ac_aur=1,10,2,500000000,10 will enable active user rewards activated at block 10, min 2 coins to earn AUR, min locktime identical to Komodo (500000000), Percentage per year of 10%

Bugs, problems, prints to analyze, debug and hide if unecessary:

0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3205714 34 * 22 * 3 / 7
0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3394285 36 * 22 * 3 / 7
0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3488571 37 * 22 * 3 / 7
0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3582857 38 * 22 * 3 / 7
0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3677142 39 * 22 * 3 / 7
0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3771428 40 * 22 * 3 / 7
0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3865714 41 * 22 * 3 / 7
0159328000000000000000000000000000000000000000000000000000000000 ht.25676 initial W.6 outerK.3960000 42 * 22 * 3 / 7

=> the deficit log is not related to -ac_aur but it belongs to -ac_apow it could be commented into KMD and Chips:

https://github.com/phm87/komodo/blob/ac_aur/src/pow.cpp#L229

https://github.com/jl777/chips3/blob/master/src/pow.cpp#L206

checkResult 7359.78225114 += val 8.00000000 interest = 0.00017200 ht.16183 lock.1606339080 tip.1606345919
checkResult 7367.78242314 += val 8.00000000 interest = 0.00016895 ht.16197 lock.1606339252 tip.1606345919
checkResult 7375.78259209 += val 8.00000000 interest = 0.00016590 ht.16210 lock.1606339353 tip.1606345919
checkResult 7383.78275799 += val 8.00000000 interest = 0.00015680 ht.16243 lock.1606339729 tip.1606345919
checkResult 7391.78291479 += val 8.00000000 interest = 0.00015068 ht.16264 lock.1606339970 tip.1606345919
checkResult 7399.78306547 += val 8.00000000 interest = 0.00014308 ht.16287 lock.1606340243 tip.1606345919
checkResult 7407.78320855 += val 8.00000000 interest = 0.00014003 ht.16305 lock.1606340380 tip.1606345919
checkResult 7415.78334858 += val 8.00000000 interest = 0.00013242 ht.16336 lock.1606340695 tip.1606345919
checkResult 7423.78348100 += val 8.00000000 interest = 0.00013091 ht.16338 lock.1606340710 tip.1606345919
checkResult 7431.78361191 += val 8.00000000 interest = 0.00012785 ht.16356 lock.1606340842 tip.1606345919

=> The checkResult log is commented into KMD, it is uncommented in ac_aur, it will be commented back before PR to komodo upstream.

https://github.com/phm87/komodo/blob/ac_aur/src/main.cpp#L2851

  1. Possible bug (corrupted wallet ?) The wallet contains coins, the chain is not synced yet. Perform a tx to send whole balance to an address of another wallet. Wait that it is synced. => listunspent still contain utxo as if they were not spent and getinfo contains interest but no balance: "interest": 0.42975205, "balance": 0.00000000,

After few more blocks, it is OK: "interest": 0.42314048, "balance": 56.00319748,

  1. Possible bug (rpc calls to adapt ?) getinfo: "interest": 9.25988933, "balance": 752.21971998, komodo-cli -ac_name=TAUR getbalance 736.21971998

komodo-cli -ac_name=TAUR listunspent [ { "txid": "517efef7b87bf81baa5d2da3557d60f129dbafd2e6465e0b252577edbece6301", "vout": 0, "generated": true, "address": "RQqcTM2XjfU6hh7mHcmMi6mm5Bjgqo4nea", "segid": 12, "amount": 8.00000000, "interest": 0.00000000, "scriptPubKey": "2102cb429d68c3665b79a4cd50c3aab844d517f780f327313d2da78c9bb4c937cb8bac", "rawconfirmations": 3, "confirmations": 3, "spendable": true }, { "txid": "f3cc422afe06d5bd896ada657dbfaa41a465e7144e72c803f7ae5a2649ab9710", "vout": 0, "generated": true, "address": "RVnGU7VohnMA5kShoVdt3zJQ96Y5B9b8xZ", "segid": 30, "amount": 8.00000000, "interest": 0.00000000, "scriptPubKey": "2103d48f1d5fdbd4e8c5837b5612fc3864e99322770590b5b3c7775dfc99ee30c8ebac", "rawconfirmations": 2, "confirmations": 2, "spendable": true }, { "txid": "e2717e35b09c6c828755acf971ff7f56fd6ec8241cd54fa7c69a39f91578a421", "vout": 0, "generated": true, "address": "RGtFvPiazWp5Bh5f7DoLWgwzfDFQAGwxRT", "segid": 6, "amount": 8.00000000, "interest": 0.00000000, "scriptPubKey": "21036c5a0c24300b8820a16235461da94c7ff3cf1f147b2167dcb34bf212ac804a40ac", "rawconfirmations": 5, "confirmations": 5, "spendable": true }, { "txid": "dba4fa197c244853fbead3a86f2b5b2b44dda72902356df28404cadedbc9f638", "vout": 0, "generated": false, "address": "RMvhEqxcj6BVMUVVh3gvobbCCKw8U9nLuy", "segid": 29, "account": "", "amount": 704.21971998, "interest": 8.80274649, "scriptPubKey": "76a9148ab93e03403f5b1e6aa5b556d9de089700cce8f788ac", "rawconfirmations": 10847, "confirmations": 10847, "spendable": true }, { "txid": "44f936b4b6b2b7bfb38c875bb2bfefe2ed791794a3d1b0d4d57d1b5601f22280", "vout": 0, "generated": true, "address": "RLg3Z17Z33ogUsvc1Z7af9H96FMVn7SVGK", "segid": 15, "amount": 8.00000000, "interest": 0.00000000, "scriptPubKey": "2102356ae47c63043ed1762975fe9e94d8a230a140aeb693f6f9863d35a5b4f2d6dfac", "rawconfirmations": 4, "confirmations": 4, "spendable": true }, { "txid": "2c9912c8abf12b351928091f18b6cc211b0eccf56c0edc174d113ab0280e6d9c", "vout": 0, "generated": true, "address": "RXPqLmCfcfwyyJ5fntwvdRzvavRbcJ183Z", "segid": 30, "amount": 8.00000000, "interest": 0.11428571, "scriptPubKey": "21033c68a91aecbd3ad054fe1002175e17661528eeb44bd90400b5b01b1adfdff690ac", "rawconfirmations": 36962, "confirmations": 36962, "spendable": true }, { "txid": "c39a06ab9a5101d22169a345f9a7f90b6a2a36388640f4c57d686f8521c819a3", "vout": 0, "generated": true, "address": "RFexuCx5YGtz6gnLSNin3fdidQ6HozPFov", "segid": 63, "amount": 8.00000000, "interest": 0.11428571, "scriptPubKey": "2102ae7e9062bc07e9b533ce87e688dddae1f1a273929fd7e670386fd460f9a23ab9ac", "rawconfirmations": 36968, "confirmations": 36968, "spendable": true }, { "txid": "9b9cda293e4930c5ace1cd7cdb0382b15272a1d2a50e6d540ef9f8de808b35bc", "vout": 0, "generated": true, "address": "RWTFd9DHAHWrcfQbSEYWqn1Mi8sSEHjXKX", "segid": 7, "amount": 8.00000000, "interest": 0.11428571, "scriptPubKey": "210207ac419122fa3373d36a3a48b2701bd1c21e149423c551d24cb9b2aad1968463ac", "rawconfirmations": 36954, "confirmations": 36954, "spendable": true }, { "txid": "2db61867c6e4de38b42c0147f65a85037e9721c6e14e1f227be4da92ea350dcb", "vout": 0, "generated": true, "address": "RJ5uG6eMQRhfBe28xwxpWKysNw4sxbmuMB", "segid": 39, "amount": 8.00000000, "interest": 0.11428571, "scriptPubKey": "2103f2dfe568b551c48c28a73dc6f80ff78d1f8b8743d031b2422447a751743ef4e5ac", "rawconfirmations": 36981, "confirmations": 36981, "spendable": true }, { "txid": "02c8de9a4babc0ce342b3a3676d528e26452bd6385a2f5b73b28bd30b9c3fecb", "vout": 0, "generated": true, "address": "RYYum9RhYLYpL8c9DQmhWBeKb8qwAR8Kp7", "segid": 53, "amount": 8.00000000, "interest": 0.00000000, "scriptPubKey": "21033f940030d16535bcd1c2ab665214ec53ece0d1787810bbbfc8b997849117ec68ac", "rawconfirmations": 1, "confirmations": 1, "spendable": true } ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment