deployment

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 24 Imported by: 186

Documentation

Index

Constants

View Source
const (
	// Default retry configuration for RPC calls
	RPCDefaultRetryAttempts = 10
	RPCDefaultRetryDelay    = 1000 * time.Millisecond

	// Default retry configuration for dialing RPC endpoints
	RPCDefaultDialRetryAttempts = 10
	RPCDefaultDialRetryDelay    = 1000 * time.Millisecond
)

Variables

View Source
var (
	ErrInvalidChainSelector = errors.New("invalid chain selector")
	ErrInvalidAddress       = errors.New("invalid address")
	ErrChainNotFound        = errors.New("chain not found")
)

Functions

func AddressBookContains

func AddressBookContains(ab AddressBook, chain uint64, addrToFind string) (bool, error)

func EnsureDeduped

func EnsureDeduped(addrs map[string]TypeAndVersion, bundle []TypeAndVersion) (bool, error)

EnsureDeduped ensures that each contract in the bundle only appears once in the address map. It returns an error if there are more than one instance of a contract. Returns true if every value in the bundle is found once, false otherwise.

func MaybeDataErr

func MaybeDataErr(err error) error

func SearchAddressBook

func SearchAddressBook(ab AddressBook, chain uint64, typ ContractType) (string, error)

SearchAddressBook search an address book for a given chain and contract type and return the first matching address.

Types

type AddressBook

type AddressBook interface {
	Save(chainSelector uint64, address string, tv TypeAndVersion) error
	Addresses() (map[uint64]map[string]TypeAndVersion, error)
	AddressesForChain(chain uint64) (map[string]TypeAndVersion, error)
	// Allows for merging address books (e.g. new deployments with existing ones)
	Merge(other AddressBook) error
	Remove(ab AddressBook) error
}

AddressBook is a simple interface for storing and retrieving contract addresses across chains. It is family agnostic as the keys are chain selectors. We store rather than derive typeAndVersion as some contracts do not support it. For ethereum addresses are always stored in EIP55 format.

type AddressBookMap

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

func NewMemoryAddressBook

func NewMemoryAddressBook() *AddressBookMap

TODO: Maybe could add an environment argument which would ensure only mainnet/testnet chain selectors are used for further safety?

func NewMemoryAddressBookFromMap

func NewMemoryAddressBookFromMap(addressesByChain map[uint64]map[string]TypeAndVersion) *AddressBookMap

func (*AddressBookMap) Addresses

func (m *AddressBookMap) Addresses() (map[uint64]map[string]TypeAndVersion, error)

func (*AddressBookMap) AddressesForChain

func (m *AddressBookMap) AddressesForChain(chainSelector uint64) (map[string]TypeAndVersion, error)

func (*AddressBookMap) Merge

func (m *AddressBookMap) Merge(ab AddressBook) error

Merge will merge the addresses from another address book into this one. It will error on any existing addresses.

func (*AddressBookMap) Remove

func (m *AddressBookMap) Remove(ab AddressBook) error

Remove removes the address book addresses specified via the argument from the AddressBookMap. Errors if all the addresses in the given address book are not contained in the AddressBookMap.

func (*AddressBookMap) Save

func (m *AddressBookMap) Save(chainSelector uint64, address string, typeAndVersion TypeAndVersion) error

Save will save an address for a given chain selector. It will error if there is a conflicting existing address. thread safety version of the save method

type AddressesByChain

type AddressesByChain map[uint64]map[string]TypeAndVersion

type ContractType

type ContractType string

ContractType is a simple string type for identifying contract types.

func (ContractType) String

func (ct ContractType) String() string

type LabelSet

type LabelSet map[string]struct{}

LabelSet represents a set of labels on an address book entry.

func NewLabelSet

func NewLabelSet(labels ...string) LabelSet

NewLabelSet initializes a new LabelSet with any number of labels.

func (LabelSet) Add

func (ls LabelSet) Add(labels string)

Add inserts a labels into the set.

func (LabelSet) Contains

func (ls LabelSet) Contains(labels string) bool

Contains checks if the set contains the given labels.

func (LabelSet) Equal

func (ls LabelSet) Equal(other LabelSet) bool

Equal checks if two LabelSets are equal.

func (LabelSet) IsEmpty

func (ls LabelSet) IsEmpty() bool

func (LabelSet) List

func (ls LabelSet) List() []string

List returns the labels as a sorted slice of strings.

func (LabelSet) Remove

func (ls LabelSet) Remove(labels string)

Remove deletes a labels from the set, if it exists.

func (LabelSet) String

func (ls LabelSet) String() string

String returns the labels as a sorted, space-separated string. It implements the fmt.Stringer interface.

type MultiClient

type MultiClient struct {
	*ethclient.Client
	Backups     []*ethclient.Client
	RetryConfig RetryConfig
	// contains filtered or unexported fields
}

func NewMultiClient

func NewMultiClient(lggr logger.Logger, rpcsCfg RPCConfig, opts ...func(client *MultiClient)) (*MultiClient, error)

func (*MultiClient) CallContract

func (mc *MultiClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

func (*MultiClient) CallContractAtHash

func (mc *MultiClient) CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error)

func (*MultiClient) CodeAt

func (mc *MultiClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)

func (*MultiClient) CodeAtHash

func (mc *MultiClient) CodeAtHash(ctx context.Context, account common.Address, blockHash common.Hash) ([]byte, error)

func (*MultiClient) NonceAt

func (mc *MultiClient) NonceAt(ctx context.Context, account common.Address, block *big.Int) (uint64, error)

func (*MultiClient) NonceAtHash

func (mc *MultiClient) NonceAtHash(ctx context.Context, account common.Address, blockHash common.Hash) (uint64, error)

func (*MultiClient) SendTransaction

func (mc *MultiClient) SendTransaction(ctx context.Context, tx *types.Transaction) error

func (*MultiClient) WaitMined

func (mc *MultiClient) WaitMined(ctx context.Context, tx *types.Transaction) (*types.Receipt, error)

type OCRSecrets added in v0.0.5

type OCRSecrets struct {
	SharedSecret [16]byte
	EphemeralSk  [32]byte
}

OCRSecrets are used to disseminate a shared secret to OCR nodes through the blockchain where OCR configuration is stored. Its a low value secret used to derive transmission order etc. They are extracted here such that they can common across signers when multiple signers are signing the same OCR config.

func XXXGenerateTestOCRSecrets added in v0.0.5

func XXXGenerateTestOCRSecrets() OCRSecrets

func (OCRSecrets) IsEmpty added in v0.0.5

func (s OCRSecrets) IsEmpty() bool

type OffchainClient added in v0.0.5

OffchainClient interacts with the job-distributor which is a family agnostic interface for performing DON operations.

type OnchainClient

type OnchainClient interface {
	bind.ContractBackend
	bind.DeployBackend
	BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
	NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
}

OnchainClient is an EVM chain client. For EVM specifically we can use existing geth interface to abstract chain clients.

type RPC

type RPC struct {
	Name               string
	WSURL              string
	HTTPURL            string
	PreferredURLScheme URLSchemePreference
}

func (RPC) ToEndpoint

func (r RPC) ToEndpoint() (string, error)

ToEndpoint returns the correct endpoint based on the preferred URL scheme If the preferred URL scheme is not set, it will return the WS URL If the preferred URL scheme is set to WS, it will return the WS URL If the preferred URL scheme is set to HTTP, it will return the HTTP URL

type RPCConfig

type RPCConfig struct {
	ChainSelector uint64
	RPCs          []RPC
}

RPCConfig is a configuration for a chain. It contains a chain selector and a list of RPCs

type RetryConfig

type RetryConfig struct {
	Attempts uint
	Delay    time.Duration
}

type TypeAndVersion

type TypeAndVersion struct {
	Type    ContractType   `json:"Type"`
	Version semver.Version `json:"Version"`
	Labels  LabelSet       `json:"Labels,omitempty"`
}

func MustTypeAndVersionFromString

func MustTypeAndVersionFromString(s string) TypeAndVersion

func NewTypeAndVersion

func NewTypeAndVersion(t ContractType, v semver.Version) TypeAndVersion

func TypeAndVersionFromString

func TypeAndVersionFromString(s string) (TypeAndVersion, error)

Note this will become useful for validation. When we want to assert an onchain call to typeAndVersion yields whats expected.

func (*TypeAndVersion) AddLabel

func (tv *TypeAndVersion) AddLabel(label string)

AddLabel adds a string to the LabelSet in the TypeAndVersion.

func (TypeAndVersion) Equal

func (tv TypeAndVersion) Equal(other TypeAndVersion) bool

func (TypeAndVersion) String

func (tv TypeAndVersion) String() string

type URLSchemePreference

type URLSchemePreference int
const (
	URLSchemePreferenceNone URLSchemePreference = iota
	URLSchemePreferenceWS
	URLSchemePreferenceHTTP
)

func URLSchemePreferenceFromString

func URLSchemePreferenceFromString(s string) (URLSchemePreference, error)

func (*URLSchemePreference) UnmarshalText

func (u *URLSchemePreference) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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