//tips
//smart contract
自分のコントラクトをrinkebyネットワークに接続の上、deployし複数回claimするとどのくらいtest ethを使うのかを観測しておく。
コントラクトのdeployコストは下記。
Contract Deploy Final cost: 0.007656682524501384 ETH
あとはclaim費用などもあるので0.1ethがもらえるchainlinkで一回は実施できそう。予備として多めに持っといた方が良いが。そこはtest ethの取得難易度との関係で調整。
またイーサリアムのマイニングの際の目標数値の取り方で、ハッシュ先頭につく0の数ではなく、ハッシュを10進数に直したときのターゲット数(4000など)以下が成功とみなされるという記述を見かけたので現在どちらのパターンで運用されているのかを調べる。
また、ブロックの中身(格納トランザクション)を各ノードが決め、提出した後に、どのブロックでマイナーたちの競争を行われるかの原理が少しわからなくなり始めたので確認。
無数のブロックのうち次のブロックを決める原理はどういうものだったか。ブロック内のガス代(トランザクションのガス代合計)が最も高いものだったか。
https://ethereum.org/ja/developers/docs/consensus-mechanisms/pow/mining/
https://cointelegraph.com/ethereum-for-beginners/how-to-mine-thereum-a-beginners-guide-to-eth-mining
ブロックチェーンの承認の流れで今まで勘違いしていたが、マイニングの競争は同じ中身のブロックに対する競争ではなく、各々のブロックに対してどれぐらいの速さで適切なノンスを見つけられるかの競争だったよう。あと、面白いのがEVM stateを新たなものに書き換えるというもの。この知らせを受け取った各マイナーは残念ながら新たなstateに書き換えなければならないので、そのステージでの競争は終了となり、受け取ったブロックの検証作業に移る。その検証完了を持ってブロックチェーンの最後に新たなブロックが追加される。
4.At some point, a mining node aggregates several dozen or hundred transaction requests into a potential block, in a way that maximizes the transaction fees they earn while still staying under the block gas limit. The mining node then:
a.Verifies the validity of each transaction request (i.e. no one is trying to transfer ether out of an account they haven’t produced a signature for, the request is not malformed, etc.), and then executes the code of the request, altering the state of their local copy of the EVM. The miner awards the transaction fee for each such transaction request to their own account.
b.Begins the process of producing the proof-of-work “certificate of legitimacy” for the potential block, once all transaction requests in the block have been verified and executed on the local EVM copy.
5.Eventually, a miner will finish producing a certificate for a block which includes our specific transaction request. The miner then broadcasts the completed block, which includes the certificate and a checksum of the claimed new EVM state.
6.Other nodes hear about the new block. They verify the certificate, execute all transactions on the block themselves (including the transaction originally broadcasted by our user), and verify that the checksum of their new EVM state after the execution of all transactions matches the checksum of the state claimed by the miner’s block. Only then do these nodes append this block to the tail of their blockchain, and accept the new EVM state as the canonical state.
https://ethereum.org/ja/developers/docs/evm/
bitcoinの合意形成がシンプルすぎたので、Ethereumは Ethashと呼ばれるPoWアルゴリズムを使っている。下記がめちゃ参考になった。頭良すぎてビビる。
https://www.etarou.work/posts/4983481/
https://ethereum.org/ja/developers/docs/consensus-mechanisms/pow/
おかげで封印されたイエローペーパーさん。
https://ethereum.github.io/yellowpaper/paper.pdf
BitcoinのBitcoinの合意形成メカニズムはnonceの発見競争だったが、その際に、覇権をとったASICと呼ばれるSHA256を計算するためだけの専用マシンに対抗し、Ethereumは Ethashというアルゴリズムが使われ、計算を複雑化させた。
difficulty targetの条件を満たし、マイニングに成功したら、完成ブロックを全ノードに伝達。ここまでが競争部分。
競争に負けた側は、伝達されたブロックを取り込み検証を行う。検証して問題なかったら、そのブロック内で使用されたトランザクションを未使用トランザクションプールから削除し、自身のチェーンの最後にブロックを追加。
負けた側がもし伝達されたブロックを受け入れなかったら、次の競争に参加できなくなるので、渋々同期する。
わかりみ。