Commit b014b0ee authored by Mark Tyneway's avatar Mark Tyneway

op-node: ComputeL2OutputRoot cleanup

Cleans up the implementation of the `ComputeL2OutputRoot`
function. No need for the intermediate `bytes.Buffer`.
parent 585a94a8
package rollup
import (
"bytes"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
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)
}
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