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 package rollup
import ( import (
"bytes" "github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto" "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 { func ComputeL2OutputRoot(l2OutputRootVersion eth.Bytes32, blockHash common.Hash, blockRoot common.Hash, storageRoot common.Hash) eth.Bytes32 {
var buf bytes.Buffer digest := crypto.Keccak256Hash(
buf.Write(l2OutputRootVersion[:]) l2OutputRootVersion[:],
buf.Write(blockRoot.Bytes()) blockRoot.Bytes(),
buf.Write(storageRoot[:]) storageRoot[:],
buf.Write(blockHash.Bytes()) blockHash.Bytes(),
return eth.Bytes32(crypto.Keccak256Hash(buf.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