beefy

package
v0.0.0-...-7cdd60a Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: LGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hex

func Hex(b []byte) string

func ScanBlocks

func ScanBlocks(ctx context.Context, meta *types.Metadata, api *gsrpc.SubstrateAPI, startBlock uint64) (chan ScanBlocksResult, error)

func ScanCommitments

func ScanCommitments(ctx context.Context, meta *types.Metadata, api *gsrpc.SubstrateAPI, startBlock uint64) (<-chan ScanCommitmentsResult, error)

Types

type BeefyAuthoritySet

type BeefyAuthoritySet struct {
	// ID
	ID types.U64
	// Number of validators in the set.
	Len types.U32
	// Merkle Root Hash build from BEEFY uncompressed AuthorityIds.
	Root types.H256
}

type BeefyClientState

type BeefyClientState struct {
	LatestBeefyBlock        uint64
	CurrentValidatorSetID   uint64
	CurrentValidatorSetRoot [32]byte
	NextValidatorSetID      uint64
	NextValidatorSetRoot    [32]byte
}

type Config

type Config struct {
	Source       SourceConfig       `mapstructure:"source"`
	Sink         SinkConfig         `mapstructure:"sink"`
	OnDemandSync OnDemandSyncConfig `mapstructure:"on-demand-sync"`
}

func (Config) Validate

func (c Config) Validate() error

type ContractsConfig

type ContractsConfig struct {
	BeefyClient string `mapstructure:"BeefyClient"`
	Gateway     string `mapstructure:"Gateway"`
}

type EthereumWriter

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

func NewEthereumWriter

func NewEthereumWriter(
	config *SinkConfig,
	conn *ethereum.Connection,
) *EthereumWriter

func (*EthereumWriter) Start

func (wr *EthereumWriter) Start(ctx context.Context, eg *errgroup.Group, requests <-chan Request) error

type FinalRequestParams

type FinalRequestParams struct {
	Commitment     contracts.BeefyClientCommitment
	Bitfield       []*big.Int
	Proofs         []contracts.BeefyClientValidatorProof
	Leaf           contracts.BeefyClientMMRLeaf
	LeafProof      [][32]byte
	LeafProofOrder *big.Int
}

type InitialRequestParams

type InitialRequestParams struct {
	Commitment contracts.BeefyClientCommitment
	Bitfield   []*big.Int
	Proof      contracts.BeefyClientValidatorProof
}

type OnDemandRelay

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

func NewOnDemandRelay

func NewOnDemandRelay(config *Config, ethereumKeypair *secp256k1.Keypair) (*OnDemandRelay, error)

func (*OnDemandRelay) Start

func (relay *OnDemandRelay) Start(ctx context.Context) error

type OnDemandSyncConfig

type OnDemandSyncConfig struct {
	// ID of the AssetHub channel
	AssetHubChannelID string `mapstructure:"asset-hub-channel-id"`
	// Maximum number of tokens available to consume
	MaxTokens uint64 `mapstructure:"max-tokens"`
	// Number of tokens added each `RefillPeriod`
	RefillAmount uint64 `mapstructure:"refill-amount"`
	// Period between token refills
	RefillPeriod uint64 `mapstructure:"refill-period"`
}

type PolkadotListener

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

func NewPolkadotListener

func NewPolkadotListener(
	config *SourceConfig,
	conn *relaychain.Connection,
) *PolkadotListener

func (*PolkadotListener) Start

func (li *PolkadotListener) Start(
	ctx context.Context,
	eg *errgroup.Group,
	currentBeefyBlock uint64,
) (<-chan Request, error)

type Relay

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

func NewRelay

func NewRelay(config *Config, ethereumKeypair *secp256k1.Keypair) (*Relay, error)

func (*Relay) Start

func (relay *Relay) Start(ctx context.Context, eg *errgroup.Group) error

type Request

type Request struct {
	// Validators that signed this commitment
	Validators       []substrate.Authority
	ValidatorsRoot   [32]byte
	SignedCommitment types.SignedCommitment
	Proof            merkle.SimplifiedMMRProof
}

func (*Request) CommitmentHash

func (r *Request) CommitmentHash() (*[32]byte, error)

func (*Request) MakeSubmitFinalParams

func (r *Request) MakeSubmitFinalParams(validatorIndices []uint64, initialBitfield []*big.Int) (*FinalRequestParams, error)

func (*Request) MakeSubmitInitialParams

func (r *Request) MakeSubmitInitialParams(valAddrIndex int64, initialBitfield []*big.Int) (*InitialRequestParams, error)

Generate RequestParams which contains merkle proof by validator's index together with the signature which will be verified in BeefyClient contract later

type ScanBlocksResult

type ScanBlocksResult struct {
	BlockNumber uint64
	BlockHash   types.Hash
	Error       error
}

type ScanCommitmentsResult

type ScanCommitmentsResult struct {
	SignedCommitment types.SignedCommitment
	Proof            merkle.SimplifiedMMRProof
	BlockHash        types.Hash
	Error            error
}

type SinkConfig

type SinkConfig struct {
	Ethereum              config.EthereumConfig `mapstructure:"ethereum"`
	DescendantsUntilFinal uint64                `mapstructure:"descendants-until-final"`
	Contracts             ContractsConfig       `mapstructure:"contracts"`
}

type SourceConfig

type SourceConfig struct {
	Polkadot  config.PolkadotConfig  `mapstructure:"polkadot"`
	BridgeHub config.ParachainConfig `mapstructure:"bridge-hub"`
}

type TokenBucket

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

func NewTokenBucket

func NewTokenBucket(maxTokens, refillAmount uint64, refillPeriod time.Duration) *TokenBucket

func (*TokenBucket) Start

func (tb *TokenBucket) Start(ctx context.Context)

func (*TokenBucket) TryConsume

func (tb *TokenBucket) TryConsume(tokens uint64) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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