Commit f03df0a5 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4643 from ethereum-optimism/fix/output-root-compute

op-node: ComputeL2OutputRoot cleanup
parents 585a94a8 d050d866
package rollup
import (
"bytes"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
// ComputeL2OutputRoot computes the L2 output root
func ComputeL2OutputRoot(l2OutputRootVersion eth.Bytes32, blockHash common.Hash, blockRoot common.Hash, storageRoot common.Hash) eth.Bytes32 {
var buf bytes.Buffer
buf.Write(l2OutputRootVersion[:])
buf.Write(blockRoot.Bytes())
buf.Write(storageRoot[:])
buf.Write(blockHash.Bytes())
return eth.Bytes32(crypto.Keccak256Hash(buf.Bytes()))
digest := crypto.Keccak256Hash(
l2OutputRootVersion[:],
blockRoot.Bytes(),
storageRoot[:],
blockHash.Bytes(),
)
return eth.Bytes32(digest)
}
// HashOutputRootProof computes the hash of the output root proof
func HashOutputRootProof(proof *bindings.TypesOutputRootProof) eth.Bytes32 {
return ComputeL2OutputRoot(
proof.Version,
proof.StateRoot,
proof.MessagePasserStorageRoot,
proof.LatestBlockhash,
)
}
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