op_service

package
v1.16.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 16 Imported by: 96

README

op-service

Issues: monorepo

Pull requests: monorepo

op-service is a collection of Go utilities to build OP-Stack services with.

├── accounting      - accounting utilities
├── apis            - interfaces for client / server RPC and misc. APIs
├── bigs            - big-int utils
├── cliapp          - Flag and lifecycle handling for a Urfave v2 CLI app.
├── client          - RPC and HTTP client utils
├── clock           - Clock interface, system clock, tickers, mock/test time utils
├── closer          - Convenience methods / patterns for closing resources
├── crypto          - Cryptography utils, complements geth crypto package
├── ctxinterrupt    - Blocking/Interrupt handling
├── dial            - Dialing util functions for RPC clients
├── endpoint        - Abstracts away type of RPC endpoint
├── enum            - Utils to create enums
├── errutil         - Utils to work with customized errors
├── eth             - Common Ethereum data types and OP-Stack extension types
├── event           - Broadcast event system
├── flags           - Utils and flag types for CLI usage
├── httputil        - Utils to create enhanced HTTP Server
├── ioutil          - File utils, including atomic files and compression
├── jsonutil        - JSON encoding/decoding utils
├── locks           - Lock utils, like read-write wrapped types
├── log             - Logging CLI and middleware utils
├── logpipe         - Logs streaming from io.Reader to logger
├── logfilter       - Logging filters
├── logmods         - Log handler wrapping/unwrapping utils
├── metrics         - Metrics types, metering abstractions, server utils
├── oppprof         - P-Prof CLI types and server setup
├── plan            - Utils to create a lazy evaluated value following dependencies
├── predeploys      - OP-Stack predeploy definitions
├── queue           - Generic queue implementation
├── retry           - Function retry utils
├── rpc             - RPC server utils
├── safego          - Utils to make Go memory more safe
├── safemath        - Utils to do math safely
├── serialize       - Binary serialization abstractions
├── signer          - CLI flags and bindings to work with a remote signer
├── solabi          - Utils to encode/decode Solidity ABI formatted data
├── sources         - RPC client bindings
├── tasks           - Err-group with panic handling
├── testreq         - Extension and improvement of the common `testify/require` package.
├── testlog         - Test logger and log-capture utils for testing
├── testutils       - Simplified Ethereum types, mock RPC bindings, utils for testing.
├── tls             - CLI flags and utils to work with TLS connections
├── txmgr           - Transaction manager: automated nonce, fee and confirmation handling.
├── txplan          - PlannedTx to declaratively build/execute/wait transactions
├── txinclude       - txinclude.Includer is a txplan-friendly txmgr
├── txintent        - IntentTx builds upon PlannedTx to prepare tx and digest the result.
└── *.go            - Miscellaneous utils (soon to be deprecated / moved)

Usage

From op-service dir:

# Run Go tests
make test
# Run Go fuzz tests
make fuzz

Product

Optimization target

Provide solid reusable building blocks for all OP-Stack Go services.

Vision
  • Remove unused utilities: op-service itself needs to stay maintainable.
  • Make all Go services consistent: op-service modules can be used to simplify and improve more Go services.

Design principles

  • Reduce boilerplate in Go services: provide service building utils ranging from CLI to testing.
  • Protect devs from sharp edges in the Go std-lib: think of providing missing composition, proper resource-closing, well set up network-binding, safe concurrency utils.

Testing

Each op-service package has its own unit-testing. More advanced utils, such as the transaction manager, are covered in op-e2e as well.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAction

func CloseAction(ctx context.Context, fn func(ctx context.Context) error) error

CloseAction runs the function in the background, until it finishes or until it is closed by the user with an interrupt.

func FindMonorepoRoot added in v1.4.2

func FindMonorepoRoot(startDir string) (string, error)

FindMonorepoRoot will recursively search upwards for the monorepo's go.mod file. It verifies that the go.mod file belongs to the optimism monorepo by checking the module path.

func FlagNameToEnvVarName added in v1.4.2

func FlagNameToEnvVarName(f string, prefix string) string

func FormatVersion added in v1.4.2

func FormatVersion(version string, gitCommit string, gitDate string, meta string) string

func Parse256BitChainID added in v1.9.3

func Parse256BitChainID(in string) (common.Hash, error)

Parse256BitChainID parses a 256-bit chain ID from a string. Chain IDs can be defined as either an integer or a hex string. If the string starts with "0x", it is treated as a hex string, otherwise it is treated as an integer string.

func ParseAddress added in v1.0.7

func ParseAddress(address string) (common.Address, error)

ParseAddress parses an ETH address from a hex string. This method will fail if the address is not a valid hexadecimal address.

func PrefixEnvVar

func PrefixEnvVar(prefix, suffix string) []string

PrefixEnvVar adds a prefix to the environment variable, and returns the env-var wrapped in a slice for usage with urfave CLI v2.

func U64UtilPtr added in v1.11.0

func U64UtilPtr(in uint64) *hexutil.Uint64

func ValidateEnvVars added in v1.0.8

func ValidateEnvVars(prefix string, flags []cli.Flag, log log.Logger)

ValidateEnvVars logs all env vars that are found where the env var is prefixed with the supplied prefix (like OP_BATCHER) but there is no actual env var with that name. It helps validate that the supplied env vars are in fact valid.

func WarnOnDeprecatedFlags added in v1.4.2

func WarnOnDeprecatedFlags(ctx *cli.Context, deprecatedFlags []cli.Flag, log log.Logger)

WarnOnDeprecatedFlags iterates through the provided deprecatedFlags and logs a warning for each that is set.

Types

This section is empty.

Directories

Path Synopsis
Package apis provides Go interfaces for most RPC / HTTP APIs used in the OP-Stack.
Package apis provides Go interfaces for most RPC / HTTP APIs used in the OP-Stack.
Package clock provides an abstraction for time to enable testing of functionality that uses time as an input.
Package clock provides an abstraction for time to enable testing of functionality that uses time as an input.
Implements interrupts: events that normally signal intent to cancel a Context, but may be repeated to encourage closure of new Contexts used to clean up resources.
Implements interrupts: events that normally signal intent to cancel a Context, but may be repeated to encourage closure of new Contexts used to clean up resources.
github
release
Package release provides helpers to download and verify binaries released on GitHub.
Package release provides helpers to download and verify binaries released on GitHub.
log
logfilter
Package logfilter provides a declarative log filtering framework for structured logging.
Package logfilter provides a declarative log filtering framework for structured logging.
doc
Package ptr provides helper functions for working with pointers.
Package ptr provides helper functions for working with pointers.
Package sources exports a number of clients used to access ethereum chain data.
Package sources exports a number of clients used to access ethereum chain data.
Package testlog provides a log handler for unit tests.
Package testlog provides a log handler for unit tests.
tls
This file contains CLI and env TLS configurations that can be used by clients or servers
This file contains CLI and env TLS configurations that can be used by clients or servers
certman
Package certman provides live reloading of the certificate and key files used by the standard library http.Server.
Package certman provides live reloading of the certificate and key files used by the standard library http.Server.
Kleene’s three-valued logic (K3) enlarges classical logic with an “undefined” value ⊥ alongside true (T) and false (F) to model partial or indeterminate statements.
Kleene’s three-valued logic (K3) enlarges classical logic with an “undefined” value ⊥ alongside true (T) and false (F) to model partial or indeterminate statements.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL