lanes

package
v0.0.0-...-7a830b8 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLinkTokenTransferMinFeeUsdCents    = suideploy.DefaultCCIPSeqConfig.AddMinFeeUsdCents[0]
	DefaultLinkTokenTransferMaxFeeUsdCents    = suideploy.DefaultCCIPSeqConfig.AddMaxFeeUsdCents[0]
	DefaultLinkTokenTransferDeciBps           = suideploy.DefaultCCIPSeqConfig.AddDeciBps[0]
	DefaultLinkTokenTransferDestGasOverhead   = suideploy.DefaultCCIPSeqConfig.AddDestGasOverhead[0]
	DefaultLinkTokenTransferDestBytesOverhead = suideploy.DefaultCCIPSeqConfig.AddDestBytesOverhead[0]
	DefaultLinkPremiumMultiplierWeiPerEth     = suideploy.DefaultCCIPSeqConfig.PremiumMultiplierWeiPerEth[0]
)

Default token transfer fee fields for FeeQuoterApplyTokenTransferFeeConfigUpdatesOp on the Sui source leg. Values match deployment.DefaultCCIPSeqConfig / connect_sui_to_evm YAML.

View Source
var ConfigureLaneLegAsDest = cldf_ops.NewSequence(
	"ConfigureLaneLegAsDest",
	semver.MustParse("1.6.0"),
	"Configures lane leg as destination on CCIP 1.6.0 for Sui",
	func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, input laneapi.UpdateLanesInput) (sequences.OnChainOutput, error) {
		if input.Source == nil || input.Dest == nil {
			return sequences.OnChainOutput{}, fmt.Errorf("ConfigureLaneLegAsDest requires Source and Dest chain definitions")
		}
		if len(input.Source.OnRamp) == 0 {
			return sequences.OnChainOutput{}, fmt.Errorf("source OnRamp address required to configure Sui as destination for chain %d", input.Source.Selector)
		}

		env, err := connectChainsEnvironment()
		if err != nil {
			return sequences.OnChainOutput{}, err
		}

		state, err := loadOffRampState(env, input.Dest.Selector)
		if err != nil {
			return sequences.OnChainOutput{}, err
		}

		deps, err := opTxDepsForChain(chains, input.Dest.Selector)
		if err != nil {
			return sequences.OnChainOutput{}, err
		}

		latestIDs := resolveLatestPackageIDs(input.Dest.Selector)

		opInput := ccip_offramp_ops.ApplySourceChainConfigUpdateInput{
			CCIPObjectRef:                         state.CCIPObjectRef,
			OffRampPackageId:                      state.OffRampAddress,
			LatestPackageId:                       latestIDs.OffRamp,
			OffRampStateId:                        state.OffRampStateObjectId,
			OwnerCapObjectId:                      state.OffRampOwnerCapId,
			SourceChainsSelectors:                 []uint64{input.Source.Selector},
			SourceChainsIsEnabled:                 []bool{!input.IsDisabled},
			SourceChainsIsRMNVerificationDisabled: []bool{!input.Source.RMNVerificationEnabled},
			SourceChainsOnRamp:                    [][]byte{append([]byte(nil), input.Source.OnRamp...)},
		}

		report, err := cldf_ops.ExecuteOperation(b, ccip_offramp_ops.ApplySourceChainConfigUpdatesOp, deps, opInput)
		if err != nil {
			return sequences.OnChainOutput{}, fmt.Errorf(
				"failed to apply source chain config on Sui OffRamp for source %d: %w",
				input.Source.Selector, err,
			)
		}

		var out sequences.OnChainOutput
		if err := appendMCMSBatchOpFromCall(&out, input.Dest.Selector, report.Output.Call, deps); err != nil {
			return sequences.OnChainOutput{}, err
		}
		return out, nil
	},
)

ConfigureLaneLegAsDest wires a remote source chain into the Sui OffRamp. Sui has no router offramp step for inbound lanes (unlike Solana).

View Source
var ConfigureLaneLegAsSource = cldf_ops.NewSequence(
	"ConfigureLaneLegAsSource",
	semver.MustParse("1.6.0"),
	"Configures lane leg as source on CCIP 1.6.0 for Sui",
	func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, input laneapi.UpdateLanesInput) (sequences.OnChainOutput, error) {
		if input.Source == nil || input.Dest == nil {
			return sequences.OnChainOutput{}, fmt.Errorf("ConfigureLaneLegAsSource requires Source and Dest chain definitions")
		}
		if len(input.Dest.Router) == 0 {
			return sequences.OnChainOutput{}, fmt.Errorf("dest Router address required to configure Sui as source for chain %d", input.Dest.Selector)
		}

		env, err := connectChainsEnvironment()
		if err != nil {
			return sequences.OnChainOutput{}, err
		}

		state, err := loadSourceChainState(env, input.Source.Selector)
		if err != nil {
			return sequences.OnChainOutput{}, err
		}

		deps, err := opTxDepsForChain(chains, input.Source.Selector)
		if err != nil {
			return sequences.OnChainOutput{}, err
		}

		destRouter, err := remoteAddressBytesToHex(input.Dest.Router)
		if err != nil {
			return sequences.OnChainOutput{}, fmt.Errorf("encode dest router for chain %d: %w", input.Dest.Selector, err)
		}

		latestIDs := resolveLatestPackageIDs(input.Source.Selector)

		var out sequences.OnChainOutput

		tokenFeeReport, err := cldf_ops.ExecuteOperation(b, ccip_ops.FeeQuoterApplyTokenTransferFeeConfigUpdatesOp, deps, ccip_ops.FeeQuoterApplyTokenTransferFeeConfigUpdatesInput{
			CCIPPackageId:        state.CCIPAddress,
			LatestPackageId:      latestIDs.CCIP,
			StateObjectId:        state.CCIPObjectRef,
			OwnerCapObjectId:     state.CCIPOwnerCapObjectId,
			DestChainSelector:    input.Dest.Selector,
			AddTokens:            []string{state.LinkTokenCoinMetadataId},
			AddMinFeeUsdCents:    []uint32{DefaultLinkTokenTransferMinFeeUsdCents},
			AddMaxFeeUsdCents:    []uint32{DefaultLinkTokenTransferMaxFeeUsdCents},
			AddDeciBps:           []uint16{DefaultLinkTokenTransferDeciBps},
			AddDestGasOverhead:   []uint32{DefaultLinkTokenTransferDestGasOverhead},
			AddDestBytesOverhead: []uint32{DefaultLinkTokenTransferDestBytesOverhead},
			AddIsEnabled:         []bool{true},
		})
		if err != nil {
			return sequences.OnChainOutput{}, fmt.Errorf("apply token transfer fee config on Sui for dest %d: %w", input.Dest.Selector, err)
		}
		if err := appendMCMSBatchOpFromCall(&out, input.Source.Selector, tokenFeeReport.Output.Call, deps); err != nil {
			return sequences.OnChainOutput{}, err
		}

		destCfgInput := TranslateDestChainConfig(input.Dest.FeeQuoterDestChainConfig, input.Dest.Selector)
		destCfgInput.CCIPPackageId = state.CCIPAddress
		destCfgInput.LatestPackageId = latestIDs.CCIP
		destCfgInput.StateObjectId = state.CCIPObjectRef
		destCfgInput.OwnerCapObjectId = state.CCIPOwnerCapObjectId
		destCfgReport, err := cldf_ops.ExecuteOperation(b, ccip_ops.FeeQuoterApplyDestChainConfigUpdatesOp, deps, destCfgInput)
		if err != nil {
			return sequences.OnChainOutput{}, fmt.Errorf("apply dest chain config on Sui FeeQuoter for dest %d: %w", input.Dest.Selector, err)
		}
		if err := appendMCMSBatchOpFromCall(&out, input.Source.Selector, destCfgReport.Output.Call, deps); err != nil {
			return sequences.OnChainOutput{}, err
		}

		premiumReport, err := cldf_ops.ExecuteOperation(b, ccip_ops.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesOp, deps, ccip_ops.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesInput{
			CCIPPackageId:              state.CCIPAddress,
			LatestPackageId:            latestIDs.CCIP,
			StateObjectId:              state.CCIPObjectRef,
			OwnerCapObjectId:           state.CCIPOwnerCapObjectId,
			Tokens:                     []string{state.LinkTokenCoinMetadataId},
			PremiumMultiplierWeiPerEth: []uint64{DefaultLinkPremiumMultiplierWeiPerEth},
		})
		if err != nil {
			return sequences.OnChainOutput{}, fmt.Errorf("apply premium multiplier on Sui FeeQuoter for dest %d: %w", input.Dest.Selector, err)
		}
		if err := appendMCMSBatchOpFromCall(&out, input.Source.Selector, premiumReport.Output.Call, deps); err != nil {
			return sequences.OnChainOutput{}, err
		}

		onRampReport, err := cldf_ops.ExecuteOperation(b, ccip_onramp_ops.ApplyDestChainConfigUpdateOp, deps, ccip_onramp_ops.ApplyDestChainConfigureOnRampInput{
			OnRampPackageId:           state.OnRampAddress,
			LatestPackageId:           latestIDs.OnRamp,
			CCIPObjectRefId:           state.CCIPObjectRef,
			OwnerCapObjectId:          state.OnRampOwnerCapObjectId,
			StateObjectId:             state.OnRampStateObjectId,
			DestChainSelector:         []uint64{input.Dest.Selector},
			DestChainAllowListEnabled: []bool{input.Source.AllowListEnabled},
			DestChainRouters:          []string{destRouter},
		})
		if err != nil {
			return sequences.OnChainOutput{}, fmt.Errorf("apply dest chain config on Sui OnRamp for dest %d: %w", input.Dest.Selector, err)
		}
		if err := appendMCMSBatchOpFromCall(&out, input.Source.Selector, onRampReport.Output.Call, deps); err != nil {
			return sequences.OnChainOutput{}, err
		}

		routerReport, err := cldf_ops.ExecuteOperation(b, ccip_router_ops.SetOnRampsOp, deps, ccip_router_ops.SetOnRampsInput{
			RouterPackageId:     state.CCIPRouterAddress,
			LatestPackageId:     latestIDs.Router,
			RouterStateObjectId: state.CCIPRouterStateObjectID,
			OwnerCapObjectId:    state.CCIPRouterOwnerCapObjectId,
			DestChainSelectors:  []uint64{input.Dest.Selector},
			OnRampAddresses:     []string{state.OnRampAddress},
		})
		if err != nil {
			return sequences.OnChainOutput{}, fmt.Errorf("set on-ramps on Sui Router for dest %d: %w", input.Dest.Selector, err)
		}
		if err := appendMCMSBatchOpFromCall(&out, input.Source.Selector, routerReport.Output.Call, deps); err != nil {
			return sequences.OnChainOutput{}, err
		}

		if input.Dest.GasPrice != nil {
			pricesReport, err := cldf_ops.ExecuteOperation(b, ccip_ops.FeeQuoterUpdatePricesWithOwnerCapOp, deps, ccip_ops.FeeQuoterUpdatePricesWithOwnerCapInput{
				CCIPPackageId:         state.CCIPAddress,
				LatestPackageId:       latestIDs.CCIP,
				CCIPObjectRef:         state.CCIPObjectRef,
				OwnerCapObjectId:      state.CCIPOwnerCapObjectId,
				GasDestChainSelectors: []uint64{input.Dest.Selector},
				GasUsdPerUnitGas:      []*big.Int{input.Dest.GasPrice},
			})
			if err != nil {
				return sequences.OnChainOutput{}, fmt.Errorf("seed initial gas price on Sui FeeQuoter for dest %d: %w", input.Dest.Selector, err)
			}
			if err := appendMCMSBatchOpFromCall(&out, input.Source.Selector, pricesReport.Output.Call, deps); err != nil {
				return sequences.OnChainOutput{}, err
			}
		}

		return out, nil
	},
)

ConfigureLaneLegAsSource wires FeeQuoter, OnRamp, and Router on Sui for outbound messages to a remote destination chain. Op order matches connect_sui_to_evm.

View Source
var DisableRemoteChain = cldf_ops.NewSequence(
	"DisableRemoteChain",
	semver.MustParse("1.6.0"),
	"No-op disable remote chain sequence for Sui",
	func(_ cldf_ops.Bundle, _ cldf_chain.BlockChains, _ laneapi.DisableRemoteChainInput) (sequences.OnChainOutput, error) {
		return sequences.OnChainOutput{}, nil
	},
)

DisableRemoteChain is a no-op on Sui until remote-chain disable is implemented on-chain.

Functions

func RunConnectChainsWithSuiScopes

func RunConnectChainsWithSuiScopes(
	e cldf.Environment,
	latestBySelector map[uint64]LatestPackageIDsConfig,
	fn func() error,
) error

RunConnectChainsWithSuiScopes wraps ConnectChains with address-book and resolver latest-package-ID scopes.

func TranslateDestChainConfig

func TranslateDestChainConfig(
	cfg laneapi.FeeQuoterDestChainConfig,
	destChainSelector uint64,
) ccip_ops.FeeQuoterApplyDestChainConfigUpdatesInput

TranslateDestChainConfig maps a product-level FeeQuoterDestChainConfig to the Sui FeeQuoter op input for configuring a remote destination on the Sui chain. CCIP package/state object IDs are filled by the caller from address book state.

func WithConnectChainsEnvironment

func WithConnectChainsEnvironment(e cldf.Environment, fn func() error) error

WithConnectChainsEnvironment runs fn while SuiAdapter address getters can read chain metadata from the given environment.

func WithSuiLatestPackageIDs

func WithSuiLatestPackageIDs(bySelector map[uint64]LatestPackageIDsConfig, fn func() error) error

WithSuiLatestPackageIDs runs fn while lane sequences read optional upgraded package IDs keyed by Sui chain selector. CLD resolver populates this map from durable pipeline YAML.

Types

type LatestPackageIDsConfig

type LatestPackageIDsConfig struct {
	OffRamp string
	CCIP    string
	OnRamp  string
	Router  string
}

LatestPackageIDsConfig holds optional upgraded Sui package IDs for MCMS PTB routing. Package IDs in the address book remain the MCMS registry identity; latest IDs route execution to upgraded bytecode.

Populated by CLD via WithSuiLatestPackageIDs from durable pipeline YAML resolver output.

type SuiAdapter

type SuiAdapter struct{}

SuiAdapter implements laneapi.LaneAdapter for Sui CCIP 1.6.0 lanes. Package IDs are resolved via LoadOnchainStatesui (datastore address refs first, legacy addresses.json fallback); the ds parameter is unused. ConnectChains must run inside WithConnectChainsEnvironment.

func (*SuiAdapter) GetChainFamilySelector

func (a *SuiAdapter) GetChainFamilySelector() [4]byte

func (*SuiAdapter) GetDefaultGasPrice

func (a *SuiAdapter) GetDefaultGasPrice() *big.Int

func (*SuiAdapter) GetFQAddress

func (a *SuiAdapter) GetFQAddress(_ datastore.DataStore, chainSelector uint64) ([]byte, error)

func (*SuiAdapter) GetFeeQuoterDestChainConfig

func (a *SuiAdapter) GetFeeQuoterDestChainConfig() laneapi.FeeQuoterDestChainConfig

GetFeeQuoterDestChainConfig returns defaults applied on remote FeeQuoters when Sui is the destination chain. Values align with wired Sui testnet lanes (evm_feequoter_dest_configure) and Sui execution limits (MaxDataBytes 16_000).

func (*SuiAdapter) GetOffRampAddress

func (a *SuiAdapter) GetOffRampAddress(_ datastore.DataStore, chainSelector uint64) ([]byte, error)

func (*SuiAdapter) GetOnRampAddress

func (a *SuiAdapter) GetOnRampAddress(_ datastore.DataStore, chainSelector uint64) ([]byte, error)

func (*SuiAdapter) GetRouterAddress

func (a *SuiAdapter) GetRouterAddress(_ datastore.DataStore, chainSelector uint64) ([]byte, error)

Jump to

Keyboard shortcuts

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