common

package
v0.0.0-...-e8e2c10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 34 Imported by: 7

Documentation

Index

Constants

View Source
const (
	ReadinessEthSyncing        readiness.Component = "ethSyncing"
	ReadinessSolanaSyncing     readiness.Component = "solanaSyncing"
	ReadinessTerraSyncing      readiness.Component = "terraSyncing"
	ReadinessAlgorandSyncing   readiness.Component = "algorandSyncing"
	ReadinessBSCSyncing        readiness.Component = "bscSyncing"
	ReadinessPolygonSyncing    readiness.Component = "polygonSyncing"
	ReadinessEthRopstenSyncing readiness.Component = "ethRopstenSyncing"
	ReadinessAvalancheSyncing  readiness.Component = "avalancheSyncing"
	ReadinessOasisSyncing      readiness.Component = "oasisSyncing"
	ReadinessAuroraSyncing     readiness.Component = "auroraSyncing"
	ReadinessFantomSyncing     readiness.Component = "fantomSyncing"
	ReadinessKaruraSyncing     readiness.Component = "karuraSyncing"
	ReadinessAcalaSyncing      readiness.Component = "acalaSyncing"
	ReadinessAlephiumSyncing   readiness.Component = "alephiumSyncing"
	ReadinessKlaytnSyncing     readiness.Component = "klaytnSyncing"
	ReadinessCeloSyncing       readiness.Component = "celoSyncing"
	ReadinessMoonbeamSyncing   readiness.Component = "moonbeamSyncing"
	ReadinessNeonSyncing       readiness.Component = "neonSyncing"
)
View Source
const MaxGuardianCount = 19

MaxGuardianCount specifies the maximum number of guardians supported by on-chain contracts.

Matching constants:

  • MAX_LEN_GUARDIAN_KEYS in Solana contract (limited by transaction size - 19 is the maximum amount possible)

The Eth and Terra contracts do not specify a maximum number and support more than that, but presumably, chain-specific transaction size limits will apply at some point (untested).

View Source
const MaxNodesPerGuardian = 15

MaxNodesPerGuardian specifies the maximum amount of nodes per guardian key that we'll accept whenever we maintain any per-guardian, per-node state.

There currently isn't any state clean up, so the value is on the high side to prevent accidentally reaching the limit due to operational mistakes.

View Source
const MaxStateAge = 1 * time.Minute

MaxStateAge specified the maximum age of state entries in seconds. Expired entries are purged from the state by Cleanup().

View Source
const ObsvReqChannelSize = 50

Variables

View Source
var ErrChanFull = errors.New("channel is full")

Functions

func DecryptAESGCM

func DecryptAESGCM(data, key []byte) ([]byte, error)

func EncryptAESGCM

func EncryptAESGCM(plaintext, key []byte) ([]byte, error)

func GetOrCreateNodeKey

func GetOrCreateNodeKey(logger *zap.Logger, path string) (crypto.PrivKey, error)

func LockMemory

func LockMemory()

LockMemory locks current and future pages in memory to protect secret keys from being swapped out to disk. It's possible (and strongly recommended) to deploy Wormhole such that keys are only ever stored in memory and never touch the disk. This is a privileged operation and requires CAP_IPC_LOCK.

func NewInstrumentedGRPCServer

func NewInstrumentedGRPCServer(logger *zap.Logger) *grpc.Server

func PostObservationRequest

func PostObservationRequest(obsvReqSendC chan<- *gossipv1.ObservationRequest, req *gossipv1.ObservationRequest) error

func SetRestrictiveUmask

func SetRestrictiveUmask()

SetRestrictiveUmask masks the group and world bits. This ensures that key material and sockets we create aren't accidentally group- or world-readable.

Types

type BridgeConfig

type BridgeConfig struct {
	Network          NetworkId
	Alephium         *ChainConfig
	Ethereum         *ChainConfig
	Bsc              *ChainConfig
	Guardian         *GuardianConfig
	EmitterAddresses []EmitterAddress
}

func ReadConfigsByNetwork

func ReadConfigsByNetwork(network string) (*BridgeConfig, error)

type ChainConfig

type ChainConfig struct {
	GroupIndex uint8     `json:"groupIndex,omitempty"`
	NodeUrl    string    `json:"nodeUrl"`
	Contracts  Contracts `json:"contracts"`

	TokenBridgeEmitterAddress string `json:"tokenBridgeEmitterAddress"`
	CoreEmitterAddress        string `json:"coreEmitterAddress"`
}

func ReadAlephiumConfig

func ReadAlephiumConfig(network string) (*ChainConfig, error)

func ReadBscConfig

func ReadBscConfig(network string) (*ChainConfig, error)

func ReadEthereumConfig

func ReadEthereumConfig(network string) (*ChainConfig, error)

type Contracts

type Contracts struct {
	Governance  string `json:"governance"`
	TokenBridge string `json:"tokenBridge"`
}

type EmitterAddress

type EmitterAddress struct {
	ChainID vaa.ChainID
	Emitter string
}

type Ethish

type Ethish interface {
	SetLogger(l *zap.Logger)
	DialContext(ctx context.Context, rawurl string) error
	NewAbiFilterer(address ethCommon.Address) error
	NewAbiCaller(address ethCommon.Address) error
	GetCurrentGuardianSetIndex(ctx context.Context) (uint32, error)
	GetGuardianSet(ctx context.Context, index uint32) (ethAbi.StructsGuardianSet, error)
	WatchLogMessagePublished(ctx, timeout context.Context, sink chan<- *ethAbi.AbiLogMessagePublished) (ethEvent.Subscription, error)
	TransactionReceipt(ctx context.Context, txHash ethCommon.Hash) (*ethTypes.Receipt, error)
	TimeOfBlockByHash(ctx context.Context, hash ethCommon.Hash) (uint64, error)
	ParseLogMessagePublished(log ethTypes.Log) (*ethAbi.AbiLogMessagePublished, error)
	SubscribeForBlocks(ctx context.Context, sink chan<- *NewBlock) (ethereum.Subscription, error)
}

type GuardianConfig

type GuardianConfig struct {
	GovernanceChainId        uint16   `json:"governanceChainId"`
	GovernanceEmitterAddress string   `json:"governanceEmitterAddress"`
	GuardianUrls             []string `json:"guardianUrls"`
}

func ReadGuardianConfig

func ReadGuardianConfig(network string) (*GuardianConfig, error)

type GuardianSet

type GuardianSet struct {
	// Guardian's public key hashes truncated by the ETH standard hashing mechanism (20 bytes).
	Keys []common.Address
	// On-chain set index
	Index uint32
}

func (*GuardianSet) KeyIndex

func (g *GuardianSet) KeyIndex(addr common.Address) (int, bool)

KeyIndex returns a given address index from the guardian set. Returns (-1, false) if the address wasn't found and (addr, true) otherwise.

func (*GuardianSet) KeysAsHexStrings

func (g *GuardianSet) KeysAsHexStrings() []string

type GuardianSetState

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

func NewGuardianSetState

func NewGuardianSetState(updateC chan *gossipv1.Heartbeat) *GuardianSetState

func (*GuardianSetState) Cleanup

func (st *GuardianSetState) Cleanup()

Cleanup removes expired entries from the state.

func (*GuardianSetState) Get

func (st *GuardianSetState) Get() *GuardianSet

func (*GuardianSetState) GetAll

func (st *GuardianSetState) GetAll() map[common.Address]map[peer.ID]*gossipv1.Heartbeat

GetAll returns all stored heartbeats.

func (*GuardianSetState) LastHeartbeat

func (st *GuardianSetState) LastHeartbeat(addr common.Address) map[peer.ID]*gossipv1.Heartbeat

LastHeartbeat returns the most recent heartbeat message received for a given guardian node, or nil if none have been received.

func (*GuardianSetState) Set

func (st *GuardianSetState) Set(set *GuardianSet)

func (*GuardianSetState) SetHeartbeat

func (st *GuardianSetState) SetHeartbeat(addr common.Address, peerId peer.ID, hb *gossipv1.Heartbeat) error

SetHeartbeat stores a verified heartbeat observed by a given guardian.

type MessagePublication

type MessagePublication struct {
	TxHash    common.Hash // TODO: rename to identifier? on Solana, this isn't actually the tx hash
	Timestamp time.Time

	Nonce            uint32
	Sequence         uint64
	ConsistencyLevel uint8
	EmitterChain     vaa.ChainID
	TargetChain      vaa.ChainID
	EmitterAddress   vaa.Address
	Payload          []byte
}

type NetworkId

type NetworkId = uint8
const DEVNET NetworkId = 2
const MAINNET NetworkId = 0
const TESTNET NetworkId = 1
const UNKNOWN_NETWORK NetworkId = 3

type NewBlock

type NewBlock struct {
	Number *big.Int
	Hash   ethCommon.Hash
}

Jump to

Keyboard shortcuts

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