Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions bindings/bind/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func compilePackageInternal(packageName contracts.Package, namedAddresses map[st
// Write Published.toml for test_secondary dependency if its address is provided
testSecondaryAddr := namedAddresses["test_secondary"]
if !isZeroAddress(testSecondaryAddr) {
log.Printf("testSecondaryAddr: %s\n", testSecondaryAddr)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing noisy logs

testSecondaryDir := filepath.Join(dstRoot, "test_secondary")
if err := managePackage(testSecondaryDir, 1, rpcURL, env, testSecondaryAddr, testSecondaryAddr, pubfilePath); err != nil {
log.Printf("failed to manage Test Secondary dependency: %v\n", err)
Expand Down Expand Up @@ -684,8 +683,6 @@ func compilePackageInternal(packageName contracts.Package, namedAddresses map[st
var deps []string
var modules []string

log.Printf("compiling package: %s\n", packageRoot)

// Check if package has dependencies by reading Move.toml
pkgMoveTomlPath := filepath.Join(packageRoot, "Move.toml")
pkgMoveTomlContent, _ := os.ReadFile(pkgMoveTomlPath)
Expand Down Expand Up @@ -839,21 +836,12 @@ func isZeroAddress(addr string) bool {

// managePackage writes Published.toml and updates Move.toml for a package
func managePackage(packageRoot string, version int, rpcURL, env, originalPkgId, latestPkgId, pubfilePath string) error {
log.Printf("managing package via Published.toml: %s\n", packageRoot)
log.Printf("version: %d\n", version)
log.Printf("rpcURL: %s\n", rpcURL)
log.Printf("env: %s\n", env)
log.Printf("originalPkgId: %s\n", originalPkgId)
log.Printf("latestPkgId: %s\n", latestPkgId)

// Fetch chain identifier directly from the node
chainID, err := getChainIdentifier(rpcURL)
if err != nil {
return fmt.Errorf("failed to query chain identifier from %s: %w", rpcURL, err)
}

log.Printf("chainID: %s\n", chainID)

// Write Published.toml for dependency resolution
// This replaces the old manage-package and update-deps commands
if err := WritePublishedTOML(packageRoot, env, chainID, latestPkgId, originalPkgId, version); err != nil {
Expand Down Expand Up @@ -966,7 +954,6 @@ func setupSuiEnv(alias, rpcURL string) error {
var envList []suiEnv
if arr, ok := parsed[0].([]any); ok {
for _, e := range arr {
log.Printf("e: %+v\n", e)
data, _ := json.Marshal(e)
var env suiEnv
if err := json.Unmarshal(data, &env); err == nil {
Expand All @@ -982,18 +969,13 @@ func setupSuiEnv(alias, rpcURL string) error {
// Step 2 — Check for existing alias and remove it
for _, e := range envList {
if e.Alias == alias {
// log.Printf("removing alias: %s\n", alias)
if err := removeAliasFromClientYAML(alias); err != nil {
return fmt.Errorf("failed to remove existing alias: %w", err)
}
log.Printf("removed alias: %s\n", alias)
break
}
}

log.Printf("before creating new env alias: %s\n", alias)
log.Printf("rpcURL: %s\n", rpcURL)

// Step — Create new alias
newCmd := exec.Command("sui", "client", "new-env",
"--rpc", rpcURL,
Expand All @@ -1005,8 +987,6 @@ func setupSuiEnv(alias, rpcURL string) error {
fmt.Printf("failed to create sui env '%s': %v\nOutput:\n%s", alias, err, string(newOut))
}

log.Printf("newOut: %+v\n", string(newOut))

// Step 4️ — Switch to new env
switchCmd := exec.Command("sui", "client", "switch", "--env", alias)
switchCmd.Env = os.Environ()
Expand All @@ -1015,8 +995,6 @@ func setupSuiEnv(alias, rpcURL string) error {
return fmt.Errorf("failed to switch to env '%s': %w\nOutput:\n%s", alias, err, string(switchOut))
}

log.Printf("switchOut: %+v\n", string(switchOut))

// Step 5️ — Verify
activeCmd := exec.Command("sui", "client", "active-env")
activeCmd.Env = os.Environ()
Expand Down
29 changes: 0 additions & 29 deletions contracts/test/Move.lock

This file was deleted.

23 changes: 0 additions & 23 deletions contracts/test_secondary/Move.lock

This file was deleted.

186 changes: 186 additions & 0 deletions deployment/adapters/fastcurse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package adapters

import (
"context"
"fmt"

"github.com/Masterminds/semver/v3"

"github.com/smartcontractkit/chainlink-ccip/deployment/fastcurse"
"github.com/smartcontractkit/chainlink-ccip/deployment/utils/sequences"
cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
cldf_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations"

"github.com/smartcontractkit/chainlink-sui/bindings/bind"
module_rmn_remote "github.com/smartcontractkit/chainlink-sui/bindings/generated/ccip/ccip/rmn_remote"
module_router "github.com/smartcontractkit/chainlink-sui/bindings/generated/ccip/ccip_router"
"github.com/smartcontractkit/chainlink-sui/deployment"
rmnops "github.com/smartcontractkit/chainlink-sui/deployment/ops/rmn"
)

var (
_ fastcurse.CurseAdapter = (*CurseAdapter)(nil)
_ fastcurse.CurseSubjectAdapter = (*CurseAdapter)(nil)
)

// CurseAdapter implements fastcurse.CurseAdapter and fastcurse.CurseSubjectAdapter for Sui.
type CurseAdapter struct {
CCIPAddress string
CCIPObjectRef string
CCIPOwnerCapObjectID string
RouterAddress string
RouterStateObjectID string
}

// NewCurseAdapter returns a new, uninitialized CurseAdapter.
func NewCurseAdapter() *CurseAdapter {
return &CurseAdapter{}
}

// Initialize populates the adapter's state fields from the on-chain state for the given selector.
func (c *CurseAdapter) Initialize(e cldf.Environment, selector uint64) error {
stateMap, err := deployment.LoadOnchainStatesui(e)
if err != nil {
return fmt.Errorf("failed to load Sui on-chain state: %w", err)
}
state, ok := stateMap[selector]
if !ok {
return fmt.Errorf("Sui chain %d not found in state", selector)
}
c.CCIPAddress = state.CCIPAddress
c.CCIPObjectRef = state.CCIPObjectRef
c.CCIPOwnerCapObjectID = state.CCIPOwnerCapObjectId
c.RouterAddress = state.CCIPRouterAddress
c.RouterStateObjectID = state.CCIPRouterStateObjectID
return nil
}

// IsSubjectCursedOnChain returns true if the given subject is cursed on the Sui chain.
func (c *CurseAdapter) IsSubjectCursedOnChain(e cldf.Environment, selector uint64, subject fastcurse.Subject) (bool, error) {
chain, ok := e.BlockChains.SuiChains()[selector]
if !ok {
return false, fmt.Errorf("Sui chain %d not found in environment", selector)
}
contract, err := module_rmn_remote.NewRmnRemote(c.CCIPAddress, chain.Client)
if err != nil {
return false, fmt.Errorf("failed to create RMN Remote contract: %w", err)
}
return contract.DevInspect().IsCursed(
context.Background(),
&bind.CallOpts{Signer: chain.Signer},
bind.Object{Id: c.CCIPObjectRef},
subject[:],
)
}

// IsChainConnectedToTargetChain returns true if targetSelector is a configured destination
// on the Sui router for the chain identified by selector.
func (c *CurseAdapter) IsChainConnectedToTargetChain(e cldf.Environment, selector uint64, targetSelector uint64) (bool, error) {
chain, ok := e.BlockChains.SuiChains()[selector]
if !ok {
return false, fmt.Errorf("Sui chain %d not found in environment", selector)
}
routerContract, err := module_router.NewRouter(c.RouterAddress, chain.Client)
if err != nil {
return false, fmt.Errorf("failed to create router contract: %w", err)
}
connected, err := routerContract.DevInspect().IsChainSupported(
context.Background(),
&bind.CallOpts{Signer: chain.Signer},
bind.Object{Id: c.RouterStateObjectID},
targetSelector,
)
if err != nil {
return false, fmt.Errorf("failed to check if chain %d is connected to chain %d: %w", selector, targetSelector, err)
}
return connected, nil
}

// IsCurseEnabledForChain always returns true for Sui — cursing is always available.
func (c *CurseAdapter) IsCurseEnabledForChain(cldf.Environment, uint64) (bool, error) {
return true, nil
}

// SubjectToSelector converts a fastcurse.Subject to a chain selector using BigEndian encoding.
func (c *CurseAdapter) SubjectToSelector(subject fastcurse.Subject) (uint64, error) {
return fastcurse.GenericSubjectToSelector(subject)
}

// SelectorToSubject converts a chain selector to a fastcurse.Subject using BigEndian encoding.
// Sui uses the same encoding as the generic (EVM-default) case.
func (c *CurseAdapter) SelectorToSubject(selector uint64) fastcurse.Subject {
return fastcurse.GenericSelectorToSubject(selector)
}

// DeriveCurseAdapterVersion returns the RMN adapter version for this Sui deployment.
func (c *CurseAdapter) DeriveCurseAdapterVersion(cldf.Environment, uint64) (*semver.Version, error) {
return semver.MustParse("1.6.0"), nil
}

// Curse returns a sequence that curses the given subjects on the specified Sui chain.
func (c *CurseAdapter) Curse() *cldf_ops.Sequence[fastcurse.CurseInput, sequences.OnChainOutput, cldf_chain.BlockChains] {
return cldf_ops.NewSequence(
rmnops.CurseSequence.ID(),
semver.MustParse("1.0.0"),
rmnops.CurseSequence.Description(),
func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, in fastcurse.CurseInput) (sequences.OnChainOutput, error) {
seqInput := rmnops.CurseUncurseSeqInput{
CCIPAddress: c.CCIPAddress,
CCIPObjectRef: c.CCIPObjectRef,
CCIPOwnerCapObjectID: c.CCIPOwnerCapObjectID,
ChainSelector: in.ChainSelector,
Subjects: in.Subjects,
}
seqReport, err := cldf_ops.ExecuteSequence(b, rmnops.CurseSequence, chains, seqInput)
if err != nil {
return sequences.OnChainOutput{}, fmt.Errorf("failed to execute curse sequence on Sui chain %d: %w", in.ChainSelector, err)
}
return seqReport.Output, nil
},
)
}

// Uncurse returns a sequence that lifts the curse on given subjects on the specified Sui chain.
func (c *CurseAdapter) Uncurse() *cldf_ops.Sequence[fastcurse.CurseInput, sequences.OnChainOutput, cldf_chain.BlockChains] {
return cldf_ops.NewSequence(
rmnops.UncurseSequence.ID(),
semver.MustParse("1.0.0"),
rmnops.UncurseSequence.Description(),
func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, in fastcurse.CurseInput) (sequences.OnChainOutput, error) {
seqInput := rmnops.CurseUncurseSeqInput{
CCIPAddress: c.CCIPAddress,
CCIPObjectRef: c.CCIPObjectRef,
CCIPOwnerCapObjectID: c.CCIPOwnerCapObjectID,
ChainSelector: in.ChainSelector,
Subjects: in.Subjects,
}
seqReport, err := cldf_ops.ExecuteSequence(b, rmnops.UncurseSequence, chains, seqInput)
if err != nil {
return sequences.OnChainOutput{}, fmt.Errorf("failed to execute uncurse sequence on Sui chain %d: %w", in.ChainSelector, err)
}
return seqReport.Output, nil
},
)
}

// ListConnectedChains returns all destination chain selectors configured in the Sui router.
func (c *CurseAdapter) ListConnectedChains(e cldf.Environment, selector uint64) ([]uint64, error) {
chain, ok := e.BlockChains.SuiChains()[selector]
if !ok {
return nil, fmt.Errorf("Sui chain %d not found in environment", selector)
}
routerContract, err := module_router.NewRouter(c.RouterAddress, chain.Client)
if err != nil {
return nil, fmt.Errorf("failed to create router contract: %w", err)
}
connectedChains, err := routerContract.DevInspect().GetDestChains(
context.Background(),
&bind.CallOpts{Signer: chain.Signer},
bind.Object{Id: c.RouterStateObjectID},
)
if err != nil {
return nil, fmt.Errorf("failed to get connected chains for chain %d: %w", selector, err)
}
return connectedChains, nil
}
22 changes: 22 additions & 0 deletions deployment/adapters/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package adapters

import (
"github.com/Masterminds/semver/v3"
chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-ccip/deployment/fastcurse"
"github.com/smartcontractkit/chainlink-ccip/deployment/utils/changesets"
)

func init() {
curseRegistry := fastcurse.GetCurseRegistry()
curseRegistry.RegisterNewCurse(fastcurse.CurseRegistryInput{
CursingFamily: chainsel.FamilySui,
CursingVersion: semver.MustParse("1.6.0"),
CurseAdapter: NewCurseAdapter(),
CurseSubjectAdapter: NewCurseAdapter(),
})

mcmsRegistry := changesets.GetRegistry()
mcmsRegistry.RegisterMCMSReader(chainsel.FamilySui, &MCMSReader{})
}
Loading
Loading