Skip to content
Closed
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
67 changes: 65 additions & 2 deletions bindings/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ type CompiledPackage struct {
Bytecode [][]byte
}

const (
dockerAptosCLIImageEnvVar = "APTOS_CLI_IMAGE"
defaultDockerAptosCLIImage = "aptoslabs/tools:aptos-node-v1.41.5"
dockerContractsRoot = "/contracts"
)

// CompilePackage compiles a package with the given name and named addresses.
// It uses the Aptos CLI for compilation, passing the named addresses as arguments.
// The packageName must be one of the packages in the contracts directory that are embedded in the binary.
Expand Down Expand Up @@ -70,8 +76,7 @@ func CompilePackage(packageName contracts.Package, namedAddresses map[string]apt
args = append(args, "--named-addresses", strings.Join(namedAddr, ","))
}

cmd := exec.Command("aptos", args...)
cmd.Dir = packageRoot // Command is run in the temporary destination directory
cmd := compileCommand(args, dstRoot, packageDir)
// Buffer stdErr and stdOut
stdOut := &bytes.Buffer{}
stdErr := &bytes.Buffer{}
Expand Down Expand Up @@ -118,6 +123,64 @@ func CompilePackage(packageName contracts.Package, namedAddresses map[string]apt
return output, nil
}

func compileCommand(args []string, dstRoot, packageDir string) *exec.Cmd {
if _, err := exec.LookPath("aptos"); err == nil {
cmd := exec.Command("aptos", args...)
cmd.Dir = filepath.Join(dstRoot, packageDir)
return cmd
}

image := strings.TrimSpace(os.Getenv(dockerAptosCLIImageEnvVar))
if image == "" {
image = detectDockerAptosCLIImage()
}

dockerArgs := []string{
"run", "--rm",
"-v", fmt.Sprintf("%s:%s", dstRoot, dockerContractsRoot),
"-w", filepath.ToSlash(filepath.Join(dockerContractsRoot, packageDir)),
"--entrypoint", "aptos",
image,
}
dockerArgs = append(dockerArgs, args...)
return exec.Command("docker", dockerArgs...)
}

func detectDockerAptosCLIImage() string {
if image := firstAptosImageFromDocker("ps", "{{.Image}}"); image != "" {
return image
}
if image := firstAptosImageFromDocker("images", "{{.Repository}}:{{.Tag}}"); image != "" {
return image
}
return defaultDockerAptosCLIImage
}

func firstAptosImageFromDocker(subcommand, format string) string {
out, err := exec.Command("docker", subcommand, "--format", format).Output()
if err != nil {
return ""
}
return firstAptosImageFromOutput(string(out))
}

func firstAptosImageFromOutput(output string) string {
for _, line := range strings.Split(output, "\n") {
image := strings.TrimSpace(line)
if image == "" {
continue
}

lower := strings.ToLower(image)
if strings.Contains(lower, "aptoslabs/tools") ||
strings.Contains(lower, "aptos-tools") ||
strings.Contains(lower, "aptos-node-v") {
return image
}
}
return ""
}

func writeEFS(efs embed.FS, srcDir, dstDir string) error {
return fs.WalkDir(efs, srcDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
Expand Down
35 changes: 35 additions & 0 deletions bindings/compile/compile_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package compile

import "testing"

func TestFirstAptosImageFromOutput(t *testing.T) {
t.Run("returns first aptos image from docker ps output", func(t *testing.T) {
output := "postgres:15\naptoslabs/tools:aptos-node-v1.41.5\nbusybox:latest\n"

got := firstAptosImageFromOutput(output)

if got != "aptoslabs/tools:aptos-node-v1.41.5" {
t.Fatalf("expected aptos image, got %q", got)
}
})

t.Run("supports unofficial arm image names", func(t *testing.T) {
output := "ghcr.io/friedemannf/aptos-tools:aptos-node-v1.41.5\n"

got := firstAptosImageFromOutput(output)

if got != "ghcr.io/friedemannf/aptos-tools:aptos-node-v1.41.5" {
t.Fatalf("expected unofficial aptos image, got %q", got)
}
})

t.Run("returns empty string when output has no aptos image", func(t *testing.T) {
output := "postgres:15\nbusybox:latest\n"

got := firstAptosImageFromOutput(output)

if got != "" {
t.Fatalf("expected empty image, got %q", got)
}
})
}
2 changes: 1 addition & 1 deletion contracts/test/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ test = "_"
test = "0x100"

[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "mainnet", subdir = "aptos-move/framework/aptos-framework" }
AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "16beac69835f3a71564c96164a606a23f259099a", subdir = "aptos-move/framework/aptos-framework" }
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ require (
github.com/prometheus/client_golang v1.23.2
github.com/shopspring/decimal v1.4.0
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260311140941-e991aad9d2f9
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260226130359-963f935e0396
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260318055650-14af889a2da8
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260318054214-bad7873faa1c
github.com/stretchr/testify v1.11.1
github.com/valyala/fastjson v1.6.10
go.opentelemetry.io/otel v1.42.0
Expand Down Expand Up @@ -105,7 +105,7 @@ require (
github.com/smartcontractkit/chainlink-protos/node-platform v0.0.0-20260205130626-db2a2aab956b // indirect
github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e // indirect
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect
github.com/smartcontractkit/libocr v0.0.0-20250912173940-f3ab0246e23d // indirect
github.com/smartcontractkit/libocr v0.0.0-20251027221354-bdc84e1ed858 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/x448/float16 v0.8.4 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,12 @@ github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw=
github.com/smartcontractkit/chain-selectors v1.0.89 h1:L9oWZGqQXWyTPnC6ODXgu3b0DFyLmJ9eHv+uJrE9IZY=
github.com/smartcontractkit/chain-selectors v1.0.89/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w=
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260311140941-e991aad9d2f9 h1:qezjjPBK1YxhH5duXmZvMFi1lExgkuTmtXkC8xSZ9uI=
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260311140941-e991aad9d2f9/go.mod h1:0ghbAr7tRO0tT5ZqBXhOyzgUO37tNNe33Yn0hskauVM=
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260318055650-14af889a2da8 h1:KDczh6wVi29Yj3MQuK3gJ/h8ANqPBUHqRdnpipTYXbo=
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260318055650-14af889a2da8/go.mod h1:u7tz3TbzVnFsxpualdyFS/pRC4NbZZxoCTaCQWIyzhQ=
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10 h1:FJAFgXS9oqASnkS03RE1HQwYQQxrO4l46O5JSzxqLgg=
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10/go.mod h1:oiDa54M0FwxevWwyAX773lwdWvFYYlYHHQV1LQ5HpWY=
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260226130359-963f935e0396 h1:03tbcwjyIEjvHba1IWOj1sfThwebm2XNzyFHSuZtlWc=
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260226130359-963f935e0396/go.mod h1:Jqt53s27Tr0jDl8mdBXg1xhu6F8Fci8JOuq43tgHOM8=
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260318054214-bad7873faa1c h1:m+XflniQiuMPvcKtiWpnsqpOiRNcONKrhF5zwpR2QJM=
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260318054214-bad7873faa1c/go.mod h1:Jqt53s27Tr0jDl8mdBXg1xhu6F8Fci8JOuq43tgHOM8=
github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b h1:QuI6SmQFK/zyUlVWEf0GMkiUYBPY4lssn26nKSd/bOM=
github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b/go.mod h1:qSTSwX3cBP3FKQwQacdjArqv0g6QnukjV4XuzO6UyoY=
github.com/smartcontractkit/chainlink-protos/node-platform v0.0.0-20260205130626-db2a2aab956b h1:36knUpKHHAZ86K4FGWXtx8i/EQftGdk2bqCoEu/Cha8=
Expand All @@ -339,8 +339,8 @@ github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e h1:Hv9
github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA=
github.com/smartcontractkit/libocr v0.0.0-20250912173940-f3ab0246e23d h1:LokA9PoCNb8mm8mDT52c3RECPMRsGz1eCQORq+J3n74=
github.com/smartcontractkit/libocr v0.0.0-20250912173940-f3ab0246e23d/go.mod h1:Acy3BTBxou83ooMESLO90s8PKSu7RvLCzwSTbxxfOK0=
github.com/smartcontractkit/libocr v0.0.0-20251027221354-bdc84e1ed858 h1:dz+lxAW+B+PUq32ODppSq5UKw06+EF6+EO6kk684bcQ=
github.com/smartcontractkit/libocr v0.0.0-20251027221354-bdc84e1ed858/go.mod h1:oJkBKVn8zoBQm7Feah9CiuEHyCqAhnp1LJBzrvloQtM=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ccip/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func SendMessageFromAptos(ctx context.Context, lggr logger.Logger, deployer *apt
return "", fmt.Errorf("failed to send ccip message: %w", err)
}
if !data.Success {
return "", fmt.Errorf("transaction %v failed: %w", tx.Hash, data.VmStatus)
return "", fmt.Errorf("transaction %v failed: %s", tx.Hash, data.VmStatus)
}

var eventsLog []any
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflow = """
name: "0000FOOBAR"
owner: "%s"
triggers:
- id: "mock-streams-trigger@1.0.0"
- id: "streams-trigger@1.0.0"
config:
maxFrequencyMs: 5000
feedIds:
Expand Down
9 changes: 5 additions & 4 deletions integration-tests/deploy/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,11 @@ func (d *Deployer) DeployCore() error {

Name: containerName,
Env: map[string]string{
"CL_CONFIG": tomlString,
"CL_DATABASE_URL": fmt.Sprintf("%s?sslmode=disable", dbUrl),
"CL_PASSWORD_KEYSTORE": "notastrongpassword",
"CL_EVM_CMD": "", // Disable LOOPP mode for EVM to enable ReplayFromBlock
"CL_CONFIG": tomlString,
"CL_DATABASE_URL": fmt.Sprintf("%s?sslmode=disable", dbUrl),
"CL_PASSWORD_KEYSTORE": "notastrongpassword",
"CL_EVM_CMD": "", // Disable LOOPP mode for EVM to enable ReplayFromBlock
"CL_ENABLE_FAKE_STREAMS_TRIGGER": "true",
},
Entrypoint: []string{"bash", "-c", fmt.Sprintf("echo -e \"%s\\n%s\" > /tmp/api_credentials && chainlink node start --api /tmp/api_credentials", coreConfig.Email, coreConfig.Password)},
}
Expand Down
Loading
Loading