Skip to content

Commit 2a02346

Browse files
committed
fix: start cmd validation on node URL for solana and improvements to log messages
1 parent 5cb1e06 commit 2a02346

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

cmd/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func startTimelock(cmd *cobra.Command) {
106106
}
107107
} else if chainFamily == chain_selectors.FamilyEVM {
108108
if !common.IsHexAddress(timelockAddress) {
109-
slog.Fatalf("value of private-key is invalid for evm: %s", err.Error())
109+
slog.Fatalf("value of private-key is invalid for evm")
110110
}
111111
}
112112

pkg/timelock/worker_evm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type WorkerEVM struct {
4545

4646
var httpSchemes = []string{"http", "https"}
4747

48-
var validNodeUrlSchemes = []string{"http", "https", "ws", "wss"}
48+
var validNodeUrlSchemesEVM = []string{"http", "https", "ws", "wss"}
4949

5050
// NewTimelockWorkerEVM initializes and returns a timelockWorker.
5151
// It's a singleton, so further executions will retrieve the same timelockWorker.
@@ -59,8 +59,8 @@ func NewTimelockWorkerEVM(
5959
return nil, err
6060
}
6161

62-
if !slices.Contains(validNodeUrlSchemes, u.Scheme) {
63-
return nil, fmt.Errorf("invalid node URL: %s (accepted schemes are: %v)", nodeURL, validNodeUrlSchemes)
62+
if !slices.Contains(validNodeUrlSchemesEVM, u.Scheme) {
63+
return nil, fmt.Errorf("invalid node URL: %s (accepted schemes are: %v)", nodeURL, validNodeUrlSchemesEVM)
6464
}
6565

6666
if !common.IsHexAddress(timelockAddress) {

pkg/timelock/worker_solana.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"github.com/smartcontractkit/timelock-worker/pkg/isclosed"
2121
)
2222

23+
var validNodeUrlSchemesSolana = []string{"http", "https"}
24+
2325
// WorkerSolana represents a solana worker instance. It fetches periodically the latest signatures
2426
// and transactions from the Solana RPC node and dispatches them to the scheduler.
2527
type WorkerSolana struct {
@@ -58,8 +60,8 @@ func NewTimelockWorkerSolana(
5860
return nil, err
5961
}
6062

61-
if !slices.Contains(validNodeUrlSchemes, u.Scheme) {
62-
return nil, fmt.Errorf("invalid node URL: %s (accepted schemes are: %v)", nodeURL, validNodeUrlSchemes)
63+
if !slices.Contains(validNodeUrlSchemesSolana, u.Scheme) {
64+
return nil, fmt.Errorf("invalid node URL: %s (accepted schemes are: %v)", nodeURL, validNodeUrlSchemesEVM)
6365
}
6466

6567
timelockPubKey, instanceSeed, err := mcmssolanasdk.ParseContractAddress(timelockAddress)
@@ -178,6 +180,7 @@ func (w *WorkerSolana) pollSignatures(ctx context.Context, sigCh chan<- solana.S
178180
w.logger.Info("pollSignatures context cancelled")
179181
return
180182
case <-ticker.C:
183+
w.logger.Infow("polling signatures timelock solana", "timelockProgramKey", w.timelockProgramKey, "lastSignature", w.lastSignature)
181184
var until solana.Signature
182185
if w.lastSignature != nil {
183186
until = *w.lastSignature
@@ -197,9 +200,10 @@ func (w *WorkerSolana) pollSignatures(ctx context.Context, sigCh chan<- solana.S
197200
continue
198201
}
199202
if len(sigs) == 0 {
203+
w.logger.Info("no new signatures found, poll again in the next cycle")
200204
continue
201205
}
202-
206+
w.logger.Infow("found new signatures", "numSignatures", len(sigs))
203207
slices.Reverse(sigs)
204208
for _, info := range sigs {
205209
select {
@@ -363,7 +367,7 @@ func (w *WorkerSolana) handleTx(ctx context.Context, tx *rpc.TransactionWithMeta
363367
// handleEventCancelled checks if the operation is cancelled and deletes it from the scheduler if it is.
364368
func (w *WorkerSolana) handleEventCancelled(_ context.Context, event SolanaTimelockCallCancelledEvent) {
365369
w.logger.With(operationID, fmt.Sprintf("%x", event.ID)).
366-
Infow("event received, cancelling operation", "event type", eventCancelled)
370+
Infow("event Cancelled received, cancelling operation", "event type", eventCancelled)
367371

368372
w.scheduler.delFromScheduler(event.ID)
369373
}
@@ -379,7 +383,7 @@ func (w *WorkerSolana) handleEventExecuted(ctx context.Context, event SolanaTime
379383
return fmt.Errorf("timelock.isOperationDone call failed (operation id: %x): %w", event.ID, err)
380384
}
381385
if isDone {
382-
logger.Infow("event received, deleting operation from scheduler", "event type ", eventCallExecuted)
386+
logger.Infow("event CallExecuted received, deleting operation from scheduler", "event type ", eventCallExecuted)
383387

384388
w.scheduler.delFromScheduler(event.ID)
385389
} else {

tests/integration/solana/worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (s *solanaIntegrationTestSuite) TestTimelockWorkerListen() {
7373

7474
s.EventuallyWithT(func(collect *assert.CollectT) {
7575
assert.GreaterOrEqual(collect, logs.FilterMessageSnippet("found event cancelled").Len(), 1)
76-
assert.GreaterOrEqual(collect, logs.FilterMessageSnippet("event received, cancelling operation").Len(), 1)
76+
assert.GreaterOrEqual(collect, logs.FilterMessageSnippet("event Cancelled received, cancelling operation").Len(), 1)
7777
assert.GreaterOrEqual(collect, logs.FilterMessageSnippet("nop.delFromScheduler").Len(), 1)
7878
}, 10*time.Second, 200*time.Millisecond, logMessages(logs))
7979
}

0 commit comments

Comments
 (0)