Skip to content
Draft
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
21 changes: 21 additions & 0 deletions .github/workflows/validate-protos-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Validate chainlink-protos version

on:
push:
branches:
- capabilities-development
pull_request:
branches:
- capabilities-development

jobs:
validate-protos-version:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Validate protos version
uses: smartcontractkit/.github/actions/validate-protos-version@e5a68c3ae58d138e4e7d1d2bbc7918e2b51d7161 #v1.0.0

Check warning on line 21 in .github/workflows/validate-protos-version.yml

View workflow job for this annotation

GitHub Actions / Validate Workflow Changes

1. Trusted actions should use a major version tag, if available. (trusted-tag-ref / warning)
97 changes: 97 additions & 0 deletions .github/workflows/validate-sdk-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Validate cre-sdk-go version

on:
push:
branches:
- capabilities-development
pull_request:
branches:
- capabilities-development

jobs:
validate-sdk-version:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Checkout cre-sdk-go
uses: actions/checkout@v6
with:
repository: smartcontractkit/cre-sdk-go
ref: capabilities-development
path: .cre-sdk-go
fetch-depth: 0
persist-credentials: false

- name: Validate cre-sdk-go versions are from capabilities-development
run: |
failed=0
found=0

# Find all lines in the root go.mod that depend on any cre-sdk-go module.
while IFS= read -r line; do
mod=$(echo "$line" | awk '{print $1}')
echo " parsed module: $mod"
version=$(echo "$line" | awk '{print $2}')
echo " parsed version: $version"

found=1

# Pseudo-versions have 3 parts separated by "-" and end with a 12-char hex commit hash.
# e.g. "v0.0.0-20260420204255-a3f3bdd56877" -> "a3f3bdd56877"
# Tagged versions like "v1.9.0-capdev.1" don't match this pattern.
suffix=${version##*-}
if [[ "$suffix" =~ ^[0-9a-f]{12}$ ]]; then
# Pseudo-version: use the commit hash directly.
commit="$suffix"
echo " parsed commit (pseudo-version): $commit"
else
# Tagged version: resolve the tag to a commit.
# The module path prefix (github.com/smartcontractkit/cre-sdk-go) maps to the
# repo root; any sub-module suffix becomes a tag prefix.
# e.g. module "github.com/smartcontractkit/cre-sdk-go/capabilities/blockchain/evm"
# with version "v1.0.0-beta.10-capdev.1" -> tag "capabilities/blockchain/evm/v1.0.0-beta.10-capdev.1"
subpath=${mod#github.com/smartcontractkit/cre-sdk-go}
subpath=${subpath#/}
if [[ -n "$subpath" ]]; then
tag="${subpath}/${version}"
else
tag="${version}"
fi
echo " resolved tag: $tag"
commit=$(git -C .cre-sdk-go rev-list -n1 "$tag" 2>/dev/null || true)
if [[ -z "$commit" ]]; then
echo "::error::$mod tag $tag not found in cre-sdk-go"
failed=1
continue
fi
echo " resolved commit: $commit"
fi

echo "Checking module=$mod version=$version commit=$commit"

# Verify the commit is reachable from capabilities-development.
if ! git -C .cre-sdk-go merge-base --is-ancestor "$commit" capabilities-development 2>/dev/null; then
echo "::error::$mod commit $commit is NOT on the capabilities-development branch of cre-sdk-go"
failed=1
else
echo "OK: $mod commit $commit is on capabilities-development"
fi
done < <(grep 'github.com/smartcontractkit/cre-sdk-go' go.mod | grep -v '^//')

if [[ "$found" -eq 0 ]]; then
echo "::error::No cre-sdk-go dependencies found in go.mod"
exit 1
fi

if [[ "$failed" -eq 1 ]]; then
echo ""
echo "One or more cre-sdk-go dependencies reference a commit not on capabilities-development."
exit 1
fi

echo ""
echo "All cre-sdk-go versions are from capabilities-development."
6 changes: 3 additions & 3 deletions cmd/secrets/common/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ type Handler struct {
func NewHandler(ctx *runtime.Context, secretsFilePath, secretsAuth string) (*Handler, error) {
var pk *ecdsa.PrivateKey
var err error
if ctx.Settings.User.EthPrivateKey != "" {
pk, err = crypto.HexToECDSA(ctx.Settings.User.EthPrivateKey)
if ethKey := ctx.Settings.User.PrivateKey(settings.EVM); ethKey != "" {
pk, err = crypto.HexToECDSA(ethKey)
if err != nil {
return nil, fmt.Errorf("failed to decode the provided private key: %w", err)
}
} else {
ctx.Logger.Debug().Msg("No EthPrivateKey found in settings; assuming a multisig request.")
ctx.Logger.Debug().Msg("No EVM private key found in settings; assuming a multisig request.")

}

Expand Down
2 changes: 1 addition & 1 deletion cmd/secrets/common/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func TestNewHandler_WorkflowRegistryClient(t *testing.T) {
Logger: &logger,
ClientFactory: cf,
Settings: &settings.Settings{
User: settings.UserSettings{EthPrivateKey: ""},
User: settings.UserSettings{PrivateKeys: map[string]string{settings.EVM.Name: ""}},
Workflow: settings.WorkflowSettings{},
},
EnvironmentSet: &environments.EnvironmentSet{GatewayURL: "http://localhost"},
Expand Down
6 changes: 3 additions & 3 deletions cmd/workflow/activate/activate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNonInteractive_WithoutYes_ReturnsError(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand All @@ -47,7 +47,7 @@ func TestNonInteractive_WithYes_PassesGuard(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestWorkflowActivateCommand(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand Down
6 changes: 3 additions & 3 deletions cmd/workflow/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestNonInteractive_WithoutYes_ReturnsError(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand All @@ -47,7 +47,7 @@ func TestNonInteractive_WithYes_Proceeds(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestWorkflowDeleteCommand(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand Down
6 changes: 3 additions & 3 deletions cmd/workflow/pause/pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNonInteractive_WithoutYes_ReturnsError(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand All @@ -46,7 +46,7 @@ func TestNonInteractive_WithYes_PassesGuard(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestWorkflowPauseCommand(t *testing.T) {
ctx := simulatedEnvironment.NewRuntimeContext()
ctx.Settings = &settings.Settings{
User: settings.UserSettings{
EthPrivateKey: chainsim.TestPrivateKey,
PrivateKeys: map[string]string{settings.EVM.Name: chainsim.TestPrivateKey},
},
}
ctx.Settings.Workflow.UserWorkflowSettings.WorkflowOwnerType = constants.WorkflowOwnerTypeEOA
Expand Down
78 changes: 78 additions & 0 deletions cmd/workflow/simulate/chain/aptos/capabilities.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package aptos

import (
"context"
"fmt"

"github.com/aptos-labs/aptos-go-sdk"
"github.com/aptos-labs/aptos-go-sdk/crypto"

aptosfakes "github.com/smartcontractkit/chainlink-aptos/capabilities/fakes"
aptosserver "github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/chain-capabilities/aptos/server"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink/v2/core/capabilities"

"github.com/smartcontractkit/cre-cli/cmd/workflow/simulate/chain"
)

// AptosChainCapabilities holds the per-selector FakeAptosChain instances
// created for simulation.
type AptosChainCapabilities struct {
AptosChains map[uint64]*aptosfakes.FakeAptosChain
}

// NewAptosChainCapabilities builds FakeAptosChain instances for every
// (selector -> client) pair, optionally wraps them with LimitedAptosChain,
// and registers each with the capability registry.
func NewAptosChainCapabilities(
ctx context.Context,
lggr logger.Logger,
registry *capabilities.Registry,
clients map[uint64]aptos.AptosRpcClient,
forwarders map[uint64]string,
privateKey *crypto.Ed25519PrivateKey,
dryRunChainWrite bool,
limits chain.Limits,
) (*AptosChainCapabilities, error) {
chains := make(map[uint64]*aptosfakes.FakeAptosChain)
for sel, client := range clients {
fwdStr, ok := forwarders[sel]
if !ok {
lggr.Infow("Forwarder not found for chain", "selector", sel)
continue
}
var fwd aptos.AccountAddress
if err := fwd.ParseStringRelaxed(fwdStr); err != nil {
return nil, fmt.Errorf("parse forwarder for selector %d: %w", sel, err)
}
fc, err := aptosfakes.NewFakeAptosChain(lggr, client, privateKey, fwd, sel, dryRunChainWrite)
if err != nil {
return nil, fmt.Errorf("new FakeAptosChain for selector %d: %w", sel, err)
}
capability := NewLimitedAptosChain(fc, limits)
server := aptosserver.NewClientServer(capability)
if err := registry.Add(ctx, server); err != nil {
return nil, fmt.Errorf("register aptos capability for selector %d: %w", sel, err)
}
chains[sel] = fc
}
return &AptosChainCapabilities{AptosChains: chains}, nil
}

func (c *AptosChainCapabilities) Start(ctx context.Context) error {
for _, fc := range c.AptosChains {
if err := fc.Start(ctx); err != nil {
return err
}
}
return nil
}

func (c *AptosChainCapabilities) Close() error {
for _, fc := range c.AptosChains {
if err := fc.Close(); err != nil {
return err
}
}
return nil
}
Loading
Loading