This code could benefit from some testing. It is probably best to test this via a dedicated test HSC with a longer-than-default blocktime, so it is easy to generate large ztx's that will be detected. Only a single node is needed for testing.
If you generate two ztxs with >=10 zouts for the next block, you should see a line in debug.log about "Skipping ztx". Similar for ztxs with >= 50 zins. Then you should see that skipped ztx be mined in the next block.
This code could benefit from some testing. It is probably best to test this via a dedicated test HSC with a longer-than-default blocktime, so it is easy to generate large ztx's that will be detected. Only a single node is needed for testing.
If you generate two ztxs with >=10 zouts for the next block, you should see a line in debug.log about "Skipping ztx". Similar for ztxs with >= 50 zins. Then you should see that skipped ztx be mined in the next block.
This code is inspired by
db292a49dd
with various improvements that will be documented below.
The largest improvement is that this code will defend against a spammer using shielded inputs (zins)
or shielded outputs (zouts) while the Pirate code only defends against zout spam.
We wrote a new RPC called z_getstats to study exactly what the distribution of shielded inputs (zins)
and shielded outputs (zouts) look like on HUSH mainnet. Sietch will never make a ztx that contains
more than 9 zouts and so transactions with 10 or more zouts are extremely rare. They correspond to custom
transactions created via code or CLI or mining pool payouts. We allow at most one of these per block. If
there are two, one will remain in the mempool and be mined in the subsequent block. Our code is more strict,
as Pirate will allow up to 6 of these transactions in a single block.
Transactions with many shielded inputs do occur normally when users spend many small shielded unspent outputs
(zutxos) in one transaction, but we determined that a cutoff of 50 zins is quite rare. Between blocks
14000000 and 15000000 only 27 ztxs had 50 or more zins, which is 0.03% . We allow at most one of these
per block and if there are more, they will wait to be mined in a subsequent block.
Also note that a transaction can match both criteria of having large zins and large zouts, so for instance,
if there is a transaction with 50 zins and 10 zouts, it counts towards both requirements and no other
transactions with >=50 zins or >=10 zouts will be mined in that block.
If >=200 transactions with either large zins or large zouts are broadcast to the network it will take at least
200 blocks for them to be mined and so via existing rules for ztx expiration they will expire and be removed
from the mempool, since by default all ztxs expire after 200 blocks. Since normal ztxs that match these
criteria are very rare, the only case when this might happen is during a spam attack and so the attackers
transactions expiring is another part of these defenses.
Other improvements are that we log txids of transactions with large zins or zouts and we do not support a
command line option to turn this protection off. This forces a potential attacker to compile their own custom
code if they want to subvert these protections on their own node and blocks they mine.
Similar to Pirate, these changes are not consensus changes but may be made consensus requirements
in the future.
These protections are not specific to HUSH and are enabled for all HSC's, including DragonX.
If the antispam defense, in this case against a large amount of zouts, works correctly, we should see those 6 TXs in different blocks rather than in one. The average blocktime must be 6 minutes which is much longer than in Hush or DragonX, it helps in testing to ensure the code works. For this we can use z_listunspent call to see the number of confirmations, or ./hush-cli -ac_name=ANTISPAM z_listunspent | grep rawconfirmation:
2023-09-19 18:22:23 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:27 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:27 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:32 CreateNewBlock: skipping ztx 0ceac22244a52f06d357db1ac3844be8648727f66a02c049cc50ace0386c8ded with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:32 CreateNewBlock: skipping ztx 0e82c0f9a76fac1360e6d98fa58ba0a7dacd55359046c97e9e6244de4fe725fe with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:32 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx 0e82c0f9a76fac1360e6d98fa58ba0a7dacd55359046c97e9e6244de4fe725fe with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx 0ceac22244a52f06d357db1ac3844be8648727f66a02c049cc50ace0386c8ded with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx 0ceac22244a52f06d357db1ac3844be8648727f66a02c049cc50ace0386c8ded with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:27:37 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:27:37 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:27:37 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:28:13 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:28:13 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:28:16 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
Looks good to me.
Arrakis created:
```
./hush-smart-chain -ac_name=ANTISPAM -ac_algo="equihash" -ac_halving="3500000" -ac_reward="300000000" -ac_blocktime="360" -ac_private="1" -testnode=1
```
Addresses created:
```
[
{
"address": "zs12vr9ydd9yrznmqhsmvw5wll2rd44z9cz33vyf7frq3l7ggtzpsfntrynalw3lfcf7e4fkl30e8k",
"balance": 32.10194649
},
{
"address": "zs1wun5acqsnqyzv7e00zmpl9jxu76kdx8pcy9cz0k4y4wrmp0ruc8gn0l9lf4lzaaqkxe3xvy80jd",
"balance": 25
},
{
"address": "zs1rmaurszr0y9f02v4clf00v9qxvazlk7ad6gh3tea2f9ruxwmpywpasatcv76fqp5tvcfjxnwayh",
"balance": 25
},
{
"address": "zs1gy8e0kl2e2ucwkg57rs3n3nuhxn6jhyd6l35xgqny20uk3rv8xxc92ywnp5lznsszzsdq77mgu5",
"balance": 25
},
{
"address": "zs18z2stwuzzlpcunu43k2hvtewhywa93sjgfvm8wn97sdl5ya3zyh08j3nj8yj7004gpmds2s4jdz",
"balance": 25
},
{
"address": "zs14xxp7qlrwu396nh620y0laflzqy3hcw396unmv3m7h0rrf5z040p8jt9mvanu4tdp9c6sdurw7r",
"balance": 25
}
]
```
Difficulty adjusted on block ~160, so on block 161 we sent 6 TXs with 12 zouts each:
```
./hush-cli -ac_name=ANTISPAM z_sendmany "zs12vr9ydd9yrznmqhsmvw5wll2rd44z9cz33vyf7frq3l7ggtzpsfntrynalw3lfcf7e4fkl30e8k" '[{"address": "zs1mc6pfmyrk5wt6j3qtm6z4kk2q6hyfzj0nxv8zjynqcupfljc2a63cx9nffqhurcxzj3xz2kyngh", "amount": 1},{"address": "zs146z08wewchpsh46kqqvcqtx4z368aluu4nvyhvjvg0ap8ektpyqnsxudff9fgh9v8k6dzqyx336", "amount": 1},{"address": "zs1cs2afl2jm0pzx454s9567ckcx59g73q5nlg26505upes7tajs4w58tapjtwsfpvgvezuscdreer", "amount": 1},{"address": "zs15tray9lqraamzs4v8un4xu6h8q0d8eaakl6w4qc0ay59ejmymd36j5xs46vmkr4gd822ytxz8pj", "amount": 1},{"address": "zs16zfcqy5lqe8fujn9kgc78l3q2z0kwesd00quuveu3vk8uvcxn23hgpyx2clnqytjn44qxz2lsfd", "amount": 1},{"address": "zs1g8ha0amvz2hqnmj8p022qc0jxr90n8gn9u6mw2e3qjh9t2nuts6v7rysthalh0x568myun2xw2s", "amount": 1},{"address": "zs1aunthnvfhajg726yjcyega6l22er9ec7pjxmcgvh5lc8xfe4ac90300huy3ccjsw3vw3gzx3fcz", "amount": 1},{"address": "zs1d0jq03f0jely4f038yuas6pvdf44gg89ql5cmz0n4743w32pddsa0trjkehn3j4hucuxc7yshtq", "amount": 1},{"address": "zs10ntmztecqc6um8a5gg8h639fzwmt2rpx2v6vtmgq7twsurkgfs2m3p36zd3h4jzz64gau7dkfhn", "amount": 1},{"address": "zs1fet000kkw5n2fvpwjluuac87gu3v3tsmk68r9jlrakdd4zjre9dk3x6kpwpzvkxae6gr6kp9lya", "amount": 1},{"address": "zs1gc3zrqdfmvuuun82sn0zvq7uneahwzmugmmxs99r7pznkg7y7fl4el0uhrqkv97gtup9qwmfmca", "amount": 1}]'
./hush-cli -ac_name=ANTISPAM z_sendmany "zs1wun5acqsnqyzv7e00zmpl9jxu76kdx8pcy9cz0k4y4wrmp0ruc8gn0l9lf4lzaaqkxe3xvy80jd" '[{"address": "zs1s9sakc2wpdagklss03awyyp6a3l3h2z0dx8z90jkud8w7llf5vfr0lhm4ncldtn52n6wg0dk46n", "amount": 1},{"address": "zs13z6equ9cckpvgtqmtk79uza4d7uagg8aq9798h56jjz7rsgllgkhynpnfsr0tmyutm0j2cfs6x8", "amount": 1},{"address": "zs1emg428xn5wgq3lvcf4rcrd6tvwy8zhah86m8vf8tdewv7tv863l4g86c6eev4j8p73hpylyu0v0", "amount": 1},{"address": "zs1f4ez53e97w8pdvzr83459tpucnt6l72nkz3cgncm7r6zj74e84skqu4uxf2zca23xtazj7c4fkf", "amount": 1},{"address": "zs19zdlhakqjfjkn5uzsf3475mn5u4yvk8nt2scyeg0y6zy878lw5tpne282gd6mry7kdv7yvme59q", "amount": 1},{"address": "zs1ay3kqu7ye9ejnj60gyd7r3hjwjjjcj2fz3mxkxta5ek373yzpryapuwrwuwe55wsmm62kkzvqtw", "amount": 1},{"address": "zs16x6jtwmflvcs9l77ckz8ud2yc3qvvgapk8f7k40s64lzljkkncwlau9scc96nua69mzzu4yqd6u", "amount": 1},{"address": "zs1z294xtk6ejlj82sj3qw6jxyge985n2ymfz0z0h4e22swufnrlg9rp9vxytfww6ypeus9qph5fn3", "amount": 1},{"address": "zs18ukh3fc0utqt9yzra45zaq73xmte7yzfc5qw3qa56ansf82uk3e23dj0tj45ql2cjlw7us53u4r", "amount": 1},{"address": "zs1pl5ehcddyppdssqx7m43588aaa06fh0r6r0uewmz5grchffr375s0rllfvsway0xqny9v3cpmux", "amount": 1},{"address": "zs12epu3qzs94n0z890cqzsx955rhlq42uszerx2cqtaahzqjesrjyzffuwx5lxayacha9qc9jkh2k", "amount": 1}]'
./hush-cli -ac_name=ANTISPAM z_sendmany "zs1rmaurszr0y9f02v4clf00v9qxvazlk7ad6gh3tea2f9ruxwmpywpasatcv76fqp5tvcfjxnwayh" '[{"address": "zs1x5ytjs0fcyase9j4yvcg2fu7w3e948wmkfp650pjvjyew7x0g3w03n98l6cqr85u0w0a5m4z83s", "amount": 1},{"address": "zs1rzq22lhpzy7hkyphdqxsq3zp3j0sxt46qglvqnfgf6drc9jg0e9ctwqunsmu2ppgnk8zqdr6n92", "amount": 1},{"address": "zs1txt77cncgrmyktwg6ft5ye0lwu4v6pev8xpf6aqt7c3p342lg8zl00dkq2wm0387ahj4k7hx3r9", "amount": 1},{"address": "zs1xx4x7vc5t5rp9r6zw2s4szu9n35vpdld2x35nttneth8w48z8ftnl26hpkcvqeks2xea2ee2xda", "amount": 1},{"address": "zs1f3yxp25w7tql7cplgll0wk620r4jv4v9l3k35uf5jsf8pg0uyukyu2hl2qmq6rql86ancr0nx87", "amount": 1},{"address": "zs1v2vku6vjndlpjgavxxgwgaht6lq94fxm433trkzgrr8yhu2zl08l73r9xv3dnhjd7pf5vxylgza", "amount": 1},{"address": "zs18scuckpuj8ux44vw6k59r8kmwsth8q0qjrsjn9g6sdem7nd3ykvhh6thlet3adg52kga63lcnkj", "amount": 1},{"address": "zs1x549frg2v3yqx5aatn5vpvupxyanq7sfhs3sxlqkmx5slef5lme35w2zl6h3ux5hl8nwylurqt2", "amount": 1},{"address": "zs1z5cyn04fwyr79m8p0crekqn5ln8cv27xa9c497aa87zuqqp67allqr6nd77dx5223rgu6pdlyp3", "amount": 1},{"address": "zs1uzrlpzsr2wsujwgzt3em9px5r8fz7q8f5gz2807pcud0p58g0cju6l6mngqcc33kgy2uqshgv97", "amount": 1},{"address": "zs1789vn5kraxae0qjp9c5xqz3q9nvkw50u80ryc6n4het9dpuwny7k9sup6ua5mukgdmxtc0vc63y", "amount": 1}]'
./hush-cli -ac_name=ANTISPAM z_sendmany "zs1gy8e0kl2e2ucwkg57rs3n3nuhxn6jhyd6l35xgqny20uk3rv8xxc92ywnp5lznsszzsdq77mgu5" '[{"address": "zs1pmm0dxhfavgnaq7wnfvrh7uuj4r0kuyd7dvq3d4ejf0wgymqv6l2u3pnctpmjhtxs60lxfhmvq7", "amount": 1},{"address": "zs1lkxh5q6apys5e3cjwngsp2pewjr634d284u8jh4clu5pr7s7wtdzvl5hwlhzsj6mglassjfv4ma", "amount": 1},{"address": "zs12fctuld778y7v9jgwfdfgkdtp2cjtwmv3wu8pdtnsmvkyugu8vn68ge2jfzdaurw58xcsp7mllg", "amount": 1},{"address": "zs1rpdhrdmny4tcwa2j0d68y8pkfqpm5t6jtq5d4sl4axuuq3xd5curspxt2lu34pvu0vgfg8dn3py", "amount": 1},{"address": "zs13gewhuf28c95lmqegjwfful8a0ve805q4zvhsdukpau4fl84r9ucfrn2fwfpg5uwpvvps9xyv9l", "amount": 1},{"address": "zs1t7nmycy22t74pkum2sq07mha5w5g2l0lq4292emq3nspcvtdyggy5cy6hjwur9hu7gvryyua7fh", "amount": 1},{"address": "zs1d2vxrkhqfsr8ep7pgyqa9glz944gtx7sq4d4n5gn36knscr2nmrrqfenzjjam7msumh556a732d", "amount": 1},{"address": "zs1v0k4qstacfxuhxeunajtv7pa7ha2xuasmtwczg0zgntpnage2qjhrhf393ps8sdsz6dxuuqw02a", "amount": 1},{"address": "zs1kfx2g5nepsusf9k54awuazklwjqyh4wkzf2jqkl9m3awaed07ayvadyhgtl5cgu8k28a2u80ltv", "amount": 1},{"address": "zs153a88pju2ky2h8x06pm8l5ylswx4nln2d54qm9vh7auvm282lzqj04hww493vvmp9arjjhcdt8z", "amount": 1},{"address": "zs1fzf3jtjc5k28zsgw36nt3ddlzzma6l3qcvdlw0gakr9n857x72gccdt3jumtmvcwwfxwkpc2s5x", "amount": 1}]'
./hush-cli -ac_name=ANTISPAM z_sendmany "zs18z2stwuzzlpcunu43k2hvtewhywa93sjgfvm8wn97sdl5ya3zyh08j3nj8yj7004gpmds2s4jdz" '[{"address": "zs12ky3rwl8yrj9k029n5xqzlyz620as7y620f0vjvdycudawltvzk046g04wq38lkurmkfyd2xh0s", "amount": 1},{"address": "zs1txw7xrms3jusmu43qrx3wt6dhxclxnk2kna6tq92e77hdhx6yd6kk24v932qph59x3qjupvl6va", "amount": 1},{"address": "zs1y7n8xpc9a5gjeyla276ha2kz0ck86usxr0mjwt3qyyxk2luggtdaa4dw5z9hdf42jjttzfwveu9", "amount": 1},{"address": "zs1a5y5wpxtlhqjf88c2vyyfqed6wxscqrdfaemz4a9n54wd9dn2ht3cezrjavla7grt4dsq3ypt5s", "amount": 1},{"address": "zs172hxk0cmyurdjvdpgvg7dt7zrdj66ama6yk8r3w6vez3svjamr3s9earezvqagyryx0uknulhmz", "amount": 1},{"address": "zs1x2gefjpx4pggp7mql0j7zm7q4dn3l23nlnpl40zqnh3k9prej6x50zt9smyed9attvjqcnelurq", "amount": 1},{"address": "zs1vzm22p3q2pulj5g8l8f2mcdugd79xfd2psdzws7ul95yjn20gphm4m7ve8ejhnfgn0ra6e3ckdj", "amount": 1},{"address": "zs1wndqw6t7ducp8huz3n5vpm7pvv09g6thnwemwawu2mgcdq0q5jfrslmtzayrrnls782f6yju4g5", "amount": 1},{"address": "zs190twxu89z8a3a2z4l536tz3n9wpp6vxwv7k27nnl5mvwx5f2xxq5xxggf3yya0ctccunc5tylkc", "amount": 1},{"address": "zs1u6a08wq4dem03p5s5mcax0r5xg0h9ce9vhc6wkxt3jvr79c4upxvkuz7n03ljmv2h3ec6s4vyg9", "amount": 1},{"address": "zs1zeze7mlr3gy268pa9nhhqwrau4y8vuqxu3vgdqfj8jk7p7kr5jc2phrsaytmpuzxuqtqg5h4h6j", "amount": 1}]'
./hush-cli -ac_name=ANTISPAM z_sendmany "zs14xxp7qlrwu396nh620y0laflzqy3hcw396unmv3m7h0rrf5z040p8jt9mvanu4tdp9c6sdurw7r" '[{"address": "zs1j5t4kuvyjy6d7pdzqjg2f86j8x05mjvnypmsrddrazxpn2t24smmp2hw0ldjw24cnlqx507meyd", "amount": 1},{"address": "zs1qsdf8yxxhq23zya6qrvhjkxm6gutaxd6hu66rq6wmz2jehd9tf5edxgs68mnfpfshg5cu2v5tdp", "amount": 1},{"address": "zs1vkfgcpvwn0s6ck40v8lmqz0uujxq9hlw8kssvh9utjkkwlh36ahhdqlhn6edvy3t883fujfe7j8", "amount": 1},{"address": "zs1dfn3epgpth80ccmnq407t52t265ufpy86xu86jku0hmmtlw0y6gk0pwsyx59p6vnrdmsz32yskq", "amount": 1},{"address": "zs1gprnc7stpapcz4549kla0fjv96gfgt9wl8r5542tj3pl5nwu2ak2k72lkhg734zfly8qvpm6p27", "amount": 1},{"address": "zs164h2vj8mk8w4c6xn8rthznyd2errwvc60dvf59gaf2p0kcknqm5pl5r4z8cqvj5zl2cw2j4s3ym", "amount": 1},{"address": "zs1gtwavx3y7hnddytly3h07p078kcwd2wjzkefc4afempr3w8udnxg26sha8fg27t04pljq7pn8er", "amount": 1},{"address": "zs12wlnk7awws4x8vdysfrd3v3vgs5tm7rrgzuqt2755ghkyn2n4vkxp0jj69nyq52vhm736esk9jh", "amount": 1},{"address": "zs1s6qzumh02twlqq2ng6zfnpsz0gldg9nsg3le7quxdrhj9ct37ecdz63qlkhrs5qx8xenw9v5zaz", "amount": 1},{"address": "zs10rcwlkkfr3fm6qsje2pm9dc730sfhmt6p4cgekgwfhh7g6y9kj84f3sr0x3xe00ckdfrx6vc6zu", "amount": 1},{"address": "zs18n0e52epsf3jep92qtmd6mqjvrgfwp0fup8qsup9lulce8sjffgrs8xhjn6u8szgxtcly5d39y9", "amount": 1}]'
```
If the antispam defense, in this case against a large amount of zouts, works correctly, we should see those 6 TXs in different blocks rather than in one. The average blocktime must be 6 minutes which is much longer than in Hush or DragonX, it helps in testing to ensure the code works. For this we can use `z_listunspent` call to see the number of confirmations, or `./hush-cli -ac_name=ANTISPAM z_listunspent | grep rawconfirmation`:
```
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 7,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 8,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 11,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 10,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 9,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
"rawconfirmations": 12,
```
Debug logs:
```
2023-09-19 18:22:23 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:27 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:27 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:32 CreateNewBlock: skipping ztx 0ceac22244a52f06d357db1ac3844be8648727f66a02c049cc50ace0386c8ded with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:32 CreateNewBlock: skipping ztx 0e82c0f9a76fac1360e6d98fa58ba0a7dacd55359046c97e9e6244de4fe725fe with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:32 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:36 CreateNewBlock: skipping ztx 0e82c0f9a76fac1360e6d98fa58ba0a7dacd55359046c97e9e6244de4fe725fe with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx 997fe01ea153c2a33d553ea4b1b950144442757ec48f30dd6326bf50ce8388ec with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:22:41 CreateNewBlock: skipping ztx 0ceac22244a52f06d357db1ac3844be8648727f66a02c049cc50ace0386c8ded with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx 0ceac22244a52f06d357db1ac3844be8648727f66a02c049cc50ace0386c8ded with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:23:22 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:27:37 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:27:37 CreateNewBlock: skipping ztx e91d39c33db050dc189b763eda064c4ce07451f2fb6caee21cda0f6c2e3ddaf5 with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:27:37 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:28:13 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:28:13 CreateNewBlock: skipping ztx 6dad830c3882622c91124d2f61f8557c19c316b7c48f0cd9d8a922fb4743d5dd with 12 zouts because there are already 1 ztxs with large zouts
2023-09-19 18:28:16 CreateNewBlock: skipping ztx a2012e0e5b74ab78944364b1aabb6883734cfd9dd0d64cf21912d3b01be5822d with 12 zouts because there are already 1 ztxs with large zouts
```
Looks good to me.
This branch also has some code which improves our automatic test suite (python qa tests) which doesn't fully work yet but is much better than it was. I believe it has undergone enough testing to merge to dev and we can improve it more in the future.
This branch also has some code which improves our automatic test suite (python qa tests) which doesn't fully work yet but is much better than it was. I believe it has undergone enough testing to merge to dev and we can improve it more in the future.
This code could benefit from some testing. It is probably best to test this via a dedicated test HSC with a longer-than-default blocktime, so it is easy to generate large ztx's that will be detected. Only a single node is needed for testing.
If you generate two ztxs with >=10 zouts for the next block, you should see a line in debug.log about "Skipping ztx". Similar for ztxs with >= 50 zins. Then you should see that skipped ztx be mined in the next block.
Arrakis created:
Addresses created:
Difficulty adjusted on block ~160, so on block 161 we sent 6 TXs with 12 zouts each:
If the antispam defense, in this case against a large amount of zouts, works correctly, we should see those 6 TXs in different blocks rather than in one. The average blocktime must be 6 minutes which is much longer than in Hush or DragonX, it helps in testing to ensure the code works. For this we can use
z_listunspent
call to see the number of confirmations, or./hush-cli -ac_name=ANTISPAM z_listunspent | grep rawconfirmation
:Debug logs:
Looks good to me.
This branch also has some code which improves our automatic test suite (python qa tests) which doesn't fully work yet but is much better than it was. I believe it has undergone enough testing to merge to dev and we can improve it more in the future.
38699a7d47
into dev 7 months ago38699a7d47
.