Skip to content

Commit 71cbdf4

Browse files
committed
feat: add support for solana chain family in configs and add validation for solana-specific values.
1 parent 524f9d9 commit 71cbdf4

5 files changed

Lines changed: 558 additions & 370 deletions

File tree

cmd/start.go

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"context"
55
"math/big"
66

7+
solana2 "github.com/gagliardetto/solana-go"
8+
chain_selectors "github.com/smartcontractkit/chain-selectors"
9+
"github.com/smartcontractkit/mcms/sdk/solana"
710
"github.com/spf13/cobra"
811

912
"github.com/smartcontractkit/timelock-worker/pkg/cli"
@@ -18,10 +21,10 @@ func startCommand() *cobra.Command {
1821
Run: startHandler,
1922
}
2023

21-
nodeURL, privateKey, timelockAddress, callProxyAddress string
22-
fromBlock, pollPeriod, eventListenerPollPeriod int64
23-
eventListenerPollSize uint64
24-
dryRun bool
24+
nodeURL, privateKey, timelockAddress, callProxyAddress, chainFamily string
25+
fromBlock, pollPeriod, eventListenerPollPeriod int64
26+
eventListenerPollSize uint64
27+
dryRun bool
2528
)
2629

2730
// Initialize timelock-worker configuration.
@@ -37,7 +40,9 @@ func startCommand() *cobra.Command {
3740
timelock.SetReadyStatus(timelock.HealthStatusError)
3841

3942
startCmd.Flags().StringVarP(&nodeURL, "node-url", "n", timelockConf.NodeURL, "RPC Endpoint for the target blockchain")
43+
startCmd.Flags().StringVarP(&chainFamily, "chain-family", "n", timelockConf.ChainFamily, "Chain family of the target blockchain (evm, solana)")
4044
startCmd.Flags().StringVarP(&timelockAddress, "timelock-address", "a", timelockConf.TimelockAddress, "Address of the target Timelock contract")
45+
startCmd.Flags().StringVarP(&timelockAddress, "timelock-instance-id", "a", timelockConf.TimelockAddress, "Address of the target Timelock contract")
4146
startCmd.Flags().StringVarP(&callProxyAddress, "call-proxy-address", "f", timelockConf.CallProxyAddress, "Address of the target CallProxyAddress contract")
4247
startCmd.Flags().StringVarP(&privateKey, "private-key", "k", timelockConf.PrivateKey, "Private key used to execute transactions")
4348
startCmd.Flags().Int64Var(&fromBlock, "from-block", timelockConf.FromBlock, "Start watching from this block")
@@ -63,20 +68,42 @@ func startTimelock(cmd *cobra.Command) {
6368
slog.Fatalf("value of node-url not set: %s", err.Error())
6469
}
6570

71+
chainFamily, err := cmd.Flags().GetString("chain-family")
72+
if err != nil {
73+
slog.Fatalf("value of node-url not set: %s", err.Error())
74+
}
75+
6676
timelockAddress, err := cmd.Flags().GetString("timelock-address")
6777
if err != nil {
6878
slog.Fatalf("value of timelock-address not set: %s", err.Error())
6979
}
80+
if chainFamily == chain_selectors.FamilySolana {
81+
// Parse contract address to ensure it's on right format
82+
key, _, err := solana.ParseContractAddress(timelockAddress)
83+
if err != nil {
84+
slog.Fatalf("value of timelock-address is invalid for solana. expected: 'timelockProgram.instanceSeed': %s", err.Error())
85+
}
86+
if key.IsZero() {
87+
slog.Fatalf("invalid timelockProgram. cannot be zero")
88+
}
89+
}
7090

7191
callProxyAddress, err := cmd.Flags().GetString("call-proxy-address")
72-
if err != nil {
92+
if err != nil && chainFamily == chain_selectors.FamilyEVM {
7393
slog.Fatalf("value of call-proxy-address not set: %s", err.Error())
7494
}
7595

7696
privateKey, err := cmd.Flags().GetString("private-key")
7797
if err != nil {
7898
slog.Fatalf("value of private-key not set: %s", err.Error())
7999
}
100+
if chainFamily == chain_selectors.FamilySolana {
101+
// Parse contract address to ensure it's on right format
102+
_, err := solana2.PrivateKeyFromBase58(privateKey)
103+
if err != nil {
104+
slog.Fatalf("value of private-key is invalid for solana: %s", err.Error())
105+
}
106+
}
80107

81108
fromBlock, err := cmd.Flags().GetInt64("from-block")
82109
if err != nil {
@@ -103,16 +130,21 @@ func startTimelock(cmd *cobra.Command) {
103130
slog.Fatalf("value of dry-run not set: %s", err.Error())
104131
}
105132

106-
tWorker, err := timelock.NewTimelockWorker(nodeURL, timelockAddress, callProxyAddress, privateKey,
107-
big.NewInt(fromBlock), pollPeriod, eventListenerPollPeriod, eventListenerPollSize, dryRun, slog)
108-
if err != nil {
109-
slog.Fatalf("error creating the timelock-worker: %s", err.Error())
110-
}
133+
if chainFamily == chain_selectors.FamilyEVM {
134+
tWorker, err := timelock.NewTimelockWorker(nodeURL, timelockAddress, callProxyAddress, privateKey,
135+
big.NewInt(fromBlock), pollPeriod, eventListenerPollPeriod, eventListenerPollSize, dryRun, slog)
136+
if err != nil {
137+
slog.Fatalf("error creating the timelock-worker: %s", err.Error())
138+
}
111139

112-
if err := tWorker.Listen(context.Background()); err != nil {
113-
slog.Fatalf("error while starting timelock-worker: %s", err.Error())
140+
if err := tWorker.Listen(context.Background()); err != nil {
141+
slog.Fatalf("error while starting timelock-worker: %s", err.Error())
142+
}
143+
} else if chainFamily == chain_selectors.FamilySolana {
144+
slog.Infof("Solana chain family is not supported yet")
145+
} else {
146+
slog.Fatalf("unsupported chain family: %s", chainFamily)
114147
}
115-
116148
slog.Infof("shutting down timelock-worker")
117149
}
118150

go.mod

Lines changed: 107 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,141 @@
11
module github.com/smartcontractkit/timelock-worker
22

3-
go 1.22
3+
go 1.24.0
4+
5+
toolchain go1.24.3
46

57
require (
68
github.com/avast/retry-go/v4 v4.6.1
79
github.com/docker/go-connections v0.5.0
8-
github.com/ethereum/go-ethereum v1.13.15
9-
github.com/google/go-cmp v0.6.0
10-
github.com/prometheus/client_golang v1.19.1
10+
github.com/ethereum/go-ethereum v1.15.7
11+
github.com/google/go-cmp v0.7.0
12+
github.com/prometheus/client_golang v1.21.1
1113
github.com/samber/lo v1.47.0
1214
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240917103524-56f1a8d2cd4b
13-
github.com/smartcontractkit/chain-selectors v1.0.17
15+
github.com/smartcontractkit/chain-selectors v1.0.55
16+
github.com/smartcontractkit/mcms v0.19.2
1417
github.com/spf13/cobra v1.8.1
1518
github.com/spf13/viper v1.19.0
1619
github.com/stretchr/testify v1.10.0
17-
github.com/testcontainers/testcontainers-go v0.34.0
20+
github.com/testcontainers/testcontainers-go v0.35.0
1821
go.uber.org/zap v1.27.0
1922
)
2023

2124
require (
22-
dario.cat/mergo v1.0.0 // indirect
23-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
24-
github.com/DataDog/zstd v1.4.5 // indirect
25+
dario.cat/mergo v1.0.1 // indirect
26+
filippo.io/edwards25519 v1.1.0 // indirect
27+
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
28+
github.com/BurntSushi/toml v1.4.0 // indirect
29+
github.com/DataDog/zstd v1.5.2 // indirect
2530
github.com/Microsoft/go-winio v0.6.2 // indirect
26-
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
31+
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
32+
github.com/allegro/bigcache v1.2.1 // indirect
33+
github.com/benbjohnson/clock v1.3.5 // indirect
2734
github.com/beorn7/perks v1.0.1 // indirect
28-
github.com/bits-and-blooms/bitset v1.10.0 // indirect
29-
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
30-
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect
31-
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
35+
github.com/bits-and-blooms/bitset v1.17.0 // indirect
36+
github.com/blendle/zapdriver v1.3.1 // indirect
37+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
3238
github.com/cespare/cp v1.1.1 // indirect
33-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
34-
github.com/cockroachdb/errors v1.8.1 // indirect
35-
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
36-
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
37-
github.com/cockroachdb/redact v1.0.8 // indirect
38-
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
39+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
40+
github.com/cockroachdb/errors v1.11.3 // indirect
41+
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
42+
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
43+
github.com/cockroachdb/pebble v1.1.2 // indirect
44+
github.com/cockroachdb/redact v1.1.5 // indirect
3945
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
40-
github.com/consensys/bavard v0.1.13 // indirect
41-
github.com/consensys/gnark-crypto v0.12.1 // indirect
42-
github.com/containerd/containerd v1.7.18 // indirect
46+
github.com/consensys/bavard v0.1.22 // indirect
47+
github.com/consensys/gnark-crypto v0.14.0 // indirect
4348
github.com/containerd/log v0.1.0 // indirect
4449
github.com/containerd/platforms v0.2.1 // indirect
4550
github.com/cpuguy83/dockercfg v0.3.2 // indirect
46-
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
47-
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
48-
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
51+
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
52+
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
53+
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
4954
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
5055
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
51-
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
56+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
57+
github.com/deepmap/oapi-codegen v1.8.2 // indirect
5258
github.com/distribution/reference v0.6.0 // indirect
53-
github.com/docker/docker v27.1.1+incompatible // indirect
59+
github.com/docker/docker v27.3.1+incompatible // indirect
5460
github.com/docker/go-units v0.5.0 // indirect
55-
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
61+
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
62+
github.com/ethereum/go-verkle v0.2.2 // indirect
63+
github.com/fatih/color v1.18.0 // indirect
5664
github.com/felixge/httpsnoop v1.0.4 // indirect
57-
github.com/fjl/memsize v0.0.2 // indirect
58-
github.com/fsnotify/fsnotify v1.7.0 // indirect
59-
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
60-
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
61-
github.com/go-logr/logr v1.4.1 // indirect
65+
github.com/fsnotify/fsnotify v1.8.0 // indirect
66+
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
67+
github.com/gagliardetto/binary v0.8.0 // indirect
68+
github.com/gagliardetto/solana-go v1.12.0 // indirect
69+
github.com/gagliardetto/treeout v0.1.4 // indirect
70+
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
71+
github.com/getsentry/sentry-go v0.27.0 // indirect
72+
github.com/go-logr/logr v1.4.2 // indirect
6273
github.com/go-logr/stdr v1.2.2 // indirect
6374
github.com/go-ole/go-ole v1.3.0 // indirect
75+
github.com/go-playground/locales v0.14.1 // indirect
76+
github.com/go-playground/universal-translator v0.18.1 // indirect
77+
github.com/go-playground/validator/v10 v10.25.0 // indirect
6478
github.com/gofrs/flock v0.8.1 // indirect
6579
github.com/gogo/protobuf v1.3.3 // indirect
66-
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
80+
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
6781
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
6882
github.com/google/uuid v1.6.0 // indirect
69-
github.com/gorilla/websocket v1.5.1 // indirect
83+
github.com/gorilla/websocket v1.5.3 // indirect
7084
github.com/hashicorp/go-bexpr v0.1.10 // indirect
7185
github.com/hashicorp/hcl v1.0.0 // indirect
7286
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
7387
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
74-
github.com/holiman/uint256 v1.2.4 // indirect
88+
github.com/holiman/uint256 v1.3.2 // indirect
7589
github.com/huin/goupnp v1.3.0 // indirect
7690
github.com/inconshreveable/mousetrap v1.1.0 // indirect
91+
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
7792
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
78-
github.com/klauspost/compress v1.17.4 // indirect
93+
github.com/json-iterator/go v1.1.12 // indirect
94+
github.com/klauspost/compress v1.18.0 // indirect
95+
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
7996
github.com/kr/pretty v0.3.1 // indirect
8097
github.com/kr/text v0.2.0 // indirect
98+
github.com/leodido/go-urn v1.4.0 // indirect
99+
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
81100
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
82101
github.com/magiconair/properties v1.8.7 // indirect
83-
github.com/mattn/go-colorable v0.1.13 // indirect
102+
github.com/mattn/go-colorable v0.1.14 // indirect
84103
github.com/mattn/go-isatty v0.0.20 // indirect
85-
github.com/mattn/go-runewidth v0.0.15 // indirect
86-
github.com/mitchellh/mapstructure v1.5.0 // indirect
104+
github.com/mattn/go-runewidth v0.0.16 // indirect
105+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
106+
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
87107
github.com/mitchellh/pointerstructure v1.2.0 // indirect
88108
github.com/mmcloughlin/addchain v0.4.0 // indirect
89109
github.com/moby/docker-image-spec v1.3.1 // indirect
90110
github.com/moby/patternmatcher v0.6.0 // indirect
91111
github.com/moby/sys/sequential v0.5.0 // indirect
92112
github.com/moby/sys/user v0.1.0 // indirect
113+
github.com/moby/sys/userns v0.1.0 // indirect
93114
github.com/moby/term v0.5.0 // indirect
115+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
116+
github.com/modern-go/reflect2 v1.0.2 // indirect
94117
github.com/morikuni/aec v1.0.0 // indirect
118+
github.com/mostynb/zstdpool-freelist v0.0.0-20201229113212-927304c0c3b1 // indirect
119+
github.com/mr-tron/base58 v1.2.0 // indirect
120+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
95121
github.com/olekukonko/tablewriter v0.0.5 // indirect
96122
github.com/opencontainers/go-digest v1.0.0 // indirect
97123
github.com/opencontainers/image-spec v1.1.0 // indirect
98-
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
124+
github.com/opentracing/opentracing-go v1.2.0 // indirect
125+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
126+
github.com/pion/dtls/v2 v2.2.7 // indirect
127+
github.com/pion/logging v0.2.2 // indirect
128+
github.com/pion/stun/v2 v2.0.0 // indirect
129+
github.com/pion/transport/v2 v2.2.1 // indirect
130+
github.com/pion/transport/v3 v3.0.1 // indirect
99131
github.com/pkg/errors v0.9.1 // indirect
100132
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
101133
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
102-
github.com/prometheus/client_model v0.5.0 // indirect
103-
github.com/prometheus/common v0.48.0 // indirect
104-
github.com/prometheus/procfs v0.12.0 // indirect
105-
github.com/rivo/uniseg v0.4.4 // indirect
106-
github.com/rogpeppe/go-internal v1.10.0 // indirect
134+
github.com/prometheus/client_model v0.6.1 // indirect
135+
github.com/prometheus/common v0.63.0 // indirect
136+
github.com/prometheus/procfs v0.16.0 // indirect
137+
github.com/rivo/uniseg v0.4.7 // indirect
138+
github.com/rogpeppe/go-internal v1.13.1 // indirect
107139
github.com/rs/cors v1.8.3 // indirect
108140
github.com/russross/blackfriday/v2 v2.1.0 // indirect
109141
github.com/sagikazarmark/locafero v0.4.0 // indirect
@@ -112,36 +144,41 @@ require (
112144
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
113145
github.com/shoenig/go-m1cpu v0.1.6 // indirect
114146
github.com/sirupsen/logrus v1.9.3 // indirect
147+
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250512193142-11507db18550 // indirect
115148
github.com/sourcegraph/conc v0.3.0 // indirect
116149
github.com/spf13/afero v1.11.0 // indirect
117-
github.com/spf13/cast v1.6.0 // indirect
118-
github.com/spf13/pflag v1.0.5 // indirect
119-
github.com/status-im/keycard-go v0.2.0 // indirect
150+
github.com/spf13/cast v1.7.1 // indirect
151+
github.com/spf13/pflag v1.0.6 // indirect
152+
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 // indirect
120153
github.com/stretchr/objx v0.5.2 // indirect
121154
github.com/subosito/gotenv v1.6.0 // indirect
122-
github.com/supranational/blst v0.3.11 // indirect
123-
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
124-
github.com/tklauser/go-sysconf v0.3.12 // indirect
125-
github.com/tklauser/numcpus v0.6.1 // indirect
126-
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
127-
github.com/urfave/cli/v2 v2.25.7 // indirect
128-
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
155+
github.com/supranational/blst v0.3.14 // indirect
156+
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
157+
github.com/tklauser/go-sysconf v0.3.13 // indirect
158+
github.com/tklauser/numcpus v0.7.0 // indirect
159+
github.com/urfave/cli/v2 v2.27.5 // indirect
160+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
129161
github.com/yusufpapurcu/wmi v1.2.4 // indirect
130-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
131-
go.opentelemetry.io/otel v1.24.0 // indirect
132-
go.opentelemetry.io/otel/metric v1.24.0 // indirect
133-
go.opentelemetry.io/otel/trace v1.24.0 // indirect
162+
go.mongodb.org/mongo-driver v1.17.0 // indirect
163+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
164+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
165+
go.opentelemetry.io/otel v1.35.0 // indirect
166+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
167+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
134168
go.uber.org/multierr v1.11.0 // indirect
135-
golang.org/x/crypto v0.26.0 // indirect
136-
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
137-
golang.org/x/net v0.28.0 // indirect
138-
golang.org/x/sync v0.8.0 // indirect
139-
golang.org/x/sys v0.24.0 // indirect
140-
golang.org/x/text v0.17.0 // indirect
141-
golang.org/x/time v0.5.0 // indirect
142-
google.golang.org/protobuf v1.33.0 // indirect
169+
go.uber.org/ratelimit v0.3.1 // indirect
170+
golang.org/x/crypto v0.36.0 // indirect
171+
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
172+
golang.org/x/net v0.37.0 // indirect
173+
golang.org/x/sync v0.12.0 // indirect
174+
golang.org/x/sys v0.31.0 // indirect
175+
golang.org/x/term v0.30.0 // indirect
176+
golang.org/x/text v0.23.0 // indirect
177+
golang.org/x/time v0.10.0 // indirect
178+
golang.org/x/tools v0.31.0 // indirect
179+
google.golang.org/protobuf v1.36.6 // indirect
143180
gopkg.in/ini.v1 v1.67.0 // indirect
144-
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
181+
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
145182
gopkg.in/yaml.v3 v3.0.1 // indirect
146183
rsc.io/tmplfunc v0.0.3 // indirect
147184
)

0 commit comments

Comments
 (0)