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
2 changes: 1 addition & 1 deletion .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ runs:
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Setup Go
uses: actions/setup-go@v6
uses: actions/setup-go@v6.2.0
with:
go-version: ${{ steps.determine.outputs.version }}
cache: true
75 changes: 75 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# CLAUDE.md

## Project Overview

`lumera-ica-client` is a Go CLI reference client for executing Lumera Cascade actions (file storage) across Cosmos chains via ICS-27 Interchain Accounts (ICA). It bridges a controller chain (e.g., Osmosis) to the Lumera host chain, handling ICA registration, action submission, supernode file upload/download, and action approval.

## Architecture

- **Controller chain**: where the user key lives; signs `MsgSendTx` wrapping Lumera messages
- **Host chain (Lumera)**: executes `MsgRequestAction` / `MsgApproveAction` via ICA
- **Supernodes**: off-chain mesh for file byte upload/download keyed by `action_id`

Key dependency: `github.com/LumeraProtocol/sdk-go` provides ICA controller, cascade client, and crypto primitives.

## Project Structure

```
main.go # Entry point, sets bech32 prefixes
cmd/
commands.go # Root cobra command, shared helpers
upload.go # Upload command (ICA registration + supernode upload)
download.go # Download command
action.go # Action status/approve subcommands
client/
config.go # TOML config loading and validation
lumera_client.go # Lumera SDK client wrapper
cascade_client.go # Cascade (supernode) client wrapper
ica_controller.go # ICA controller wrapper
config.toml # Example/default configuration
spec.md # Full ICA specification
docs/
DEVELOPER_GUIDE.md # Detailed developer documentation
WORKFLOWS.md # Workflow documentation
```

## Build & Run

```bash
make build # Outputs binary to build/lumera-ica-client
```

No test suite exists yet. The project uses Go 1.25.5.

## Configuration

Config is TOML-based (`config.toml`). Two sections:
- `[lumera]` — host chain settings (chain_id, grpc/rpc endpoints, key_name, key_type)
- `[controller]` — controller chain settings (chain_id, endpoints, keyring config, connection_id)

Keyring backends: `os`, `file`, `test`. Key types: `cosmos` (secp256k1), `evm` (eth_secp256k1).

## CLI Commands

```bash
lumera-ica-client upload <file> [--public] [--action-id <id>]
lumera-ica-client download <action_id> --out <dir>
lumera-ica-client action status <action_id>
lumera-ica-client action approve <action_id> [--ica-address <addr>]
```

## Conventions

- CLI uses `cobra` with a shared `app` struct for config state
- JSON output to stdout via `writeJSON()`
- 10-minute default command timeout
- Config validation is strict — all required fields must be non-empty
- Bech32 prefix is hardcoded to `lumera` / `lumerapub` in main.go

## Local Development with sdk-go

The `go.mod` has a commented-out replace directive for local sdk-go development:
```
//github.com/LumeraProtocol/sdk-go => ../sdk-go
```
Uncomment to develop against a local clone of sdk-go.
30 changes: 30 additions & 0 deletions client/cascade_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ func NewCascadeClient(ctx context.Context, cfg *Config) (*Client, error) {
if err != nil {
return nil, err
}
// Validate that keys in the keyring match the configured key types.
if err := validateKeyType(controllerKR, cfg.Controller.KeyName, cfg.Controller.KeyType); err != nil {
return nil, fmt.Errorf("controller key type: %w", err)
}
if err := validateKeyType(controllerKR, cfg.Lumera.KeyName, cfg.Lumera.KeyType); err != nil {
return nil, fmt.Errorf("lumera key type: %w", err)
}
// Resolve controller owner address using the configured controller account HRP.
ownerAddr, err := sdkcrypto.AddressFromKey(controllerKR, cfg.Controller.KeyName, cfg.Controller.AccountHRP)
if err != nil {
Expand Down Expand Up @@ -62,6 +69,29 @@ func NewCascadeClient(ctx context.Context, cfg *Config) (*Client, error) {
return &Client{Cascade: casc, Keyring: controllerKR, OwnerAddress: ownerAddr}, nil
}

// validateKeyType checks that a key in the keyring uses the algorithm matching
// the configured key_type. This catches misconfigurations early — e.g. when a
// config says key_type = "evm" but the keyring holds a cosmos secp256k1 key.
func validateKeyType(kr keyring.Keyring, keyName, configuredType string) error {
kt, err := ParseKeyType(configuredType)
if err != nil {
return err
}
rec, err := kr.Key(keyName)
if err != nil {
return fmt.Errorf("key %q not found in keyring: %w", keyName, err)
}
pub, err := rec.GetPubKey()
if err != nil {
return fmt.Errorf("get pubkey for %q: %w", keyName, err)
}
expected := string(kt.SigningAlgo().Name())
if actual := pub.Type(); actual != expected {
return fmt.Errorf("key %q type mismatch: config expects %s but keyring has %s", keyName, expected, actual)
}
return nil
}

// newControllerKeyring constructs the Cosmos keyring for the controller chain.
func newControllerKeyring(cfg ControllerConfig) (keyring.Keyring, error) {
passphrase, err := resolvePassphrase(cfg.KeyringPassphrasePlain, cfg.KeyringPassphraseFile)
Expand Down
37 changes: 37 additions & 0 deletions client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"path/filepath"
"strings"

sdkcrypto "github.com/LumeraProtocol/sdk-go/pkg/crypto"

"github.com/BurntSushi/toml"
)

Expand All @@ -25,6 +27,7 @@ type LumeraConfig struct {
RPCEndpoint string `toml:"rpc_endpoint"`
LogLevel string `toml:"log_level"`
KeyName string `toml:"key_name"`
KeyType string `toml:"key_type"`
}

// ControllerConfig stores controller chain and keyring settings.
Expand All @@ -36,6 +39,7 @@ type ControllerConfig struct {
Binary string `toml:"binary"`
Home string `toml:"home"`
KeyName string `toml:"key_name"`
KeyType string `toml:"key_type"`
KeyringBackend string `toml:"keyring_backend"`
KeyringDir string `toml:"keyring_dir"`
KeyringPassphrasePlain string `toml:"keyring_passphrase_plain"`
Expand Down Expand Up @@ -88,6 +92,16 @@ func (c *Config) Validate() error {
return err
}
c.Lumera.LogLevel = logLevel
lumeraKeyType, err := normalizeKeyType(c.Lumera.KeyType)
if err != nil {
return fmt.Errorf("lumera.%w", err)
}
c.Lumera.KeyType = lumeraKeyType
controllerKeyType, err := normalizeKeyType(c.Controller.KeyType)
if err != nil {
return fmt.Errorf("controller.%w", err)
}
c.Controller.KeyType = controllerKeyType
Comment thread
akobrin1 marked this conversation as resolved.
if strings.TrimSpace(c.Lumera.ChainID) == "" {
return fmt.Errorf("lumera.chain_id is required")
}
Expand Down Expand Up @@ -147,6 +161,29 @@ func (c *Config) Validate() error {
return nil
}

// ParseKeyType converts a config string to sdkcrypto.KeyType.
// It defaults to KeyTypeCosmos when the value is empty.
func ParseKeyType(value string) (sdkcrypto.KeyType, error) {
val := strings.ToLower(strings.TrimSpace(value))
switch val {
case "", "cosmos":
return sdkcrypto.KeyTypeCosmos, nil
case "evm":
return sdkcrypto.KeyTypeEVM, nil
default:
return 0, fmt.Errorf("key_type must be one of: cosmos, evm (got %q)", value)
}
}

// normalizeKeyType normalizes a key_type value in place.
func normalizeKeyType(value string) (string, error) {
kt, err := ParseKeyType(value)
if err != nil {
return "", err
}
return kt.String(), nil
}

// normalizeLogLevel maps user input to supported log levels.
func normalizeLogLevel(value string) (string, error) {
val := strings.ToLower(strings.TrimSpace(value))
Expand Down
1 change: 1 addition & 0 deletions client/ica_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func NewICAController(ctx context.Context, cfg *Config, kr keyring.Keyring) (*Co
Host: hostCfg,
Keyring: kr,
KeyName: cfg.Controller.KeyName,
HostKeyName: cfg.Lumera.KeyName,
ConnectionID: cfg.Controller.ConnectionID,
CounterpartyConnectionID: cfg.Controller.CounterpartyConnectionID,
})
Expand Down
7 changes: 7 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ log_level = "info"
# Key name in the controller keyring to use for Lumera signing.
key_name = "lumera"

# Key type for the Lumera (host) chain key: "cosmos" (secp256k1) or "evm" (eth_secp256k1).
# Default: "cosmos"
#key_type = "cosmos"

[controller]
# Chain ID of the controller network
chain_id = "osmo-test-5"
Expand All @@ -27,6 +31,9 @@ home = "~/.osmosisd-testnet"
gas_prices = "0.03uosmo"

key_name = "osmosis-ibc-test"
# Key type for the controller chain key: "cosmos" (secp256k1) or "evm" (eth_secp256k1).
# Default: "cosmos"
#key_type = "cosmos"
# This keyring is used for ICA signing and cascade metadata (no separate Lumera keyring).
# KeyRing backend for storing keys: "file", "test", or "os" (default: test)
keyring_backend = "test"
Expand Down
68 changes: 34 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.25.5
replace (
// for local development
//github.com/LumeraProtocol/sdk-go => ../sdk-go
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.14
github.com/envoyproxy/protoc-gen-validate => github.com/bufbuild/protoc-gen-validate v1.3.0
github.com/lyft/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v1.3.0
nhooyr.io/websocket => github.com/coder/websocket v1.8.7
Expand All @@ -14,19 +13,19 @@ replace (
require (
cosmossdk.io/math v1.5.3
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
github.com/LumeraProtocol/lumera v1.9.1
github.com/LumeraProtocol/sdk-go v1.0.7
github.com/cosmos/cosmos-sdk v0.53.0
github.com/LumeraProtocol/lumera v1.10.1
github.com/LumeraProtocol/sdk-go v1.0.9
github.com/cosmos/cosmos-sdk v0.53.5
github.com/spf13/cobra v1.10.1
)

require (
cosmossdk.io/api v0.9.2 // indirect
cosmossdk.io/collections v1.3.0 // indirect
cosmossdk.io/collections v1.3.1 // indirect
cosmossdk.io/core v0.11.3 // indirect
cosmossdk.io/depinject v1.2.0 // indirect
cosmossdk.io/depinject v1.2.1 // indirect
cosmossdk.io/errors v1.0.2 // indirect
cosmossdk.io/log v1.6.0 // indirect
cosmossdk.io/log v1.6.1 // indirect
cosmossdk.io/schema v1.1.0 // indirect
cosmossdk.io/store v1.1.2 // indirect
cosmossdk.io/x/tx v0.14.0 // indirect
Expand All @@ -37,14 +36,14 @@ require (
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
github.com/DataDog/zstd v1.5.7 // indirect
github.com/LumeraProtocol/rq-go v0.2.1 // indirect
github.com/LumeraProtocol/supernode/v2 v2.4.26 // indirect
github.com/LumeraProtocol/supernode/v2 v2.4.27 // indirect
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.2.0 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.14.1 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/bytedance/sonic v1.14.2 // indirect
github.com/bytedance/sonic/loader v0.4.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
Expand All @@ -54,24 +53,24 @@ require (
github.com/cockroachdb/pebble v1.1.5 // indirect
github.com/cockroachdb/redact v1.1.6 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.38.18 // indirect
github.com/cometbft/cometbft v0.38.20 // indirect
github.com/cometbft/cometbft-db v0.14.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.1.2 // indirect
github.com/cosmos/cosmos-db v1.1.3 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.7.0 // indirect
github.com/cosmos/iavl v1.2.4 // indirect
github.com/cosmos/ibc-go/v10 v10.3.0 // indirect
github.com/cosmos/gogoproto v1.7.2 // indirect
github.com/cosmos/iavl v1.2.6 // indirect
github.com/cosmos/ibc-go/v10 v10.5.0 // indirect
github.com/cosmos/ics23/go v0.11.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.16.0 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/desertbit/timer v1.0.1 // indirect
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgraph-io/ristretto v0.2.0 // indirect
github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
Expand All @@ -80,7 +79,7 @@ require (
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/getsentry/sentry-go v0.32.0 // indirect
github.com/getsentry/sentry-go v0.35.0 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -89,8 +88,7 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.5 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.5-0.20231225225746-43d5d4cd4e0e // indirect
github.com/google/btree v1.1.3 // indirect
Expand Down Expand Up @@ -136,10 +134,10 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.22.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/rs/cors v1.11.1 // indirect
Expand All @@ -157,32 +155,34 @@ require (
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/zondax/golem v0.27.0 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
github.com/zondax/ledger-go v1.0.1 // indirect
go.etcd.io/bbolt v1.4.0-alpha.1 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/mock v0.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.15.0 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/arch v0.17.0 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect
golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/term v0.36.0 // indirect
golang.org/x/text v0.30.0 // indirect
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
google.golang.org/grpc v1.77.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.2 // indirect
lukechampine.com/blake3 v1.4.1 // indirect
nhooyr.io/websocket v1.8.17 // indirect
pgregory.net/rapid v1.2.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading