infra/op-ufm/pkg/config/config.go
Jacob Elias a771a64d3f
feat: Merge op ufm into infra (#3)
* skeleton, poll, heartbeat, configs, healthz, dockerfile

* signer tls, send tx on heartbeat

* round trip receipt

* tx_pool, heartbeat

* example.config.toml

* add .

* addr semgrep

* metrics, instrumented clients, already known nonce handling and retry

* refactor metrics, add metric debug

* metric with error details

* fix imports

* fixes, deployed to dev

* semgrep

* lint

* add kmstool

* lint err

* fix(ufm): betterer error metric label (#6535)

* fix(ufm): betterer error metric label

* remove commented code

* feat(ufm): track nonce locally

* format log ctx

* build(deps): bump github.com/ethereum/go-ethereum in /op-ufm

Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.12.0 to 1.12.1.
- [Release notes](https://github.com/ethereum/go-ethereum/releases)
- [Commits](https://github.com/ethereum/go-ethereum/compare/v1.12.0...v1.12.1)

---
updated-dependencies:
- dependency-name: github.com/ethereum/go-ethereum
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* add cooldown

* config update

* improve error metrics

* use network nonce

* use network gas

* remove gas configs

* send mutex

* add debug tools to docker file

* update example.config.toml

* remove gas configs

* timeout metrics

* build(deps): bump github.com/supranational/blst in /op-ufm

Bumps [github.com/supranational/blst](https://github.com/supranational/blst) from 0.3.11-0.20230406105308-e9dfc5ee724b to 0.3.11.
- [Release notes](https://github.com/supranational/blst/releases)
- [Commits](https://github.com/supranational/blst/commits/v0.3.11)

---
updated-dependencies:
- dependency-name: github.com/supranational/blst
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* deps: golang 1.21

Updates the go version used to 1.21

* modify external files

* build(deps): bump github.com/consensys/gnark-crypto in /op-ufm

Bumps [github.com/consensys/gnark-crypto](https://github.com/consensys/gnark-crypto) from 0.10.0 to 0.12.0.
- [Release notes](https://github.com/consensys/gnark-crypto/releases)
- [Changelog](https://github.com/Consensys/gnark-crypto/blob/master/CHANGELOG.md)
- [Commits](https://github.com/consensys/gnark-crypto/compare/v0.10.0...v0.12.0)

---
updated-dependencies:
- dependency-name: github.com/consensys/gnark-crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump golang.org/x/net from 0.12.0 to 0.17.0 in /op-ufm

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.12.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.12.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(ufm): gracefully handle failed tx creation

* chore(ufm): update deps

* address rabbits concerns

* address mr rabbits concerns part ii

* extract gas tip cap const

* fix: resolving dependabot vulnerabilities. (#8643)

* resolving dependabot vulnerabilities.
setting go-ethereum v.1.13.5 everywhere and grpc to v1.56.3

* fixing sum sha

* build(deps): bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /op-ufm (#8672)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* op-ufm: use `fmt.Errorf()` for `panic()` (#8754)

* chore: clean up makefiles across the monorepo (#8862)

* Update op-geth dependency to upstream geth v1.13.8 and migrate to slog (#8917)

* Update op-geth dependency (v1.13.8) & migrate to slog

* op-e2e: format system_test.go

* op-chain-ops/genesis: Ignore nil addresses in BuildL1DeveloperGenesis

* go: Update to latest op-geth

commit fb90ca39bc5c4f45e99ef320abfab85eeb56c561

* update latest op-geth dependency

* op-program,op-wheel: Use new StateDB.OpenStorageTrie

* all: fix more slog stuff after merging

* proxyd: update geth 1.13.8 & migrate to slog

* op-ufm: update monorepo dependency to prev commit

* testlog: Return pointer with FindLog

* genesis: Parse addresses from dump string keys in BuildL1DeveloperGenesis

* op-ufm: go mod tidy

* update to latest op-geth

* genesis: Update ForgeDump.UnmarshalJSON to latest geth types

* eth: Use hexutils.U256 instead of uint256.Int as type in ExecutionPayload

This fixes JSON mashaling.

* op-e2e: fix usage of legacy geth levels

* go: update latest op-geth dependency

* check-ecotone: adapt to field type change

* Resolve remaining TODOs

* op-program: remove json-pretty formatting option from test

* go: update to latest op-geth v1.101308.0-rc.1

* op-dispute-mon: Fix logger setup

* log: improve LevelFromString docs

* op-e2e/config: treat EthNodeVerbosity as legacy log level

* all: fix order of imports

* ci: Skip flaky test (#9437)

* op-ufm: Update mod tidy again (#9456)

* op-ufm: mod tidy (#9537)

* op-ufm: Update go.mod (#9631)

* op-ufm: pin monorepo dependency, remove replace (#9641)

also udpate op-geth dependency while we're at it

* Fix check-changed for cannon and op-ufm go.mod checks (#9733)

* cannon: Update go mod in examples and fix check-changed to catch this in future

* Break op-ufm go.sum to work out what fails when it's out of date.

* Update go.sum

* op-ufm: Switch back to using latest monorepo code in op-ufm.

* op-ufm: Include op-ufm in mod tidy checks

* Remove hardfork activation time overrides (#9642)

* go get github.com/ethereum-optimism/superchain-registry/superchain@1203fe7 && go mod tidy

* update op-geth dependency

* remove hardfork activation time overrides

* remove unused consts

* Revert "remove hardfork activation time overrides"

This reverts commit 34b761f267aa3bbeaaa16f4d328ad91dec20d4e9.

* update superchain

* Revert "remove unused consts"

This reverts commit d1fca170f24f608f75d0d9ca8c12597bffd9df83.

* get Canyon,Delta and EcotoneTime fron superchain chain config

* remove sepolia devnet specialcase (will be moved to superchain registry)

* update op-geth

* add oplabs-devnet-0-sepolia-dev-0 to chains_test

* fix correct DeltaTime for sepoliaDev0Cfg

* go get github.com/ethereum-optimism/superchain-registry/superchain@2dcb036 && go mod tidy

* remove TODO

* go get github.com/ethereum-optimism/superchain-registry/superchain@c2e25cc && go mod tidy

* update dependency on op-geth

* update expected CanyonTime for oplabs-devnet-0-sepolia-dev-0

* update dependency on superchain and op-geth

* make mod-tidy

* go get github.com/ethereum-optimism/superchain-registry/superchain@c557df8 && go mod tidy

* update op-geth to v1.101308.3-rc.1 && go mod tidy

* make mod-tidy

* Update dependency on superchain-registry (#9929)

* go get github.com/ethereum-optimism/superchain-registry/superchain@52d3dbd1605dd43f419e838584abd0ec163d462b

* make mod-tidy

* remove goerli chaincfg

* op-program: replace references to goerli with sepolia

* op-node: remove references to goerli or replace with sepolia

* remove unused var

* go: update op-geth to latest v1.101308.4-rc.1

* op-node: remove Goerli references & config overrides

---------

Co-authored-by: Sebastian Stammler <seb@oplabs.co>

* build(deps): bump google.golang.org/protobuf in /op-ufm (#9854)

Bumps google.golang.org/protobuf from 1.32.0 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update op-geth dependency to  v1.101309.0-rc.2 (#9935)

* use updated op-geth

* update geth moar

* resource usage cleanup

* remove sleeping

* go: fix broken indirect dependency of github.com/kataras/iris/v12

* proxyd: update to geth v1.13.10

* proxyd: update to geth v1.13.14

* op-chain-ops: reduce diff, utilize chainID from caller to make Permit2 path use correct chainID during deployment

* op-chain-ops: L2 backend only, enable shanghai/canyon by default, fix doc comments

* op-chain-ops: simulator without L2 features, to support op-upgrade

---------

Co-authored-by: protolambda <proto@protolambda.com>

* update geth dependency to version w/ v1.13.11 upstream commits (#10041)

* update geth dependency to version with upstream updates to v1.13.11

* fix op-program tests

* update op-geth dep to tagged commit

* op-plasma: basic da server with S3 and leveldb storage (#9813)

* feat: basic plasma da server

* catch all not found errors

* feat: switch to minio and file server

* add file

* fix: handle feedback

* fix: tidy

* fix: tidy mods again

* chore: add S3 config info

* Update dependency on `superchain` package (#10204)

* pin superchain registry

to a commit on https://github.com/ethereum-optimism/superchain-registry/pull/190

* slice into mapping with superchain name

* update superchain-registry to latest commit on main

* build(deps): bump golang.org/x/net from 0.21.0 to 0.23.0 in /op-ufm (#10233)

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.21.0 to 0.23.0.
- [Commits](https://github.com/golang/net/compare/v0.21.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* geth: update to v1.13.15 (#10353)

* point at op-geth v1.13.13

* update triedb import path

* update deprecated core structs to types package

* Update op-geth with tx pool fix.

* point at v1.13.14

* point at geth v1.13.15

* fix NewStackTrie call

* remove pin

* use op-geth v1.101315.0-rc.1

---------

Co-authored-by: Adrian Sutton <adrian@oplabs.co>

* dependabot(gomod): bump golang.org/x/crypto from 0.21.0 to 0.23.0 (#10420)

* dependabot(gomod): bump golang.org/x/crypto from 0.21.0 to 0.23.0

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.21.0 to 0.23.0.
- [Commits](https://github.com/golang/crypto/compare/v0.21.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* deps: update

* deps: update

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>

* op-node: Add dedicated PlasmaConfig struct to rollup.Config (#10499)

* op-node: Add dedicated PlasmaConfig struct to rollup.Config

This commit adds a dedicated PlasmaConfig section to the rollup
config. This collects all Plasma Mode configuration to the same place
and enables future expansion of Plasma Mode configuration to be confined
to a single location.

In the interim, the op-node can read from both the legacy fields and the
dedicated struct. If both are set, they must be consistent. The genesis
creation tooling currently only writes with the new config.

* Set plasma mode from superchain registry

* Remove LegacyUsePlasma usage

* dependabot(gomod): bump github.com/decred/dcrd/dcrec/secp256k1/v4 from 4.2.0 to 4.3.0 (#10009)

* dependabot(gomod): bump github.com/decred/dcrd/dcrec/secp256k1/v4

Bumps [github.com/decred/dcrd/dcrec/secp256k1/v4](https://github.com/decred/dcrd) from 4.2.0 to 4.3.0.
- [Release notes](https://github.com/decred/dcrd/releases)
- [Changelog](https://github.com/decred/dcrd/blob/master/CHANGES)
- [Commits](https://github.com/decred/dcrd/compare/dcrec/secp256k1/v4.2.0...dcrec/secp256k1/v4.3.0)

---
updated-dependencies:
- dependency-name: github.com/decred/dcrd/dcrec/secp256k1/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* deps: update

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>

* Enable Fjord devnet activation (#10573)

* Enable Fjord devnet activation

* chaincfg: add Fjord time to sepolia-devnet-0

* Activate Fjord on Sepolia (#10610)

* feat: circle ci configurations for op-ufm

* feat: updated go.mod to contain remote reference github.com/ethereum-optimism/optimism

* feat: fix linting errors, and add golangci-lint config

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Felipe Andrade <felipe@oplabs.co>
Co-authored-by: OptimismBot <112345690+OptimismBot@users.noreply.github.com>
Co-authored-by: felipe andrade <130432649+felipe-op@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>
Co-authored-by: Sabnock01 <24715302+Sabnock01@users.noreply.github.com>
Co-authored-by: Raffaele <151576068+raffaele-oplabs@users.noreply.github.com>
Co-authored-by: Taeguk Kwon <xornrbboy@gmail.com>
Co-authored-by: refcell.eth <abigger87@gmail.com>
Co-authored-by: Sebastian Stammler <seb@oplabs.co>
Co-authored-by: Matthew Slipper <me@matthewslipper.com>
Co-authored-by: Adrian Sutton <adrian@oplabs.co>
Co-authored-by: George C. Knee <georgeknee@googlemail.com>
Co-authored-by: Roberto Bayardo <roberto.bayardo@coinbase.com>
Co-authored-by: protolambda <proto@protolambda.com>
Co-authored-by: tdot <tdotchardin@gmail.com>
Co-authored-by: Axel Kingsley <axel.kingsley@gmail.com>
Co-authored-by: Joshua Gutow <jgutow@oplabs.co>
2024-05-30 12:33:46 -07:00

172 lines
4.8 KiB
Go

package config
import (
"math/big"
"github.com/BurntSushi/toml"
"github.com/pkg/errors"
)
type Config struct {
LogLevel string `toml:"log_level"`
Signer SignerServiceConfig `toml:"signer_service"`
Metrics MetricsConfig `toml:"metrics"`
Healthz HealthzConfig `toml:"healthz"`
Wallets map[string]*WalletConfig `toml:"wallets"`
Providers map[string]*ProviderConfig `toml:"providers"`
}
type SignerServiceConfig struct {
URL string `toml:"url"`
TLSCaCert string `toml:"tls_ca_cert"`
TLSCert string `toml:"tls_cert"`
TLSKey string `toml:"tls_key"`
}
type MetricsConfig struct {
Enabled bool `toml:"enabled"`
Debug bool `toml:"debug"`
Host string `toml:"host"`
Port string `toml:"port"`
}
type HealthzConfig struct {
Enabled bool `toml:"enabled"`
Host string `toml:"host"`
Port string `toml:"port"`
}
type WalletConfig struct {
ChainID big.Int `toml:"chain_id"`
// signer | static
SignerMethod string `toml:"signer_method"`
Address string `toml:"address"`
// private key is used for static signing
PrivateKey string `toml:"private_key"`
// transaction parameters
TxValue big.Int `toml:"tx_value"`
}
type ProviderConfig struct {
Network string `toml:"network"`
URL string `toml:"url"`
ReadOnly bool `toml:"read_only"`
ReadInterval TOMLDuration `toml:"read_interval"`
SendInterval TOMLDuration `toml:"send_interval"`
SendTransactionRetryInterval TOMLDuration `toml:"send_transaction_retry_interval"`
SendTransactionRetryTimeout TOMLDuration `toml:"send_transaction_retry_timeout"`
SendTransactionCoolDown TOMLDuration `toml:"send_transaction_cool_down"`
ReceiptRetrievalInterval TOMLDuration `toml:"receipt_retrieval_interval"`
ReceiptRetrievalTimeout TOMLDuration `toml:"receipt_retrieval_timeout"`
Wallet string `toml:"wallet"`
}
func New(file string) (*Config, error) {
cfg := &Config{}
if _, err := toml.DecodeFile(file, cfg); err != nil {
return nil, err
}
return cfg, nil
}
func (c *Config) Validate() error {
if c.Metrics.Enabled {
if c.Metrics.Host == "" || c.Metrics.Port == "" {
return errors.New("metrics is enabled but host or port are missing")
}
}
if c.Healthz.Enabled {
if c.Healthz.Host == "" || c.Healthz.Port == "" {
return errors.New("healthz is enabled but host or port are missing")
}
}
if len(c.Wallets) == 0 {
return errors.New("at least one wallet must be set")
}
if len(c.Providers) == 0 {
return errors.New("at least one provider must be set")
}
for name, wallet := range c.Wallets {
if wallet.ChainID.BitLen() == 0 {
return errors.Errorf("wallet [%s] chain_id is missing", name)
}
if wallet.SignerMethod != "signer" && wallet.SignerMethod != "static" {
return errors.Errorf("wallet [%s] signer_method is invalid", name)
}
if wallet.SignerMethod == "signer" {
if c.Signer.URL == "" {
return errors.New("signer url is missing")
}
if c.Signer.TLSCaCert == "" {
return errors.New("signer tls_ca_cert is missing")
}
if c.Signer.TLSCert == "" {
return errors.New("signer tls_cert is missing")
}
if c.Signer.TLSKey == "" {
return errors.New("signer tls_key is missing")
}
}
if wallet.SignerMethod == "static" {
if wallet.PrivateKey == "" {
return errors.Errorf("wallet [%s] private_key is missing", name)
}
}
if wallet.Address == "" {
return errors.Errorf("wallet [%s] address is missing", name)
}
if wallet.TxValue.BitLen() == 0 {
return errors.Errorf("wallet [%s] tx_value is missing", name)
}
}
for name, provider := range c.Providers {
if provider.URL == "" {
return errors.Errorf("provider [%s] url is missing", name)
}
if provider.ReadInterval == 0 {
return errors.Errorf("provider [%s] read_interval is missing", name)
}
if provider.SendInterval == 0 {
return errors.Errorf("provider [%s] send_interval is missing", name)
}
if provider.SendTransactionRetryInterval == 0 {
return errors.Errorf("provider [%s] send_transaction_retry_interval is missing", name)
}
if provider.SendTransactionRetryTimeout == 0 {
return errors.Errorf("provider [%s] send_transaction_retry_timeout is missing", name)
}
if provider.SendTransactionCoolDown == 0 {
return errors.Errorf("provider [%s] send_transaction_cool_down is missing", name)
}
if provider.ReceiptRetrievalInterval == 0 {
return errors.Errorf("provider [%s] receipt_retrieval_interval is missing", name)
}
if provider.ReceiptRetrievalTimeout == 0 {
return errors.Errorf("provider [%s] receipt_retrieval_timeout is missing", name)
}
if provider.Wallet == "" {
return errors.Errorf("provider [%s] wallet is missing", name)
}
if _, ok := c.Wallets[provider.Wallet]; !ok {
return errors.Errorf("provider [%s] has an invalid wallet [%s]", name, provider.Wallet)
}
}
if c.LogLevel == "" {
c.LogLevel = "debug"
}
return nil
}