Contract-Deployment

執行恢復:DepositContract:重建的 DepositData 與提供的 deposit_data_root 不匹配

  • December 1, 2020

通過 Remix 部署 Goerli 的 Medalla Beacon Contract 時出現此錯誤。

execution reverted: DepositContract: reconstructed DepositData does not match supplied deposit_data_root

輸入(web3)

pubkey: 0x94a61e90d697a287c31d389d2389aff2523a3e677949810381f3e485d79eb07150463f2c2b2796f744874e4810e3e778
withdrawal_credentials: 0x0045fe3422a0c68e6192a3782850334ed9fe162212a9f888c31aaa67c8d34e7b
signature: 0x81c0e6d9953ba76c1d0c27162e98576019e702fd94b27269791fcf30d0afc371acc9385444cfe82dbc2b50612b1ae20416d17fa1360151209a09d66f5b615f84f0a701fe60d668d0ef4fabcb815c4fe95855c242edaa02bf5f5f9a3d7b7cc87f
deposit_data_root: 0x2467b379933a366aa89584578cfd63434769a07bec11a347a207f70862fa1a92

交易:https ://goerli.etherscan.io/tx/0x2f9118dafa84846768dcac5d66fea223729bbc22799e787f511774dfe437d211

合約:https ://goerli.etherscan.io/address/0x07b39f4fde4a38bace212b546dac87c58dfe3fdc#code

任何的想法?先感謝您

以下是您應該如何調查問題:

  1. 轉到合約的程式碼
  2. 搜尋錯誤消息DepositContract: reconstructed DepositData does not match supplied deposit_data_root
  3. 在函式中找到它function deposit
// Verify computed and expected deposit data roots match
require(node == deposit_data_root, "DepositContract: reconstructed DepositData does not match supplied deposit_data_root");
  1. 你知道是什麼deposit_data_root(因為你提供了它作為輸入),所以向上滾動一下看看node是如何計算的:
bytes32 node = sha256(abi.encodePacked(
   sha256(abi.encodePacked(pubkey_root, withdrawal_credentials)),
   sha256(abi.encodePacked(amount, bytes24(0), signature_root))
));
  1. 您知道pubkey_root, withdrawal_credentialsand signature_rootare (因為您提供了它們中的每一個作為輸入),所以向上滾動一下以查看如何amount計算:
uint deposit_amount = msg.value / GWEI;
  1. 如果你的問題中陳述的所有輸入值都是正確的,那麼問題就在amount,在這種情況下,問題的原因是你傳遞了一個不正確的msg.value(即,你在執行交易時傳遞了不正確的乙太幣數量)

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