read.cash Log in

@jtoomim

Joined 2 July 2020 · 5 posts

120 KT

0 KT · $4255.15 received · 0 KT · $135.10 given

Posts

@jtoomim

When and how to spam scalenet Most of this article will be a step-by-step guide on how to generate spam on scalenet. But before we get to that, I would like to discuss the purpose of scalenet, and what kinds of behavior are appropriate and inappropriate on scalenet. When to spam There is a right way and a wrong way to use scalenet; a path of light, and a path of darkness. The purpose of this section is to describe the straight and narrow path of light, and the mysterious path of darkness. Scalenet is intended to be a public sandbox for testing performance-related aspects of Bitcoin Cash. It is intended to be a proving ground for new technologies, a place where people can try out weird and unexpected things and make a mess of the blockchain in an attempt to stress the limits of technology. It's the Wild West of blockchains. Here are some behaviors that are considered **acceptable** on scalenet: Testing your own software that you are running to see if you can break it Testing other people's software to see if you can break it Testing your hardware to see if you can break it Testing other people's hardware to see if you can break it Seeing how quickly you can generate spam because why not Leaving that spam around for other miners to clean up Screwing around and having fun Intentionally bloating the UTXO set to tens or hundreds of gigabytes Trying out worst-case scenarios and exploiting O(n^2) vulnerabilities Attempting 51% attack shenanigans Doing CPU mining Doing ASIC mining Forking scalenet to test new protocol upgrade code Forking scalenet because you were bored Forking scalenet because there is no spoon Using bitcoin-cli to generate a million transactions because the infinite scroll of TXIDs in terminal windows with a green font makes you feel like *The Matrix* Trying to trick your boss into thinking that you're being productive when you just want to have fun Scalenet is a pretty open an permissive environment. However, there are four important guidelines that everyone ought to follow in order to make sure that scalenet works well for everyone. The following behaviors are explicitly **discouraged** on scalenet: Asking for permission to use scalenet Not using scalenet because you don't want to disturb others Staying off of scalenet because you think you're not smart enough to participate Failing to learn because you were afraid to experiment The path of light leads to places we've already been. The path of darkness leads into the unknown. We must keep our project safe from monsters; and if we are to succeed at that, we must learn how to become monsters ourselves. Stare into the abyss and explore its depths until eventually the abyss stares back at you. How to spam Method 1: Using BCHN, bitcoin-cli, and bash Download BCHN. https://bitcoincashnode.org/en/download.html Unpack and/or install BCHN. For the rest of this guide, I will assume that you are running a Linux/Unix terminal from the folder containing your BCHN binaries. Run BCHN on scalenet: ./bitcoind -daemon -scalenet -blockmaxsize=256000000 -debug=bench Optionally, **in a separate terminal window**, watch the debug.log file: tail -f ~/.bitcoin/scalenet/debug.log Get money. You can either ask someone else (e.g. me) to give you some coins, or you can try mining a block or two with https://github.com/pooler/cpuminer. To do either, you'll first need to get a scalenet tBCH address: ./bitcoin-cli -scalenet getnewaddress should return something like`bchtest:qrfeyt384f6a29aw5uf4g5cteaumup99gqx8nmwu2j` Use that address to beg for coins, or try setting up the cpuminer to mine to that address. (I might add CPU mining instructions later.) You should now have money in your wallet. Verify that you're no longer poor: `./bitcoin-cli -scalenet getunconfirmedbalance` or `getbalance` should return something like `50.00000000` Wait until it confirms and shows up in `getbalance`, then store that amount into a BASH variable: bb=$(./bitcoin-cli -scalenet getbestblockhash) while [ $(./bitcoin-cli -scalenet getbestblockhash) == $bb ]; do sleep 1; done rootamt=$(./bitcoin-cli -scalenet getbalance) These lines of BASH will run the command encapsulated in the $(), and replace the $(...) text with the output of that command. That output then gets stored into the variables `bb` and `rootamt`. Check that it worked: `echo $rootamt` should show something like `50.00000000`. Now we're going to start generating UTXOs in a fan-out process. BCH is currently limited to 50 unconfirmed transactions in a chain. In order to make more than 50 transactions per block, you will need to be able to start with more than one UTXO in your wallet at the start of each block interval. We can do this with a fan-out process using the sendmany RPC call, which generates a single transaction with multiple specified outputs. Because we're sending money from our own wallet to our own wallet, if we make multiple transactions, there's a chance that the wallet might consume the UTXOs that the previous transaction created, so we're going to be careful to decrease the amount output in each transaction each round in order to discourage the wallet coin selection code from spending more than one input per transaction. Let's craft a transaction that sends 1/100th of our rootamt to 99 different addresses which we'll generate, with the remainder going to a change address that our wallet generates: outputcnt=100 outputamt=$(echo $rootamt | awk '{printf "%0.8f", $1 / $outputcnt}') echo $outputamt # make a json dictionary of {"address":"amount", ...} pairings outputs=$(for i in $(seq 1 99); do echo "\"$(./bitcoin-cli -scalenet getnewaddress)\":\"$outputamt\", " done) outputs=${outputs%??} # trim off the last comma and space outputs={$outputs} # Make outputs a valid json dictionary # Generate the sendmany transaction ./bitcoin-cli -scalenet sendmany "" "$outputs" Wait for that transaction to confirm, then we'll do another round to multiply our number of UTXOs by 100. To save time: bb=$(./bitcoin-cli -scalenet getbestblockhash); while [ $(./bitcoin-cli -scalenet getbestblockhash) == $bb ]; do sleep 1; done; echo Block found! outputcnt=$((outputcnt * 100)) outputamt=$(echo $rootamt $outputcnt | awk '{printf "%0.8f", $1 / $2}') echo $outputamt # make a json dictionary of {"address":"amount", ...} pairings outputs=$(for i in $(seq 1 99); do echo "\"$(./bitcoin-cli -scalenet getnewaddress)\":\"$outputamt\", " done) outputs=${outputs%??} # trim off the last comma and space outputs={$outputs} # Make outputs a valid json dictionary # Generate the sendmany transactions for i in $(seq 1 $((outputcnt/100 - 1))); do echo -n "$i " ./bitcoin-cli -scalenet sendmany "" "$outputs" done You should now have 10,000 UTXOs in your wallet. If you want more, you can repeat step 9 as many times as you want. But 10k should be enough for most mortals. You are now ready to start spamming. If you want to make 1000 transactions as quickly as you can, using a freshly generated address each time, and sending 546 satoshis (the dust limit) to each address, you can use the following command: for i in $(seq 1 1000); do echo -n "$i " ./bitcoin-cli -scalenet sendtoaddress "$(./bitcoin-cli -scalenet getnewaddress)" 0.00000546 "" "" false 2 done If you wish to improve performance you can try some of the following: Make sure your wallet.dat file (usually at `~/.bitcoin/scalenet/wallet.dat`) is stored on fast media like an SSD or a ramdisk. You can use the `./bitcoind -walletdir=<path> ...` command-line option to specify where you want the wallet to go. Keep in mind that if you use a ramdisk, you will lose your wallet and many of your coins when you reboot unless you copy your wallet back to permanent storage. An HDD or SD card will likely limit you to a generation rate of about 10 tx/sec; a SSD can get you up to around 100 tx/sec, and a RAM disk (`sudo mkdir /tmpfs; sudo mount -t tmpfs -size 4G /tmpfs`) can sometimes get you past that, especially if you: Use MR !830 and compile from source, if you know how. MR !830 with a RAM disk can usually sustain around 300 tx/sec on a decent x86 CPU. https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/merge_requests/830 Reuse the same output address: address=$(./bitcoin-cli -scalenet getnewaddress) for i in $(seq 1 1000); do echo -n "$i " ./bitcoin-cli -scalenet sendtoaddress "$address" 0.00000546 "" "" false 2 done Use more computers, or run multiple nodes on the same computer to get access to multiple CPU cores. To see how your spamming is coming along, you can run `./bitcoin-cli -scalenet getmempoolinfo` or check https://sbch.loping.net/. If you've had enough, you can shut down scalenet with ./bitcoin-cli -scalenet stop ... Profit! Method 2: txVulcano txVulcano (from Flowee) might be able to work with scalenet, but I haven't tried it yet. https://flowee.org/docs/vulcano-tutorial/ Method 3: Txunami Andrew Stone of Bitcoin Unlimited has developed the Txunami tool for multithreaded spam generation. It does not save the output UTXOs, so any coins you use with Txunami will eventually be lost. https://www.bitcoinunlimited.info/blog/c004658e-7c6c-4ae1-96c6-47853aaa3f3d I have not used this tool, so I do not know how hard it would be to get it to work on scalenet. If anyone is able to get this to work, please write down how you did it. Scalenet is a fountain of chaos. May its waters remain forever turbulent.

@jtoomim

Grasberg DAA不为人知的问题 中文版前言 *Bitcoin Cash的英文社区对于Bitcoin ABC在处理DAA升级这件事上的行为已经非常地不满了。Grasberg的宣布直接致使很多英文社区的成员完全丧失了他们对ABC领导风格以及合作能力的信心。本文中的批判不只是针对Grasberg本身,也是对Bitcoin ABC行事的批判,这些内容现在依然成立。* *本文最初于2020-08-03发表。英文原文请参见:**https://read.cash/@jtoomim/dark-secrets-of-the-grasberg-daa-a9239fb6* 0. 介绍 2020年3月27日Bitcoin ABC高调发布了一种用于Bitcoin Cash网络的新的难度调整算法,并命名为Grasberg。这次发布中提及了Grasberg的诸多优势,听起来让人不免有些激动。然而更令人十分在意的是这次的发布里被省略了的内容,其中包括几点ABC没有提及但是很重要的关键之处。在我们选择接受Grasberg或者其他的DAA之前, Bitcoin Cash社区的大家同样需要得知这些没有提到的事实 https://blog.bitcoinabc.org/2020/07/23/announcing-the-grasberg-daa/ 在本文中, 我会从四个方面讲解Grasberg存在的问题: • Grasberg 会降低 Bitcoin Cash的应用价值(第1-2部分) • Grasberg 会危害Bitcoin Cash 的经济准则(第2-3部分) • Grasberg 作为 Bitcoin ABC 政治化工具很有危害(第3-6部分) • Grasberg 是解决DAA问题的不佳选择(第7-10部分) 本文会包含一系列认真反驳Bitcoin ABC的观点,它们中的有些仍需要更多的验证。不过大量严肃的反对声音正证明了我们应该采取更加谨慎和严格的行动。 因为即使其中只有一小部分是准确的, Bitcoin Cash都应该迅速而且有力地去应对这些风险。 首先存疑的是Grasberg 历史漂移矫正(historical drift)的机制 , Bitcoin ABC没有说明Grasberg会消耗多少资源,而实际上这会是一个不小的负担。 1. Grasberg 会导致在接下来的6.5年里出块速度为11.25分钟 直到2027年的四月之前Grasberg会导致挖矿速度慢12.5%,导致各种延迟和安全问题: 交易确认会慢12.5% 向平台转账会慢12.5% 待确认交易链会更拥堵12.5% BCH的矿工将少11.1%的收入 BCH的算力和安全保障会少11.1% 需要一定出块数量确认的转账会需要更多12.5%的时间来释放 11.25分钟,这个出块时间不是什么计算错误, 它正是Grasberg代码中`computeTargetBlockTime(…)` 函数的固有特性。这一点Bitcoin ABC是知晓的,然而他们选择不提。 2. Grasberg 会改变BCH发行的既定计划(emission schedule) 根据Bitcoin ABC的说法, 执行Grasberg算法的主要原因就是要避免重新定义BCH发行的计划,这也是他们认为ASERT不能用的理由,原文如下: Choosing a reference point other than the genesis block is effectively equivalent to redefining the coin emission policy, which is a big NO. 选择除了创设块之外的任何基准点都是改变发币计划的行为,是大写的NO 然而,他们自己却在开倒车。如果要避免重新定义BCH发行计划,就需要使用最新无分叉块(pre-fork)来作为参考基准,也就是ASERT所采用的方法。但是Grasberg并没有这样做。 如果还不太熟悉各种DAA算法(比如ASERT尤其尚不广泛为人所知),这些术语听起来会有些费解,要去跟进最新技术讨论的难度也不小。不过还是有办法用简单的方法来解释这个问题的:用数据说话(实话)。我们可以看到Grasberg算法实际上会改变BCH的发行计划,而ASERT则和现行的cw-144保持一致。 到下次减半前,现行的发行计划是每日**900 BCH** (6.25 BCH * 144) ASERT在下次分叉前的发行计划也是同样的每日**900 BCH**,维持了现有的发行方针,并且和现在的DAA几乎等同(此处可以放大来看它们的细微差别),这是因为ASERT设计中是正是用了cw-144的最后区块作为参考,并且继续扩展现行的发行方案,并且有更高的精确度,同时避免了24.5小时震荡。 http://toom.im/bch/grasberg_coin_issuance.html 如果使用Grasberg,到下次减半以前的每日发行量为**800 BCH** (6.25 BCH * 144 /112.5%)。这就重新定义了BCH的发行方案了;另一方面 Grasberg 将降低出块速度12.5%,也就是说在接下来6.5年中会少发11.1%的币,使得减半延后8个月。这些令人颇感意外甚至随意的新参数不管是在Bitcoin白皮书或者源代码中从来都没有出现过,不论是12.5%还是675秒。包括随后的6.5年这个数字也很是随意。Amaury Séchet和Bitcoin ABC团队选择了这些数字,然而也没有做出什么合理性解释。其中12.5%这个数字倒是与此文章有些奇妙的相似。 https://medium.com/@jiangzhuoer/infrastructure-funding-plan-for-bitcoin-cash-131fdcd2412e 如果Bitcoin Cash要成为一个实在的货币,那么就一定得避免开发者随便修改发布计划。如果我们现在容许Amaury Séchet来改方案,开了这种先例,之后更改发行量和价值的手段也会握在他的手中。这使他成为类似于中央银行或者说是总理一般的存在。在这6.5年中估计我们也得迎来Bitcoin ABC版“央行第二轮救市”了(此处指中本聪在创世块提到的英国救市)。 https://explorer.bitcoin.com/bch/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 选择创世块当DAA参考基准点无异于从头改写BCH的发行方案,这无疑是个大大的NO。 3. Grasberg越过了技术和政治的界限 货币的发行方案会决定新的价值将如何分配,改方案相当于改分配,是非常关键的红线。 诸如Grasberg的11.1%发行减少这样的改动尤其危险,其正是因为这非常有诱惑力。要把这11.1%的减少发行合理化成减少膨胀有益于大持币者是很容易的。对于那些有大量库存BCH的持有人,比如说如果他们在2017年八月到十一月之间挖了大笔BCH(那时的矿工能得到3.5倍于中本聪设计的回报),那么他们会很有兴趣这种减少发行的行为,因为这样的话可以带给他们短期内的资产大增值并且更容易套现。 但我们不能就这么放弃思考了,因为本质上币的发行是一个零和博弈。每一块老持币者在暂时的高价卖出的美元都出于最终在高价买入的新持币者身上。 https://zh.wikipedia.org/wiki/%E9%9B%B6%E5%92%8C%E5%8D%9A%E5%BC%88 更进一步讲,任何打算靠操作通胀率来操控货币价值的行为都会需要代偿的。这一次如此操作BCH的发行, Bitcoin ABC将会释放出BCH的经济和货币政策不稳定的信号,BCH的持有者将会感觉到他们买入的BCH随时面临变故。当前的持有者会失去对BCH未来的信心,并且会在价格尚可的时候进行抛售。而潜在的购买者也会对BCH失去信任,也就更没有买入的意愿了。然而,货币的价值正是在于其对未来价值的保障。 Bitcoin应该是是个世界性抗监查的电子货币,带给世界经济的自主,并且帮助人们脱离自利政府机构的控制,而不是成为早期投资者的致富直通车。为了实现Bitcoin的目标,保持公正且稳定的规则很需要。我们不应该杀鸡取卵,在经济方针上用未来用户的钱来填满现在的大户口袋;恰恰一旦我们走上了这条路,也就没有未来用户来薅了。 4. Grasberg的历史偏移修正方案不受BCH开发者的欢迎 七月二十六日,Future of Bitcoin Cash主持了关于BCH DAA问题的开发会议。整个一小时五十分钟的会议都在讨论历史偏移修正的问题。总共有以下十名开发者参加了会议: Amaury Séchet,Bitcoin ABC的首席开发者 Antony Zegers,Bitcoin ABC的开发成员 Zawy12 (Scott Roberts),专精于DAA的一位非BCH开发者 Jacob Eliosoff, 擅长EMA的一位开发者,并且使第一个提出ASERT方法的人(非BCH开发者) Jonathan Toomim(本人), 独立BCH开发者 Jason Dreyzehner,bitauth.com钱包SPV的开发成员 Chris Pacia,BCHD团队的一半 Josh Ellithorpe,BCHD团队的另一半 Andrew Stone,Bitcoin Unlimited的首席开发者 Freetrader,,BCHN的首席开发者 经过这接近两小时的讨论之后,关于是否支持历史偏修正,大家进行了一次非正式的投票,结果如下: 2票赞成,来自ABC的两位 2票弃权,来自不是BCH开发者的两位,他们表达了批判但是没有投票 6票反对,来自其余的所有人 参会者中只有八人是BCH的开发者,但在更广的社区中观点也是类似的。其中一些开发者做出了他们反对历史偏移修正的陈述: Tom Zander ,来自Flowee Jonathan Silverblood,来自BU and Cashaccounts Mark Lundeberg Jacob Eliosoff (尽管在会议中他弃权了) Josh Green以及Bitcoin Verde (其他四位成员也签名了) BigBlockIfTrue, 来自BCHN Calin Culianu,来自BCHN 除了Amaury和Antony之外的,我所知的历史偏移修正支持者还包括: • Joannes Vermorel (来自Telegram [WG] Difficulty Adjustment group) 这项提案基本上只有Bitcoin ABC支持,更多的是其他开发者广泛而且强烈的反对意见。这也表明如果在十一月的更新中ABC强推Grasberg的历史修正的话,可能会造成链的分裂。 5. 在ABC还在进行写作的时候,他们早已经收到一份完整的提案了。 ABC发布Grasberg的文案里开头是这么写的: Bitcoin Cash社区对改善DAA表现出极大的兴趣。尽管围绕DAA进行了大量讨论,但在撰写本文时,ABC尚未收到任何具体建议,使我们没有足够的时间进行充分的审查、模拟和测试,并在8月15日的功能冻结之前获得反馈。 **这个申明简单地就是错的。** 我在七月八日04:55 UTC提交了我们团队关于asert3-2d的提案,比Bitcoin ABC团队发布Grasberg早了整整15天。我们的提案中不止提出了以为两日半衰期对ASERT的三次整数近似(a cubic integer approximation of ASERT with a 2-day half-life)算法概念,也包含了基于BCHN full Node的Python3 和 C++应用实例。 https://read.cash/@jtoomim/bch-protocol-upgrade-proposal-use-asert-as-the-new-daa-1d875696 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#ee35cfc09ad35fa12b8d0a6280a950e4edde3d20_285_299 当Bitcoin ABC说出前文中的申明的时候,铺天盖地的评论都指出了他们的这个谎言,先是在 Amaury Séchet的read.cash发布文章下面,后来又是在Reddit上。然而他们到现在也没有为他们的错误道歉。 https://read.cash/@deadalnix/announcing-the-grasberg-daa-ff52e96d#comment-4bf763a6 https://read.cash/@deadalnix/announcing-the-grasberg-daa-ff52e96d#comment-d78eca6c https://read.cash/@deadalnix/announcing-the-grasberg-daa-ff52e96d#comment-937e90ce https://www.reddit.com/r/btc/comments/hwkeqq/announcing_the_grasberg_daa/fz0970g/ 我们在七月八日的提案和实例一经发布就吸引了BCH节点软件开发者们的关注和代码审核,其中包括 Flowee (Tom Zander), Knuth (Fernando Pelliccioni), BCHN (freetrader 及 mtrycz), 还有 Bitcoin Unlimited (Andrea Suisani)。提案获得了广泛而且很热情的支持,并且得到了BCH开发社区的帮助,并且有一些节点已经开始尝试整合我们的代码了。然而ABC的开发者并没有给我们任何的审核反馈。 https://twitter.com/KnuthNode/status/1290237886911188992 我向ABC的两位开发者(Antony Zegers and Amaury Séchet)发了好几次这个链接,但他们从来也没有测试或者审核过代码。七月十三日到十五日,Amaury来问了我一些关于`aserti3-2d`算法和代码的内容和设计问题,我也进行了细致完整的回复。 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commits/daa/aserti3-wip https://github.com/jtoomim/bitcoin-abc/commit/83de74761631e509cba3fd58455b9f094e219a8c 当时问的问题看起来并不对他们审核代码,或者说充分测试我的提案有帮助。他们没时间做这些,因为人家正在秘密准备Grasberg。Grasberg的设计里有很多是基于我们团队的研究的,甚至有些就是从我们的实例代码里扩展的。包括现行DAA有问题的基础前提(用新的DAA可以解决问题),和Bonded Mining不是个好选择(ASERT或者RSERT很可能是最优解),以及使用`2^(x+n) = 2^(x) * 2^(n)`一致性来帮助进行整数近似步骤。 https://www.reddit.com/r/btc/comments/fanc6o/the_bch_difficulty_adjustment_algorithm_is_broken/ https://old.reddit.com/r/btc/comments/hph3gk/review_of_the_asert_daa_proposal/fxrti0e/ Bitcoin ABC没有做好引用申明这一点倒不是很让人介意,但是比较难以接受的是ABC堵截我的提案还否认这个提案的存在,同时又复制其中的关键点,最后还尝试拿下解决DAA问题的首发。 更有意思的是,他们还把Grasberg宣称成好像已经是一个既成事实了,已经要使用了的熟饭的样子。 于是ABC就按着Grasberg DAA继续行动。 我在开源项目中交流的时候总是抱持着互相信任开放的态度,但这次要是仍然假设对方还是诚信的,就相当说不通了;以下是一些事实: Bitcoin ABC知道我的提案 Bitcoin ABC问过我关于这个提案的问题 Bitcoin ABC对外宣称没有我这个提案 Bitcoin ABC后来发布了使用我的提案里的功能的竞品 Bitcoin ABC的项目和我的提案有一样的基本特征并且受到我的提案的影响 Bitcoin ABC说他们没时间来开发、模拟、跑测试和审核我的代码, 没时间反馈(不止对我的提案,其他的提案也没时间) Bitcoin ABC有时间来开发、模拟、跑测试和征求反馈他们自己的提案,并且给自己的提案提反馈,尽管他们的项目开始得晚得多, 并且也不成熟 Bitcoin ABC没有把Grasberg作为一种提案提出,直接声称这就是解决方案了 考虑到如上的情况, 我认为可以这么说,至少Bitcoin ABC的行为是不专业而且轻率的。然而仅仅用不专业和轻率又不能完全解释他们的行为。个人觉得BCH社区应该多考虑下Bitcoin ABC做了不诚实并且私利的事情。 对于Bitcoin ABC的行为,我能给出的最仁慈的原因就是Not-Invented-Here syndrome (NIH),这可以解释他们为什么宁愿多花时间在自己开发而不是来评估别人的代码。然而NIH也不能充分解释为什么ABC假装不知道别人的提案,以及为什么要像既成事实一样发布Grasberg。也许不那么仁慈的解释才更准确吧。 https://read.cash/@noise/the-not-invented-here-syndrome-in-bitcoin-cash-development-0f983972 https://www.reddit.com/r/btc/comments/i0bvo7/this_is_what_not_invented_here_syndrome_sounds/ 这里引用BU开发者Andrew Stone的话: https://youtu.be/F5b0Unf1aA0?t=4250 对前人的工作予以充分引用是很重要的。在这一案例中的算法被套上了全新的包装,但仔细一看,它其实就是Jonathan花了很长时间劳动的成果,再附加一些别的东西。**这看起来像极了瓢窃...** 我们得考虑到这样一种可能性:Bitcoin ABC企图复制我们团队的DAA的核心设计,夺取别人的成果,并且重新拿回他们因为在IFP上的失败所损失的政治权利。历史偏移修正和新的币发布方案或许只是他们给其盟友或者金主的妥协条件从而获得他们的支持,或者就是当做分裂社区的一枚楔子,以便他们夺得决定权。 我也无法得知Bitcoin ABC的真实意图是什么,我希望能是最好的那种。不过说到底,这也没什么意义了:即使我们可以寄希望是他们是善意的,我们也得最好最坏的打算。 6. Grasberg 是迈向腐败的一大步 Bitcoin创立的契机有很大一部分正是为了对抗全球经济系统的腐坏(这种腐坏的一个结果就是导致了2007年到2009年的经济危机)。Bitcoin本身的设计就是能让它能够抵抗政府和巨头的操控,审查,监控,还有腐败。发布Bitcoin的时间已经过去了许久,以至于很多人都忘记了Bitcoin是如何做到这些的,并且把这当成是可以高枕无忧的自带属性。其实这些性质需要保障才能达到,而我们正面临丢掉这些特性的边缘上。 Bitcoin抗操控及腐败的能力是从其系统中的这些特性产生的: Bitcoin的核心经济参数是通过算法和计算产生的,并且大家认为其不可改变 这个系统不被任何人所有或者控制,也没有人会被胁迫; 而Bitcoin Cash不再保持这些特性,我们每六个月就被“友善的”导演指挥着上演一出硬分叉剧目。 此时Grasberg又将我们往前推了两步。如果Graberg上线激活,那么: Bitcoin Cash的核心参数比如发行方案会被有意地改动 Amaury Séchet和Bitcoin ABC会独揽大权,成为一切协议修改的终极裁定者 这就使得Bitcoin Cash无力对抗贿赂和胁迫,相当于对任何有意向的组织或人宣称,只要给Amaury Séchet足够的压力,他们就能按他们的想法改动Bitcoin Cash的经济参数。或者也不需要多大的压力,五毛的板砖就成了。 https://xkcd.com/538/ Bitcoin ABC现在是不是腐败了或者被贿赂了不重要,重要的是如果我们希望我们的经济体系可以对抗腐败,积极主动的安全措施是必须的,而不是事后应对型的措施。我们得预防任何可能造成贿赂,胁迫和腐败的行为,而且需要预防那些鼓励以及给腐败行为提供温床的行为。 我们来考虑下面这两个情景: **情景A:**假设有一个或者几个在EDA时期挖了大量块的矿工,并且现在握有大量币储备并想要将其转化成价值。这些矿工也希望能获得Bitcoin Cash更大的操控力,这样的话他们就能更容易地去将其政治化。他们可能会支持减少出块量12.5%,而他们自身的收益并不会减少,因为他们可以去挖BTC。考虑到BCH在SHA256总hashrate中只占2.5%,他们最多也就损失11.11%*2.5% = 0.27%的利益。与此同时,他们持有的币增值了11.11%。如果这个人或者机构有2亿美元的储备,他应该可以从推进其所希望的政策上线过程中获利。一旦事情能够成功,将会产生超过两千万的收益。我们再假设如果捐赠180万美金给相关的实现方案的话,他还能有25%的机会招揽到足够多的说客来推行他偏好的政策。按期望算下来,也就是是说给开发者投入180万可以带来360万的收益。 想要按自己的想法改变Bitcoin Cash是一件很自然的事情,没必要去指责矿工,这样没什么好处。如果Bitcoin Cash想要保持公正和自主,我们就得确保上面这件事情*不会发生*。 **场景B:**假设有一家公司(或者个人、政府机构)特别希望看到某个加密货币垮台。他们可能主要持有大量BTC或者BSV,或者希望扩大这些币的的市场占比。又或者,他们也可能是视加密货币为威胁的银行。如果储备十亿美金,那么如果可以摧毁掉Bitcoin Cash的市场份额,他将获利10%(也就是一千万)。我们假设这些机构给先前有分裂社区行为的开发组捐助两百万,要求他们强推一项有争议的政策,那么这些机构有5%的可能造成链的分叉继而分裂社区,遏制发展,抹除Bitcoin Cash这个威胁。这时按照期望算下来,给开发者的两百万投入可以带来三百万的收益。各方都可以靠改变BCH的政策来打压BCH,从而获利。 在这些场景里,考虑到这些参与者都会做很好的掩饰,普通的大众很难有办法知道背后进行了这种交易。当能拿到腐败行为证据的时候,事情已经太迟了,存在最坏的可能性本身就足以让大家都行动起来。 7. Grasberg并没有进行合适的模拟运行 在二月的时候, 我花了两周来优化和扩展一款支持多币种的模拟器,后续用于测试不同的DAA算法,来解决BCH算力的震荡问题。之后我又花了大半个六月和Zawy12以及Jacob Eliosoff 一起来用这款模拟器测试了所有已知的候选DAA算法,找出在效果,简洁度,抗攻击能力之间的平衡最完善的那一个。我考虑的各种细节,同时也仔细记录了各次的模拟,以作为改动协议这种严肃的事情的可靠参考。 https://www.youtube.com/watch?v=Fd6GFpZjLxU https://github.com/zawy12/difficulty-algorithms/issues/62 https://read.cash/@jtoomim/bch-protocol-upgrade-proposal-use-asert-as-the-new-daa-1d875696 Grasberg怎么讲他们的模拟呢: Bitcoin ABC已经对这个算法进行了模拟和实测 多位Telegram上DAA工作组的开发成员向Bitcoin ABC要他们所说的跑过的模拟结果。 然后我们从Amaury那里就拿到**了**这张表格。没有注释,没有描述,没有合理性的说明,也没有测试源代码,就是一表格上一些直接写上去的数字。Amaury Séchet甚至进一步解释说我们不可以相信这张表格里的任何东西: https://docs.google.com/spreadsheets/d/1rb2q5uaTl2JAm0Uhq1_7DmNg3Y3WHTWdhkd-ayorkNs/edit#gid=433230462 说既草率也不专业。完全不能反映Bitcoin ABC的竞争力的领导力。 8. Grasberg的模拟测试表现不佳 于是我自己动手将Grasberg整合进我的的测试框架并且进行了Grasberg的模拟。在http://ml.toom.im:8051/可以见到模拟器的实时运行。 https://github.com/jtoomim/difficulty/blob/comparator/mining.py#L428 https://github.com/jtoomim/difficulty/tree/comparator Grasberg的变量有一小部分不同于我的模拟器的,其中第一个标记为`grasberg-288`,用于模拟Grasberg在前6.5年保持11.25分钟的出块时间目标。第二个是`grasberg-neutral-288`,反映了Grasberg在恢复10分钟一块的出块时间后的行为。进一步为了模拟在去除掉历史偏移修正的部分后Grasberg的运行,我加入了变量`grasberg-nodrift-288`。除此之外还加入了一系列用于尝试不同的时间参数,来平衡响应能力和图像平滑。 Grasberg的表现在以下两种情况下需要单独来进行分析: 在其前6.5年的运行中,Grasberg的运行主要被11.25分钟的目标出块时间所影响 在Grasberg用基于创世块的发币方案来中和掉了历史偏移以后的行为 **情景一**看起来颇为直白,Grasberg 较aserti3-2d挖矿速度慢,而算法类似,致使确实时间变慢并且使挖矿公平性下降。但结果比我们想的更糟糕:grasberg-288使确认时间和挖矿公平变差了了不止12.5%,达到19-25%的下降。 (出块时间和确认时间,以及不同挖矿策略下的营收能力) 而在**场景二**下, 两种两种算法在开始阶段看起来很像,但是仍然存在差异。 (出块时间和确认时间,以及不同挖矿策略下的营收能力) 当Grasberg回归600秒出块时,其性能得到很大的提升。越过了6.5年的界限以后Grasberg的性能还是很不错的,虽然依旧不如aserti3-2d。 我认为在这些测试中的不良表现主要是因为Grasberg所选择的时间参数。Bitcoin ABC没有听从我关于半衰期设定和时间参数选择的建议(然而讽刺的是,用了2天半衰期这件事是他们唯一说来在于我的贡献)。其中看起来却发生率混淆了:时间常量(或者说弛豫时间 *relaxation time*)和半衰期(half-life)。其中前者是自然对数函数中`e^(x/tau)`的tau,后者是以2为底的函数`2^(x/lambda)`中的lambda. 我推荐使用两天作为半衰期, 并且我自己的代码里也是用了这个参数;然而Bitcoin ABC是用了288块(两天)作为时间常数。时间常数要换算成半衰期的话需要乘以ln(2),于是他们的半衰期就变成了199.6块。我告知过Bitcoin ABC这个错误的存在,不过他们也没进行改正。出现这种混淆的原因看起来就是因为他们没有在不同的场景下测试。 9. Grasberg比ASERTI3-2D复杂很多 不管是设计上还是实际代码,Grasberg已经比它需要的程度复杂太多了。将两边的代码并排对比一下很容易看出来这一点。然而这种繁杂并不只是字数多,还有更深的问题。 ASERT的共同作者Mark Lundeberg在七月二十四日撰写了他对Grasberg的细致评价,在他的文章中不止一次地表达了他对Grasberg过于复杂这一点的担忧: https://www.reddit.com/r/btc/comments/hx4kgz/thoughts_on_grasberg_daa/ 我认为以其目标来说,这算法的细节过于复杂,同样的事可以用更简单的方法完成...如上述,我觉得这算法的复杂度和计算量大大超出了必要程度。其中 `deterministicExp2`是在定点运算中0<=x<1范围对2^x - 1的近似。这是个由16个不连续二次区段组成的复合曲线,精度约为~1ppm。相对于其精度而言这算法过于复杂,但在这之上我也不知道为什么选这个精度。 https://imgur.com/ZmkrtVk 10. Grasberg的复杂程度使得BCH在面对攻击的时候更加脆弱 从本质上讲,Grasberg既不是绝对型也不是相对型的调整算法, 既不是ASERT也不是RSERT。它两者的特性都有。Grasberg使用相对规划反馈循环(RSERT)来控制短时程的挖坑难度,同时用绝对规划反馈循环(ASERT)来调节目标目标出块间隔。 这种双重循环不止造成了Grasberg代码量的激增, 也使得grasberg算法的运行过程非常复杂,使之变得更脆弱,就算其中ASERT或RSERT单独部分都不会发生震荡,两部分结合在一起的杂糅系统有还是有可能会发生震荡。 这其中的原因是这两部分法运行是基于不同的延迟时间的,快的循环在遇到扰动的时候可能已经在出下一块之前完成调整了,而慢的才刚开始。这样慢的循环会有残留效益,进一步导致overshoot,ringing,还有可能的震荡。在一些Grasberg的特定案例中,这种现象被专门挑选设定的数值掩盖掉了。其中,在用于决定慢循环的的反馈以及进行历史偏移修正的函数`computeTargetBlockTime()`里,参数`tau`和`X_CLIP`需要分别设置成一高一低来预防震荡; 如果将其中一个做足够大的改动,或者两个都稍微改动一下,那么就会产生不稳定。当改动比较大的时候,震荡的情况就会变得比较严重了, 比如以`tau = 600` 和 `X_CLIP = 2729822324`进行的模拟中的情况这样。 在普通的正常挖矿场景下,使用参数`tau`和`X_CLIP`的默认值对于防止震荡和不规范行为是足够用的,但是在遇到恶意攻击的情况中,比如在遭遇到我称为快速前向攻击(fast forward attack)的挖矿攻击时,Grasberg的双重循环会使得情况变得更加糟糕。 快速前向攻击是一种所有DAA算法都可能会受到的攻击方式,尽管其严重程度不尽相同。在这种攻击中,某位矿工会私下用诚实链101%的算力来挖几天的秘密链(这一部分比较像reorg攻击,例如前几年在Bitcoin Gold链上发生的事情),但之后就不同了,当矿工进行快速前向攻击的时候,他们会修改他们的块上的时间戳,使之十分接近他们准备公开这些块的时间点。这样一来次链上的难度会快速下降,而使他们在挖其余大部分块的时候就可以使用比较少的算力。当攻击者追上了诚实链的高度,整个过程中用更少的算力就达到了同样数目的块数和收益。之后攻击者继续挖几块中高难度的块,直到他们的链超过诚实链。合下来他们会多出几个区块。具体多多少取决于DAA和挖矿的策略。 https://github.com/jtoomim/difficulty/blob/comparator/attacks.py#L19 我在测试攻击cw-144算法的时候最高的记录是攻击链209块,诚实链145块,也就是44%的额外收益。与此同时对是aserti3-2d算法的最高记录是1138块对816块,也就是多39%,由于需要的链很长,对于这么庞大(而且更难)的投入而言这个收益不够多。对于Grasberg来说,其严重程度取决于慢循环里`computeTargetBlockTime()`函数的偏移矫正。如果函数运行,在6.5年后Grasberg完成矫正,其被快速前向攻击时可以产出**52%**的额外利益。但是如果函数实际不起效(比如使其输出固定为600秒),那么就和aserti3-2d一样都只产出39%的额外利益。 快速前向攻击并不是一个让人担忧的个例。这种攻击需要101%的算力还有多日的reorg,不论这种攻击可不可行,我们都有更严重的问题需要担心。而且这种前向攻击可以被ABC和BCHN的十块定型(10 block finalization)规则来避免。但是明确Grasberg反应的复杂性本身是十分重要的,其他更实际的潜在的攻击一样有可能会存在。 11. 结论 在本文中,我从十个不同的方面说明了Grasberg是糟糕的。按照重要性的顺序大致可以如下排列: Grasberg下之后6.5年中都会慢12.5% Grasberg重新定义了发币计划,并且使Bitcoin ABC成为BCH中央银行一样的存在 Grasberg改变了收益的分配方式 Grasberg广泛地为人所反对,尤其是BCH的开发社区,最近的意见调查显示有75%的DAA开发者反对Grasberg Grasberg的申明并不诚实,为了争夺政治力,不止忽略掉了aserti3-2,同时还试图盗取其他开发者的成果 Grasberg为用贿赂及威胁的方式控制BCH敞开了大门 Grasberg的开发者并没有认真为其跑测试 Grasberg的模拟测试表现并不如其他各种知名的DAA方案 Grasberg的代码复杂度已经远远超出了一个DAA算法应该有的程度 Grasberg使得BCH面对攻击时,更多了技术上的脆弱性 在论述以上问题的过程中,我同时也讲了一些Bitcoin ABC的迷惑行为: Bitcoin ABC总是在误导大众:首先, 他们掩盖了11.25分钟出块这一重要信息,其次,他们错误地声称ASERT会改变发币计划(其实Grasberg才是会改变计划的那个),第三,他们宣称不存在其他的提案。 Bitcoin ABC经常性地表现出他们对Grasberg技术上的不专业和不上心。例如没有可靠的模拟,没有震荡场景的测试,代码过于复杂,以及容易受到攻击。 Bitcoin ABC完全不尊重其他Bitcoin Cash开发者的立场和贡献。 Bitcoin ABC看起来是按照“你们做你们的,我们做我们的”("You do you. We will do us")方式来进行软开发,他们几乎是为了应对aserti3-2d而开发了Grasberg,并且逐步推进链的分裂 https://old.reddit.com/r/btc/comments/hqbpri/why_do_we_need_to_change_daa_immediately_with/fxy5spf/?context=1 Bitcoin ABC犯了作为开发者的一个最大禁忌:尝试改变Bitcoin的经济体系还有货币政策,并企图成为中央银行。 Bitcoin ABC正试图扩大他们对Bitcoin Cash的话语权和控制力。一旦成功了,他们就很有可能可以利用其牟利。 Amaury Séchet在过去为Bitcoin Cash做了很多贡献,2017年,他和freetrader两人创立了Bitcoin Cash,在后来的三年中努力维护之着Bitcoin Cash最受欢迎的全节点,并且维持代码有可以抵抗攻击的能力。在Blockstream把Bitcoin的经济体系变成高费用、限制块大小的体制,试图把用户都导向他们自己的产品Liquid时,Amaury帮助大家脱离Blockstream的控制。我们会一直感谢他做出的这些贡献。 但随着时间的推移,他逐渐容许自己膨胀了起来,并且最近开始认为他应该得到更多的回报。为了达到他想要的回报,Amaury开始试图巩固自己对Bitcoin Cash的控制力,并且寻求更多的收入。首先,他试着用IFP来重新分配收益给他自己,随后就被被BCH的用户们驳回了。我尊重IFP的这种透明诚实和直白,也不打算怪罪ABC进行了这种尝试。尽管如此, BCH在二月的的时候给Bitcoin ABC发出了明确的信号: *君必不得撼利益之分配*。 不幸的是,Bitcoin ABC似乎是没有收到这一信息,再次尝试去改变利益分配,这一次流向他们自家金库的通路本身的证据变得不那么明显了, 但也就是说,在其他方面Bitcoin ABC的不诚实和诡计有了实锤;并且也有证据表明他们在试图掩藏什么,在Grasberg的动机方面表现得也是遮遮掩掩。 12. 正在发生什么 Bitcoin ABC目前是覆水难收,气数将绝。 不知道各位有没有见过蛇的脑袋,是即使断了也能咬人的。当Bitcoin ABC垮台的时候,他们仍然可以极限一换一。这可能会在Amaury Séchet发现他已经无力回天之前的几周发生,挣扎着想要保住他的控制力。 Bitcoin ABC一直在进行在悬崖边上的冒险行为。他们利用了人们害怕链分裂的情绪来确保他们自己的领导地位。对分裂的恐惧会提高他们在不分裂的情况下的赢面:在懦夫博弈(注:两人对这对方开车驶去,先拐弯避让的是懦夫)中,先让步的就先输了。为了打破这种僵局,我们有两个比较好的选择,一是我们可以使他们没有能力造成有意义的链分裂,二是产生一个更强的默契选择(Schelling point)。如果这么做的话,我们可以改变这个博弈的条件:小电驴对卡车的懦夫博弈里,小电驴无论怎么整都是惨败。 为了使Bitcoin ABC无力分裂链,我推荐所有的Bitcoin Cash相关项目,用户还有投资者来进行以下的步骤: 大家每一个人都不要继续使用Bitcoin ABC的软件,可以改用其他的全节点应用。没有用户的话,Bicoin ABC也就没有了谈判的资本,也就没有办法按他们的方式威胁要分裂链了。如果你现在正在用ABC,选什么替代节点都可以,重要的是现在就不要继续用;根据不同的需求,可以选: Bitcoin Unlimited 高挖矿效率及块/交易铜梁 https://www.bitcoinunlimited.info/download BCHD 拥有先进的gRPG API和Neutrino支持 https://bchd.cash/ Flowee-the-Hub 拥有先进的效率和API可扩展性 https://flowee.org/hub/ Bitcoin Cash Node (BCHN) 经过了细致的验证和评估的全节点软件,可作为开箱可用的ABC替代品 https://bitcoincashnode.org/ Bitcoin Verde 一个完备的节点/区块探索平台 https://bitcoinverde.org/documentation/ Knuth 作为node-as-a-library的软件包,拥有多种编程语言下可用的代码库 http://kth.cash/ 撤回给Bitcoin ABC的捐助,或者如果你是按月自动给ABC捐助,那么直接取消。可以的话请给其他的项目一些帮助。 公开明确声明在链分裂的时候不会跟Bitcoin ABC或者Grasberg,并且会卖掉Grasberg链上的币。(对我来说这还蛮简单的) 如果可能,请为Jason Cox, Fabien, 还有Antony Zegers提供工作机会,他们是非常正直优秀的工程师,而且在这种糟糕的情况下已经做到他们能做的最好了。 如果Amaury Séchet资源放弃了Grasberg,请给他一个开发者的工作,*但别请他做管理岗*。Amaury作为工程师是很优秀的,但是在他不能胜任的岗位上容易膨胀起来。请不要拜托他做经常需要审核别人工作的事情,请他回到他擅长的写代码的的工作中去。 https://zh.wikipedia.org/wiki/%E5%BD%BC%E5%BE%97%E5%8E%9F%E7%90%86 为了产生一个更好的默契选择(Schelling point),我们需要: 如果你觉得aserti3-2d更好,请讲出来吧,不管是企业还是个人,对于开发来说这非常重要。 这些事情我们如果做了,那么事情会变得更加平和地过去。 13. 之后将会发生什么 对我自己来说早2018年到2019年之间, 我在做一些基准测试项目,还有基于Bitcoin ABC的Xthinner的开发工作,最终我也只能放弃了Xthinner的开发, 因为代码审核一点儿都不进展。即使都达到了3000 tx/sec,Amaury似乎对我的项目没什么反应,也没有说需要我做更多测试的意思。几个月后,我开始打算在BCHN继续进行开发(一方面也是为了缓解新冠疫情中的情绪),得到的反应差别非常大。BCHN的开发团队对基础压力测试的概念非常有兴趣,当我给项目的测试代码推新的合并请求时,他们的好几位开发者立即就给出了详细的反馈,不仅指出了我之前没注意到的问题,而且给出了很好的解决。 https://www.youtube.com/watch?v=j5UvgfWVnYg https://www.reddit.com/r/btc/comments/bgr143/xthinner_mainnet_compression_performance_stats/ https://www.reddit.com/r/btc/comments/hwoy8x/congrats_bch_the_daa_is_fixed_and_the_code/fz2kdn4/ https://reviews.bitcoinabc.org/D3025#71873 https://gitlab.com/jtoomim/bitcoin-cash-node/-/merge_requests/1 五月中旬我意识到如果十一月要让DAA得到修复的话时间已经不剩多少了,于是我暂时把Xthinner的工作先放到了一边。考虑到之前我受到的帮助,而且BCHN的发展路线图里也包括了改进DAA的部分,在进行完python3的模拟工作以后,基于BCHN代码库来开发aserti3-2d的C++版本的决定就非常明确了 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commits/xthinner https://news.bitcoin.com/bitcoin-cash-node-upgrade-plans/ 之后我也完全没后悔过这个决定。在我发布了我的提案以后,开发者们在slack上问了很多关于aserti3中的设计想法问题,像是开发全节点的Tom Zander (Flowee) 还有 Fernando Pelliccioni (Knuth)。Tom Harding也参与了其中的一些讨论。七月十四日,也就是这之后的几天,freetrader在我已经去休息了的时候一连问了一个小时的问题以及表达了他们要怎么来审核我的代码。因为还在睡觉我没回复他,然后freetrader和mtrycz没等我回复就立即着手进行了审核测试,然后醒来的时候我眼前是这样的。之后的一晚大有不同,不再是诸如这里有xxx问题,应该加上xxx的单元测试这一类的消息:我起来之后看到了freetrader fork了我的代码,开始写单元测试,如同我之前期待ABC能做的。在之后的几天里,我们像这样来来回回了好几次,在对方休息了时候复制下来对方做好的分支进行查看和修改,或者是给对方提交合并请求。这正是开源开发应该有的样子,迅速,无需许可确认,混沌的状态。非常高效,而且*很有趣*。 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67 我期待着aserti3-2d可以被改进,被完整地测试,准备上线,这样的话之后我就可以继续进行更多的开发工作了,比如提升Bitcoin的规模。如果在Xthinner和Blocktorrent的开发上也能像aserti3-2d这样有来有回,我觉得我们可以进展得更快。个人认为我自己是很擅长做研究,提出新想法做出原型的,而BCHN还有freetrader已经向我们展示了他们很擅长调试概念原型并将其实用化。 在接下来的几个月里,我们将把Grasberg的闹剧抛在身后,在一个健康的开发环境中,大家可以专注于一个建立更好的p2p货币。最终Amaury留下的问题都会被解决,比如50tx的限制,我们会建立完善的基准测试系统,并行化代码,加入更好的区块广播技术。自从2017年以来,Bitcoin ABC在改进全节点运行上做的事情比其他的全节点软件少之又少。当Bitcoin ABC不再是BCH网络的瓶颈,我们就可以继续扩大BCH的规模,让Bitcoin Cash成为一个连中本聪都会觉得骄傲的存在。

+11 more

@jtoomim

Dark secrets of the Grasberg DAA On July 23, 2020, Bitcoin ABC announced Grasberg, a new difficulty adjustment algorithm (DAA) for Bitcoin Cash, to much fanfare. The announcement certainly sounds exciting, and mentions several advantages to the new DAA. But the announcement is more noteworthy for the facts that it omits. There are some very important facts about the Grasberg DAA that Bitcoin ABC did not mention. The Bitcoin Cash community should be aware of these facts before making a decision about whether to accept Grasberg, or whether to choose the alternative instead. https://blog.bitcoinabc.org/2020/07/23/announcing-the-grasberg-daa/ In this article, I will present evidence for four types of arguments against Grasberg: Grasberg will have *negative practical effects* on Bitcoin Cash (sections 1-2) Grasberg will *compromise the economic principles* of Bitcoin Cash (sections 2-3) Grasberg is a *dangerous political tool* of Bitcoin ABC (sections 3-6) Grasberg is a *technically inferior* *option* to fix the DAA issue (sections 7-10) In this article, I present a large number of serious claims against Bitcoin ABC. These claims require verification. But **serious claims demand severe action.** If even a few of my claims are accurate, then Bitcoin Cash should respond quickly and strongly to respond to this threat. The first few of Grasberg secrets concern the mechanism for correcting historical drift. Bitcoin ABC did not clearly state what the costs of this system would be, and they are significant. 1. Grasberg will cause 11.25 minute block times for the next 6.5 years Grasberg will cause blocks to be mined 12.5% slower until April 2027. This means: Confirmations will be 12.5% slower Deposits to exchanges will be 12.5% slower The 50-tx chain limit will be 12.5% more restrictive BCH miners will earn 11.1% less revenue BCH will have 11.1% less hashrate and security Height-based nLockTime transactions will be unlocked 12.5% later The 11.25 minute block times is not a mistake. It is the intended effect of Grasberg's `computeTargetBlockTime(...)` function. Bitcoin ABC knew that Grasberg would produce 11.25 minute block times, and they chose not to mention it in their announcement. 2. Grasberg will change the BCH coin emission schedule Bitcoin ABC claims that the main motivation for Grasberg is to avoid redefining the emission schedule. They claim that this is the main reason why ASERT can not be an option. To quote their article: *Choosing a reference point other than the genesis block is effectively equivalent to redefining the coin emission policy, which is a big NO."* Unfortunately, they have it backwards. The only way to avoid redefining the coin emission schedule is to use the *most recent* (pre-fork) block as a reference point. This is what my ASERT proposal does, but it is not what Grasberg does. Most people who are not experts in DAAs (and ASERT in particular) may find this terminology confusing and unfamiliar, and may find a theoretical argument difficult to follow. Fortunately, there is much simpler way to explain this issue: with data. Data don't lie. We can see which algorithm actually redefines the coin emission schedule by looking at the coin issuance schedules for Grasberg, ASERT, and the current status quo (cw-144). The current coin emission schedule is **900 BCH per day** (6.25 BCH * 144) until the next halving. The coin emission schedule for ASERT is also **900 BCH per day** until the next halving. ASERT preserves the existing coin emission policy, and is nearly indistinguishable in coin emission from the current DAA (cw-144) without zooming in. That's because ASERT is designed to use the last cw-144 block as its reference; ASERT simply extends the current coin emission policy, but with greater precision and without the 24.5-hr oscillations. http://toom.im/bch/grasberg_coin_issuance.html The coin emission schedule for Grasberg is **800 BCH per day (**6.25 BCH * 144 /112.5%) until the next halving. Grasberg defines an entirely new coin emission policy. Grasberg generates blocks 12.5% slower, which gives us 11.11% fewer coins for the next 6.5 years, after which it delays all halvings by about 8 months. This new, unexpected coin emission schedule is defined by several new, arbitrary numbers. Nowhere in the Bitcoin white paper or original source code was the number 12.5% or 675 seconds listed. The consequent 6.5 year length is likewise arbitrary. These numbers were chosen by Amaury Séchet and Bitcoin ABC without explanation. The 12.5% number in particular is eerily familiar. https://medium.com/@jiangzhuoer/infrastructure-funding-plan-for-bitcoin-cash-131fdcd2412e If Bitcoin Cash is to be hard money, then it must resist attempts by developers to arbitrarily change the coin emission schedule. If we allow Amaury Séchet to change the schedule now, that sets the precedent that changing the timing or quantity of coin issuance should be within his power. It makes him akin to a central banker or a chancellor, handing out free money to hodlers. With that precedent, and when this change expires in 6.5 years, we might find that Bitcoin ABC's chancellor is on the brink of a second bailout. https://explorer.bitcoin.com/bch/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f Choosing the genesis block as a reference point is effectively equivalent to redefining the coin emission policy from scratch, which is a big NO. 3. Grasberg crosses the line from technology to politics The coin emission schedule determines how new wealth is distributed. Changes to the coin emission schedule is changing the distribution of wealth. This is a major red flag. Changes like Grasberg's 11.1% reduction in coin issuance rate are extremely dangerous precisely because they are attractive to many people. It's easy to rationalize Grasberg as benefiting hodlers via a 11.1% reduction in issuance and inflation. A person who already has a large stash of BCH -- for example, if they had mined a lot of BCH during Aug 2017-Nov 2017, when miners were earning up to 3.5x as much BCH per day as Satoshi intended -- then they might be interested in seeing a reduction in issuance to give them a short-term boost in their investment's value and make it easier for them to cash out. We should not let ourselves be swayed by arguments like these, because coin issuance is inherently a zero-sum game. For every dollar of direct benefit that a coin issuance change gives to old users and hodlers by allowing them to sell at a temporarily higher price, there is a dollar of direct detriment to new users by forcing them to buy at a temporarily higher price. https://en.wikipedia.org/wiki/Zero-sum_game Furthermore, any attempt to manipulate the value of the currency by changing inflation is bound to backfire. By changing coin issuance this one time, Bitcoin ABC would be sending a strong signal that the current economic and monetary rules of Bitcoin Cash are not permanent, and that any coins they buy are for a supply that is subject to change. Current holders will lose faith in the currency's future, and will be inclined to sell while the price is still high. Potential buyers will lose faith in the currency's future, and will be less inclined to buy. A currency is only as strong as its promise of future value. Bitcoin is supposed to be censorship-resistant worldwide electronic cash, to bring economic freedom to the world, and to free people from the economic control of corrupt and self-serving governments, not to be an investment vehicle for early adopters to get rich. In order to accomplish its goals, Bitcoin's rules need to be kept fair and economically consistent. We should not allow changes to Bitcoin Cash's economic policy that take from future users to enrich the present ones. If we follow this path, there likely won't be any future users to take from. 4. Grasberg's historical drift correction is unpopular among BCH developers On Monday, July 26th, a development meeting was hosted by Future of Bitcoin Cash on the BCH DAA issue. The entire 1h50m meeting was dedicated to the historical drift correction issue. This meeting was attended by the following ten developers: https://www.youtube.com/watch?v=F5b0Unf1aA0 Amaury Séchet, the lead developer of Bitcoin ABC Antony Zegers, a developer of Bitcoin ABC Zawy12 (Scott Roberts), a non-BCH developer who specializes in DAAs Jacob Eliosoff, a non-BCH developer who specializes in EMAs, and who was the first to discover ASERT Jonathan Toomim (myself), an independent BCH developer Jason Dreyzehner, a developer of an SPV wallet at bitauth.com Chris Pacia, one half of the BCHD team Josh Ellithorpe, the other half of the BCHD team Andrew Stone, the lead developer of Bitcoin Unlimited Freetrader, the lead developer of BCHN After having discussed the drift issue for nearly two hours, an informal poll was done of the developers about whether or not they supported the proposal to do historical drift correction. The results were: 2 in favor (Both Bitcoin ABC devs) 2 abstentions (both non-BCH devs expressed criticism, but did not vote) 6 opposed (everyone else) Only 8 BCH developers were present in this meeting, but sentiment among the broader development community seems similar. Some of the developers who have made statements opposing historical drift correction include: Tom Zander of Flowee https://www.reddit.com/r/btc/comments/i2a6ir/bitcoin_cash_historic_and_forecasted_drift/g0386zl/ Jonathan Silverblood of BU and Cashaccounts https://bitco.in/forum/threads/buip150-reject-past-drift-correcting-daas.26486/ Mark Lundeberg https://twitter.com/BitcoinUnlimit/status/1288177166102999053 Jacob Eliosoff (though he abstained during the meeting) https://medium.com/@jacob.eliosoff/drift-correction-and-the-asert-daa-2c2d148c3250 Josh Green and of Bitcoin Verde (4 other companies also signed) https://read.cash/@GeneralProtocols/joint-statement-on-aserti3-2d-algorithm-f98f0a2c BigBlockIfTrue of BCHN https://read.cash/@BigBlockIfTrue/bitcoin-cash-historic-and-forecasted-drift-36f8a6d4 Calin Culianu of BCHN https://read.cash/@NilacTheGrim/hard-money-sound-money-war-is-peace-day-is-night-black-is-white-1984-levels-of-double-speak-b1807d9a Besides Amaury and Antony, those in favor of drift correction, that I'm aware of, include: Joannes Vermorel (via the [WG] Difficulty Adjustment group on Telegram) The fact that this proposal appears to be supported only by Bitcoin ABC, and garners strong and near-universal opposition from other developers, suggests that ABC's attempt to push Grasberg's historical drift correction through in the November upgrade could result in a chainsplit. 5. A concrete proposal had reached ABC at the time of their writing ABC's Grasberg announcement began with the following paragraph: *While there is a lot of discussion around the DAA, no concrete proposal has reached ABC at the time of this writing, which does not leave us with sufficient time to review adequately, simulate and test, and get feedback addressed before the feature freeze on August 15th.* **That claim is simply false.** I submitted my team's proposal for aserti3-2d on July 8th at 04:55 UTC -- a full 15 days before Bitcoin ABC announced Grasberg. Our proposal, aserti3-2d (a cubic integer approximation of ASERT with a 2-day half-life), was very concrete, and included both a Python3 implementation and a C++ implementation built on top of the BCHN full node implementation. https://read.cash/@jtoomim/bch-protocol-upgrade-proposal-use-asert-as-the-new-daa-1d875696 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#ee35cfc09ad35fa12b8d0a6280a950e4edde3d20_285_299 When Bitcoin ABC made the above statement, they were flooded with comments that called out the falsehood on Amaury Séchet's read.cash article and again on Reddit. Bitcoin ABC has not apologized for their error. https://read.cash/@deadalnix/announcing-the-grasberg-daa-ff52e96d#comment-4bf763a6 https://read.cash/@deadalnix/announcing-the-grasberg-daa-ff52e96d#comment-d78eca6c https://read.cash/@deadalnix/announcing-the-grasberg-daa-ff52e96d#comment-937e90ce https://www.reddit.com/r/btc/comments/hwkeqq/announcing_the_grasberg_daa/fz0970g/ Our July 8th proposal and implementation had attracted immediate attention and code review from many BCH node developers, including Flowee (Tom Zander), Knuth (Fernando Pelliccioni), BCHN (freetrader and mtrcyz), and Bitcoin Unlimited (Andrea Suisani). The proposal garnered a lot of excitement, general approval, and collaboration from most of the BCH development community, and several nodes have already begun integrating the code. However, we did not get any code review from any ABC developers. I sent links to my code to two of ABC's developers (Antony Zegers and Amaury Séchet) several times, but they never tested or reviewed the code. From July 13th-15th, Amaury Séchet asked me some questions about the contents and design of the `aserti3-2d` algorithm and code, which I answered promptly and fully. https://twitter.com/KnuthNode/status/1290237886911188992 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commits/daa/aserti3-wip https://github.com/jtoomim/bitcoin-abc/commit/83de74761631e509cba3fd58455b9f094e219a8c The purpose of these questions does not appear to have been to help them perform code review, or to adequately simulate and test my proposal. They didn't have time to do that, *because they were too busy secretly developing Grasberg*. A lot of Grasberg's design and features is based on my team's research, or is directly derived from my implementation. This includes the fundamental premise that the DAA is broken, that a new DAA can solve the issue, that Bonded Mining is not an appropriate choice, that ASERT or RSERT is likely to be the best choice, and the use of the `2^(x+n) = 2^(x) * 2^(n)` identity to help with the integer approximation step. https://www.reddit.com/r/btc/comments/fanc6o/the_bch_difficulty_adjustment_algorithm_is_broken/ https://old.reddit.com/r/btc/comments/hph3gk/review_of_the_asert_daa_proposal/fxrti0e/ I am not bothered by the fact that I did not receive as much credit for my work as they should have given me. What bothers me is that Bitcoin ABC *stonewalled* my proposal and denied its existence, while simultaneously copying its critical features, and finally attempted to take primary credit for fixing the DAA and the oscillation issue. Furthermore, their announcement provided Grasberg as a done packaged deal, a *fait accompli*, rather than as a proposal: Bitcoin ABC is therefore moving forward with the Grasberg DAA. I try to always assume good faith in my interactions with other developers in open source projects, but I struggle to explain this behavior as being in good faith. These are the facts: Bitcoin ABC was aware of my proposal Bitcoin ABC asked me questions on my proposal Bitcoin ABC publicly claimed the nonexistence of my proposal Bitcoin ABC developed a competing project, using features from my proposal Bitcoin ABC's project shared fundamental properties with and was influenced by my proposal Bitcoin ABC claimed they did not have time to review, simulate, test, and get feedback addressed for my proposal or any other proposals Bitcoin ABC had time to *develop*, review, simulate, test, solicit feedback, and address feedback for their own proposal, even though it was started much later and was less mature than mine Bitcoin ABC did not announce their project as a proposal, but as a conclusion Given these facts, I think it is clear that at a minimum, Bitcoin ABC's behavior has been unprofessional and immature. However, it's hard to explain these facts based solely on immaturity. Consequently, I think the BCH community needs to consider the hypothesis that Bitcoin ABC has been acting dishonestly and selfishly. The most charitable explanation I can give for this behavior is that Bitcoin ABC has a severe case of Not-Invented-Here syndrome (NIH), which causes Bitcoin ABC to prefer to spend extra time developing their own ideas instead of reviewing other's code. However, NIH fails to adequately explain why Bitcoin ABC did not adequately acknowledge the *existence* of another proposal, nor why ABC presented Grasberg as a *fait accompli*. This suggests that a less charitable explanation may be more accurate. https://read.cash/@noise/the-not-invented-here-syndrome-in-bitcoin-cash-development-0f983972 https://www.reddit.com/r/btc/comments/i0bvo7/this_is_what_not_invented_here_syndrome_sounds/ To quote developer Andrew Stone of Bitcoin Unlimited: https://youtu.be/F5b0Unf1aA0?t=4250 A greater acknowledgement of the previous work done is probably very important. And in particular in this case to be branded as a whole new algorithm on the outside, but if you look under the covers, it's what Jonathan has been working on for a long time plus some other stuff, you know, **makes it look like a steal...** We should consider the possibility that Bitcoin ABC was attempting to copy the core elements of the design of my team's DAA fix in order to take credit for the work and to reaffirm the political power that they had lost after their failed IFP proposal. The historical drift correction proposal and new coin issuance schedule may have been a concession or political compromise to one of their allies or funding sources intended to secure their continued support, or it may have simply been intended as a wedge to divide the community and allow them to seize control with decisive leadership. I do not know what Bitcoin ABC's true motivations were. I hope they were for the best. Ultimately, it does not matter: Although we can hope for the best, we must always be prepared for the worst. 6. Grasberg is a big step on the path to corruption Bitcoin was created largely in response to the corruption in the world's financial system that led to the 2007-2009 financial crisis. Bitcoin was designed to be resistant to government manipulation, censorship, and corruption. Bitcoin's publication was so long ago that many people have forgotten *how* Bitcoin achieved these properties, and have assumed that Bitcoin Cash will always have them. This is not guaranteed, and we are dangerously close to losing them. Bitcoin's resistance to manipulation and corruption came as a result of a few properties of the system: Bitcoin's main economic parameters were defined by math and code, and were thought to be immutable. The system was not owned or controlled by anybody; there was no person who could be coerced. Bitcoin Cash does not have those properties any longer. We have a hard fork every 6 months as directed by a "benevolent" dictator. Grasberg takes us two steps further. If Grasberg is activated, it will demonstrate two new facts: The main economic parameters of Bitcoin Cash, like the coin emission schedule, can be intentionally changed. Amaury Séchet and Bitcoin ABC are in control of Bitcoin Cash, and have the sole and ultimate authority over protocol changes. This makes Bitcoin Cash vulnerable to bribery and coersion. It tells any interested parties that if they want to change the core economic parameters of Bitcoin Cash, all they need to do is to get sufficient leverage against Amaury Séchet -- either via bribery or via a $5 wrench attack. https://xkcd.com/538/ It does not matter if Bitcoin ABC is currently corrupt. It does not matter if they were bribed or coerced into making this change. If we want our economic system to be resistant to corruption, we need proactive security, not reactive security. We need to prevent any actions that *could* be the result of bribery, coersion, or corruption. And we need to prevent any actions that would *encourage* them, or *enable* them. Consider the following hypothetical scenarios. **Scenario A:** Let's say that there is one or more large miners who mined a lot of blocks during the EDA era, and now has a large stash of coins that they want to appreciate in value. This miner may also wish to have greater control over the Bitcoin Cash blockchain, so that they are able to police it more effectively. This miner might advocate for a reduction in the BCH block issuance by 12.5%. This would not adversely affect the miner's *revenue*, since they can just switch some of their hashrate over to mine BTC instead. Since BCH gets only 2.5% of the total SHA256 hashrate, they would lose only 11.11% * 2.5% = 0.27% of their revenue. Meanwhile, their BCH holdings might appreciate 11.11%. If that individual or company has $200 million at stake, they might expect to gain returns of should their preferred policy be enacted. That gives them $21.67 million of benefit if they should succeed. Let's say that by donating $1.8 million to the reference implementation, this person has a 25% chance of gaining enough lobbyist influence in order to get his preferred change enacted. This results in an expected return on investment of $3.6 million for the miner and $1.8 million for the developer. https://blog.coinbase.com/a-deep-dive-into-the-recent-bch-hard-fork-incident-2ee14132f435 It's natural for individuals, businesses, or governments to want to make these changes to Bitcoin Cash. Blaming miners for wanting to get rich will not help us. If Bitcoin Cash is to be kept uncorrupt and free, we need to ensure that they *can't make them*. **Scenario B:** Let's say there is a company, individual, or government with a significant financial interest in seeing a specific cryptocurrency platform collapse. Perhaps they are a major BTC or BSV holder, and expect their other cryptocurrency to gain market share in that event. Or perhaps they are a major bank and see cryptocurrencies as a threat. If they have $1 billion at stake, and they stand to gain 10% if they destroy Bitcoin Cash's market share, that's $100 million of potential gain. Let's say that by donating $2 million in funding a development team with a history of divisive behavior, and demanding a controversial policy be implemented, this entity has a 5% chance of triggering a chainsplit that would fragment the community, stagnate growth, and eliminate Bitcoin Cash as a threat. This results in an expected return on investment of $3 million for the attacker and $2 million for the developer. Both parties can improve their income by shorting BCH prior to the policy's deployment. In both of these scenarios, there is no way for the general public to know that such an arrangement has been made as long as all parties involved cover their tracks appropriately. We should not wait for proof of malfeasance. The fact that these attacks are possible is reason enough why we need to act now. 7. Grasberg was not properly simulated https://read.cash/@jtoomim/dark-secrets-of-the-grasberg-daa-a9239fb6#7-grasberg-was-not-properly-simulated In February, I did two weeks of development work on improving and extending a good multi-coin mining simulator to test out different DAAs and show conclusively that a DAA change could fix BCH's hashrate oscillation issues. I spent most of June again working with that simulator along with Zawy12 and Jacob Eliosoff to compare all known candidate DAAs to identify which ones had the best balance of performance, simplicity, and attack resistance. I consider detailed and well-documented simulations to be critical for any serious protocol change proposal. https://www.youtube.com/watch?v=Fd6GFpZjLxU https://github.com/zawy12/difficulty-algorithms/issues/62 https://read.cash/@jtoomim/bch-protocol-upgrade-proposal-use-asert-as-the-new-daa-1d875696 The Grasberg announcement said this about Grasberg's testing: Bitcoin ABC has already run simulations and real-world testing of this algorithm Several developers in the DAA working group on Telegram asked for a copy of the simulations that Bitcoin ABC claimed to have done on Grasberg. All we got from Amaury was this spreadsheet. No explanation, no description, no justification, no source code. Just a spreadsheet with a bunch of hard-coded values. Amaury Séchet went a step further and explicitly told us not to trust anything in it. https://docs.google.com/spreadsheets/d/1rb2q5uaTl2JAm0Uhq1_7DmNg3Y3WHTWdhkd-ayorkNs/edit#gid=433230462 This is sloppy and unprofessional, and does not reflect well on Bitcoin ABC's competence and leadership quality. 8. Grasberg's simulation performance is inferior So I did my own sims of Grasberg. I integrated Grasberg into my own simulation framework. A live web copy of my simulator is running at http://ml.toom.im:8051/. https://github.com/jtoomim/difficulty/blob/comparator/mining.py#L428 https://github.com/jtoomim/difficulty/tree/comparator The Grasberg proposal has a few different variants in my simulator. The first one is labeled as `grasberg-288`, and emulates the behavior of Grasberg during the first 6.5 years while Grasberg targets a 11.25 minute block time. The second is `grasberg-neutral-288`, and reflects Grasberg's behavior after Grasberg has returned to a 10 minute block time target. I also included the `grasberg-nodrift-288` variant to simulate how Grasberg would perform if the drift correction code were ripped out entirely, as well as variants using different time constants for different resonsiveness/smoothness tradeoffs. Grasberg's performance needs to be separately analyzed in two conditions: Over the first 6.5 years of operation, while grasberg's performance is dominated by the 11.25 minute target block time After Grasberg has neutralized the drift backlog against its genesis block-derived schedule **Scenario 1** seems pretty straight-forward. Grasberg mines blocks slower than aserti3-2d and similar algorithms, and consequently gets worse confirmation times and mining fairness performance. But it's a bit worse than we expected: rather than performing 12.5% worse on confirmation times and mining fairness, `grasberg-288` performs about 19-25% worse. When we switch to **scenario 2**, the algorithms start to look more similar, but a performance difference persists. Once Grasberg has returned to a neutral 600 seconds per block, its performance is much improved. Across the board, grasberg has decent performance. However, it still does not perform as well as aserti3-2d. I believe the main reason why Grasberg underperforms in these tests is because of Grasberg's choice of time constants. Bitcoin ABC did not follow my advice correctly on the choice of half-lives and time constants. (Ironically, the advice to use a 2-day half-life is the only thing that Bitcoin ABC credited me for, despite the fact that they did not follow the advice.) The source of this confusion appears to be the distinction between a *time constant* (or *relaxation time*), which would be tau in the natural exponential function `e^(x/tau)`, and a *half life*, which would be lambda in the base-2 exponential function `2^(x/lambda)`. I recommended the use of a 2-day *half-life*, and used that in my code; however, Bitcoin ABC ended up using a 288-block (2-day) *time constant*. The conversion from a time constant to half-life is done by multiplying by ln(2), so they ended up with a 199.6-block half-life. I informed Bitcoin ABC of this error on July 23, 2020, the day Grasberg was published. Amaury acknowledged the error, but has not fixed it. This appears to be because he did not simulate it in a scenario in which the difference manifests. 9. Grasberg is far more complex than ASERTI3-2D Grasberg is far more complicated than it needs to be, in both implementation and design. This is readily apparent by comparing the aserti3-2d and Grasberg code side-by-side, but the complexity goes much deeper than that. Mark Lundeberg (the co-inventor of ASERT) wrote a detailed review of the Grasberg implementation on July 24th. His review repeatedly raised concerns about Grasberg's complexity: https://www.reddit.com/r/btc/comments/hx4kgz/thoughts_on_grasberg_daa/ I find the detailed algorithm is unnecessarily complex for what it accomplishes, i.e., the same thing could be done much simpler. ... As alluded to above, I think the algorithm has way more complexity and computation than is needed. `deterministicExp2` is an approximation to 2^x - 1, for 0<=x<1, in fixed point math. It is a compound curve made up of 16 quadratic segments with discontinuities. It has a ~1 ppm accuracy (if I have translated it correctly). I find this algorithm is much more complicated than is needed for its accuracy level, but also I don't know why this accuracy level was selected in the first place: https://imgur.com/ZmkrtVk 10. Grasberg's complexity adds vulnerability to attacks Fundamentally, Grasberg is neither absolute nor relative, neither ASERT nor RSERT; it's both simultaneously. Grasberg has a relative scheduling (RSERT) feedback loop for controlling mining difficulty over short time spans, as well as an absolute scheduling feedback loop that regulates the targeted block interval. Not only does this dual loop system increase the amount of code Grasberg requires, but it also makes the behavior of grasberg more complex and adds vulnerabilities. While neither ASERT nor RSERT by themselves will oscillate, combining the two into a hybrid system does have oscillatory potential. The problem arises because the two parallel feedback loops can operate with different delays. The fast loop can complete its response to a perturbation in block interval while the slow loop is only getting started. This can leave a residual effect from the slow loop that can cause overshoot, ringing, and potentially oscillations. In the specific case of Grasberg, this oscillation is fortunately mitigated by the values that were chosen for some of the constants. Specifically, in the `computeTargetBlockTime()` function (which determines the slow loop's feedback and provides the drift correction), the constants `tau` and `X_CLIP` need to have high and low values, respectively, in order to prevent oscillation. If either one is changed enough, or if both variables are changed a moderate amount, then some instabilities can result. With larger changes, the oscillations become somewhat severe, as shown in the simulation run below with `tau = 600` and `X_CLIP = 2729822324`. While the default values of `tau` and `X_CLIP` are sufficient to prevent any oscillation or bad behavior in natural mining scenarios, they can be successfully manipulated in adversarial scenarios. For example, there's a mining attack I call the fast forward attack which is exacerbated by Grasberg's dual feedback loop design. The fast forward attack is an attack that all DAAs seem to be vulnerable to, albeit to different degrees. In the fast forward attack, a miner will create a secret chain which they mine for several days with 101% as much hashrate as the honest chain -- this part is somewhat similar to the reorg attacks that have been attempted against coins like Bitcoin Gold over recent years. But there's a twist: when the miner starts a fast-forward attack, they manipulate the timestamps of their blocks to be very close to the time at which they intend to publish the blocks. This fast forwarding of the timestamps causes the difficulty to drop, allowing for most of the blocks to be mined at a lower difficulty. Once the attacker gets to the same height that the honest chain will end at, the attacker will have used less hashrate to get the same number of blocks and coins. The attacker can then mine a few extra medium-to-high difficulty blocks until their chainwork exceeds the honest chain's. This gives them a few extra blocks overall. The amount of extra profit the attacker gets depends on the DAA and the exact mining strategy used. https://github.com/jtoomim/difficulty/blob/comparator/attacks.py#L19 My best attack against the cw-144 algorithm gets 209 blocks with as much work as 145 honest blocks, for 44% extra profit, whereas the aserti3-2d algorithm only allows 1138 blocks for the price of 816, or 39% -- that's a lower profit ratio for a larger (and harder) gamble. With Grasberg, the severity of the vulnerability depends on the `computeTargetBlockTime()` drift correction in the slow feedback loop. With it enabled, and after 6.5 years have elapsed and Grasberg is at equilibrium, **Grasberg can be fast-forward attacked for 52% extra profit.** But if `computeTargetBlockTime()` is bypassed (made to return 600 sec no matter what), then that extra vulnerability disappears, and Grasberg can only be attacked for 39%, which is same as aserti3-2d. The fast-forward attack is not a particularly worrisome attack. Since it requires 101% of the hashrate and a multi-day reorg, whenever it is possible to perform it there are usually much more serious issues that we need to worry about. Also, the fast-forward attack is prevented by the 10 block finalization rule in ABC and BCHN. But it serves to illustrate the complexity of Grasberg's response, and suggests that there may be other potential attacks which are more practical and which are yet to be discovered. 11. Conclusion In this article, I have shown Grasberg to be inferior in 10 different respects. In rough order of importance: Grasberg will be 12.5% slower for 6.5 years. Grasberg redefines the coin emission schedule, and sets Bitcoin ABC up as the central bank of BCH. Grasberg changes the distribution of wealth. Grasberg is widely opposed, especially in the BCH developer community, where 75% of DAA developers opposed it in a recent straw poll. Grasberg's announcement was dishonest, ignored aserti3-2d, and appears to have been an attempt to steal credit from others for political gain. Grasberg opens the door for BCH to be controlled via bribery and coersion. Grasberg was not very well simulated by its creators. Grasberg does not perform as well in simulations as the best-known proposals. Grasberg's code is far more complex than a DAA needs to be. Grasberg unnecessarily adds technical vulnerabilities to attack. In the process of showing this, I have also shown disturbing patterns in Bitcoin ABC's behavior: Bitcoin ABC has repeatedly misled the public. First, they withheld information about the 11.25 minute block times. Second, they falsely claimed that ASERT changes the coin emission policy, when that's actually what Grasberg does. Third, they claimed the nonexistence of other proposals. Bitcoin ABC has repeatedly demonstrated technical incompetence and unpreparedness with Grasberg. This has been shown with the lack of solid simulation results, the potentially oscillatory design, the algorithm's complexity, and the algorithm's susceptibility to attack. Bitcoin ABC has demonstrated a complete disregard for the positions and contributions of other Bitcoin Cash developers. Bitcoin ABC appears to be taking a "You do you. We will do us" approach to software development. They appear to have developed Grasberg *in response to* aserti3-2d, and may be intentionally escalating to a chainsplit. https://old.reddit.com/r/btc/comments/hqbpri/why_do_we_need_to_change_daa_immediately_with/fxy5spf/?context=1 Bitcoin ABC is performing one of the gravest sins a developer can make: they are attempting to push through a change to Bitcoin's economic and monetary policy, and take on the role of a central bank. Bitcoin ABC appears to be attempting to consolidate political power over Bitcoin Cash. Should they succeed in doing so, they will likely be able to leverage their power for money. Amaury Séchet has done many good things for Bitcoin Cash in the past. In 2017, he and freetrader created Bitcoin Cash, and Amaury has worked hard for three years to maintain Bitcoin Cash's most popular full node, and to keep the code secured against attack. He helped us free ourselves from the control of Blockstream, after they transitioned Bitcoin's economy to a high-fee constrained-blocksize regime and attempted to push Bitcoin's users toward Blockstream's own product, Liquid. For his help with that, we will always be grateful to Amaury. But over time, he has allowed his ego to grow unchecked, and has recently come to believe that he deserves more. In order to get what he thinks he deserves, he has attempted to consolidate control over Bitcoin Cash, and then leverage that control for income. First, he attempted to openly redistribute wealth to himself with the IFP, and his attempt was rejected by BCH's users. I respect the honesty and directness of the IFP, and do not fault Bitcoin ABC for it. Nonetheless, BCH sent a clear message to Bitcoin ABC in February: *Thou shalt not change the distribution of wealth.* Unfortunately, Bitcoin ABC seems to have not gotten that message, and is once again attempting to change the distribution of wealth. This time, there is the possibility of a path back into their own coffers, but no direct evidence of such a path. That said, there is direct evidence of dishonesty and subterfuge from Bitcoin ABC in other respects; and there's evidence that they're hiding *something*, and have not been forthright about their motivations for Grasberg. 12. What happens now There is no coming back from this for Bitcoin ABC as an organization. This is the end-of-life for Bitcoin ABC. Unfortunately, the severed head of a snake can still bite. As Bitcoin ABC collapses, they will still be able to do some harm to Bitcoin Cash in their death throes. It will likely be a few weeks before Amaury Séchet realizes that he has lost, and in the mean time, he will continue to struggle for dominance. Bitcoin ABC has been playing a game of brinkmanship. They are using the fear of a chainsplit to try to convince everybody to conform to their leadership and their solution as a Schelling point. This fear of a chainsplit increases their chance of winning without a chainsplit: in the game of chicken, the person who swerves first loses. To counter this, we have two good options. We can remove their power to generate a meaningful chainsplit, and we can create a stronger Schelling point. If we do this properly, then we can change the game: the person who plays chicken on a motorcycle against a freight truck loses no matter what. To remove Bitcoin ABC's ability to plausibly threaten a chainsplit, I recommend all Bitcoin Cash businesses, users, and investors take the following steps: Every business, miner, and individual in the BCH ecosystem needs to stop running Bitcoin ABC software immediately, and switch to another full node implementation. Without users, Bitcoin ABC will have no bargaining power, and they will be unable to use the threat of a chainsplit to get their way. If you are running ABC, you need to switch immediately. It does not matter which node you choose; all are led by reasonable people. Depending on your business, you may want to choose: Bitcoin Unlimited for high performance mining and block/transaction throughput https://www.bitcoinunlimited.info/download BCHD for its advanced gRPC API and Neutrino support https://bchd.cash/ Flowee-the-Hub for its cutting-edge performance and API extensibility https://flowee.org/hub/ Bitcoin Cash Node (BCHN) for the thoroughness of their code review, or as a drop-in ABC replacement https://bitcoincashnode.org/ Bitcoin Verde for an integrated full node/block explorer platform https://bitcoinverde.org/documentation/ Knuth for a node-as-a-library interface from several programming languages http://kth.cash/ Revoke funding from Bitcoin ABC. If you are making monthly contributions to Bitcoin ABC, cancel them. Contribute financially to other projects if you can. State publicly and clearly that you will not follow Bitcoin ABC or Grasberg in the event of a chainsplit, and will sell coins on any Grasberg chain. (This one is easy for me.) If you can, offer jobs to Jason Cox, Fabien, and Antony Zegers. They're good engineers and good people who have been trying to make the best of a difficult situation. If Amaury Séchet abandons Grasberg voluntarily, offer him a job as a developer, *but not as a manager*. Amaury is a good engineer who unfortunately was promoted until he was in a position of incompetence. Do not put him in a position where he will need to frequently review the work of others. Let him return to what he's good at: writing (but not reading) code. https://en.wikipedia.org/wiki/Peter_principle To create a stronger Schelling point, what we need to do is simple: If you prefer prefer aserti3-2d, say so, clearly and unambiguously. Do so as an individual or as a business. This is especially true for developers. If we do these things, then we will make this transition as smooth as possible. 13. What comes next On a more personal note, in 2018-2019 I was working on some benchmark projects and Xthinner development work based on Bitcoin ABC, but which I eventually abandoned because even simple changes got stalled in code review. Amaury seemed indifferent to my project, even when I demonstrated 3,000 tx/sec in my benchmark, and never engaged except to tell me that it needed more unit tests. A few months ago, as a way to ease my COVID blues, I decided to try resurrecting some of these projects for BCHN, and the difference in response was incredible. The BCHN devs were enthusiastic about the idea of stress test benchmarks. As soon as I published a merge request with draft code, they pored over it with detailed and simultaneous code review from several different devs on the team. Not only did they find problems in my code that I hadn't thought of, they *offered to fix them for me*, and then they made good on that offer. https://www.youtube.com/watch?v=j5UvgfWVnYg https://www.reddit.com/r/btc/comments/bgr143/xthinner_mainnet_compression_performance_stats/ https://www.reddit.com/r/btc/comments/hwoy8x/congrats_bch_the_daa_is_fixed_and_the_code/fz2kdn4/ https://reviews.bitcoinabc.org/D3025#71873 https://gitlab.com/jtoomim/bitcoin-cash-node/-/merge_requests/1 In mid-May, I realized that the deadline was coming soon if i wanted to get the DAA fix done for November, so I shelved the benchmarking/Xthinner stuff for the time being. Given the outpouring of help I had received earlier, as well as the fact that BCHN had always had a DAA improvement on their roadmap, it was an obvious decision to base my C++ aserti3-2d work on the BCHN codebase after I finished my Python3 simulation work. https://gitlab.com/jtoomim/bitcoin-cash-node/-/commits/xthinner https://news.bitcoin.com/bitcoin-cash-node-upgrade-plans/ I never once regretted it. After I published my proposal, developers started asking questions about the aserti3 design decisions in the BCHN slack, *including developers for other full nodes* like Tom Zander (Flowee) and Fernando Pelliccioni (Knuth). Tom Harding also chipped in in a few cases. On July 14th, after a couple of days of this, I was asked a question from freetrader about an hour after I went to sleep, asking me where and how they should do code review. Being asleep, I didn't respond, and freetrader and mtrycz didn't wait; they just did it on my repository, so I woke up to this. The next night was very different. Instead of comments like "Hey, there are problems X, Y, and Z, and you should add such-and-such unit tests," as I would expect at ABC, what I woke up to was that freetrader had forked my code, started fixing stuff, and started writing unit tests. Over the next few days, this continued back and forth, with each of us copying from each other's branches while the other slept, or occasionally submitting merge requests to each other. It was the kind of rapid, permissionless, chaotic development that open source development is supposed to be. It was productive, and it was *fun*. https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67 I'm looking forward to getting aserti3-2d merged, fully tested, and ready for activation, because afterward I'll be able to work again on what I've always enjoyed most: scaling Bitcoin. If we can replicate the pattern we had with the aserti3-2d work on stuff like Xthinner and Blocktorrent, I think we'll be able to make some pretty rapid progress. I think I'm pretty good at doing research and coming up with new ideas and developing prototypes, and BCHN and freetrader have shown that they're pretty good at taking prototypes and turning them into well-specified production-ready code. In a few months, we will be able to put this Grasberg drama behind us, and with a healthy development ecosystem, we will be able to can focus on building a better platform for p2p cash. We'll finally be able to fix all of the issues that Amaury stonewalled, like the 50 tx chain limit issue, building proper system benchmarks, parallelizing code, and adopting better block propagation technologies. Since 2017, Bitcoin ABC has put less work into code performance optimizations than any other full node that I've seen. Once Bitcoin ABC is no longer the network's bottleneck, we should be able to resume scaling BCH again, and turning Bitcoin Cash into something that will make Satoshi proud.

+12 more

@jtoomim

BCH升级提案:使用一种新的DAA算法——ASERT 摘要 BCH的难度调整算法(DAA)允许“摇摆”矿工从忠诚矿工中谋取大量利润。矿工来回切算力导致挖矿难度和算力振荡。在我的测试模拟中,DAA会导致忠诚矿工损失约6%的收入,而EMA系列的DAA却能将损失控制在0.35%至0.65%之间。我为BCH 2020年11月的协议升级提出了一种称为ASERT的特定类型的EMA,并提供了关于该算法的广泛模拟结果以及示例C ++部署(未测试)。 http://toom.im/files/da-asert.pdf https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#ee35cfc09ad35fa12b8d0a6280a950e4edde3d20_285_299 DAA存在的问题 当前的BCH难度调整算法“cw-144”得名于链工作量(chainwork)的。它存在这样一个问题:易于振荡。该振荡是当前BCH DAA使用简单移动平均线(simple moving average)的结果。此前的文章对这一问题进行了详细描述。早在2017年10月份,cw-144就被曝出了这一问题。那时cw-144尚未在主网上被激活。 https://www.youtube.com/watch?v=Fd6GFpZjLxU https://github.com/zawy12/difficulty-algorithms/issues/48 https://medium.com/@Mengerian/dgenr8s-difficulty-adjustment-algorithm-explained-e77aa47eb281 (如果你很熟悉这一问题,或者观看了我在2020年2月27日的视频,可跳过此部分,转到“稳定DAA”部分。) https://www.youtube.com/watch?v=Fd6GFpZjLxU 该问题及其引发的激励问题存在以下bug: 1,如果90%的算力行为都是理智的,它将使平均交易确认时间增加约2倍。 2,如果100%的算力行为理智,它将导致链完全停止; 3,它允许自私挖矿攻击。自私挖矿会导致区块重组,降低公众对该区块链的信心,并使双花攻击更加可行; 4,对BCH的忠诚矿工是一种惩罚; 5,小型个体矿工无法掌握相关技术以自动执行算力切换; 6,它允许矿工作恶,有意放大振荡,激励算力切换。方法是自己来回猛烈地切换算力,或者操纵他们所挖区块的时间戳。 简而言之,振荡是由于cw-144使用最新144个区块的简单移动平均线(SMA)来估计哈希。例如在一个高哈希的块离开SMA窗口后,挖矿难度降低的幅度与新区块进入该窗口增加的幅度相同。因此,离开窗口的区块会剧烈地改变挖矿难度,激励矿工重复这一离开区块的哈希。我称这种效果为“哈希回声”。值得注意的是,这些回声并不是恶意的矿工行为,而仅仅是矿工在遵循DAA给他们的直接短期激励。 这些算力振荡的周期约为1.05天,在大多数难度或算力图表(使用1天的采样间隔)中不可见,但在此交互式图表中清晰可见。 http://toom.im/bch_hashrate_new.html 这些哈希回声在cw-144 DAA于2017年11月被激活不久后首次出现在BCH中。当时,振荡幅度约为1 EH / s,每日峰值通常为每日最小值的2倍: 由于一些大型BCH矿池的挖矿行为发生了变化,这些回声在2019年10月1日左右变得极为严重。BitMEX Research甚至发表了一篇文章。振荡幅度达到11 EH / s,日峰值为日最小值的4倍至8倍。2020年1月20日左右和2020年4月的大部分时间都观察到了类似的极端情况。 https://blog.bitmex.com/bitcoin-cashs-october-2019-hashrate-volatility-increase/ 算力振荡是由挖矿难度的变化引起的。这些难度振荡幅度通常超过10%,导致忠诚矿工在大多数时间都处于亏损状态(与挖矿BTC相比),而摇摆矿工每天切入约2-6个小时来获得所有有利可图的区块。 振荡严重影响了用户体验。高算力迸发很短,两者之间的算力低谷很长。大多数交易是在算力低谷期间发布的。因此对于正常的泊松分布(Poisson distribution),平均交易需要等待的时间远比理想的600秒长得多。在此交互式确认时间图表中可以看到这种效果。确认时间最近也变得更糟,自2019年9月以来平均大约15分钟,并在2020年1月达到峰值28分钟。 http://toom.im/bch_conftime_new.html 在2017年9、10月份,kyuupichan和其他一些开发人员编写了“ 难度软件套件”,模拟这些难度波动以及使用不同DAA进行的算力切换。 2020年2月,我用基于浏览器的图形用户界面(代码;慢在线版本)扩展了此套件。这些仿真证实了使用cw-144算法哪怕没有任何恶意矿工行为就能产生了这些振荡。对矿工来说,用cw-144生成它们所需的一切,在任何给定时刻挖最赚钱的币(BCH或BTC)即可。 https://github.com/kyuupichan/difficulty https://github.com/jtoomim/difficulty/tree/comparator http://ml.toom.im:8051/ 模拟证明了振荡是特定于cw- *的故障。只要矿工是逐利的,cw的所有变体中都会出现这种振荡,对于灵敏度更高的变体w(例如,cw-144比cw-576更糟),其摆幅更大且更频繁,但是所有的摆幅都不存在其他好的DAA种类中。 摇摆矿工的收入可能比忠诚矿工高5-20%。通过切换到不同的DAA(例如EMA系列算法),我们可以将切换挖矿的动机降低大约90%-95%。 稳定的DAA 基于简单移动平均线(SMA)的cw-144算法的不稳定性是由区块离开144块窗口时突然结束的难度造成的。这种不稳定性可以随着时间的流逝来降低块的影响而逐渐消失。例如,如果影响在144个块上线性减小,则不稳定性消失。这就是lwma(线性权重移动平均值)算法以及Tom Harding的相关wt(权重时间)算法的作用。另一种选择是使影响随着时间呈指数衰减,例如144个块的时间常量。这就是EMA(指数移动平均线)算法系列的功能。该系列包括许多变体,例如Jacob Eliosoff的ema-1d和simpexp-1d,Tom Harding的wtema和Mark Lundeberg的asert算法。 在这些稳定的DAA中,我们确定了四种主要的候选算法:asert,wtema,lwma和wt。在我的模拟和zawy12的模拟中,所有这四种算法均表现良好。下表是针对所有四种候选算法进行一次这样的模拟运行的数据表,另加cw作为参考,对应于1天(如当前的DAA,cw-144),2天或4天的三种不同的响应设置。表中第三列中包含交易的平均确认时间。理想情况下,该数字应尽可能低。在“贪婪”到“稳定”列中,该表显示了各种挖矿策略(与挖BTC相比)的相对获利能力。在最后一列中,该表显示了从最差的挖矿策略切换到最佳挖矿策略所获得的优势。理想情况下,该数字应尽可能接近0%。 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646159947 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-645735330 算法  — 区块平均间隔(秒)  —  平均确认时间(秒)  —   贪婪  —  可变   — 稳定  — 优势 模拟中这四个选项之间的算力调节性能差异很小。基于EMA的算法(wtema和asert)常常有一个很小的优势,但是优势很小,我们相信应该选择其他方面的考虑,例如部署复杂性。 lwma和wt都需要抽样其窗口中的每个块标投(如288个块)才能计算下一个块的难度,而EMA系列通常只需要采样两个区块头,因此我们应把注意力集中在EMA系列上。基于EMA的算法(wtema和asert)似乎常常有一个很小的优势,但是优势很小,我们相信应该选择其他方面的考虑,例如部署复杂性。 lwma和wt都需要抽样其窗口中的每个块标投(如288个块)才能计算下一个块的难度,而EMA系列通常只需要采样两个区块头,因此我们应把注意力集中在EMA系列上。 我们要考虑使用哪种EMA。最有趣的似乎是wtema 和 asert。 WTEMA和ASERT 看起来最好的两个EMA算法是wtema和asert。 wtema算法是由dgenr8(Tom Harding)在2018年1月1日或之前创建的。这是一种基于以下伪代码的非常简单的纯整数EMA: https://github.com/kyuupichan/difficulty/pull/30 https://github.com/kyuupichan/difficulty/pull/30/commits `next_target = prior_target / (IDEAL_BLOCK_TIME * alpha_recip)` `next_target *= block_time + IDEAL_BLOCK_TIME * (alpha_recip - 1)` 用抽象的术语来说,如果最新的块间隔完全代表算力,则wtema首先估计要改变多少区块“目标”(难度的倒数)才能实现600秒的块。然后,它使用1 / alpha_recip作为加权系数,在该值和最后一个块的目标之间执行加权平均。这使得wtema成为递归定义的函数,并且是典型的简单一阶IIR过滤程序,等效于电子RC过滤程序。它的性能与复杂的PID控制器系统一样好,但是复杂度却很小。 http://www.tsdconseil.fr/tutos/tuto-iir1-en.pdf https://github.com/zawy12/difficulty-algorithms/issues/20 asert算法主要是由Mark Lundeberg在2020年2月或之前开发的。(其等效公式在2018由Jacob Eliosoff独立发现,但没有Mark Lundeberg的详细分析。) asert由以下公式定义: http://toom.im/files/da-asert.pdf `target_timestamp = (height + 1 - activation_height)*IDEAL_BLOCK_TIME next_target = target_at_activation * 2^((last_timestamp − target_timestamp)/tau)` *注意:^表示浮点指数,而不是整数XOR。* asert代表绝对时间计划的指数上升目标。用抽象的术语来说,Asert的工作原理是设定一个理想的出块时间计划,并根据其父块在该计划之前或之后的差距以指数方式设置每个块的难度。每个区块提前该时间计划tau秒,下一个区块的难度将增加两倍。tau的合理值可以从几小时到几周不等。像wtema一样,asert的代码和数学都很简单,并且仅取决于两个区块。与wtema不同的是,asert仅依赖于最新的块,创世区块或激活了asert的分叉区块。这避免了wtema的递归定义。有关asert的更多信息,我强烈推荐Mark Lundeberg的简要介绍性论文。 http://toom.im/files/da-asert.pdf 只要出块间隔时间正常,这两种算法在功能上几乎相同,仅在极端情况下有所不同。 两种算法之间的争论围绕以下四个问题: https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646071315 1,整数近似:由于wtert使用显式指数函数,因此wtema比asert更容易,但二者都可以实现。 2,奇点和消极的解决时间:如上图所示(来源:dgenr8),wtema会引起问题,但asert不会。可能需要规则来将求解时间限制为大于某个值(例如wtema-144> -0.5 * 144 * 600秒) https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-648958314 3,数学和理论上的优雅-两者兼而有之,但asert更好 4,四舍五入/近似误差的累积:wtema适中,asert由于其绝对性质而不存在。 #1和#2是主要问题。对2 ^ x的整数近似的需要使asert更复杂。而防止大量负面解决时间的需求使wtema更加复杂。为解决这一问题,我们最终决定对难度计算函数本身添加几行代码,而非添加或更改其他共识规则。因此,我们选择了asert。 在讨论了不同的整数近似方法后,我最终选择对0 <= x <1使用Mark Lundeberg的2 ^ x三次近似,并使用2 ^ x = 2 * 2 ^(x-1)恒等式将域扩展到所有实数。此近似值可将误差容限保持在0.013%以下。这里有一个aserti3算法的尚未测试的示例C ++部署,还有一个经过良好测试的aserti3的python3部署。性能与真正的asert非常相似。 我们接下来会进行C ++部署的测试。 https://twitter.com/MarkLundeberg/status/1191831127306031104 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#ee35cfc09ad35fa12b8d0a6280a950e4edde3d20_285_299 https://github.com/jtoomim/difficulty/blob/6787454d03d37107a5cc0c5fe35e2ec0c3aff7d0/mining.py#L373 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-647060200 另一种选择是Jacob Eliosoff的exp_int_approx()实现,该实现使用从Stack Overflow抓取的算法来实现随机精度,但要使用for指令和更晦涩的数学和代码。 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646866050 https://math.stackexchange.com/a/56064 我选择了2天的半衰期(tau = 2 * 24 * 60 * 60,等效于2 * 144 / ln(2)或aserti3-415.5的响应设置),这在模拟中性能几乎达到最佳的值范围,同时也易于理解和讨论。区块的时间戳每提前两天,难度就会加倍。我认为1天的半衰期(aserti3-207.75)也可以接受,但建议不要低于207.75或高于576。 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646312380 激活 因为asert计算取决于分叉块的高度和难度,所以如果激活是在预定的区块高度而不是在经过的预定的中间时间(MTP)上进行的,则实现起来将更加简单。如果使用后一种方法,则需要分叉新的asert代码,以便在区块链中搜索MTP超过分叉时间的第一个区块,并从该区块的区块头中提取高度和难度。相反,如果使用分叉高度,则asert算法仅需要在区块链中搜索已知高度上的难度-该操作非常简单。虽然可以基于MTP激活asert,但我认为基于块高度进行激活会更简单。 Bitcoin ABC习惯在其代码中预先添加自戕式防御,以在预先确定的MTP分叉掉过时的软件版本。如果使用分叉高度激活asert,那么自戕式防御和asert激活将不会完全重合。这可能会导致接连出现两个技术性硬分叉,而不是单个三向分叉。这是使用分叉高度激活的一个小缺点。但是即使自戕式防御不能重合,它仍然可以达到其目的:阻止个人继续运行过时的软件。 我相信基于高度激活的asert更简单的代码要比无法重合的问题更重要,因此我在示例C ++部署中使用了基于高度的激活。如果大多数BCH开发社区不同意这一点,我也可以接受。 https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#00a11683af1b8f38bab65b15de6c73734d272438_74_76 测试网 标准的20分钟测试网规则适用如下:如果某个块的时间戳比上个块的时间戳至少早20分钟,则该区块的挖矿难度可能是1。因为在asert机制下,挖矿难度调整是基于时间而非区块高度,所以“时间翘曲(timewarp)”技术在测试网上重置难度(通过反复向前移动时间戳以降低最后一个难度调整间隔内的平均链工作)。因此,在进行此更改后,测试网的难度调整将比以前慢,并且ASIC矿工离开测试网后,测试网用户可能会在几天中都遇到20分钟才出一个块的情况。这一问题可通过降低测试网上的tau值来解决,但是这样会降低测试网与主网的相似度。经常使用测试网的开发人员应该讨论他们更喜欢哪种方法。 攻击 我们研究了针对aserti3的多种不同类型的攻击。目前为止,使用现有的共识规则和非ABC / BCHN的节点策略在几乎所有情况下aserti3的性能均优于cw-144。只有少数一些情况存在问题。目前已发现的攻击影响都很小(小于其他已知和现有的攻击类型),并且只需要稍微更改节点策略即可改善。 第一种攻击是在没有振荡的情况下进行自私挖矿。在这种情况下,自私的矿工A可以人为地创造时间更早的时间戳为A1的区块(例如,求解时间为1秒),这会使下一个区块A2的难度增加0.24%。这可能导致链A2的工作量比B2多,导致节点更喜欢A2而不是B2,即哪怕节点先看到B2。Bitcoin ABC和BCHN已经具有阻止此攻击的节点策略规则,但BU和大多数其他节点并没有。为解决此问题,我们建议所有其他节点在块的先见规则( first-seen rule)中增加滞后:只有当新链的工作量超过第一个链的某一数值,如10%或50%时,节点才应切换链。 https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/validation.cpp#L2516 https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/blob/master/src/validation.cpp#L2699 https://github.com/BitcoinUnlimited/BitcoinUnlimited/blob/release/src/validation/validation.cpp#L1289 第二种攻击是FTL(未来时间限制)攻击。在此攻击中,矿工创建了一个时间戳设置为FTL的区块(目前为7200秒),以降低在秘密链上进行挖矿的难度,尽可能挖出多的区块直到难度恢复正常。在某些(但不是全部)情况下,asert上更容易进行这种攻击。这是因为,asert的难度是在单个区块后做出相应,而非连续两个块。通过使用较慢的响应度设置(aserti3-2d大约是cw-144的响应度的1/4)可以大大减轻这种影响,但是可以通过简单地降低FTL更好的解决。 https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/chain.h#L27 降低FTL看起来是一种直接的改进。许多竞争币都降低了FTL,且没有发现负面影响。在NTP和GPS的现代世界中,将系统时钟同步到0.1秒以内很容易,因此没有理由允许高达7200秒的错误而不受惩罚。即使在跨星际的未来中,600秒的FTL也不会对比特币协议造成问题,因为区块的时间戳反映的是发布时间,将导致其他行星使用旧时间戳(而不是未来时间戳)接收区块。在遥远的未来,一旦使用以相对论速度的工具来挖比特币,我们可能不得不重新考虑FTL。但在此之前,我建议将其降低到600秒。 以上没有对潜在的攻击进行详尽讨论。 zawy12的BCH EMA(第2部分)和哈希攻击示例Github发行线程中可以找到对其他攻击场景的讨论。 https://github.com/zawy12/difficulty-algorithms/issues/62 https://github.com/zawy12/difficulty-algorithms/issues/18 结论 当前的DAA算法(cw-144),给BCH带来了很多问题。切换到EMA或LWMA算法能解决这些问题。 aserti3-2d算法似乎总体上优于cw-144,我相信它是我们拥有的最佳选择。 好的DAA应该具有以下属性(按重要性的高低顺序排列): 1,它应该是稳定的,并且不易产生振荡; 2,它应保持较低的确认时间; 3,降低矿工来回切算力的动机; 4,降低矿工操纵时间戳的动机。 5,降低矿工自私挖矿的动机。 6,由于#3,#4和#5,具有忠诚的矿工应该获得最大的收入; 7,在算力和/或汇率突然变化后,链应能迅速恢复; 8,平均出块间隔应接近目标(如600秒); 9,该算法在数学上应该简单而优雅; 10,该算法应易于理解和分析; 11,该算法应易于部署; 12,该算法应几乎没有边缘情况。 我在本文中提供了一些证据,证明aserti3-2d能满足大多数或以上所有要求。我期待BCH开发者社区以及整个BCH社区能找到aserti3-2d无法实现以上条件的场景,并将aserti3-2d与cw-144和其他候选DAA算法进行比较。

+6 more

@jtoomim

BCH upgrade proposal: Use ASERT as the new DAA Abstract The current BCH difficulty adjustment algorithm (DAA) allows for a switch miner to extract a large amount of profit from constant-hashrate miners. This strongly discourages constant-hashrate mining and encourages switch mining, and causes oscillations in difficulty and hashrate. In my test simulation, the stolen profit is on the order of 6% lost revenue by constant hashrate miners for the current DAA, but only about 0.35% to 0.65% for the EMA family of DAAs. I propose a specific type of EMA, called ASERT, for BCH to be activated in the November 2020 scheduled protocol upgrade, and provide extensive simulation results on this algorithm, as well as an untested sample C++ implementation. http://toom.im/files/da-asert.pdf https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#ee35cfc09ad35fa12b8d0a6280a950e4edde3d20_285_299 Why the DAA is a problem The current BCH difficulty adjustment algorithm — known as `cw-144`, since the algorithm is based on chainwork — has a problem: it is prone to oscillation. This oscillation is the result of the current BCH DAA using a simple moving average, and has been described in detail in previous works. It was a known issue with `cw-144` even in October, 2017, before it was activated on mainnet. (*If you're already familiar with this oscillation, such as if you watched my* *Feb 27, 2020 video**, feel free to skip this section and jump to the* ***Stable DAAs*** *heading.)* https://www.youtube.com/watch?v=Fd6GFpZjLxU https://github.com/zawy12/difficulty-algorithms/issues/48 https://medium.com/@Mengerian/dgenr8s-difficulty-adjustment-algorithm-explained-e77aa47eb281 There are a few reasons why this bug, and the incentive problem it engenders, are problematic: It increases average transaction confirmation times by a factor of about 2x if 90% of the hashrate behaves in a rational manner; It causes the chain to stall completely if 100% of the hashrate behaves in a rational manner; It allows for some really nasty selfish mining attacks. Selfish mining attacks cause block reorgs, and reduce public confidence in the block chain, and make double-spend attacks more feasible; It punishes miners for being loyal to BCH; It punishes small solo miners who do not have the technological sophistication to automate hashrate switching strategies; and It allows for malicious strategies in which a miner can intentionally amplify the oscillations and pro-switching incentives, either by switching their hashrate themselves in a pumped fashion, or by manipulating the timestamps of the blocks they mine. In brief, the oscillation is due to `cw-144` using a simple moving average (SMA) over the last 144 blocks to estimate hashrate. When e.g. a high-hashrate block leaves the SMA window, it reduces the difficulty by the same magnitude as a new block entering the window would increase it. Blocks leaving the window therefore sharply change the difficulty in a direction that incentivizes miners to repeat the hashrate of the departing block. I call this effect "hashrate echoes." Notably, these echoes do not require any malicious miner behavior to occur. They are merely the result of miners following the direct short-term incentives that the DAA gives them. These hashrate oscillations have a period of about 1.05 days, so they're not visible on most difficulty or hashrate charts (which use a 1-day sample interval), but they're clearly visible on this interactive chart. http://toom.im/bch_hashrate_new.html These hashrate echoes first appeared in BCH shortly after the `cw-144` DAA was activated on November 2017. At that time, the oscillation amplitude was about 1 EH/s, with daily peak hashrate typically at 2x the daily minimum: Due to changes in the behavior of a few large BCH mining pools, these echoes became significantly more severe around October 1st, 2019, prompting an article from BitMEX Research. The oscillation amplitude reached 11 EH/s, with daily peaks at 4x to 8x the daily minimum. Similar extremes were observed around January 20, 2020 and most of April, 2020. https://blog.bitmex.com/bitcoin-cashs-october-2019-hashrate-volatility-increase/ These oscillations in hashrate cause and are caused by changes in mining difficulty. These difficulty oscillations frequently exceed 10% in amplitude, causing dedicated miners to mine at a loss (compared to mining BTC) most of the time, with switch miners swooping in for around 2-6 hours per day to capture all of the profitable blocks. These oscillations significantly worsen the user experience. The high-hashrate bursts are short; the hashrate droughts in between are long. Most transactions are issued during hashrate droughts, and the average transaction needs to wait much longer than the ideal 600 seconds for the normal Poisson block distribution. This effect can be seen in this interactive chart of confirmation times. Confirmation times have also gotten worse recently, averaging about 15 minutes since September, 2019, and peaking at 28 minutes in January, 2020. http://toom.im/bch_conftime_new.html In Sep-Oct 2017, kyuupichan and a few other developers wrote the "difficulty" software suite to simulate these difficulty oscillations and hashrate switching with different DAAs. In Feb 2020, I extended this suite with a graphing browser-based UI (code; slow online version). These simulations confirmed that with the `cw-144` algorithm, these oscillations are produced without any malicious miner behavior. All that is necessary to generate them with `cw-144` is for miners to mine whichever coin (BCH or BTC) is the most profitable at any given moment. https://github.com/kyuupichan/difficulty https://github.com/jtoomim/difficulty/tree/comparator http://ml.toom.im:8051/ The simulations also prove that the oscillations are specifically `cw-*`'s fault. The oscillations are present in all variants of the `cw` family when miners follow rational incentives, with larger and more frequent oscillations for `cw` variants with higher sensitivity (e.g. `cw-144` is worse than `cw-576`), but the oscillations are entirely absent from all other good DAA families, regardless of sensitivity. The fact that it's possible for switch miners to earn 5-20% more than constant-HR miners is a bug. This bug is the result of the 1-day resonance and tendency for oscillation that the current DAA has. We can reduce the incentive for switch mining by about 90%-95% by switching to a different DAA, such as an EMA-family algorithm. Stable DAAs The instability in the simple-moving-average (SMA)-based `cw-144` algorithm is caused by the influence of a block on difficulty ending abruptly when the block leaves the 144-block window. This instability can be avoided by having the influence of a block fade slowly over time. For example, if the influence fades linearly over 144 blocks, the instability disappears. This is what the `lwma` (linearly-weighted moving average) algorithm does, as well as Tom Harding's related `wt` (weighted time) algorithm. Another option is to have the influence fade exponentially over time, with e.g. a 144-block time constant. This is what the EMA (exponential moving average) family of algorithms do. This family includes many variants, such as Jacob Eliosoff's `ema-1d` and `simpexp-1d`, Tom Harding's `wtema`, and Mark Lundeberg's `asert` algorithms. Among these stable DAAs, we identified four major candidate algorithms: `asert`, `wtema`, `lwma`, and `wt`. All four algorithms performed well in my simulations and in zawy12's simulations. Below is a table of data on one such simulation run for all four candidate algorithms, plus `cw` for reference, at three different responsiveness settings corresponding to 1 day (as in the current DAA, `cw-144`), 2 days, or 4 days. The table includes the average confirmation time for transactions in the third column. That number should ideally be as low as possible. In the "Greedy" through "Steady" columns, the table shows the relative profitability of various mining strategies (compared to mining BTC). In the final column, the table shows the advantage to be gained by switching from the worst mining strategy to the best mining strategy. That number should ideally be as close to 0% as possible. https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646159947 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-645735330 Differences in hashrate regulation performance between these four options in simulations were minor. There seemed to often be a small edge for the EMA based algorithms (`wtema` and `asert`), but the advantages were small enough that we believed that the choice should be made on other concerns, like implementation complexity. Both `lwma` and `wt` require sampling every block header in their windows (e.g. 288 blocks) in order to calculate the next block's difficulty, whereas the EMA family generally only requires sampling two block headers, so our attention focused on the EMA family. Our attention then focused on determining which EMA algorithm to use. The most interesting ones seemed to be `wtema` and `asert`. WTEMA and ASERT The two EMAs that seemed like the best candidates were `wtema` and `asert`. The `wtema` algorithm was created by dgenr8 (Tom Harding) on or before Jan 1st, 2018. It is an exceptionally simple integer-only EMA based on the following pseudocode: https://github.com/kyuupichan/difficulty/pull/30 https://github.com/kyuupichan/difficulty/pull/30/commits next_target = prior_target / (IDEAL_BLOCK_TIME * alpha_recip) next_target *= block_time + IDEAL_BLOCK_TIME * (alpha_recip - 1) In abstract terms, it first estimates how much the block's "target" (the reciprocal of difficulty) should be changed in order to achieve 600 second blocks if the most recent block interval were perfectly representative of the hashrate. Then, it performs a weighted average between that value and the last block's target, using `1/alpha_recip` as the weighting coefficient. This makes `wtema` a recursively defined function, and a classic example of a simple first-order IIR filter, equivalent to an electronic RC filter. But don't be fooled by the simplicity: it performs just as well as a complex PID controller system, but with a fraction of the complexity. http://www.tsdconseil.fr/tutos/tuto-iir1-en.pdf https://github.com/zawy12/difficulty-algorithms/issues/20 The `asert` algorithm was developed mostly by Mark Lundeberg on or before February, 2020, though an equivalent formula was also independently discovered in 2018 by Jacob Eliosoff but without Mark Lundeberg's detailed analysis, and again in 2020 by Werner et. al at Imperial College London. `asert` is defined by the following formulae: http://toom.im/files/da-asert.pdf https://arxiv.org/pdf/2006.03044.pdf target_timestamp = (height + 1 - activation_height)*IDEAL_BLOCK_TIME next_target = target_at_activation * 2^((last_timestamp − target_timestamp)/tau) *Note:* `^` *denotes floating point exponentiation, not integer XOR.* `asert` stands for absolutely scheduled exponentially rising targets. In abstract terms, `asert` works by defining an ideal block schedule, and setting each block's difficulty exponentially, based on how far ahead of or behind that schedule its parent block was. For every `tau` seconds ahead of schedule a block is, the next block's difficulty goes up by a factor of 2. Reasonable values of `tau` can be from a few hours to a few weeks. Like `wtema`, `asert`'s code and math are simple, and only depend on two blocks. Unlike `wtema`, `asert` depends only on the most recent block and the genesis block or the fork block at which `asert` was activated. This avoids the recursive definition that `wtema` has. For more information on `asert`, I highly recommend Mark Lundeberg's succinct introductory paper. http://toom.im/files/da-asert.pdf The two algorithms are functionally nearly identical when block intervals are reasonably close to normal, and only differ at the extremes. The debate between the two algorithms seemed to center around four issues: https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646071315 Integer approximations — easier with `wtema` than `asert`, due to `asert`'s use of an explicit exponential function, but possible in both Singularity and negative solvetimes — problematic with `wtema`, but not `asert` , as shown in the graph above (source: dgenr8). `wtema` likely needs rules restricting solvetimes to be greater than some value (e.g. > `-0.5 * 144 * 600 sec` for `wtema-144`) https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-648958314 Mathematical and theoretical elegance — good with both, but better for `asert` Accumulation of rounding/approximation error — modest in `wtema`, but absent in `asert` due to its absolute nature The main issues seemed to be #1 and #2. The need for integer approximations of 2^x makes `asert` more complex. The need to protect against large negative solvetimes makes `wtema` more complex. Ultimately, we decided that it would be better to add a few lines of code to the difficulty calculation function itself than to add or change other consensus rules in order to forbid large negative solvetimes, so we settled on `asert`. It is important to not include floating point code in Bitcoin consensus rules, since C and C++ are generally not IEEE 754-compliant, and different compilers and hardware can disagree on floating-point computations. So we need an integer approximation. We then began looking at different approximation implementations. https://stackoverflow.com/questions/5777484/how-to-check-if-c-compiler-uses-ieee-754-floating-point-standard The method I chose relies uses the `2^x = 2 * 2^(x-1)` identity to shift the `2^x` approximation to the `0 <= x < 1` range. Once this has been done, `asert` becomes remarkably insensitive to any residual error, and even an approximation as simple as `2^x ~= 1 + x` works pretty well. But we could do much better than that, so we did. After testing a few approaches, I eventually choose to use Mark Lundeberg's cubic approximation of `2^x` for `0 <= x < 1`. This approximation maintains an error margin below 0.013%. https://twitter.com/MarkLundeberg/status/1191831127306031104 Here is an as-yet untested example C++ implementation of the `aserti3` algorithm, and here is a well-tested python3 implementation of `aserti3`. Performance mirrors that of true `asert` very closely. Testing of the C++ implementation should follow soon. https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#ee35cfc09ad35fa12b8d0a6280a950e4edde3d20_285_299 https://github.com/jtoomim/difficulty/blob/6787454d03d37107a5cc0c5fe35e2ec0c3aff7d0/mining.py#L373 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-647060200 The main competing approximation option was Jacob Eliosoff's `exp_int_approx()` implementation, which uses an algorithm grabbed from Stack Overflow to achieve arbitrary precision, but at the cost of the use of a `for` loop and more opaque math and code. I chose a half-life of 2 days (`tau = 2*24*60*60`, equivalent to a responsiveness setting of `2*144/ln(2)` or `aserti3-415.5` due to a difference in exponential bases) because that seems within the range of values that perform near-optimally in simulation while also being easy for humans to understand and discuss — for every 2 days ahead of schedule a block's timestamp gets, difficulty doubles. I consider a half-life of 1 day (`aserti3-207.75`) to also be acceptable. I recommend against going lower than 207.75 or higher than 576. https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646866050 https://math.stackexchange.com/a/56064 https://github.com/zawy12/difficulty-algorithms/issues/62#issuecomment-646312380 Activation Because the `asert` calculation depends on the fork block's height and difficulty, implementation is substantially simpler and easier if activation is on a predetermined block height, rather than at a predetermined median time past (MTP). If the latter approach is used, then post-fork the new `asert` code will need to search the blockchain for the first block whose MTP exceeded the fork time, and extract the height and difficulty from that block's header. In contrast, if a fork height is used, the `asert` algorithm just needs to search the blockchain for the difficulty at the known height — a considerably simpler operation. While an MTP-based activation of `asert` is possible, it is my belief that it will be simpler and better overall to do this activation based on block height instead. Bitcoin ABC has a tradition of adding a poison pill to their code in advance to fork off obsolete versions of their software at a predetermined MTP. If a fork height is used to activate `asert`, then the poison pill activation and the `asert` activation will not coincide exactly. This will likely result in two technical hard forks in quick succession, rather than a single three-way fork. This is a minor disadvantage to using a fork height activation. But even if the poison pill does not coincide perfectly, it will still serve its purpose: It will discourage individuals from continuing to run obsolete software. I believe that the (potentially permanently) simpler code of a height-based activation of `asert` outweighs the timing mismatch issue, so I used a height-based activation in my sample C++ implementation. I am okay with this being changed if a majority of the BCH development community disagrees. https://gitlab.com/jtoomim/bitcoin-cash-node/-/commit/fd92035c2e8d16360fb3e314b626bf52f2a2be67#00a11683af1b8f38bab65b15de6c73734d272438_74_76 Testnet The standard 20-minute testnet rule applies: A block may be mined with difficulty 1 if its timestamp is at least 20 minutes ahead of the previous block's. Because `asert` difficulty adjustments are based on time rather than block height, the "timewarp" technique to reset difficulty on testnet (by jumping the timestamp forward repeatedly to lower the average chainwork over the last difficulty adjustment interval) does not work. Because of this, testnet difficulties will be slower to adjust after this change than before, and testnet users may be stuck with 20 minute blocks for a few days after an ASIC miner leaves testnet. This could be addressed by reducing the `tau` value on testnet, but the cost of this change would be that testnet would less accurately resemble mainnet. Developers who use testnet frequently should discuss which approach they prefer. Attacks We have looked at a few different types of attack against `aserti3`, and so far, with existing consensus rules and non-ABC/BCHN node policy, `aserti3` outperforms `cw-144` in almost all scenarios. There are only a few that seem concerning. All attacks that have been identified so far are small in magnitude (usually smaller than other known and existing attack vectors) and/or easily mitigated with small node policy changes. The attack scenarios of significant concern are all ones that the current DAA protects against by using a median-of-three prefilter. The current DAA will use the median timestamp of the most recent three blocks as well as the median timestamp of the blocks 144, 145, and 146 blocks ago. This median-of-three prefilter effectively adds 1 block of delay to the DAA in most scenarios, which prevents difficulty from being exploited in a 2-block reorg attack, such as are used in most known selfish mining strategies. However, this extra block of delay also tends to cause oscillation issues in most DAAs that aren't already oscillatory, including EMAs, so zawy12 and I strongly advise against the use of median prefilters. This leaves two types of 2-block attacks as needing special attention. https://www.bitcoinabc.org/2017-11-01-DAA/ https://github.com/zawy12/difficulty-algorithms/issues/49 The first attack is selfish mining in the absence of oscillations. In this scenario, a selfish miner `A` can make a block `A1` with an artificially early timestamp — say, a solvetime of 1 second — which increases the difficulty of the next block `A2` by 0.24%. This can cause chain `A2` to have slightly more chainwork than `B2`, and can make nodes to prefer `A2` over `B2` even if `B2` was seen first. Bitcoin ABC and BCHN already have node policy rules that block this attack, but Bitcoin Unlimited and most other nodes do not. To address this issue, we recommend that all remaining nodes add hysteresis to the first-seen rule for blocks: nodes should only switch chains if the new chain's work exceeds the first's by some substantial threshold, like 10% or 50% of one block's chainwork. https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/validation.cpp#L2516 https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/blob/master/src/validation.cpp#L2699 https://github.com/BitcoinUnlimited/BitcoinUnlimited/blob/release/src/validation/validation.cpp#L1289 The second attack is the FTL (future time limit) attack. In this attack, a miner creates a block with the timestamp set to the FTL (currently 7200 seconds in the future according to most BCH nodes' policies) to lower the difficulty on a secret chain, then mines as many blocks as possible until the difficulty on that chain returns to normal. This attack can be slightly more effective for `asert` than for `cw` in some (but not all) circumstances because `asert`'s difficulty responds after a single block rather than two for `cw`. This effect is largely mitigated by the use of a slower responsiveness setting (`aserti3-2d` is about 1/4 as responsive as `cw-144`), but it is better addressed by simply lowering the FTL. https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/chain.h#L27 Lowering FTL appears to be a straightforward improvement. Many altcoins have lowered FTL with no observed negative consequences. In the modern world of NTP and GPS, keeping system clocks synchronized to within 0.1 sec is easy, so there's no reason to allow up to 7,200 sec errors without punishment. Even in humanity's interplanetary future, an FTL of 600 seconds will not cause problems for the Bitcoin protocol, because blocks in which the timestamp reflects the publication time will result in blocks being received with *old* timestamps on other planets, not future timestamps. In the far future, once bitcoin mining starts to be performed on vehicles traveling at relativistic speeds, we might have to rethink the FTL; but until then, I recommend lowering it to 600 seconds or less. Furthermore, whenever the FTL is reduced, the DEFAULT_MAX_TIME_ADJUSTMENT limit on how far peer time can differ from local time (the "peer time revert rule", as zawy12 calls it) must be adjusted accordingly. https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/blob/master/src/timedata.h#L13 This is not an exhaustive discussion of potential attacks, but merely an introduction to the known attacks of concern. Discussion of a few other attack scenarios can be found in zawy12's EMA for BCH (part 2) and Hash Attack Examples Github issue threads. https://github.com/zawy12/difficulty-algorithms/issues/62 https://github.com/zawy12/difficulty-algorithms/issues/18 Conclusion The current DAA, `cw-144`, is causing a lot of problems for BCH. We should fix it. Switching to an EMA or LWMA algorithm would fix those problems. The `aserti3-2d` algorithm appears to be far superior to `cw-144` overall, and I believe it to be the best option we have. A good DAA should have the following properties, in rough order of importance: It should be stable, and not prone to oscillations; It should keep confirmation times low; It should keep incentives for miners to perform hashrate shenanigans low; It should keep incentives for miners to perform timestamp manipulation shenanigans low; It should keep incentives for miners to perform selfish mining shenanigans low; Because of #3, #4, and #5, honest mining strategies with steady hashrate should get near-optimal income; The chain should recover quickly after sudden changes in hashrate and/or exchange rate; The average block interval should be kept close to the target (e.g. 600 seconds); The algorithm should be mathematically simple and elegant; The algorithm should be easily understood and analyzed; The algorithm should be easy to implement elegantly and simply; and The algorithm should have few or no edge and corner cases. In this article, I have provided some evidence that `aserti3-2d` likely satisfies most or all of these requirements. I encourage the BCH developer community, and the BCH community as a whole, to search for scenarios in which `aserti3-2d` fails to satisfy these criteria, and to compare `aserti3-2d` to `cw-144` and any other candidate DAAs in those scenarios.

+8 more