timelock

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SolanaTimelockCallScheduledDiscriminator = solanaEventDiscriminator("CallScheduled")
	SolanaTimelockCallExecutedDiscriminator  = solanaEventDiscriminator("CallExecuted")
	SolanaTimelockCancelledDiscriminator     = solanaEventDiscriminator("Cancelled")
)

Discriminators for each event type.

View Source
var ErrMaxGasLimit = errors.New("transaction gas exceeds max gas limit")

Functions

func Retry added in v0.0.11

func Retry[T any](ctx context.Context, callback retryCallback[T]) (T, error)

func SetLiveStatus added in v0.0.3

func SetLiveStatus(status HealthStatus)

func SetReadyStatus added in v0.0.3

func SetReadyStatus(status HealthStatus)

func StartHTTPHealthServer added in v0.0.3

func StartHTTPHealthServer(log *zap.SugaredLogger)

Starts a http server, serving the healthz endpoint.

func StartMetricsServer added in v0.0.3

func StartMetricsServer(log *zap.SugaredLogger)

Types

type HealthStatus added in v0.0.3

type HealthStatus int

HealthStatus represents the health status enum.

const (
	HealthStatusOK HealthStatus = iota
	HealthStatusError
)

func GetLiveStatus added in v0.0.3

func GetLiveStatus() HealthStatus

func GetReadyStatus added in v0.0.3

func GetReadyStatus() HealthStatus

type MockScheduler added in v0.1.0

type MockScheduler struct {
	mock.Mock
}

MockScheduler is an autogenerated mock type for the Scheduler type

func NewMockScheduler added in v0.1.0

func NewMockScheduler(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockScheduler

NewMockScheduler creates a new instance of MockScheduler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockScheduler) EXPECT added in v0.1.0

func (_m *MockScheduler) EXPECT() *MockScheduler_Expecter

type MockScheduler_Expecter added in v0.1.0

type MockScheduler_Expecter struct {
	// contains filtered or unexported fields
}

type MockScheduler_addToScheduler_Call added in v0.1.0

type MockScheduler_addToScheduler_Call struct {
	*mock.Call
}

MockScheduler_addToScheduler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'addToScheduler'

func (*MockScheduler_addToScheduler_Call) Return added in v0.1.0

func (*MockScheduler_addToScheduler_Call) Run added in v0.1.0

func (*MockScheduler_addToScheduler_Call) RunAndReturn added in v0.1.0

type MockScheduler_delFromScheduler_Call added in v0.1.0

type MockScheduler_delFromScheduler_Call struct {
	*mock.Call
}

MockScheduler_delFromScheduler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'delFromScheduler'

func (*MockScheduler_delFromScheduler_Call) Return added in v0.1.0

func (*MockScheduler_delFromScheduler_Call) Run added in v0.1.0

func (*MockScheduler_delFromScheduler_Call) RunAndReturn added in v0.1.0

func (_c *MockScheduler_delFromScheduler_Call) RunAndReturn(run func(op operationKey)) *MockScheduler_delFromScheduler_Call

type MockScheduler_dumpOperationStore_Call added in v0.1.0

type MockScheduler_dumpOperationStore_Call struct {
	*mock.Call
}

MockScheduler_dumpOperationStore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'dumpOperationStore'

func (*MockScheduler_dumpOperationStore_Call) Return added in v0.1.0

func (*MockScheduler_dumpOperationStore_Call) Run added in v0.1.0

func (*MockScheduler_dumpOperationStore_Call) RunAndReturn added in v0.1.0

type MockScheduler_runScheduler_Call added in v0.1.0

type MockScheduler_runScheduler_Call struct {
	*mock.Call
}

MockScheduler_runScheduler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'runScheduler'

func (*MockScheduler_runScheduler_Call) Return added in v0.1.0

func (_c *MockScheduler_runScheduler_Call) Return(valCh <-chan struct{}) *MockScheduler_runScheduler_Call

func (*MockScheduler_runScheduler_Call) Run added in v0.1.0

func (*MockScheduler_runScheduler_Call) RunAndReturn added in v0.1.0

func (_c *MockScheduler_runScheduler_Call) RunAndReturn(run func(ctx context.Context) <-chan struct{}) *MockScheduler_runScheduler_Call

type Scheduler added in v0.0.7

type Scheduler interface {
	// contains filtered or unexported methods
}

type SolanaTimelockCallCancelledEvent added in v0.1.0

type SolanaTimelockCallCancelledEvent struct {
	ID operationKey
}

SolanaTimelockCallCancelledEvent corresponds to #[event] Cancelled { id }.

type SolanaTimelockCallExecutedEvent added in v0.1.0

type SolanaTimelockCallExecutedEvent struct {
	ID     operationKey
	Index  uint64
	Target solana.PublicKey
	Data   []byte
}

SolanaTimelockCallExecutedEvent corresponds to #[event] CallExecuted { id, index, target, data }.

type SolanaTimelockCallScheduledEvent added in v0.1.0

type SolanaTimelockCallScheduledEvent struct {
	ID          operationKey
	Index       uint64
	Target      solana.PublicKey
	Predecessor eth.Hash
	Salt        eth.Hash
	Delay       uint64
	Data        []byte
	BlockNumber *big.Int `borsh_skip:"true"`
	TxHash      string   `borsh_skip:"true"`
}

SolanaTimelockCallScheduledEvent corresponds to #[event] CallScheduled { id, index, target, predecessor, salt, delay, data }.

type SolanaTimelockEvents added in v0.1.0

type SolanaTimelockEvents struct {
	Scheduled []SolanaTimelockCallScheduledEvent
	Executed  []SolanaTimelockCallExecutedEvent
	Cancelled []SolanaTimelockCallCancelledEvent
}

TxTimelockEvents groups all decoded events from one transaction.

func ParseTimelockEvents added in v0.1.0

func ParseTimelockEvents(tx *rpc.TransactionWithMeta) (*SolanaTimelockEvents, error)

ParseTimelockEvents extracts and decodes Anchor events from tx.Meta.LogMessages.

type TimelockCallScheduled added in v0.1.0

type TimelockCallScheduled interface {
	Id() operationKey
	Index() int
	BlockNumber() *big.Int
	TxHash() string
	Predecessor() eth.Hash
	Salt() eth.Hash
	String() string
}

func NewEVMTimelockCallScheduled added in v0.1.0

func NewEVMTimelockCallScheduled(callScheduled *bindings.RBACTimelockCallScheduled) TimelockCallScheduled

func NewSolanaTimelockCallScheduled added in v0.1.0

func NewSolanaTimelockCallScheduled(callScheduledEvent SolanaTimelockCallScheduledEvent) TimelockCallScheduled

type Worker

type Worker interface {
	Listen(ctx context.Context) error
}

type WorkerEVM added in v0.1.0

type WorkerEVM struct {
	// contains filtered or unexported fields
}

WorkerEVM represents an EVM worker instance. addresses is an array of addresses as expected by ethereum.FilterQuery, but it's enforced only to one addresses in the logic.

func NewTimelockWorkerEVM added in v0.1.0

func NewTimelockWorkerEVM(
	nodeURL, timelockAddress, callProxyAddress, privateKey string, fromBlock *big.Int,
	maxGasLimit uint64, pollPeriod int64, listenerPollPeriod int64, pollSize uint64, dryRun bool,
	logger *zap.SugaredLogger,
) (*WorkerEVM, error)

NewTimelockWorkerEVM initializes and returns a timelockWorker. It's a singleton, so further executions will retrieve the same timelockWorker.

func (*WorkerEVM) Listen added in v0.1.0

func (tw *WorkerEVM) Listen(ctx context.Context) error

Listen is the main function of a Timelock WorkerEVM. It handles the retrieval of old and new events, contexts and cancellations.

type WorkerSolana added in v0.1.0

type WorkerSolana struct {
	// contains filtered or unexported fields
}

WorkerSolana represents a solana worker instance. It fetches periodically the latest signatures and transactions from the Solana RPC node and dispatches them to the scheduler.

func NewTimelockWorkerSolana added in v0.1.0

func NewTimelockWorkerSolana(
	nodeURL,
	timelockAddress,
	privateKey string,
	pollPeriod int64,
	listenerPollPeriod int64,
	pollSize int,
	dryRun bool,
	commitmentType rpc.CommitmentType,
	logger *zap.SugaredLogger,
) (*WorkerSolana, error)

NewTimelockWorkerSolana initializes and returns a timelockWorker.

func (*WorkerSolana) Listen added in v0.1.0

func (w *WorkerSolana) Listen(ctx context.Context) error

Listen is the main function of a Timelock WorkerSolana. It handles the retrieval of old and new events, contexts and cancellations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL