forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tool to reconstruct L2 deposit tx hash (ethereum-optimism#12893)
- Loading branch information
1 parent
38ee089
commit 9f3f8cb
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
|
||
"github.com/ethereum-optimism/optimism/op-node/rollup/derive" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/ethclient" | ||
"github.com/ethereum/go-ethereum/log" | ||
) | ||
|
||
func main() { | ||
var rpcURL, txHash string | ||
flag.StringVar(&rpcURL, "rpc", "", "L1 RPC URL") | ||
flag.StringVar(&txHash, "tx", "", "Deposit transaction hash on L1") | ||
flag.Parse() | ||
|
||
depositLogTopic := common.HexToHash("0xb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32") | ||
|
||
ethClient, err := ethclient.Dial(rpcURL) | ||
if err != nil { | ||
log.Crit("Error creating RPC", "err", err) | ||
} | ||
|
||
l1Receipt, err := ethClient.TransactionReceipt(context.TODO(), common.HexToHash(txHash)) | ||
if err != nil { | ||
log.Crit("Error fetching transaction", "err", err) | ||
} | ||
|
||
for _, ethLog := range l1Receipt.Logs { | ||
if ethLog.Topics[0].String() == depositLogTopic.String() { | ||
|
||
reconstructedDep, err := derive.UnmarshalDepositLogEvent(ethLog) | ||
if err != nil { | ||
log.Crit("Failed to parse deposit event ", "err", err) | ||
} | ||
tx := types.NewTx(reconstructedDep) | ||
fmt.Println("L2 Tx Hash", tx.Hash().String()) | ||
} | ||
} | ||
} |