mcmsutil

package
v0.0.0-...-92c9f9d Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultMCMSWasmRelative = "target/wasm32v1-none/release/mcms.wasm"

DefaultMCMSWasmRelative is the release artifact path relative to the chainlink-stellar repo root.

View Source
const DefaultTimelockWasmRelative = "target/wasm32v1-none/release/timelock.wasm"

DefaultTimelockWasmRelative is the timelock WASM path relative to the chainlink-stellar repo root.

Variables

AllMCMSRoles is the deployment order for the three role-specific MCMS instances.

Functions

func ChainNetworkID

func ChainNetworkID(passphrase string) [32]byte

ChainNetworkID is SHA-256 of the network passphrase (Soroban MCMS chain_network_id).

func ConfigToStellarSetConfig

func ConfigToStellarSetConfig(cfg *mcmstypes.Config, clearRoot bool) (mcmsbindings.SignerAddresses, mcmsbindings.SignerGroups, [32]byte, [32]byte, bool, error)

ConfigToStellarSetConfig maps mcms types.Config to Soroban set_config inputs using the shared ExtractSetConfigInputs helper from github.com/smartcontractkit/mcms/sdk.

func DecodeSorobanMCMSInvokePayload

func DecodeSorobanMCMSInvokePayload(data []byte) (string, []xdr.ScVal, error)

DecodeSorobanMCMSInvokePayload is the inverse of EncodeSorobanMCMSInvokePayload: it splits an MCMS transaction-data payload back into the invoked function name and its argument ScVals. The Vec wrapper is mandatory on the wire (see EncodeSorobanInvokeArgs), so a missing or nil Vec is an error rather than an empty invocation.

func DeployMCMS

func DeployMCMS(
	ctx context.Context,
	deployer *deployment.Deployer,
	owner string,
	chainNetworkID [32]byte,
	config *types.Config,
	instanceLabel string,
	salt [32]byte,
) (string, error)

DeployMCMS uploads + instantiates the MCMS.

func EncodeSorobanInvokeArgs

func EncodeSorobanInvokeArgs(argScVals []xdr.ScVal) ([]byte, error)

EncodeSorobanInvokeArgs encodes Soroban invocation arguments as the canonical XDR for `ScVal::Vec([...args])` for timelock `Call.args_xdr` and mcms `StellarOp.args_xdr`, matching contracts/common/helpers/src/soroban_invoke.rs (decode_invoke_args). The function name is carried separately by the `function` field on those structs and must not be included here.

The encoding is the SCV_VEC discriminant (0x10) + the XDR optional "present" flag + a u32 element count + the elements, so nil/empty args encode to the 12-byte canonical empty vector 000000100000000100000000 (the normative `args_xdr_hex` in contracts/mcms/testdata/stellar_golden_vectors.json). decode_invoke_args runs soroban_sdk Vec::<Val>::from_xdr and then re-encodes and byte-compares, so the ScVal wrapper is mandatory: a bare xdr.ScVec marshal omits it and traps the Soroban host inside deserialize_from_bytes, which is unrecoverable on chain rather than a mappable contract error.

Build the value via scval.VecToScVal: its `&scVec` indirection is what makes the "present" flag true. A hand-rolled xdr.ScVal{Type: ScvVec} with a nil inner pointer encodes as `ScVal::Vec(None)`, which soroban rejects.

func EncodeSorobanMCMSInvokePayload

func EncodeSorobanMCMSInvokePayload(functionName string, argScVals []xdr.ScVal) ([]byte, error)

EncodeSorobanMCMSInvokePayload builds the MCMS transaction-data payload for Stellar proposals: XDR for ScVal::Vec([Symbol(fn), ...args]). This is the wire format consumed by the MCMS proposal transformer marked by AdditionalFields {"family":"stellar","encodingVersion":1}, which splits it into StellarOp.function / StellarOp.args_xdr before submission.

func FindExistingStellarMCMSByRole

func FindExistingStellarMCMSByRole(refs []datastore.AddressRef, chainSelector uint64, qual string, role MCMSRole) (string, bool, error)

FindExistingStellarMCMSByRole returns the address for exactly one role, or (","false) if absent. It never falls back to another role or a base MCMS type — a missing role ref must fail closed.

func FindExistingStellarTimelock

func FindExistingStellarTimelock(refs []datastore.AddressRef, chainSelector uint64, qual string) (string, bool)

FindExistingStellarTimelock returns the RBACTimelock contract id from refs when present.

func FindStellarMCMSAddressRef

func FindStellarMCMSAddressRef(e cldf.Environment, chainSelector uint64, input mcmsutils.Input) (frameworkdatastore.AddressRef, error)

FindStellarMCMSAddressRef resolves the role-specific MCMS contract from the datastore. It fails closed: the exact role ref must exist, with no fallback to another role.

func FindStellarTimelockAddressRef

func FindStellarTimelockAddressRef(e cldf.Environment, chainSelector uint64, input mcmsutils.Input) (frameworkdatastore.AddressRef, error)

FindStellarTimelockAddressRef resolves RBACTimelock from the datastore. It fails closed: there is no fallback to an MCMS contract (We deploy a distinct timelock).

func LookupStellarTimelockAddressRef

func LookupStellarTimelockAddressRef(e cldf.Environment, chainSelector uint64, input mcmsutils.Input) frameworkdatastore.AddressRef

LookupStellarTimelockAddressRef resolves RBACTimelock from the datastore, returning an empty ref when the chain has no RBACTimelock at the MCMS version — EOA lanes deploy none (an empty input qualifier matches any qualifier, mirroring the shared GetAddressRef semantics). It never errors: MCMSReader.GetTimelockRef must not error, because callers such as token expansion resolve the timelock unconditionally and detect MCMS-less setups via the empty ref (the EVM/Solana reader contract). There is still no fallback to an MCMS contract (we deploy a distinct timelock).

func MCMSInvokeTx

func MCMSInvokeTx(ref datastore.AddressRef, data []byte) mcmstypes.BatchOperation

MCMSInvokeTx wraps an encoded Soroban invoke payload as a one-transaction MCMS batch operation against ref. ref.Address must already be the contract strkey.

func MCMSRefTypeForAction

func MCMSRefTypeForAction(action mcmstypes.TimelockAction) (cldf.ContractType, error)

MCMSRefTypeForAction returns the single datastore contract type for a timelock action.

func MCMSRoleDeploySalt

func MCMSRoleDeploySalt(chainSelector uint64, qual, label string, role MCMSRole) [32]byte

MCMSRoleDeploySalt derives a deterministic per-role deploy salt so the three role instances land at distinct addresses.

func QualifierStr

func QualifierStr(q *string) string

QualifierStr returns the qualifier string or empty if nil.

func ResolveMCMSWasmPath

func ResolveMCMSWasmPath() (string, error)

ResolveMCMSWasmPath returns the path to mcms.wasm. Order: STELLAR_MCMS_WASM (full path), then CHAINLINK_STELLAR_ROOT + DefaultMCMSWasmRelative, then a walk up from CWD to the repo root.

func ResolveTimelockWasmPath

func ResolveTimelockWasmPath() (string, error)

ResolveTimelockWasmPath returns the path to timelock.wasm. Order: STELLAR_TIMELOCK_WASM (full path), then CHAINLINK_STELLAR_ROOT + DefaultTimelockWasmRelative, then a walk up from CWD to the repo root.

func StellarMCMSRoleDatastoreRef

func StellarMCMSRoleDatastoreRef(chainSelector uint64, qual string, role MCMSRole, contractID string) (datastore.AddressRef, error)

StellarMCMSRoleDatastoreRef emits the datastore ref for a single role-specific MCMS instance.

func StellarMCMSTxAdditionalFields

func StellarMCMSTxAdditionalFields() json.RawMessage

StellarMCMSTxAdditionalFields marks proposal transactions as Soroban invokes so the MCMS transformer decodes them with the matching encoding version.

func StellarTimelockDatastoreRef

func StellarTimelockDatastoreRef(chainSelector uint64, qual, contractID string) datastore.AddressRef

StellarTimelockDatastoreRef is a single RBACTimelock ref (matches EVM datastore labeling).

func StellarTimelocksByQualifier

func StellarTimelocksByQualifier(refs []datastore.AddressRef, chainSelector uint64) map[string]string

StellarTimelocksByQualifier returns every RBACTimelock contract id on the chain keyed by its qualifier. The qualifier is a generic MCMS stack selector, matching how EVM and Sui route proposals, so every deployed qualifier is returned rather than a fixed list.

func TimelockDeploySalt

func TimelockDeploySalt(chainSelector uint64, qual, label string) [32]byte

TimelockDeploySalt derives a deterministic deploy salt for a Soroban timelock instance.

Types

type MCMSRole

type MCMSRole string

MCMSRole identifies one of the three role-specific Soroban MCMS instances. Each role deploys an independent contract with its own signer config, root, nonce, and datastore ref.

const (
	RoleProposer  MCMSRole = "proposer"
	RoleCanceller MCMSRole = "canceller"
	RoleBypasser  MCMSRole = "bypasser"
)

func (MCMSRole) DatastoreType

func (r MCMSRole) DatastoreType() (datastore.ContractType, error)

DatastoreType maps a role to its EVM-style datastore contract type. There is deliberately no base "MCMS" alias: each role resolves to exactly one address, and a missing role fails closed.

func (MCMSRole) InstanceLabel

func (r MCMSRole) InstanceLabel() string

InstanceLabel is the immutable on-chain label passed to MCMS initialize (PROPOSER/CANCELLER/BYPASSER).

Jump to

Keyboard shortcuts

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