Commit 90ade85a authored by clabby's avatar clabby

Remove unused dependencies from `contracts-bedrock`

parent eeed99ed
...@@ -114,7 +114,7 @@ func (n *nodeAPI) OutputAtBlock(ctx context.Context, number hexutil.Uint64) (*et ...@@ -114,7 +114,7 @@ func (n *nodeAPI) OutputAtBlock(ctx context.Context, number hexutil.Uint64) (*et
} }
var l2OutputRootVersion eth.Bytes32 // it's zero for now var l2OutputRootVersion eth.Bytes32 // it's zero for now
l2OutputRoot := rollup.ComputeL2OutputRoot(l2OutputRootVersion, head.Hash(), head.Root(), proof.StorageHash) l2OutputRoot := rollup.ComputeL2OutputRoot(l2OutputRootVersion, head.Root(), proof.StorageHash, head.Hash())
return &eth.OutputResponse{ return &eth.OutputResponse{
Version: l2OutputRootVersion, Version: l2OutputRootVersion,
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
) )
// ComputeL2OutputRoot computes the L2 output root // ComputeL2OutputRoot computes the L2 output root
func ComputeL2OutputRoot(l2OutputRootVersion eth.Bytes32, blockHash common.Hash, blockRoot common.Hash, storageRoot common.Hash) eth.Bytes32 { func ComputeL2OutputRoot(l2OutputRootVersion eth.Bytes32, blockRoot common.Hash, storageRoot common.Hash, blockHash common.Hash) eth.Bytes32 {
digest := crypto.Keccak256Hash( digest := crypto.Keccak256Hash(
l2OutputRootVersion[:], l2OutputRootVersion[:],
blockRoot.Bytes(), blockRoot.Bytes(),
......
...@@ -59,8 +59,6 @@ ...@@ -59,8 +59,6 @@
}, },
"devDependencies": { "devDependencies": {
"@eth-optimism/hardhat-deploy-config": "^0.2.5", "@eth-optimism/hardhat-deploy-config": "^0.2.5",
"@ethereumjs/trie": "^5.0.0-beta.1",
"@ethereumjs/util": "^8.0.0-beta.1",
"@ethersproject/abstract-provider": "^5.7.0", "@ethersproject/abstract-provider": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/abstract-signer": "^5.7.0",
"ethereumjs-wallet": "^1.0.2", "ethereumjs-wallet": "^1.0.2",
......
...@@ -5,17 +5,16 @@ import ( ...@@ -5,17 +5,16 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain" "github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
) )
var UnknownNonceVersion = errors.New("Unknown nonce version") var UnknownNonceVersion = errors.New("Unknown nonce version")
var ZeroPadding = [32]byte{}
// checkOk checks if ok is false, and panics if so. // checkOk checks if ok is false, and panics if so.
// Shorthand to ease go's god awful error handling // Shorthand to ease go's god awful error handling
func checkOk(ok bool) { func checkOk(ok bool) {
...@@ -53,52 +52,26 @@ func encodeCrossDomainMessage(nonce *big.Int, sender common.Address, target comm ...@@ -53,52 +52,26 @@ func encodeCrossDomainMessage(nonce *big.Int, sender common.Address, target comm
// hashWithdrawal hashes a withdrawal transaction. // hashWithdrawal hashes a withdrawal transaction.
func hashWithdrawal(nonce *big.Int, sender common.Address, target common.Address, value *big.Int, gasLimit *big.Int, data []byte) (common.Hash, error) { func hashWithdrawal(nonce *big.Int, sender common.Address, target common.Address, value *big.Int, gasLimit *big.Int, data []byte) (common.Hash, error) {
// Pack withdrawal wd := crossdomain.Withdrawal{
wdtx := struct {
Nonce *big.Int
Sender common.Address
Target common.Address
Value *big.Int
GasLimit *big.Int
Data []byte
}{
Nonce: nonce, Nonce: nonce,
Sender: sender, Sender: &sender,
Target: target, Target: &target,
Value: value, Value: value,
GasLimit: gasLimit, GasLimit: gasLimit,
Data: data, Data: data,
} }
packed, err := withdrawalTransactionArgs.Pack(&wdtx) return wd.Hash()
if err != nil {
return common.Hash{}, err
}
// Hash packed withdrawal (we ignore the pointer)
return crypto.Keccak256Hash(packed[32:]), nil
} }
// hashOutputRootProof hashes an output root proof. // hashOutputRootProof hashes an output root proof.
func hashOutputRootProof(version common.Hash, stateRoot common.Hash, messagePasserStorageRoot common.Hash, latestBlockHash common.Hash) (common.Hash, error) { func hashOutputRootProof(version common.Hash, stateRoot common.Hash, messagePasserStorageRoot common.Hash, latestBlockHash common.Hash) common.Hash {
// Pack proof proof := bindings.TypesOutputRootProof{
proof := struct {
Version common.Hash
StateRoot common.Hash
MessagePasserStorageRoot common.Hash
LatestBlockHash common.Hash
}{
Version: version, Version: version,
StateRoot: stateRoot, StateRoot: stateRoot,
MessagePasserStorageRoot: messagePasserStorageRoot, MessagePasserStorageRoot: messagePasserStorageRoot,
LatestBlockHash: latestBlockHash, LatestBlockhash: latestBlockHash,
}
packed, err := outputRootProofArgs.Pack(&proof)
if err != nil {
return common.Hash{}, err
} }
return common.Hash(rollup.HashOutputRootProof(&proof))
// Hash packed proof
return crypto.Keccak256Hash(packed), nil
} }
// makeDepositTx creates a deposit transaction type. // makeDepositTx creates a deposit transaction type.
...@@ -139,3 +112,15 @@ func makeDepositTx( ...@@ -139,3 +112,15 @@ func makeDepositTx(
return depositTx return depositTx
} }
// Custom type to write the generated proof to
type proofList [][]byte
func (n *proofList) Put(key []byte, value []byte) error {
*n = append(*n, value)
return nil
}
func (n *proofList) Delete(key []byte) error {
panic("not supported")
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment