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 package rollup
import ( import (
"bytes"
"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"
) )
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)
} }
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