Uncle-Blocks

檢測孤兒或叔塊

  • May 16, 2020

在特定時間,我從物理節點得到一個帶有編號的塊10074305,它返回雜湊0xdd30541695c4e574839d2356a01ff19e68c8c90c180b8955623c5e0b4b7e864a(#0),然後在一段時間後,這個雜湊更改為0x6dcb187acb68646a4238f645650c9ee356746193b8dc06bc9df46f2dfedc2777(#1)。我研究過,它是由re-organization chainref)呼叫的,但我不知道 #0 是什麼類型的塊?

目前,通過使用eth_getBlockByHash來檢查,塊#0 仍然可以在網路上使用(在公共資源管理器 ex etherscan 上不可用,…),但在塊 #1 中我沒有看到任何uncles []. 來自 #0 的所有 17 筆交易都是有效交易,但其中 2 筆屬於下一個區塊10074306。所以,請幫我解釋幾個問題:

  • 哪種類型的塊 #0?

  • 如果是re-organization chain情況下,事務可能會被回滾,如果我記錄了一個事務,但不幸被回滾了,我該怎麼辦?我想這時候我檢查交易收據,它仍然有效,所以在 12 下一個區塊過去後,我有一個幽靈(不存在)交易?

非常感謝您的幫助和最誠摯的問候。

以下是響應(為了節省空間而刪除了事務雜湊):

0:

{
   "jsonrpc": "2.0",
   "id": 1,
   "result": {
       "difficulty": "0x8054b1954c717",
       "extraData": "0x505059452d65746865726d696e652d6575312d31",
       "gasLimit": "0x989680",
       "gasUsed": "0x985f5e",
       "hash": "0xdd30541695c4e574839d2356a01ff19e68c8c90c180b8955623c5e0b4b7e864a",
       "logsBloom": "0x3a324b2d994ca318c0c0222141083aa7cb20d08194590030204303a402e118d8249015421c0408672440500400202724528200c228063782455c4028922896a831040902e208d4044992953ea2b2c4ac225c2284245b204a701caf42c0483019c0250dac2252362b1028d1840c410800dc2842220a082d200820bd1815991480c00016c0c0076850a4453008808a001888d3efab618258f775c14bc2c23448058e4048040404b820200008dc0d8084c7bb11c004a902282a0dcb0312a06e1849800c2e565502540b8203163320316e050541e271e5cd4e038418203b5b1571280010f44682981202ac020686061e748684450430ba14a00540959237c59440cc",
       "miner": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
       "mixHash": "0x292cbe5354bc1654e08055b1e9991f10b8b7dbed03c97ac24b881978744536e2",
       "nonce": "0x6253a4a314383e07",
       "number": "0x99b8c1",
       "parentHash": "0xb64ff03f8a72f1931622fde9172a440d9fe82b6b1e14cdc9f76689fcd591205f",
       "receiptsRoot": "0x60d49574be7f70a8cfc128a65c579fd7db2eee2640f38817e264909fdf4ece5a",
       "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
       "size": "0x100f4",
       "stateRoot": "0xf7e12beab13dada068e802f300870121cecbf982f63ce906799bd1ba359f44ce",
       "timestamp": "0x5ebf4949",
       "totalDifficulty": "0x3452c6dc17cbf4da827",
       "transactions": [17txs],
       "transactionsRoot": "0x44d21304539fff5005c1d3db41392e30f64cc6504d84f3f479fbaf0b8ac143a4",
       "uncles": []
   }
}

1:

{
   "jsonrpc": "2.0",
   "id": 1,
   "result": {
       "difficulty": "0x8054b1954c717",
       "extraData": "0x505059452d65746865726d696e652d6575312d34",
       "gasLimit": "0x989680",
       "gasUsed": "0x9854f8",
       "hash": "0x6dcb187acb68646a4238f645650c9ee356746193b8dc06bc9df46f2dfedc2777",
       "logsBloom": "0x3a304b2cd94da318c1c4232141083ea7cb249080945d0070204302e402c018dc249014421d04484f2440500402206f34528200e329063782455c40a8562896a835042906e608c6046192953ea2f2c5ac265c62062453204a701eaf46e24a3099c0250dcc22523e39102891840c718820dc2842230a082d200822bd19159914a2c20012c0e0056850a4453808808a001c88dbe7eb608258d775c14be9c23458058e40088404049820308028cc098084c7bf11c004a902282a0fcb0312a06e1b49818c2e565502548b8223163320736c252441f2f1e5cc46038018213b5b5571280810f64683981200ac000682071e6c8684450c30ba14a0054695d235e99440ec",
       "miner": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
       "mixHash": "0x0f453fe6267e7e432bfe3c4bb19973dfe92b894ffab44fe5cce408ce25c48a5a",
       "nonce": "0xcde83c5800562c35",
       "number": "0x99b8c1",
       "parentHash": "0xb64ff03f8a72f1931622fde9172a440d9fe82b6b1e14cdc9f76689fcd591205f",
       "receiptsRoot": "0xe0ba91bfd24347ac359d8c2207b8b2d871d7bcfd9175ddaa6e6330ad3c57f399",
       "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
       "size": "0x10956",
       "stateRoot": "0xc7f8bbb8d2957d6840fafbae1efbf28d101a9cc968c7d4c63097999ae6cd99a5",
       "timestamp": "0x5ebf4949",
       "totalDifficulty": "0x3452c6dc17cbf4da827",
       "transactions": [15txs],
       "transactionsRoot": "0xaa6ac619660443054e9eb72b088fdd9b4e9a380c7b5dd53c796fa50737b127d4",
       "uncles": []
   }
}

塊 (#0) 沒有名稱。它可能會在未來的區塊中顯示為叔叔,但不一定。

來自塊 (#0) 的交易應被視為待處理。它們可能仍會出現在未來的區塊中。如果它們仍處於待處理狀態,則收據應該有一個空塊,如果它們被開採,則應該有一個新的塊雜湊。

如果交易在一段時間後仍處於待處理狀態,您可能需要考慮更換它,方法是使用相同的 nonce 和更高的 gas 價格重新發送它們。

即使您嘗試替換待處理的交易,也可能會發生第一個交易被探勘而舊交易被丟棄的情況。

引用自:https://ethereum.stackexchange.com/questions/83460