Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion op-e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (cfg SystemConfig) start() (*System, error) {
Alloc: l2Alloc,
Difficulty: common.Big1,
GasLimit: 5000000,
Nonce: 4660,
Nonce: 0,
// must be equal (or higher, while within bounds) as the L1 anchor point of the rollup
Timestamp: genesisTimestamp,
BaseFee: big.NewInt(7),
Expand Down
260 changes: 0 additions & 260 deletions op-node/l2/source.go

This file was deleted.

3 changes: 2 additions & 1 deletion op-node/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Metrics struct {
RPCClientResponsesTotal *prometheus.CounterVec

L1SourceCache *CacheMetrics
// TODO: L2SourceCache *CacheMetrics
L2SourceCache *CacheMetrics

DerivationIdle prometheus.Gauge

Expand Down Expand Up @@ -136,6 +136,7 @@ func NewMetrics(procName string) *Metrics {
}),

L1SourceCache: NewCacheMetrics(registry, ns, "l1_source_cache", "L1 Source cache"),
L2SourceCache: NewCacheMetrics(registry, ns, "l2_source_cache", "L2 Source cache"),

DerivationIdle: promauto.With(registry).NewGauge(prometheus.GaugeOpts{
Namespace: ns,
Expand Down
27 changes: 8 additions & 19 deletions op-node/node/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package node
import (
"context"
"fmt"
"math/big"

"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-node/eth"
Expand All @@ -13,20 +12,14 @@ import (
"github.com/ethereum-optimism/optimism/op-node/version"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
)

type l2EthClient interface {
GetBlockHeader(ctx context.Context, blockTag string) (*types.Header, error)
InfoByRpcNumber(ctx context.Context, num rpc.BlockNumber) (eth.BlockInfo, error)
// GetProof returns a proof of the account, it may return a nil result without error if the address was not found.
GetProof(ctx context.Context, address common.Address, blockTag string) (*eth.AccountResult, error)

BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
L2BlockRefByNumber(ctx context.Context, l2Num *big.Int) (eth.L2BlockRef, error)
L2BlockRefByHash(ctx context.Context, l2Hash common.Hash) (eth.L2BlockRef, error)
}

type driverClient interface {
Expand Down Expand Up @@ -75,7 +68,7 @@ func (n *nodeAPI) OutputAtBlock(ctx context.Context, number rpc.BlockNumber) ([]
defer recordDur()
// TODO: rpc.BlockNumber doesn't support the "safe" tag. Need a new type

head, err := n.client.GetBlockHeader(ctx, toBlockNumArg(number))
head, err := n.client.InfoByRpcNumber(ctx, number)
if err != nil {
n.log.Error("failed to get block", "err", err)
return nil, err
Expand All @@ -93,13 +86,13 @@ func (n *nodeAPI) OutputAtBlock(ctx context.Context, number rpc.BlockNumber) ([]
return nil, ethereum.NotFound
}
// make sure that the proof (including storage hash) that we retrieved is correct by verifying it against the state-root
if err := proof.Verify(head.Root); err != nil {
n.log.Error("invalid withdrawal root detected in block", "stateRoot", head.Root, "blocknum", number, "msg", err)
if err := proof.Verify(head.Root()); err != nil {
n.log.Error("invalid withdrawal root detected in block", "stateRoot", head.Root(), "blocknum", number, "msg", err)
return nil, fmt.Errorf("invalid withdrawal root hash")
}

var l2OutputRootVersion eth.Bytes32 // it's zero for now
l2OutputRoot := rollup.ComputeL2OutputRoot(l2OutputRootVersion, head.Hash(), head.Root, proof.StorageHash)
l2OutputRoot := rollup.ComputeL2OutputRoot(l2OutputRootVersion, head.Hash(), head.Root(), proof.StorageHash)

return []eth.Bytes32{l2OutputRootVersion, l2OutputRoot}, nil
}
Expand All @@ -123,11 +116,7 @@ func (n *nodeAPI) Version(ctx context.Context) (string, error) {
}

func toBlockNumArg(number rpc.BlockNumber) string {
if number == rpc.LatestBlockNumber {
return "latest"
}
if number == rpc.PendingBlockNumber {
return "pending"
}
return hexutil.EncodeUint64(uint64(number.Int64()))
// never returns an error
out, _ := number.MarshalText()
return string(out)
}
Loading