Expand description
Common utilities for MPC-node services.
This crate provides building blocks shared across nodes in the MPC network.
Environment– represents the deployment environment (prod / staging / test).StartedServices– tracks whether all async background services have started, used to drive the/healthendpoint.spawn_shutdown_task/default_shutdown_signal– wiring for graceful shutdown viaCTRL+CorSIGTERM.version_info!– macro that returns a version string containing the crate name, semver version, and git hash.
§Optional Features
api– exposes/healthand/versionAxum endpoints.middleware– enables themiddlewaremodule containing Axum/Tower middleware layers.unkey(impliesmiddleware) –middleware::unkey::UnkeyLayer, a Tower middleware that verifiesAuthorization: Bearertokens against the Unkey API.serde– ser/de implementation forEnvironment.postgres–postgres::PostgresConfigandpostgres::pg_pool_with_schemafor creating asqlxconnection pool pinned to a schema, with configurable retry behaviour.web3–web3::HttpRpcProvider,web3::HttpRpcProviderBuilder, andweb3::HttpRpcProviderConfigfor building HTTP Ethereum RPC providers with automatic retry and failover, plus ERC-165 interface detection utilities andweb3::GetReceiptExt::get_receipt_with_retryfor more robust receipt fetching.test-utils(impliespostgres) – enables thetest_utilsmodule of integration-test helpers:test_utils::postgres_testcontainer/test_utils::shared_postgres_testcontainerfor ephemeral Postgres containers,test_utils::next_test_schemafor isolated schema names, andtest_utils::random_port.axum-test(impliestest-utils) – adds thetest_utils::axum_testre-export andtest_utils::test_serverfor spinning up an Axum test server.web3-asserter(impliesweb3) – addsweb3::HttpRpcProvider::with_mock_asserter(and a matchingFrom<Asserter>impl) for building a provider backed by Alloy’s mocked provider infrastructure, intended for tests.
Re-exports§
pub use git_version;
Modules§
- api
- Health Check Endpoints
- middleware
- Axum middleware layers.
- postgres
- Configuration for a Postgres database.
- test_
utils - Utilities for testing nodes.
- web3
- HTTP RPC provider utilities for interacting with Ethereum nodes.
Macros§
- version_
info - Macro to generate version information including the crate name, version, and git hash.
Structs§
- Parse
Environment Error - Error type for parsing an
Environmentfrom a string. - Started
Services - A struct that keeps track of the health of all async services started by the service.
Enums§
- Environment
- The environment the service is running in.
Functions§
- default_
shutdown_ signal - Returns a future that completes when the application should shut down.
- spawn_
shutdown_ task - Spawns a shutdown task and creates an associated
CancellationToken. This task will complete when either the providedshutdown_signalfutures completes or if some other tasks cancels the shutdown token. The associated shutdown token will be cancelled either way.