Commit 877ecdf0 authored by Ethen Pociask's avatar Ethen Pociask

Merge branch 'develop' of https://github.com/epociask/optimism into indexer.l1height-param

parents 5cd548ca c6e6f6e8
...@@ -68,7 +68,7 @@ func Main(version string, cliCtx *cli.Context) error { ...@@ -68,7 +68,7 @@ func Main(version string, cliCtx *cli.Context) error {
l.Info("starting metrics server", "addr", metricsCfg.ListenAddr, "port", metricsCfg.ListenPort) l.Info("starting metrics server", "addr", metricsCfg.ListenAddr, "port", metricsCfg.ListenPort)
go func() { go func() {
if err := m.Serve(ctx, metricsCfg.ListenAddr, metricsCfg.ListenPort); err != nil { if err := m.Serve(ctx, metricsCfg.ListenAddr, metricsCfg.ListenPort); err != nil {
l.Error("error starting metrics server", err) l.Error("error starting metrics server", "err", err)
} }
}() }()
m.StartBalanceMetrics(ctx, l, batchSubmitter.L1Client, batchSubmitter.TxManager.From()) m.StartBalanceMetrics(ctx, l, batchSubmitter.L1Client, batchSubmitter.TxManager.From())
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -13,7 +13,7 @@ const ProxyStorageLayoutJSON = "{\"storage\":null,\"types\":{}}" ...@@ -13,7 +13,7 @@ const ProxyStorageLayoutJSON = "{\"storage\":null,\"types\":{}}"
var ProxyStorageLayout = new(solc.StorageLayout) var ProxyStorageLayout = new(solc.StorageLayout)
var ProxyDeployedBin = "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100be5780638f283970146100f8578063f851a440146101185761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61012d565b005b61006b61012d565b34801561008157600080fd5b5061006b6100903660046106d9565b610224565b6100a86100a33660046106f4565b610296565b6040516100b59190610777565b60405180910390f35b3480156100ca57600080fd5b506100d3610419565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100b5565b34801561010457600080fd5b5061006b6101133660046106d9565b6104b0565b34801561012457600080fd5b506100d3610517565b60006101577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b905073ffffffffffffffffffffffffffffffffffffffff8116610201576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f50726f78793a20696d706c656d656e746174696f6e206e6f7420696e6974696160448201527f6c697a656400000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b3660008037600080366000845af43d6000803e8061021e573d6000fd5b503d6000f35b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061027d575033155b1561028e5761028b816105a3565b50565b61028b61012d565b60606102c07fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806102f7575033155b1561040a57610305846105a3565b6000808573ffffffffffffffffffffffffffffffffffffffff16858560405161032f9291906107ea565b600060405180830381855af49150503d806000811461036a576040519150601f19603f3d011682016040523d82523d6000602084013e61036f565b606091505b509150915081610401576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603960248201527f50726f78793a2064656c656761746563616c6c20746f206e657720696d706c6560448201527f6d656e746174696f6e20636f6e7472616374206661696c65640000000000000060648201526084016101f8565b91506104129050565b61041261012d565b9392505050565b60006104437fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061047a575033155b156104a557507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b6104ad61012d565b90565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610509575033155b1561028e5761028b8161060b565b60006105417fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610578575033155b156104a557507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81905560405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60006106357fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61038390556040805173ffffffffffffffffffffffffffffffffffffffff8084168252851660208201529192507f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a15050565b803573ffffffffffffffffffffffffffffffffffffffff811681146106d457600080fd5b919050565b6000602082840312156106eb57600080fd5b610412826106b0565b60008060006040848603121561070957600080fd5b610712846106b0565b9250602084013567ffffffffffffffff8082111561072f57600080fd5b818601915086601f83011261074357600080fd5b81358181111561075257600080fd5b87602082850101111561076457600080fd5b6020830194508093505050509250925092565b600060208083528351808285015260005b818110156107a457858101830151858201604001528201610788565b818111156107b6576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b818382376000910190815291905056fea164736f6c634300080f000a" var ProxyDeployedBin = "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100be5780638f283970146100f8578063f851a440146101185761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61012d565b005b61006b61012d565b34801561008157600080fd5b5061006b6100903660046106dd565b610224565b6100a86100a33660046106f8565b610296565b6040516100b5919061077b565b60405180910390f35b3480156100ca57600080fd5b506100d3610419565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100b5565b34801561010457600080fd5b5061006b6101133660046106dd565b6104b0565b34801561012457600080fd5b506100d3610517565b60006101577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b905073ffffffffffffffffffffffffffffffffffffffff8116610201576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f50726f78793a20696d706c656d656e746174696f6e206e6f7420696e6974696160448201527f6c697a656400000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b3660008037600080366000845af43d6000803e8061021e573d6000fd5b503d6000f35b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061027d575033155b1561028e5761028b816105a3565b50565b61028b61012d565b60606102c07fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806102f7575033155b1561040a57610305846105a3565b6000808573ffffffffffffffffffffffffffffffffffffffff16858560405161032f9291906107ee565b600060405180830381855af49150503d806000811461036a576040519150601f19603f3d011682016040523d82523d6000602084013e61036f565b606091505b509150915081610401576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603960248201527f50726f78793a2064656c656761746563616c6c20746f206e657720696d706c6560448201527f6d656e746174696f6e20636f6e7472616374206661696c65640000000000000060648201526084016101f8565b91506104129050565b61041261012d565b9392505050565b60006104437fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061047a575033155b156104a557507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b6104ad61012d565b90565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610509575033155b1561028e5761028b8161060c565b60006105417fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610578575033155b156104a557507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81815560405173ffffffffffffffffffffffffffffffffffffffff8316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a25050565b60006106367fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61038381556040805173ffffffffffffffffffffffffffffffffffffffff80851682528616602082015292935090917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a1505050565b803573ffffffffffffffffffffffffffffffffffffffff811681146106d857600080fd5b919050565b6000602082840312156106ef57600080fd5b610412826106b4565b60008060006040848603121561070d57600080fd5b610716846106b4565b9250602084013567ffffffffffffffff8082111561073357600080fd5b818601915086601f83011261074757600080fd5b81358181111561075657600080fd5b87602082850101111561076857600080fd5b6020830194508093505050509250925092565b600060208083528351808285015260005b818110156107a85785810183015185820160400152820161078c565b818111156107ba576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b818382376000910190815291905056fea164736f6c634300080f000a"
func init() { func init() {
if err := json.Unmarshal([]byte(ProxyStorageLayoutJSON), ProxyStorageLayout); err != nil { if err := json.Unmarshal([]byte(ProxyStorageLayoutJSON), ProxyStorageLayout); err != nil {
......
...@@ -5,6 +5,8 @@ import ( ...@@ -5,6 +5,8 @@ import (
"fmt" "fmt"
"github.com/ethereum-optimism/optimism/op-node/chaincfg" "github.com/ethereum-optimism/optimism/op-node/chaincfg"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
oppprof "github.com/ethereum-optimism/optimism/op-service/pprof"
"github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
) )
...@@ -105,7 +107,9 @@ type Config struct { ...@@ -105,7 +107,9 @@ type Config struct {
CannonL2 string // L2 RPC Url CannonL2 string // L2 RPC Url
CannonSnapshotFreq uint // Frequency of snapshots to create when executing cannon (in VM instructions) CannonSnapshotFreq uint // Frequency of snapshots to create when executing cannon (in VM instructions)
TxMgrConfig txmgr.CLIConfig TxMgrConfig txmgr.CLIConfig
MetricsConfig opmetrics.CLIConfig
PprofConfig oppprof.CLIConfig
} }
func NewConfig( func NewConfig(
...@@ -122,7 +126,9 @@ func NewConfig( ...@@ -122,7 +126,9 @@ func NewConfig(
TraceType: traceType, TraceType: traceType,
TxMgrConfig: txmgr.NewCLIConfig(l1EthRpc), TxMgrConfig: txmgr.NewCLIConfig(l1EthRpc),
MetricsConfig: opmetrics.DefaultCLIConfig(),
PprofConfig: oppprof.DefaultCLIConfig(),
CannonSnapshotFreq: DefaultCannonSnapshotFreq, CannonSnapshotFreq: DefaultCannonSnapshotFreq,
} }
...@@ -182,5 +188,11 @@ func (c Config) Check() error { ...@@ -182,5 +188,11 @@ func (c Config) Check() error {
if err := c.TxMgrConfig.Check(); err != nil { if err := c.TxMgrConfig.Check(); err != nil {
return err return err
} }
if err := c.MetricsConfig.Check(); err != nil {
return err
}
if err := c.PprofConfig.Check(); err != nil {
return err
}
return nil return nil
} }
...@@ -8,9 +8,11 @@ import ( ...@@ -8,9 +8,11 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings" "github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/config" "github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types" "github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/metrics"
"github.com/ethereum-optimism/optimism/op-challenger/version"
"github.com/ethereum-optimism/optimism/op-service/client" "github.com/ethereum-optimism/optimism/op-service/client"
oppprof "github.com/ethereum-optimism/optimism/op-service/pprof"
"github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -25,12 +27,14 @@ type Service interface { ...@@ -25,12 +27,14 @@ type Service interface {
type service struct { type service struct {
logger log.Logger logger log.Logger
metrics metrics.Metricer
monitor *gameMonitor monitor *gameMonitor
} }
// NewService creates a new Service. // NewService creates a new Service.
func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*service, error) { func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*service, error) {
txMgr, err := txmgr.NewSimpleTxManager("challenger", logger, &metrics.NoopTxMetrics{}, cfg.TxMgrConfig) m := metrics.NewMetrics()
txMgr, err := txmgr.NewSimpleTxManager("challenger", logger, &m.TxMetrics, cfg.TxMgrConfig)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create the transaction manager: %w", err) return nil, fmt.Errorf("failed to create the transaction manager: %w", err)
} }
...@@ -40,6 +44,27 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se ...@@ -40,6 +44,27 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
return nil, fmt.Errorf("failed to dial L1: %w", err) return nil, fmt.Errorf("failed to dial L1: %w", err)
} }
pprofConfig := cfg.PprofConfig
if pprofConfig.Enabled {
logger.Info("starting pprof", "addr", pprofConfig.ListenAddr, "port", pprofConfig.ListenPort)
go func() {
if err := oppprof.ListenAndServe(ctx, pprofConfig.ListenAddr, pprofConfig.ListenPort); err != nil {
logger.Error("error starting pprof", "err", err)
}
}()
}
metricsCfg := cfg.MetricsConfig
if metricsCfg.Enabled {
logger.Info("starting metrics server", "addr", metricsCfg.ListenAddr, "port", metricsCfg.ListenPort)
go func() {
if err := m.Serve(ctx, metricsCfg.ListenAddr, metricsCfg.ListenPort); err != nil {
logger.Error("error starting metrics server", "err", err)
}
}()
m.StartBalanceMetrics(ctx, logger, client, txMgr.From())
}
factory, err := bindings.NewDisputeGameFactory(cfg.GameFactoryAddress, client) factory, err := bindings.NewDisputeGameFactory(cfg.GameFactoryAddress, client)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to bind the fault dispute game factory contract: %w", err) return nil, fmt.Errorf("failed to bind the fault dispute game factory contract: %w", err)
...@@ -49,9 +74,14 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se ...@@ -49,9 +74,14 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
monitor := newGameMonitor(logger, client.BlockNumber, cfg.GameAddress, loader, func(addr common.Address) (gamePlayer, error) { monitor := newGameMonitor(logger, client.BlockNumber, cfg.GameAddress, loader, func(addr common.Address) (gamePlayer, error) {
return NewGamePlayer(ctx, logger, cfg, addr, txMgr, client) return NewGamePlayer(ctx, logger, cfg, addr, txMgr, client)
}) })
m.RecordInfo(version.SimpleWithMeta)
m.RecordUp()
return &service{ return &service{
monitor: monitor,
logger: logger, logger: logger,
metrics: m,
monitor: monitor,
}, nil }, nil
} }
......
...@@ -9,6 +9,8 @@ import ( ...@@ -9,6 +9,8 @@ import (
opservice "github.com/ethereum-optimism/optimism/op-service" opservice "github.com/ethereum-optimism/optimism/op-service"
openum "github.com/ethereum-optimism/optimism/op-service/enum" openum "github.com/ethereum-optimism/optimism/op-service/enum"
oplog "github.com/ethereum-optimism/optimism/op-service/log" oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
oppprof "github.com/ethereum-optimism/optimism/op-service/pprof"
"github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -134,6 +136,8 @@ var optionalFlags = []cli.Flag{ ...@@ -134,6 +136,8 @@ var optionalFlags = []cli.Flag{
func init() { func init() {
optionalFlags = append(optionalFlags, oplog.CLIFlags(envVarPrefix)...) optionalFlags = append(optionalFlags, oplog.CLIFlags(envVarPrefix)...)
optionalFlags = append(optionalFlags, txmgr.CLIFlags(envVarPrefix)...) optionalFlags = append(optionalFlags, txmgr.CLIFlags(envVarPrefix)...)
optionalFlags = append(optionalFlags, opmetrics.CLIFlags(envVarPrefix)...)
optionalFlags = append(optionalFlags, oppprof.CLIFlags(envVarPrefix)...)
Flags = append(requiredFlags, optionalFlags...) Flags = append(requiredFlags, optionalFlags...)
} }
...@@ -201,6 +205,8 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) { ...@@ -201,6 +205,8 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) {
} }
txMgrConfig := txmgr.ReadCLIConfig(ctx) txMgrConfig := txmgr.ReadCLIConfig(ctx)
metricsConfig := opmetrics.ReadCLIConfig(ctx)
pprofConfig := oppprof.ReadCLIConfig(ctx)
traceTypeFlag := config.TraceType(strings.ToLower(ctx.String(TraceTypeFlag.Name))) traceTypeFlag := config.TraceType(strings.ToLower(ctx.String(TraceTypeFlag.Name)))
...@@ -222,5 +228,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) { ...@@ -222,5 +228,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) {
CannonSnapshotFreq: ctx.Uint(CannonSnapshotFreqFlag.Name), CannonSnapshotFreq: ctx.Uint(CannonSnapshotFreqFlag.Name),
AgreeWithProposedOutput: ctx.Bool(AgreeWithProposedOutputFlag.Name), AgreeWithProposedOutput: ctx.Bool(AgreeWithProposedOutputFlag.Name),
TxMgrConfig: txMgrConfig, TxMgrConfig: txMgrConfig,
MetricsConfig: metricsConfig,
PprofConfig: pprofConfig,
}, nil }, nil
} }
package metrics
import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/prometheus/client_golang/prometheus"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
txmetrics "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
)
const Namespace = "op_challenger"
type Metricer interface {
RecordInfo(version string)
RecordUp()
// Record Tx metrics
txmetrics.TxMetricer
}
type Metrics struct {
ns string
registry *prometheus.Registry
factory opmetrics.Factory
txmetrics.TxMetrics
info prometheus.GaugeVec
up prometheus.Gauge
}
var _ Metricer = (*Metrics)(nil)
func NewMetrics() *Metrics {
registry := opmetrics.NewRegistry()
factory := opmetrics.With(registry)
return &Metrics{
ns: Namespace,
registry: registry,
factory: factory,
TxMetrics: txmetrics.MakeTxMetrics(Namespace, factory),
info: *factory.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "info",
Help: "Pseudo-metric tracking version and config info",
}, []string{
"version",
}),
up: factory.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "up",
Help: "1 if the op-challenger has finished starting up",
}),
}
}
func (m *Metrics) Serve(ctx context.Context, host string, port int) error {
return opmetrics.ListenAndServe(ctx, m.registry, host, port)
}
func (m *Metrics) StartBalanceMetrics(ctx context.Context, l log.Logger, client *ethclient.Client, account common.Address) {
opmetrics.LaunchBalanceMetrics(ctx, l, m.registry, m.ns, client, account)
}
// RecordInfo sets a pseudo-metric that contains versioning and
// config info for the op-proposer.
func (m *Metrics) RecordInfo(version string) {
m.info.WithLabelValues(version).Set(1)
}
// RecordUp sets the up metric to 1.
func (m *Metrics) RecordUp() {
prometheus.MustRegister()
m.up.Set(1)
}
func (m *Metrics) Document() []opmetrics.DocumentedMetric {
return m.factory.Document()
}
package metrics
import (
txmetrics "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
)
type noopMetrics struct {
txmetrics.NoopTxMetrics
}
var NoopMetrics Metricer = new(noopMetrics)
func (*noopMetrics) RecordInfo(version string) {}
func (*noopMetrics) RecordUp() {}
...@@ -27,4 +27,6 @@ $CHALLENGER_DIR/bin/op-challenger \ ...@@ -27,4 +27,6 @@ $CHALLENGER_DIR/bin/op-challenger \
--game-address $FAULT_GAME_ADDRESS \ --game-address $FAULT_GAME_ADDRESS \
--private-key $CHARLIE_KEY \ --private-key $CHARLIE_KEY \
--num-confirmations 1 \ --num-confirmations 1 \
--metrics.enabled --metrics.port=7304 \
--pprof.enabled --pprof.port=6064 \
--agree-with-proposed-output=true --agree-with-proposed-output=true
...@@ -27,4 +27,6 @@ $CHALLENGER_DIR/bin/op-challenger \ ...@@ -27,4 +27,6 @@ $CHALLENGER_DIR/bin/op-challenger \
--game-address $FAULT_GAME_ADDRESS \ --game-address $FAULT_GAME_ADDRESS \
--private-key $MALLORY_KEY \ --private-key $MALLORY_KEY \
--num-confirmations 1 \ --num-confirmations 1 \
--metrics.enabled --metrics.port=7305 \
--pprof.enabled --pprof.port=6065 \
--agree-with-proposed-output=false --agree-with-proposed-output=false
...@@ -4,3 +4,11 @@ var ( ...@@ -4,3 +4,11 @@ var (
Version = "v0.1.0" Version = "v0.1.0"
Meta = "dev" Meta = "dev"
) )
var SimpleWithMeta = func() string {
v := Version
if Meta != "" {
v += "-" + Meta
}
return v
}()
...@@ -85,7 +85,7 @@ func Main(version string, cliCtx *cli.Context) error { ...@@ -85,7 +85,7 @@ func Main(version string, cliCtx *cli.Context) error {
l.Info("starting metrics server", "addr", metricsCfg.ListenAddr, "port", metricsCfg.ListenPort) l.Info("starting metrics server", "addr", metricsCfg.ListenAddr, "port", metricsCfg.ListenPort)
go func() { go func() {
if err := m.Serve(ctx, metricsCfg.ListenAddr, metricsCfg.ListenPort); err != nil { if err := m.Serve(ctx, metricsCfg.ListenAddr, metricsCfg.ListenPort); err != nil {
l.Error("error starting metrics server", err) l.Error("error starting metrics server", "err", err)
} }
}() }()
m.StartBalanceMetrics(ctx, l, proposerConfig.L1Client, proposerConfig.TxManager.From()) m.StartBalanceMetrics(ctx, l, proposerConfig.L1Client, proposerConfig.TxManager.From())
......
...@@ -13,8 +13,18 @@ const ( ...@@ -13,8 +13,18 @@ const (
EnabledFlagName = "metrics.enabled" EnabledFlagName = "metrics.enabled"
ListenAddrFlagName = "metrics.addr" ListenAddrFlagName = "metrics.addr"
PortFlagName = "metrics.port" PortFlagName = "metrics.port"
defaultListenAddr = "0.0.0.0"
defaultListenPort = 7300
) )
func DefaultCLIConfig() CLIConfig {
return CLIConfig{
Enabled: false,
ListenAddr: defaultListenAddr,
ListenPort: defaultListenPort,
}
}
func CLIFlags(envPrefix string) []cli.Flag { func CLIFlags(envPrefix string) []cli.Flag {
return []cli.Flag{ return []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
...@@ -25,13 +35,13 @@ func CLIFlags(envPrefix string) []cli.Flag { ...@@ -25,13 +35,13 @@ func CLIFlags(envPrefix string) []cli.Flag {
&cli.StringFlag{ &cli.StringFlag{
Name: ListenAddrFlagName, Name: ListenAddrFlagName,
Usage: "Metrics listening address", Usage: "Metrics listening address",
Value: "0.0.0.0", // TODO(CLI-4159): Switch to 127.0.0.1 Value: defaultListenAddr, // TODO(CLI-4159): Switch to 127.0.0.1
EnvVars: opservice.PrefixEnvVar(envPrefix, "METRICS_ADDR"), EnvVars: opservice.PrefixEnvVar(envPrefix, "METRICS_ADDR"),
}, },
&cli.IntFlag{ &cli.IntFlag{
Name: PortFlagName, Name: PortFlagName,
Usage: "Metrics listening port", Usage: "Metrics listening port",
Value: 7300, Value: defaultListenPort,
EnvVars: opservice.PrefixEnvVar(envPrefix, "METRICS_PORT"), EnvVars: opservice.PrefixEnvVar(envPrefix, "METRICS_PORT"),
}, },
} }
......
...@@ -12,8 +12,18 @@ const ( ...@@ -12,8 +12,18 @@ const (
EnabledFlagName = "pprof.enabled" EnabledFlagName = "pprof.enabled"
ListenAddrFlagName = "pprof.addr" ListenAddrFlagName = "pprof.addr"
PortFlagName = "pprof.port" PortFlagName = "pprof.port"
defaultListenAddr = "0.0.0.0"
defaultListenPort = 6060
) )
func DefaultCLIConfig() CLIConfig {
return CLIConfig{
Enabled: false,
ListenAddr: defaultListenAddr,
ListenPort: defaultListenPort,
}
}
func CLIFlags(envPrefix string) []cli.Flag { func CLIFlags(envPrefix string) []cli.Flag {
return []cli.Flag{ return []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
...@@ -24,13 +34,13 @@ func CLIFlags(envPrefix string) []cli.Flag { ...@@ -24,13 +34,13 @@ func CLIFlags(envPrefix string) []cli.Flag {
&cli.StringFlag{ &cli.StringFlag{
Name: ListenAddrFlagName, Name: ListenAddrFlagName,
Usage: "pprof listening address", Usage: "pprof listening address",
Value: "0.0.0.0", // TODO(CLI-4159): Switch to 127.0.0.1 Value: defaultListenAddr, // TODO(CLI-4159): Switch to 127.0.0.1
EnvVars: opservice.PrefixEnvVar(envPrefix, "PPROF_ADDR"), EnvVars: opservice.PrefixEnvVar(envPrefix, "PPROF_ADDR"),
}, },
&cli.IntFlag{ &cli.IntFlag{
Name: PortFlagName, Name: PortFlagName,
Usage: "pprof listening port", Usage: "pprof listening port",
Value: 6060, Value: defaultListenPort,
EnvVars: opservice.PrefixEnvVar(envPrefix, "PPROF_PORT"), EnvVars: opservice.PrefixEnvVar(envPrefix, "PPROF_PORT"),
}, },
} }
......
...@@ -25,6 +25,7 @@ Bytes_slice_Test:test_slice_fromZeroIdx_works() (gas: 20804) ...@@ -25,6 +25,7 @@ Bytes_slice_Test:test_slice_fromZeroIdx_works() (gas: 20804)
Bytes_toNibbles_Test:test_toNibbles_expectedResult128Bytes_works() (gas: 78882) Bytes_toNibbles_Test:test_toNibbles_expectedResult128Bytes_works() (gas: 78882)
Bytes_toNibbles_Test:test_toNibbles_expectedResult5Bytes_works() (gas: 3992) Bytes_toNibbles_Test:test_toNibbles_expectedResult5Bytes_works() (gas: 3992)
Bytes_toNibbles_Test:test_toNibbles_zeroLengthInput_works() (gas: 823) Bytes_toNibbles_Test:test_toNibbles_zeroLengthInput_works() (gas: 823)
Constants_Test:test_eip1967Constants_succeeds() (gas: 453)
CrossDomainMessenger_BaseGas_Test:test_baseGas_succeeds() (gas: 20435) CrossDomainMessenger_BaseGas_Test:test_baseGas_succeeds() (gas: 20435)
CrossDomainOwnable2_Test:test_onlyOwner_notMessenger_reverts() (gas: 8461) CrossDomainOwnable2_Test:test_onlyOwner_notMessenger_reverts() (gas: 8461)
CrossDomainOwnable2_Test:test_onlyOwner_notOwner2_reverts() (gas: 57515) CrossDomainOwnable2_Test:test_onlyOwner_notOwner2_reverts() (gas: 57515)
...@@ -239,7 +240,7 @@ L2OutputOracleUpgradeable_Test:test_initValuesOnImpl_succeeds() (gas: 23902) ...@@ -239,7 +240,7 @@ L2OutputOracleUpgradeable_Test:test_initValuesOnImpl_succeeds() (gas: 23902)
L2OutputOracleUpgradeable_Test:test_initValuesOnProxy_succeeds() (gas: 46800) L2OutputOracleUpgradeable_Test:test_initValuesOnProxy_succeeds() (gas: 46800)
L2OutputOracleUpgradeable_Test:test_initializeImpl_alreadyInitialized_reverts() (gas: 15216) L2OutputOracleUpgradeable_Test:test_initializeImpl_alreadyInitialized_reverts() (gas: 15216)
L2OutputOracleUpgradeable_Test:test_initializeProxy_alreadyInitialized_reverts() (gas: 20216) L2OutputOracleUpgradeable_Test:test_initializeProxy_alreadyInitialized_reverts() (gas: 20216)
L2OutputOracleUpgradeable_Test:test_upgrading_succeeds() (gas: 191346) L2OutputOracleUpgradeable_Test:test_upgrading_succeeds() (gas: 191348)
L2OutputOracle_constructor_Test:test_constructor_l2BlockTimeZero_reverts() (gas: 39212) L2OutputOracle_constructor_Test:test_constructor_l2BlockTimeZero_reverts() (gas: 39212)
L2OutputOracle_constructor_Test:test_constructor_submissionInterval_reverts() (gas: 39222) L2OutputOracle_constructor_Test:test_constructor_submissionInterval_reverts() (gas: 39222)
L2OutputOracle_constructor_Test:test_constructor_succeeds() (gas: 51777) L2OutputOracle_constructor_Test:test_constructor_succeeds() (gas: 51777)
...@@ -430,7 +431,7 @@ OptimismMintableTokenFactory_Test:test_createStandardL2Token_succeeds() (gas: 12 ...@@ -430,7 +431,7 @@ OptimismMintableTokenFactory_Test:test_createStandardL2Token_succeeds() (gas: 12
OptimismPortalUpgradeable_Test:test_initialize_cannotInitImpl_reverts() (gas: 11178) OptimismPortalUpgradeable_Test:test_initialize_cannotInitImpl_reverts() (gas: 11178)
OptimismPortalUpgradeable_Test:test_initialize_cannotInitProxy_reverts() (gas: 16111) OptimismPortalUpgradeable_Test:test_initialize_cannotInitProxy_reverts() (gas: 16111)
OptimismPortalUpgradeable_Test:test_params_initValuesOnProxy_succeeds() (gas: 26781) OptimismPortalUpgradeable_Test:test_params_initValuesOnProxy_succeeds() (gas: 26781)
OptimismPortalUpgradeable_Test:test_upgradeToAndCall_upgrading_succeeds() (gas: 191412) OptimismPortalUpgradeable_Test:test_upgradeToAndCall_upgrading_succeeds() (gas: 191414)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputRootChanges_reverts() (gas: 178667) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputRootChanges_reverts() (gas: 178667)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 182306) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 182306)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41780) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41780)
...@@ -533,11 +534,11 @@ ProxyAdmin_Test:test_delegateResolvedGetProxyAdmin_succeeds() (gas: 17691) ...@@ -533,11 +534,11 @@ ProxyAdmin_Test:test_delegateResolvedGetProxyAdmin_succeeds() (gas: 17691)
ProxyAdmin_Test:test_delegateResolvedGetProxyImplementation_succeeds() (gas: 62028) ProxyAdmin_Test:test_delegateResolvedGetProxyImplementation_succeeds() (gas: 62028)
ProxyAdmin_Test:test_delegateResolvedUpgradeAndCall_succeeds() (gas: 98039) ProxyAdmin_Test:test_delegateResolvedUpgradeAndCall_succeeds() (gas: 98039)
ProxyAdmin_Test:test_delegateResolvedUpgrade_succeeds() (gas: 58482) ProxyAdmin_Test:test_delegateResolvedUpgrade_succeeds() (gas: 58482)
ProxyAdmin_Test:test_erc1967ChangeProxyAdmin_succeeds() (gas: 33812) ProxyAdmin_Test:test_erc1967ChangeProxyAdmin_succeeds() (gas: 33820)
ProxyAdmin_Test:test_erc1967GetProxyAdmin_succeeds() (gas: 15616) ProxyAdmin_Test:test_erc1967GetProxyAdmin_succeeds() (gas: 15616)
ProxyAdmin_Test:test_erc1967GetProxyImplementation_succeeds() (gas: 52071) ProxyAdmin_Test:test_erc1967GetProxyImplementation_succeeds() (gas: 52073)
ProxyAdmin_Test:test_erc1967UpgradeAndCall_succeeds() (gas: 78969) ProxyAdmin_Test:test_erc1967UpgradeAndCall_succeeds() (gas: 78971)
ProxyAdmin_Test:test_erc1967Upgrade_succeeds() (gas: 50078) ProxyAdmin_Test:test_erc1967Upgrade_succeeds() (gas: 50080)
ProxyAdmin_Test:test_isUpgrading_succeeds() (gas: 19442) ProxyAdmin_Test:test_isUpgrading_succeeds() (gas: 19442)
ProxyAdmin_Test:test_onlyOwner_notOwner_reverts() (gas: 22767) ProxyAdmin_Test:test_onlyOwner_notOwner_reverts() (gas: 22767)
ProxyAdmin_Test:test_owner_succeeds() (gas: 9738) ProxyAdmin_Test:test_owner_succeeds() (gas: 9738)
...@@ -547,16 +548,16 @@ ProxyAdmin_Test:test_setImplementationName_notOwner_reverts() (gas: 11111) ...@@ -547,16 +548,16 @@ ProxyAdmin_Test:test_setImplementationName_notOwner_reverts() (gas: 11111)
ProxyAdmin_Test:test_setImplementationName_succeeds() (gas: 38945) ProxyAdmin_Test:test_setImplementationName_succeeds() (gas: 38945)
ProxyAdmin_Test:test_setProxyType_notOwner_reverts() (gas: 10814) ProxyAdmin_Test:test_setProxyType_notOwner_reverts() (gas: 10814)
Proxy_Test:test_delegatesToImpl_succeeds() (gas: 45207) Proxy_Test:test_delegatesToImpl_succeeds() (gas: 45207)
Proxy_Test:test_implementationKey_succeeds() (gas: 20909) Proxy_Test:test_implementationKey_succeeds() (gas: 20911)
Proxy_Test:test_implementation_isZeroAddress_reverts() (gas: 47626) Proxy_Test:test_implementation_isZeroAddress_reverts() (gas: 47628)
Proxy_Test:test_implementation_zeroAddressCaller_succeeds() (gas: 14752) Proxy_Test:test_implementation_zeroAddressCaller_succeeds() (gas: 14752)
Proxy_Test:test_ownerKey_succeeds() (gas: 19059) Proxy_Test:test_ownerKey_succeeds() (gas: 19067)
Proxy_Test:test_ownerProxyCall_notAdmin_succeeds() (gas: 34615) Proxy_Test:test_ownerProxyCall_notAdmin_succeeds() (gas: 34623)
Proxy_Test:test_proxyCallToImp_notAdmin_succeeds() (gas: 30008) Proxy_Test:test_proxyCallToImp_notAdmin_succeeds() (gas: 30010)
Proxy_Test:test_upgradeToAndCall_functionDoesNotExist_reverts() (gas: 104565) Proxy_Test:test_upgradeToAndCall_functionDoesNotExist_reverts() (gas: 104567)
Proxy_Test:test_upgradeToAndCall_isPayable_succeeds() (gas: 53742) Proxy_Test:test_upgradeToAndCall_isPayable_succeeds() (gas: 53744)
Proxy_Test:test_upgradeToAndCall_succeeds() (gas: 125190) Proxy_Test:test_upgradeToAndCall_succeeds() (gas: 125192)
Proxy_Test:test_upgradeTo_clashingFunctionSignatures_succeeds() (gas: 101359) Proxy_Test:test_upgradeTo_clashingFunctionSignatures_succeeds() (gas: 101363)
RLPReader_readBytes_Test:test_readBytes_bytestring00_succeeds() (gas: 1863) RLPReader_readBytes_Test:test_readBytes_bytestring00_succeeds() (gas: 1863)
RLPReader_readBytes_Test:test_readBytes_bytestring01_succeeds() (gas: 1840) RLPReader_readBytes_Test:test_readBytes_bytestring01_succeeds() (gas: 1840)
RLPReader_readBytes_Test:test_readBytes_bytestring7f_succeeds() (gas: 1861) RLPReader_readBytes_Test:test_readBytes_bytestring7f_succeeds() (gas: 1861)
...@@ -631,7 +632,7 @@ ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 20020816) ...@@ -631,7 +632,7 @@ ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 20020816)
ResourceMetering_Test:test_meter_useMoreThanMax_reverts() (gas: 19549) ResourceMetering_Test:test_meter_useMoreThanMax_reverts() (gas: 19549)
SafeCall_Test:test_callWithMinGas_noLeakageHigh_succeeds() (gas: 1021670598) SafeCall_Test:test_callWithMinGas_noLeakageHigh_succeeds() (gas: 1021670598)
SafeCall_Test:test_callWithMinGas_noLeakageLow_succeeds() (gas: 1095190710) SafeCall_Test:test_callWithMinGas_noLeakageLow_succeeds() (gas: 1095190710)
Semver_Test:test_behindProxy_succeeds() (gas: 506748) Semver_Test:test_behindProxy_succeeds() (gas: 507558)
Semver_Test:test_version_succeeds() (gas: 9418) Semver_Test:test_version_succeeds() (gas: 9418)
SequencerFeeVault_L2Withdrawal_Test:test_withdraw_toL2_succeeds() (gas: 78333) SequencerFeeVault_L2Withdrawal_Test:test_withdraw_toL2_succeeds() (gas: 78333)
SequencerFeeVault_L2Withdrawal_Test:test_withdraw_toL2recipientReverts_fails() (gas: 46486) SequencerFeeVault_L2Withdrawal_Test:test_withdraw_toL2recipientReverts_fails() (gas: 46486)
...@@ -643,11 +644,11 @@ SequencerFeeVault_Test:test_withdraw_toL1_succeeds() (gas: 171357) ...@@ -643,11 +644,11 @@ SequencerFeeVault_Test:test_withdraw_toL1_succeeds() (gas: 171357)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11549) SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11549)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936) StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072) StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
SystemConfig_Initialize_Test:test_initialize_events_succeeds() (gas: 72059) SystemConfig_Initialize_Test:test_initialize_events_succeeds() (gas: 72060)
SystemConfig_Initialize_Test:test_initialize_startBlockOverride_succeeds() (gas: 65240) SystemConfig_Initialize_Test:test_initialize_startBlockOverride_succeeds() (gas: 65242)
SystemConfig_Initialize_Test:test_initialize_values_succeeds() (gas: 64946) SystemConfig_Initialize_Test:test_initialize_values_succeeds() (gas: 64946)
SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 55653) SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 55655)
SystemConfig_Initialize_TestFail:test_initialize_startBlock_reverts() (gas: 78350) SystemConfig_Initialize_TestFail:test_initialize_startBlock_reverts() (gas: 78352)
SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 15607) SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 15607)
SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 15577) SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 15577)
SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 15676) SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 15676)
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
import { Constants } from "../libraries/Constants.sol";
/// @title IL1ChugSplashDeployer /// @title IL1ChugSplashDeployer
interface IL1ChugSplashDeployer { interface IL1ChugSplashDeployer {
function isUpgrading() external view returns (bool); function isUpgrading() external view returns (bool);
...@@ -21,12 +23,6 @@ contract L1ChugSplashProxy { ...@@ -21,12 +23,6 @@ contract L1ChugSplashProxy {
/// contract, the appended bytecode will be deployed as given. /// contract, the appended bytecode will be deployed as given.
bytes13 internal constant DEPLOY_CODE_PREFIX = 0x600D380380600D6000396000f3; bytes13 internal constant DEPLOY_CODE_PREFIX = 0x600D380380600D6000396000f3;
/// @notice bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
bytes32 internal constant IMPLEMENTATION_KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/// @notice bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
bytes32 internal constant OWNER_KEY = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/// @notice Blocks a function from being called when the parent signals that the system should /// @notice Blocks a function from being called when the parent signals that the system should
/// be paused via an isUpgrading function. /// be paused via an isUpgrading function.
modifier onlyWhenNotPaused() { modifier onlyWhenNotPaused() {
...@@ -160,16 +156,18 @@ contract L1ChugSplashProxy { ...@@ -160,16 +156,18 @@ contract L1ChugSplashProxy {
/// @notice Sets the implementation address. /// @notice Sets the implementation address.
/// @param _implementation New implementation address. /// @param _implementation New implementation address.
function _setImplementation(address _implementation) internal { function _setImplementation(address _implementation) internal {
bytes32 proxyImplementation = Constants.PROXY_IMPLEMENTATION_ADDRESS;
assembly { assembly {
sstore(IMPLEMENTATION_KEY, _implementation) sstore(proxyImplementation, _implementation)
} }
} }
/// @notice Changes the owner of the proxy contract. /// @notice Changes the owner of the proxy contract.
/// @param _owner New owner of the proxy contract. /// @param _owner New owner of the proxy contract.
function _setOwner(address _owner) internal { function _setOwner(address _owner) internal {
bytes32 proxyOwner = Constants.PROXY_OWNER_ADDRESS;
assembly { assembly {
sstore(OWNER_KEY, _owner) sstore(proxyOwner, _owner)
} }
} }
...@@ -203,8 +201,9 @@ contract L1ChugSplashProxy { ...@@ -203,8 +201,9 @@ contract L1ChugSplashProxy {
/// @return Implementation address. /// @return Implementation address.
function _getImplementation() internal view returns (address) { function _getImplementation() internal view returns (address) {
address implementation; address implementation;
bytes32 proxyImplementation = Constants.PROXY_IMPLEMENTATION_ADDRESS;
assembly { assembly {
implementation := sload(IMPLEMENTATION_KEY) implementation := sload(proxyImplementation)
} }
return implementation; return implementation;
} }
...@@ -213,8 +212,9 @@ contract L1ChugSplashProxy { ...@@ -213,8 +212,9 @@ contract L1ChugSplashProxy {
/// @return Owner address. /// @return Owner address.
function _getOwner() internal view returns (address) { function _getOwner() internal view returns (address) {
address owner; address owner;
bytes32 proxyOwner = Constants.PROXY_OWNER_ADDRESS;
assembly { assembly {
owner := sload(OWNER_KEY) owner := sload(proxyOwner)
} }
return owner; return owner;
} }
......
...@@ -21,6 +21,15 @@ library Constants { ...@@ -21,6 +21,15 @@ library Constants {
/// non-zero to reduce the gas cost of message passing transactions. /// non-zero to reduce the gas cost of message passing transactions.
address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD; address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD;
/// @notice The storage slot that holds the address of a proxy implementation.
/// @dev `bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)`
bytes32 internal constant PROXY_IMPLEMENTATION_ADDRESS =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/// @notice The storage slot that holds the address of the owner.
/// @dev `bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)`
bytes32 internal constant PROXY_OWNER_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/// @notice Returns the default values for the ResourceConfig. These are the recommended values /// @notice Returns the default values for the ResourceConfig. These are the recommended values
/// for a production network. /// for a production network.
function DEFAULT_RESOURCE_CONFIG() internal pure returns (ResourceMetering.ResourceConfig memory) { function DEFAULT_RESOURCE_CONFIG() internal pure returns (ResourceMetering.ResourceConfig memory) {
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
import { Constants } from "../libraries/Constants.sol";
/// @title Proxy /// @title Proxy
/// @notice Proxy is a transparent proxy that passes through the call if the caller is the owner or /// @notice Proxy is a transparent proxy that passes through the call if the caller is the owner or
/// if the caller is address(0), meaning that the call originated from an off-chain /// if the caller is address(0), meaning that the call originated from an off-chain
/// simulation. /// simulation.
contract Proxy { contract Proxy {
/// @notice The storage slot that holds the address of the implementation.
/// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
bytes32 internal constant IMPLEMENTATION_KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/// @notice The storage slot that holds the address of the owner.
/// bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
bytes32 internal constant OWNER_KEY = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/// @notice An event that is emitted each time the implementation is changed. This event is part /// @notice An event that is emitted each time the implementation is changed. This event is part
/// of the EIP-1967 specification. /// of the EIP-1967 specification.
/// @param implementation The address of the implementation contract /// @param implementation The address of the implementation contract
...@@ -107,8 +101,9 @@ contract Proxy { ...@@ -107,8 +101,9 @@ contract Proxy {
/// @notice Sets the implementation address. /// @notice Sets the implementation address.
/// @param _implementation New implementation address. /// @param _implementation New implementation address.
function _setImplementation(address _implementation) internal { function _setImplementation(address _implementation) internal {
bytes32 proxyImplementation = Constants.PROXY_IMPLEMENTATION_ADDRESS;
assembly { assembly {
sstore(IMPLEMENTATION_KEY, _implementation) sstore(proxyImplementation, _implementation)
} }
emit Upgraded(_implementation); emit Upgraded(_implementation);
} }
...@@ -117,8 +112,9 @@ contract Proxy { ...@@ -117,8 +112,9 @@ contract Proxy {
/// @param _admin New owner of the proxy contract. /// @param _admin New owner of the proxy contract.
function _changeAdmin(address _admin) internal { function _changeAdmin(address _admin) internal {
address previous = _getAdmin(); address previous = _getAdmin();
bytes32 proxyOwner = Constants.PROXY_OWNER_ADDRESS;
assembly { assembly {
sstore(OWNER_KEY, _admin) sstore(proxyOwner, _admin)
} }
emit AdminChanged(previous, _admin); emit AdminChanged(previous, _admin);
} }
...@@ -152,8 +148,9 @@ contract Proxy { ...@@ -152,8 +148,9 @@ contract Proxy {
/// @return Implementation address. /// @return Implementation address.
function _getImplementation() internal view returns (address) { function _getImplementation() internal view returns (address) {
address impl; address impl;
bytes32 proxyImplementation = Constants.PROXY_IMPLEMENTATION_ADDRESS;
assembly { assembly {
impl := sload(IMPLEMENTATION_KEY) impl := sload(proxyImplementation)
} }
return impl; return impl;
} }
...@@ -162,8 +159,9 @@ contract Proxy { ...@@ -162,8 +159,9 @@ contract Proxy {
/// @return Owner address. /// @return Owner address.
function _getAdmin() internal view returns (address) { function _getAdmin() internal view returns (address) {
address owner; address owner;
bytes32 proxyOwner = Constants.PROXY_OWNER_ADDRESS;
assembly { assembly {
owner := sload(OWNER_KEY) owner := sload(proxyOwner)
} }
return owner; return owner;
} }
......
...@@ -5,6 +5,7 @@ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; ...@@ -5,6 +5,7 @@ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { Proxy } from "./Proxy.sol"; import { Proxy } from "./Proxy.sol";
import { AddressManager } from "../legacy/AddressManager.sol"; import { AddressManager } from "../legacy/AddressManager.sol";
import { L1ChugSplashProxy } from "../legacy/L1ChugSplashProxy.sol"; import { L1ChugSplashProxy } from "../legacy/L1ChugSplashProxy.sol";
import { Constants } from "../libraries/Constants.sol";
/// @title IStaticERC1967Proxy /// @title IStaticERC1967Proxy
/// @notice IStaticERC1967Proxy is a static version of the ERC1967 proxy interface. /// @notice IStaticERC1967Proxy is a static version of the ERC1967 proxy interface.
...@@ -163,9 +164,7 @@ contract ProxyAdmin is Ownable { ...@@ -163,9 +164,7 @@ contract ProxyAdmin is Ownable {
Proxy(_proxy).upgradeTo(_implementation); Proxy(_proxy).upgradeTo(_implementation);
} else if (ptype == ProxyType.CHUGSPLASH) { } else if (ptype == ProxyType.CHUGSPLASH) {
L1ChugSplashProxy(_proxy).setStorage( L1ChugSplashProxy(_proxy).setStorage(
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) Constants.PROXY_IMPLEMENTATION_ADDRESS, bytes32(uint256(uint160(_implementation)))
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc,
bytes32(uint256(uint160(_implementation)))
); );
} else if (ptype == ProxyType.RESOLVED) { } else if (ptype == ProxyType.RESOLVED) {
string memory name = implementationName[_proxy]; string memory name = implementationName[_proxy];
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { Constants } from "src/libraries/Constants.sol";
contract Constants_Test is Test {
/// @notice Check EIP1967 related constants.
function test_eip1967Constants_succeeds() external {
assertEq(
bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1), Constants.PROXY_IMPLEMENTATION_ADDRESS
);
assertEq(bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1), Constants.PROXY_OWNER_ADDRESS);
}
}
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