Skip to content

Commit 699de75

Browse files
[wip] feat: implement
1 parent 93c8c2a commit 699de75

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

pkg/timelock/scheduler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ type TimelockCallScheduled interface {
2626
Index() int
2727
BlockNumber() *big.Int
2828
TxHash() string
29+
Predecessor() eth.Hash
30+
Salt() eth.Hash
2931
}
3032

3133
type Scheduler interface {

pkg/timelock/scheduler_evm.go

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

7+
eth "github.com/ethereum/go-ethereum/common"
78
bindings "github.com/smartcontractkit/ccip-owner-contracts/gethwrappers"
89
)
910

@@ -34,3 +35,11 @@ func (cs *evmTimelockCallScheduled) BlockNumber() *big.Int {
3435
func (cs *evmTimelockCallScheduled) TxHash() string {
3536
return fmt.Sprintf("%x", cs.callScheduled.Raw.TxHash[:])
3637
}
38+
39+
func (cs *evmTimelockCallScheduled) Predecessor() eth.Hash {
40+
return cs.callScheduled.Predecessor
41+
}
42+
43+
func (cs *evmTimelockCallScheduled) Salt() eth.Hash {
44+
return cs.callScheduled.Salt
45+
}

pkg/timelock/scheduler_solana.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package timelock
22

33
import (
44
"math/big"
5+
6+
eth "github.com/ethereum/go-ethereum/common"
57
)
68

79
var _ TimelockCallScheduled = NewEVMTimelockCallScheduled(nil)
@@ -31,3 +33,11 @@ func (cs *solanaTimelockCallScheduled) BlockNumber() *big.Int {
3133
func (cs *solanaTimelockCallScheduled) TxHash() string {
3234
return cs.callScheduledEvent.TxHash
3335
}
36+
37+
func (cs *solanaTimelockCallScheduled) Predecessor() eth.Hash {
38+
return cs.callScheduledEvent.Predecessor
39+
}
40+
41+
func (cs *solanaTimelockCallScheduled) Salt() eth.Hash {
42+
return cs.callScheduledEvent.Salt
43+
}

pkg/timelock/solana_event_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"math/big"
99
"strings"
1010

11+
eth "github.com/ethereum/go-ethereum/common"
1112
bin "github.com/gagliardetto/binary"
1213
"github.com/gagliardetto/solana-go"
1314
"github.com/gagliardetto/solana-go/rpc"
@@ -34,8 +35,8 @@ type SolanaTimelockCallScheduledEvent struct {
3435
ID operationKey
3536
Index uint64
3637
Target solana.PublicKey
37-
Predecessor operationKey
38-
Salt [32]byte
38+
Predecessor eth.Hash
39+
Salt eth.Hash
3940
Delay uint64
4041
Data []byte
4142
BlockNumber *big.Int `borsh_skip:"true"`

pkg/timelock/worker_solana.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ import (
1212

1313
"github.com/gagliardetto/solana-go"
1414
"github.com/gagliardetto/solana-go/rpc"
15-
1615
"go.uber.org/zap"
16+
17+
mcmssolanasdk "github.com/smartcontractkit/mcms/sdk/solana"
1718
)
1819

1920
// WorkerSolana represents a solana worker instance. It fetches periodically the latest signatures
2021
// and transactions from the Solana RPC node and dispatches them to the scheduler.
2122
type WorkerSolana struct {
2223
solanaClient *rpc.Client
24+
timelockAddress string
2325
timelockProgramKey solana.PublicKey
2426
pollPeriod int64
2527
listenerPollPeriod int64
@@ -28,6 +30,7 @@ type WorkerSolana struct {
2830
logger *zap.SugaredLogger
2931
privateKey solana.PrivateKey
3032
lastSignature *solana.Signature // last signature processed
33+
inspector *mcmssolanasdk.TimelockInspector
3134
scheduler Scheduler
3235
}
3336

@@ -80,12 +83,13 @@ func NewTimelockWorkerSolana(
8083
dryRun: dryRun,
8184
logger: logger,
8285
privateKey: privateKeySolana,
86+
inspector: mcmssolanasdk.NewTimelockInspector(client),
8387
}
8488

8589
if dryRun {
86-
tWorker.scheduler = nil // TODO: add solana nopScheduler implementation
90+
tWorker.scheduler = newNopScheduler(logger)
8791
} else {
88-
tWorker.scheduler = nil // TODO: add solana Scheduler implementation
92+
tWorker.scheduler = newScheduler(time.Duration(pollPeriod)*time.Second, logger, tWorker.execute)
8993
}
9094

9195
return tWorker, nil

0 commit comments

Comments
 (0)