Documentation
¶
Overview ¶
Package mcmsutils provides utilities for working with Multi-Chain Multi-Sig (MCMS) operations across different blockchain networks. This package serves as a bridge between the chainlink deployments framework and the MCMS SDK, offering factory patterns to create blockchain-specific instances of MCMS components and other utility functions.
MCMS enables secure multi-signature operations across multiple blockchain networks through timelock contracts and multi-signature wallets. This package abstracts the complexity of creating the appropriate MCMS components for different blockchain families (EVM, Solana, Aptos).
Factory Pattern Overview ¶
This package implements the factory pattern to create blockchain-specific MCMS components:
- InspectorFactory: Creates inspectors for inspecting the MCMS contract
- ConverterFactory: Creates converters for transforming timelock proposals
- ExecutorFactory: Creates executors for executing the MCMS operations
- TimelockExecutorFactory: Creates executors for executing the Timelock contract operations
Supported Blockchains ¶
Different operations are supported on different blockchain families:
- EVM: All operations (inspection, conversion, execution, timelock execution)
- Solana: All operations (inspection, conversion, execution, timelock execution)
- Aptos: Limited to timelock operations (timelock inspection, conversion, execution)
Usage Example ¶
// Create an inspector for a blockchain inspectorFactory, err := GetInspectorFactory(blockchain) if err != nil { return fmt.Errorf("failed to get inspector factory: %w", err) } inspector, err := inspectorFactory.Make() if err != nil { return fmt.Errorf("failed to create inspector: %w", err) }
Index ¶
- Variables
- func DecodeProposal(proposal string) (*mcmslib.Proposal, error)
- func DecodeTimelockProposal(proposal string) (*mcmslib.TimelockProposal, error)
- func EncodeProposal(proposal *mcmslib.Proposal) (string, error)
- func EncodeTimelockProposal(proposal *mcmslib.TimelockProposal) (string, error)
- type ConverterFactory
- type Executor
- type ExecutorFactory
- type InspectorFactory
- type Signer
- type TimelockExecutorFactory
Constants ¶
This section is empty.
Variables ¶
var ErrFamilyNotSupported = errors.New("chain family not supported")
errFamilyNotSupported is the error returned when a chain family is not implemented.
Functions ¶
func DecodeProposal ¶
DecodeProposal deserializes a JSON string back into a standard MCMS Proposal struct.
func DecodeTimelockProposal ¶
func DecodeTimelockProposal(proposal string) (*mcmslib.TimelockProposal, error)
DecodeTimelockProposal deserializes a JSON string back into a TimelockProposal struct.
func EncodeProposal ¶
EncodeProposal serializes a standard MCMS Proposal to a JSON string format.
func EncodeTimelockProposal ¶
func EncodeTimelockProposal(proposal *mcmslib.TimelockProposal) (string, error)
EncodeTimelockProposal serializes a TimelockProposal to a JSON string format.
Types ¶
type ConverterFactory ¶
type ConverterFactory interface {
Make() (mcmssdk.TimelockConverter, error)
}
ConverterFactory creates MCMS TimelockConverter instances for converting a Timelock proposal to an MCMS proposal.
func GetConverterFactory ¶
func GetConverterFactory(family string) (ConverterFactory, error)
GetConverterFactory returns a blockchain family specific ConverterFactory.
Returns an error if the blockchain family is not supported.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor provides functionality to execute MCMS proposals and timelock proposals across multiple blockchain networks. It handles the orchestration of proposal execution, transaction confirmation, and retry logic for timelock operations.
func NewExecutor ¶
func NewExecutor(e fdeployment.Environment) *Executor
NewExecutor creates a new Executor with default configuration.
The executor is initialized with: - Default executable factory functions for MCMS and timelock operations - 50 retry attempts for timelock readiness checks - 100ms delay between retry attempts
func (*Executor) ExecuteMCMS ¶
ExecuteMCMS executes a multi-chain multi-sig proposal across all specified chains.
The execution process includes: 1. Validating the proposal structure and metadata 2. Creating chain-specific executors for each target chain 3. Setting the merkle root on each chain to initialize the proposal 4. Executing each operation sequentially and confirming transactions
Returns an error if any step fails
func (*Executor) ExecuteTimelock ¶
func (e *Executor) ExecuteTimelock(ctx context.Context, timelockProposal *mcmslib.TimelockProposal) error
ExecuteTimelock executes a timelock proposal, which involves both MCMS execution and timelock-specific operations. The execution process includes:
- Validating the timelock proposal
- Converting the timelock proposal to an MCMS proposal and executing it
- For scheduled actions, executing operations on the timelock contract after waiting for the proposal to become ready (with retry logic)
- Handling chain-specific configurations like call proxies for EVM chains
Returns early for non-scheduled actions. For scheduled actions, waits up to 5 seconds (configurable via retryAttempts and retryDelay) for the timelock to become ready before executing operations.
type ExecutorFactory ¶
ExecutorFactory creates MCMS Executor instances for executing MCMS contract operations.
func GetExecutorFactory ¶
func GetExecutorFactory( blockchain fchain.BlockChain, encoder mcmssdk.Encoder, ) (ExecutorFactory, error)
GetExecutorFactory returns a blockchain-specific ExecutorFactory with the appropriate encoder.
The provided encoder must match the blockchain type for proper transaction encoding and execution.
Returns an error if the blockchain family is not supported.
type InspectorFactory ¶
InspectorFactory creates MCMS Inspector instances for MCMS contract inspection.
func GetInspectorFactory ¶
func GetInspectorFactory( blockchain fchain.BlockChain, ) (InspectorFactory, error)
GetInspectorFactory returns a blockchain-specific InspectorFactory based on the provided blockchain's type for use in performing MCMS operations.
Note: Aptos chains only support timelock-specific inspection (use GetTimelockInspectorFactory when performing inspection against a Timelock proposal).
Returns an error if the blockchain family is not supported.
func GetTimelockInspectorFactory ¶
func GetTimelockInspectorFactory( blockchain fchain.BlockChain, action mcmstypes.TimelockAction, ) (InspectorFactory, error)
GetTimelockInspectorFactory returns a blockchain-specific InspectorFactory based on the provided blockchain's type for use in performing MCMS Timelock operations.
Returns an error if the blockchain family is not supported.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer provides functionality for signing MCMS and Timelock proposals. It manages the environment configuration and handles the conversion of timelock proposals to MCMS proposals before signing.
func NewSigner ¶
NewSigner creates a new MCMS signer with the provided environment configuration.
The signer is configured to use simulated EVM backends by default, which affects how encoders are generated for signing EVM proposals.
func (*Signer) SignMCMS ¶
func (s *Signer) SignMCMS( ctx context.Context, proposal *mcmslib.Proposal, privateKey *ecdsa.PrivateKey, ) error
SignMCMS signs an MCMS proposal using the provided private key and appends the generated signature to the proposal's signatures list.
func (*Signer) SignTimelock ¶
func (s *Signer) SignTimelock( ctx context.Context, timelockProposal *mcmslib.TimelockProposal, privateKey *ecdsa.PrivateKey, ) error
SignTimelock signs a timelock proposal by first converting it to an MCMS proposal, signing it, and appending the signature back to the original timelock proposal.
type TimelockExecutorFactory ¶
type TimelockExecutorFactory interface {
Make() (mcmssdk.TimelockExecutor, error)
}
TimelockExecutorFactory creates MCMS TimelockExecutor instances for executing the Timelock contract operations.
func GetTimelockExecutorFactory ¶
func GetTimelockExecutorFactory( blockchain fchain.BlockChain, ) (TimelockExecutorFactory, error)
GetTimelockExecutorFactory returns a blockchain-specific TimelockExecutorFactory based on the provided blockchain type.
Returns an error if the blockchain family is not supported.