Documentation ¶
Index ¶
- Constants
- Variables
- func ChainPrivateKeyToOperatorKeyPair(chainPrivateKey *ecdsa.PrivateKey) (*operator.PrivateKey, *operator.PublicKey, error)
- func Connect(ctx context.Context, config ethereum.Config) (*BeaconChain, *TbtcChain, chain.BlockCounter, chain.Signing, ...)
- type BeaconChain
- func (bc BeaconChain) AverageBlockTime() time.Duration
- func (bc BeaconChain) BlockCounter() (chain.BlockCounter, error)
- func (bc *BeaconChain) CalculateDKGResultHash(dkgResult *beaconchain.DKGResult) (beaconchain.DKGResultHash, error)
- func (bc *BeaconChain) CanRestoreRewardEligibility() (bool, error)
- func (bc *BeaconChain) CurrentRequestGroupPublicKey() ([]byte, error)
- func (bc *BeaconChain) CurrentRequestPreviousEntry() ([]byte, error)
- func (bc *BeaconChain) CurrentRequestStartBlock() (*big.Int, error)
- func (bc *BeaconChain) EligibleStake(stakingProvider chain.Address) (*big.Int, error)
- func (bc BeaconChain) GetBlockHashByNumber(blockNumber uint64) ([32]byte, error)
- func (bc BeaconChain) GetBlockNumberByTimestamp(timestamp uint64) (uint64, error)
- func (bc *BeaconChain) GetConfig() *beaconchain.Config
- func (bc *BeaconChain) GetOperatorID(operatorAddress chain.Address) (chain.OperatorID, error)
- func (bc *BeaconChain) IsBetaOperator() (bool, error)
- func (bc *BeaconChain) IsChaosnetActive() (bool, error)
- func (bc *BeaconChain) IsEligibleForRewards() (bool, error)
- func (bc *BeaconChain) IsEntryInProgress() (bool, error)
- func (bc *BeaconChain) IsGroupRegistered(groupPublicKey []byte) (bool, error)
- func (bc *BeaconChain) IsOperatorInPool() (bool, error)
- func (bc *BeaconChain) IsOperatorUpToDate() (bool, error)
- func (bc *BeaconChain) IsPoolLocked() (bool, error)
- func (bc *BeaconChain) IsRecognized(operatorPublicKey *operator.PublicKey) (bool, error)
- func (bc *BeaconChain) IsStaleGroup(groupPublicKey []byte) (bool, error)
- func (bc *BeaconChain) JoinSortitionPool() error
- func (bc *BeaconChain) OnDKGResultSubmitted(handler func(event *event.DKGResultSubmission)) subscription.EventSubscription
- func (bc *BeaconChain) OnDKGStarted(handler func(event *event.DKGStarted)) subscription.EventSubscription
- func (bc *BeaconChain) OnGroupRegistered(handler func(groupRegistration *event.GroupRegistration)) subscription.EventSubscription
- func (bc *BeaconChain) OnRelayEntryRequested(handler func(request *event.RelayEntryRequested)) subscription.EventSubscription
- func (bc *BeaconChain) OnRelayEntrySubmitted(handler func(entry *event.RelayEntrySubmitted)) subscription.EventSubscription
- func (bc BeaconChain) OperatorKeyPair() (*operator.PrivateKey, *operator.PublicKey, error)
- func (bc *BeaconChain) OperatorToStakingProvider() (chain.Address, bool, error)
- func (bc *BeaconChain) ReportRelayEntryTimeout() error
- func (bc *BeaconChain) RestoreRewardEligibility() error
- func (bc BeaconChain) RolesOf(stakingProvider chain.Address) (owner, beneficiary, authorizer chain.Address, hasStake bool, err error)
- func (bc *BeaconChain) SelectGroup(seed *big.Int) (chain.Addresses, error)
- func (bc BeaconChain) Signing() chain.Signing
- func (bc *BeaconChain) Staking() (chain.Address, error)
- func (bc *BeaconChain) SubmitDKGResult(participantIndex beaconchain.GroupMemberIndex, ...) error
- func (bc *BeaconChain) SubmitRelayEntry(entry []byte) error
- func (bc *BeaconChain) UpdateOperatorStatus() error
- type BitcoinDifficultyChain
- func (bc BitcoinDifficultyChain) AverageBlockTime() time.Duration
- func (bc BitcoinDifficultyChain) BlockCounter() (chain.BlockCounter, error)
- func (bdc *BitcoinDifficultyChain) CurrentEpoch() (uint64, error)
- func (bc BitcoinDifficultyChain) GetBlockHashByNumber(blockNumber uint64) ([32]byte, error)
- func (bc BitcoinDifficultyChain) GetBlockNumberByTimestamp(timestamp uint64) (uint64, error)
- func (bdc *BitcoinDifficultyChain) GetCurrentAndPrevEpochDifficulty() (*big.Int, *big.Int, error)
- func (bdc *BitcoinDifficultyChain) IsAuthorized(address chain.Address) (bool, error)
- func (bdc *BitcoinDifficultyChain) IsAuthorizedForRefund(address chain.Address) (bool, error)
- func (bc BitcoinDifficultyChain) OperatorKeyPair() (*operator.PrivateKey, *operator.PublicKey, error)
- func (bdc *BitcoinDifficultyChain) ProofLength() (uint64, error)
- func (bdc *BitcoinDifficultyChain) Ready() (bool, error)
- func (bdc *BitcoinDifficultyChain) Retarget(headers []*bitcoin.BlockHeader) error
- func (bdc *BitcoinDifficultyChain) RetargetWithRefund(headers []*bitcoin.BlockHeader) error
- func (bc BitcoinDifficultyChain) RolesOf(stakingProvider chain.Address) (owner, beneficiary, authorizer chain.Address, hasStake bool, err error)
- func (bc BitcoinDifficultyChain) Signing() chain.Signing
- type Command
- type TbtcChain
- func (tc *TbtcChain) ApproveDKGResult(dkgResult *tbtc.DKGChainResult) error
- func (tc *TbtcChain) AssembleDKGResult(submitterMemberIndex group.MemberIndex, groupPublicKey *ecdsa.PublicKey, ...) (*tbtc.DKGChainResult, error)
- func (bc TbtcChain) AverageBlockTime() time.Duration
- func (bc TbtcChain) BlockCounter() (chain.BlockCounter, error)
- func (tc *TbtcChain) BuildDepositKey(fundingTxHash bitcoin.Hash, fundingOutputIndex uint32) *big.Int
- func (tc *TbtcChain) BuildRedemptionKey(walletPublicKeyHash [20]byte, redeemerOutputScript bitcoin.Script) (*big.Int, error)
- func (tc *TbtcChain) CalculateDKGResultSignatureHash(groupPublicKey *ecdsa.PublicKey, misbehavedMembersIndexes []group.MemberIndex, ...) (dkg.ResultSignatureHash, error)
- func (tc *TbtcChain) CanRestoreRewardEligibility() (bool, error)
- func (tc *TbtcChain) ChallengeDKGResult(dkgResult *tbtc.DKGChainResult) error
- func (tc *TbtcChain) ComputeMainUtxoHash(mainUtxo *bitcoin.UnspentTransactionOutput) [32]byte
- func (tc *TbtcChain) DKGParameters() (*tbtc.DKGParameters, error)
- func (tc *TbtcChain) EligibleStake(stakingProvider chain.Address) (*big.Int, error)
- func (bc TbtcChain) GetBlockHashByNumber(blockNumber uint64) ([32]byte, error)
- func (bc TbtcChain) GetBlockNumberByTimestamp(timestamp uint64) (uint64, error)
- func (tc *TbtcChain) GetDKGState() (tbtc.DKGState, error)
- func (tc *TbtcChain) GetDepositParameters() (dustThreshold uint64, treasuryFeeDivisor uint64, txMaxFee uint64, ...)
- func (tc *TbtcChain) GetDepositRequest(fundingTxHash bitcoin.Hash, fundingOutputIndex uint32) (*tbtc.DepositChainRequest, bool, error)
- func (tc *TbtcChain) GetDepositSweepMaxSize() (uint16, error)
- func (tc *TbtcChain) GetOperatorID(operatorAddress chain.Address) (chain.OperatorID, error)
- func (tc *TbtcChain) GetPendingRedemptionRequest(walletPublicKeyHash [20]byte, redeemerOutputScript bitcoin.Script) (*tbtc.RedemptionRequest, bool, error)
- func (tc *TbtcChain) GetRedemptionMaxSize() (uint16, error)
- func (tc *TbtcChain) GetRedemptionParameters() (dustThreshold uint64, treasuryFeeDivisor uint64, txMaxFee uint64, ...)
- func (tc *TbtcChain) GetRedemptionRequestMinAge() (uint32, error)
- func (tc *TbtcChain) GetWallet(walletPublicKeyHash [20]byte) (*tbtc.WalletChainData, error)
- func (tc *TbtcChain) IsBetaOperator() (bool, error)
- func (tc *TbtcChain) IsChaosnetActive() (bool, error)
- func (tc *TbtcChain) IsDKGResultValid(dkgResult *tbtc.DKGChainResult) (bool, error)
- func (tc *TbtcChain) IsEligibleForRewards() (bool, error)
- func (tc *TbtcChain) IsOperatorInPool() (bool, error)
- func (tc *TbtcChain) IsOperatorUpToDate() (bool, error)
- func (tc *TbtcChain) IsPoolLocked() (bool, error)
- func (tc *TbtcChain) IsRecognized(operatorPublicKey *operator.PublicKey) (bool, error)
- func (tc *TbtcChain) JoinSortitionPool() error
- func (tc *TbtcChain) OnDKGResultApproved(handler func(event *tbtc.DKGResultApprovedEvent)) subscription.EventSubscription
- func (tc *TbtcChain) OnDKGResultChallenged(handler func(event *tbtc.DKGResultChallengedEvent)) subscription.EventSubscription
- func (tc *TbtcChain) OnDKGResultSubmitted(handler func(event *tbtc.DKGResultSubmittedEvent)) subscription.EventSubscription
- func (tc *TbtcChain) OnDKGStarted(handler func(event *tbtc.DKGStartedEvent)) subscription.EventSubscription
- func (bc TbtcChain) OperatorKeyPair() (*operator.PrivateKey, *operator.PublicKey, error)
- func (tc *TbtcChain) OperatorToStakingProvider() (chain.Address, bool, error)
- func (tc *TbtcChain) PastDKGStartedEvents(filter *tbtc.DKGStartedEventFilter) ([]*tbtc.DKGStartedEvent, error)
- func (tc *TbtcChain) PastDepositRevealedEvents(filter *tbtc.DepositRevealedEventFilter) ([]*tbtc.DepositRevealedEvent, error)
- func (tc *TbtcChain) PastNewWalletRegisteredEvents(filter *tbtc.NewWalletRegisteredEventFilter) ([]*tbtc.NewWalletRegisteredEvent, error)
- func (tc *TbtcChain) PastRedemptionRequestedEvents(filter *tbtc.RedemptionRequestedEventFilter) ([]*tbtc.RedemptionRequestedEvent, error)
- func (tc *TbtcChain) RestoreRewardEligibility() error
- func (bc TbtcChain) RolesOf(stakingProvider chain.Address) (owner, beneficiary, authorizer chain.Address, hasStake bool, err error)
- func (tc *TbtcChain) SelectGroup() (*tbtc.GroupSelectionResult, error)
- func (bc TbtcChain) Signing() chain.Signing
- func (tc *TbtcChain) Staking() (chain.Address, error)
- func (tc *TbtcChain) SubmitDKGResult(dkgResult *tbtc.DKGChainResult) error
- func (tc *TbtcChain) SubmitDepositSweepProofWithReimbursement(transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, ...) error
- func (tc *TbtcChain) SubmitRedemptionProofWithReimbursement(transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, ...) error
- func (tc *TbtcChain) TxProofDifficultyFactor() (*big.Int, error)
- func (tc *TbtcChain) UpdateOperatorStatus() error
- func (tc *TbtcChain) ValidateDepositSweepProposal(walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, ...) error
- func (tc *TbtcChain) ValidateHeartbeatProposal(walletPublicKeyHash [20]byte, proposal *tbtc.HeartbeatProposal) error
- func (tc *TbtcChain) ValidateRedemptionProposal(walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal) error
Constants ¶
const ( LightRelayContractName = "LightRelay" LightRelayMaintainerProxyContractName = "LightRelayMaintainerProxy" )
Definitions of contract names.
const ( // TODO: The WalletRegistry address is taken from the Bridge contract. // Remove the possibility of passing it through the config. WalletRegistryContractName = "WalletRegistry" BridgeContractName = "Bridge" MaintainerProxyContractName = "MaintainerProxy" WalletProposalValidatorContractName = "WalletProposalValidator" )
Definitions of contract names.
const (
RandomBeaconContractName = "RandomBeacon"
)
Definitions of contract names.
const (
TokenStakingContractName = "TokenStaking"
)
Definitions of contract names.
Variables ¶
var DefaultCurve elliptic.Curve = crypto.S256()
DefaultCurve is the default elliptic curve implementation used in the chain/ethereum package. Ethereum uses the secp256k1 curve and the specific implementation is provided by the go-ethereum package.
Functions ¶
func ChainPrivateKeyToOperatorKeyPair ¶ added in v1.21.0
func ChainPrivateKeyToOperatorKeyPair( chainPrivateKey *ecdsa.PrivateKey, ) (*operator.PrivateKey, *operator.PublicKey, error)
ChainPrivateKeyToOperatorKeyPair converts the Ethereum chain private key to a universal operator key pair. This conversion decouples the key from the chain-specific curve implementation while preserving the curve.
func Connect ¶
func Connect( ctx context.Context, config ethereum.Config, ) ( *BeaconChain, *TbtcChain, chain.BlockCounter, chain.Signing, *operator.PrivateKey, error, )
Connect creates Random Beacon and TBTC Ethereum chain handles.
Types ¶
type BeaconChain ¶ added in v1.21.0
type BeaconChain struct {
// contains filtered or unexported fields
}
BeaconChain represents a beacon-specific chain handle.
func (BeaconChain) AverageBlockTime ¶ added in v1.21.0
func (BeaconChain) BlockCounter ¶ added in v1.21.0
func (bc BeaconChain) BlockCounter() (chain.BlockCounter, error)
func (*BeaconChain) CalculateDKGResultHash ¶ added in v1.21.0
func (bc *BeaconChain) CalculateDKGResultHash( dkgResult *beaconchain.DKGResult, ) (beaconchain.DKGResultHash, error)
CalculateDKGResultHash calculates Keccak-256 hash of the DKG result. Operation is performed off-chain.
It first encodes the result using solidity ABI and then calculates Keccak-256 hash over it. This corresponds to the DKG result hash calculation on-chain. Hashes calculated off-chain and on-chain must always match.
func (*BeaconChain) CanRestoreRewardEligibility ¶ added in v1.21.0
func (bc *BeaconChain) CanRestoreRewardEligibility() (bool, error)
Checks whether the operator is able to restore their eligibility for rewards right away.
func (*BeaconChain) CurrentRequestGroupPublicKey ¶ added in v1.21.0
func (bc *BeaconChain) CurrentRequestGroupPublicKey() ([]byte, error)
TODO: Implement a real CurrentRequestGroupPublicKey function.
func (*BeaconChain) CurrentRequestPreviousEntry ¶ added in v1.21.0
func (bc *BeaconChain) CurrentRequestPreviousEntry() ([]byte, error)
TODO: Implement a real CurrentRequestPreviousEntry function.
func (*BeaconChain) CurrentRequestStartBlock ¶ added in v1.21.0
func (bc *BeaconChain) CurrentRequestStartBlock() (*big.Int, error)
TODO: Implement a real CurrentRequestStartBlock function.
func (*BeaconChain) EligibleStake ¶ added in v1.21.0
EligibleStake returns the current value of the staking provider's eligible stake. Eligible stake is defined as the currently authorized stake minus the pending authorization decrease. Eligible stake is what is used for operator's weight in the sortition pool. If the authorized stake minus the pending authorization decrease is below the minimum authorization, eligible stake is 0.
func (BeaconChain) GetBlockHashByNumber ¶ added in v1.21.0
GetBlockHashByNumber gets the block hash for the given block number.
func (BeaconChain) GetBlockNumberByTimestamp ¶ added in v1.21.0
GetBlockNumberByTimestamp gets the block number for the given timestamp. In the best case, the block with the exact same timestamp is returned. If the aforementioned is not possible, it tries to return the closest possible block.
WARNING: THIS FUNCTION MAY NOT BE PERFORMANT FOR BLOCKS EARLIER THAN 15537393 (SEPTEMBER 15, 2022, AT 1:42:42 EST) BEFORE THE ETH2 MERGE. PRE-MERGE AVERAGE BLOCK TIME WAS HIGHER THAN THE VALUE ASSUMED WITHIN THIS FUNCTION SO MORE OVERSHOOTS WILL BE DONE DURING THE BLOCK PREDICTION. OVERSHOOTS MUST BE COMPENSATED BY ADDITIONAL CLIENT CALLS THAT TAKE TIME.
func (*BeaconChain) GetConfig ¶ added in v1.21.0
func (bc *BeaconChain) GetConfig() *beaconchain.Config
GetConfig returns the expected configuration of the random beacon. TODO: Adjust to the random beacon v2 requirements.
func (*BeaconChain) GetOperatorID ¶ added in v1.21.0
func (bc *BeaconChain) GetOperatorID( operatorAddress chain.Address, ) (chain.OperatorID, error)
GetOperatorID returns the ID number of the given operator address. An ID number of 0 means the operator has not been allocated an ID number yet.
func (*BeaconChain) IsBetaOperator ¶ added in v1.21.0
func (bc *BeaconChain) IsBetaOperator() (bool, error)
Returns true if operator is a beta operator, false otherwise. Chaosnet status does not matter.
func (*BeaconChain) IsChaosnetActive ¶ added in v1.21.0
func (bc *BeaconChain) IsChaosnetActive() (bool, error)
Returns true if the chaosnet phase is active, false otherwise.
func (*BeaconChain) IsEligibleForRewards ¶ added in v1.21.0
func (bc *BeaconChain) IsEligibleForRewards() (bool, error)
IsEligibleForRewards checks whether the operator is eligible for rewards or not.
func (*BeaconChain) IsEntryInProgress ¶ added in v1.21.0
func (bc *BeaconChain) IsEntryInProgress() (bool, error)
TODO: Implement a real IsEntryInProgress function.
func (*BeaconChain) IsGroupRegistered ¶ added in v1.21.0
func (bc *BeaconChain) IsGroupRegistered(groupPublicKey []byte) (bool, error)
TODO: Implement a real IsGroupRegistered function.
func (*BeaconChain) IsOperatorInPool ¶ added in v1.21.0
func (bc *BeaconChain) IsOperatorInPool() (bool, error)
IsOperatorInPool returns true if the operator is registered in the sortition pool.
func (*BeaconChain) IsOperatorUpToDate ¶ added in v1.21.0
func (bc *BeaconChain) IsOperatorUpToDate() (bool, error)
IsOperatorUpToDate checks if the operator's authorized stake is in sync with operator's weight in the sortition pool. If the operator's authorized stake is not in sync with sortition pool weight, function returns false. If the operator is not in the sortition pool and their authorized stake is non-zero, function returns false.
func (*BeaconChain) IsPoolLocked ¶ added in v1.21.0
func (bc *BeaconChain) IsPoolLocked() (bool, error)
IsPoolLocked returns true if the sortition pool is locked and no state changes are allowed.
func (*BeaconChain) IsRecognized ¶ added in v1.21.0
func (bc *BeaconChain) IsRecognized(operatorPublicKey *operator.PublicKey) (bool, error)
IsRecognized checks whether the given operator is recognized by the BeaconChain as eligible to join the network. If the operator has a stake delegation or had a stake delegation in the past, it will be recognized.
func (*BeaconChain) IsStaleGroup ¶ added in v1.21.0
func (bc *BeaconChain) IsStaleGroup(groupPublicKey []byte) (bool, error)
TODO: Implement a real IsStaleGroup function.
func (*BeaconChain) JoinSortitionPool ¶ added in v1.21.0
func (bc *BeaconChain) JoinSortitionPool() error
JoinSortitionPool executes a transaction to have the operator join the sortition pool.
func (*BeaconChain) OnDKGResultSubmitted ¶ added in v1.21.0
func (bc *BeaconChain) OnDKGResultSubmitted( handler func(event *event.DKGResultSubmission), ) subscription.EventSubscription
TODO: Implement a real OnDKGResultSubmitted event subscription. The current implementation just pipes the DKG submission event generated within SubmitDKGResult to the handlers registered in the dkgResultSubmissionHandlers map.
func (*BeaconChain) OnDKGStarted ¶ added in v1.21.0
func (bc *BeaconChain) OnDKGStarted( handler func(event *event.DKGStarted), ) subscription.EventSubscription
TODO: Implement a real OnDKGStarted event subscription. The current implementation generates a fake event every 500th block where the seed is the keccak256 of the block number.
func (*BeaconChain) OnGroupRegistered ¶ added in v1.21.0
func (bc *BeaconChain) OnGroupRegistered( handler func(groupRegistration *event.GroupRegistration), ) subscription.EventSubscription
TODO: Implement a real OnGroupRegistered function.
func (*BeaconChain) OnRelayEntryRequested ¶ added in v1.21.0
func (bc *BeaconChain) OnRelayEntryRequested( handler func(request *event.RelayEntryRequested), ) subscription.EventSubscription
TODO: Implement a real OnRelayEntryRequested function.
func (*BeaconChain) OnRelayEntrySubmitted ¶ added in v1.21.0
func (bc *BeaconChain) OnRelayEntrySubmitted( handler func(entry *event.RelayEntrySubmitted), ) subscription.EventSubscription
TODO: Implement a real OnRelayEntrySubmitted function.
func (BeaconChain) OperatorKeyPair ¶ added in v1.21.0
func (bc BeaconChain) OperatorKeyPair() ( *operator.PrivateKey, *operator.PublicKey, error, )
OperatorKeyPair returns the key pair of the operator assigned to this chain handle.
func (*BeaconChain) OperatorToStakingProvider ¶ added in v1.21.0
func (bc *BeaconChain) OperatorToStakingProvider() (chain.Address, bool, error)
OperatorToStakingProvider returns the staking provider address for the operator. If the staking provider has not been registered for the operator, the returned address is empty and the boolean flag is set to false If the staking provider has been registered, the address is not empty and the boolean flag indicates true.
func (*BeaconChain) ReportRelayEntryTimeout ¶ added in v1.21.0
func (bc *BeaconChain) ReportRelayEntryTimeout() error
TODO: Implement a real ReportRelayEntryTimeout function.
func (*BeaconChain) RestoreRewardEligibility ¶ added in v1.21.0
func (bc *BeaconChain) RestoreRewardEligibility() error
Restores reward eligibility for the operator.
func (BeaconChain) RolesOf ¶ added in v1.21.0
func (bc BeaconChain) RolesOf(stakingProvider chain.Address) ( owner, beneficiary, authorizer chain.Address, hasStake bool, err error, )
RolesOf returns the stake owner, the beneficiary and the authorizer for the specified staking provider address. If the owner is set, the function considers the staking provider to have a stake delegation and returns the boolean flag set to true.
func (*BeaconChain) SelectGroup ¶ added in v1.21.0
SelectGroup returns the group members for the group generated by the given seed. This function can return an error if the beacon chain's state does not allow for group selection at the moment.
func (*BeaconChain) Staking ¶ added in v1.21.0
func (bc *BeaconChain) Staking() (chain.Address, error)
Staking returns address of the TokenStaking contract the RandomBeacon is connected to.
func (*BeaconChain) SubmitDKGResult ¶ added in v1.21.0
func (bc *BeaconChain) SubmitDKGResult( participantIndex beaconchain.GroupMemberIndex, dkgResult *beaconchain.DKGResult, signatures map[beaconchain.GroupMemberIndex][]byte, ) error
TODO: Implement a real SubmitDKGResult action. The current implementation just creates and pipes the DKG submission event to the handlers registered in the dkgResultSubmissionHandlers map.
func (*BeaconChain) SubmitRelayEntry ¶ added in v1.21.0
func (bc *BeaconChain) SubmitRelayEntry( entry []byte, ) error
TODO: Implement a real SubmitRelayEntry function.
func (*BeaconChain) UpdateOperatorStatus ¶ added in v1.21.0
func (bc *BeaconChain) UpdateOperatorStatus() error
UpdateOperatorStatus executes a transaction to update the operator's state in the sortition pool.
type BitcoinDifficultyChain ¶ added in v1.21.0
type BitcoinDifficultyChain struct {
// contains filtered or unexported fields
}
BitcoinDifficultyChain represents a Bitcoin difficulty-specific chain handle.
func ConnectBitcoinDifficulty ¶ added in v1.21.0
func ConnectBitcoinDifficulty( ctx context.Context, ethereumConfig ethereum.Config, maintainerConfig maintainer.Config, ) ( *BitcoinDifficultyChain, error, )
ConnectBitcoinDifficulty creates Bitcoin difficulty chain handle.
func NewBitcoinDifficultyChain ¶ added in v1.21.0
func NewBitcoinDifficultyChain( ethereumConfig ethereum.Config, maintainerConfig maintainer.Config, baseChain *baseChain, ) (*BitcoinDifficultyChain, error)
NewBitcoinDifficultyChain construct a new instance of the Bitcoin difficulty - specific Ethereum chain handle.
func (BitcoinDifficultyChain) AverageBlockTime ¶ added in v1.21.0
func (BitcoinDifficultyChain) BlockCounter ¶ added in v1.21.0
func (bc BitcoinDifficultyChain) BlockCounter() (chain.BlockCounter, error)
func (*BitcoinDifficultyChain) CurrentEpoch ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) CurrentEpoch() (uint64, error)
CurrentEpoch returns the number of the latest difficulty epoch which is proven to the relay. If the genesis epoch's number is set correctly, and retargets along the way have been legitimate, this equals the height of the block starting the most recent epoch, divided by 2016.
func (BitcoinDifficultyChain) GetBlockHashByNumber ¶ added in v1.21.0
GetBlockHashByNumber gets the block hash for the given block number.
func (BitcoinDifficultyChain) GetBlockNumberByTimestamp ¶ added in v1.21.0
GetBlockNumberByTimestamp gets the block number for the given timestamp. In the best case, the block with the exact same timestamp is returned. If the aforementioned is not possible, it tries to return the closest possible block.
WARNING: THIS FUNCTION MAY NOT BE PERFORMANT FOR BLOCKS EARLIER THAN 15537393 (SEPTEMBER 15, 2022, AT 1:42:42 EST) BEFORE THE ETH2 MERGE. PRE-MERGE AVERAGE BLOCK TIME WAS HIGHER THAN THE VALUE ASSUMED WITHIN THIS FUNCTION SO MORE OVERSHOOTS WILL BE DONE DURING THE BLOCK PREDICTION. OVERSHOOTS MUST BE COMPENSATED BY ADDITIONAL CLIENT CALLS THAT TAKE TIME.
func (*BitcoinDifficultyChain) GetCurrentAndPrevEpochDifficulty ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) GetCurrentAndPrevEpochDifficulty() ( *big.Int, *big.Int, error, )
GetCurrentAndPrevEpochDifficulty returns the difficulties of the current and previous Bitcoin epochs.
func (*BitcoinDifficultyChain) IsAuthorized ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) IsAuthorized(address chain.Address) (bool, error)
IsAuthorized checks whether the given address has been authorized to submit a retarget directly to LightRelay. This function should be used when retargetting via LightRelayMaintainerProxy is disabled.
func (*BitcoinDifficultyChain) IsAuthorizedForRefund ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) IsAuthorizedForRefund(address chain.Address) (bool, error)
IsAuthorizedForRefund checks whether the given address has been authorized to submit a retarget via LightRelayMaintainerProxy. This function should be used when retargetting via LightRelayMaintainerProxy is not disabled.
func (BitcoinDifficultyChain) OperatorKeyPair ¶ added in v1.21.0
func (bc BitcoinDifficultyChain) OperatorKeyPair() ( *operator.PrivateKey, *operator.PublicKey, error, )
OperatorKeyPair returns the key pair of the operator assigned to this chain handle.
func (*BitcoinDifficultyChain) ProofLength ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) ProofLength() (uint64, error)
ProofLength returns the number of blocks required for each side of a retarget proof.
func (*BitcoinDifficultyChain) Ready ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) Ready() (bool, error)
Ready checks whether the relay is active (i.e. genesis has been performed). Note that if the relay is used by querying the current and previous epoch difficulty, at least one retarget needs to be provided after genesis; otherwise the prevEpochDifficulty will be uninitialised and zero.
func (*BitcoinDifficultyChain) Retarget ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) Retarget(headers []*bitcoin.BlockHeader) error
Retarget adds a new epoch to the relay by providing a proof of the difficulty before and after the retarget. The cost of calling this function is not refunded to the caller.
func (*BitcoinDifficultyChain) RetargetWithRefund ¶ added in v1.21.0
func (bdc *BitcoinDifficultyChain) RetargetWithRefund(headers []*bitcoin.BlockHeader) error
RetargetWithRefund adds a new epoch to the relay by providing a proof of the difficulty before and after the retarget. The cost of calling this function is refunded to the caller.
func (BitcoinDifficultyChain) RolesOf ¶ added in v1.21.0
func (bc BitcoinDifficultyChain) RolesOf(stakingProvider chain.Address) ( owner, beneficiary, authorizer chain.Address, hasStake bool, err error, )
RolesOf returns the stake owner, the beneficiary and the authorizer for the specified staking provider address. If the owner is set, the function considers the staking provider to have a stake delegation and returns the boolean flag set to true.
type Command ¶ added in v1.21.0
Command if a wrapper for cobra.Command that holds Ethereum config used by the generated sub-commands to initialize the Ethereum chain connection.
func (*Command) GetConfig ¶ added in v1.21.0
func (c *Command) GetConfig() *commonEthereum.Config
GetConfig returns the Ethereum config.
func (*Command) SetConfig ¶ added in v1.21.0
func (c *Command) SetConfig(config *commonEthereum.Config)
SetConfig is used to set the ethereum configuration that is used by the generated sub-commands to initialize the Ethereum chain connection.
type TbtcChain ¶ added in v1.21.0
type TbtcChain struct {
// contains filtered or unexported fields
}
TbtcChain represents a TBTC-specific chain handle.
func (*TbtcChain) ApproveDKGResult ¶ added in v1.21.0
func (tc *TbtcChain) ApproveDKGResult(dkgResult *tbtc.DKGChainResult) error
func (*TbtcChain) AssembleDKGResult ¶ added in v1.21.0
func (tc *TbtcChain) AssembleDKGResult( submitterMemberIndex group.MemberIndex, groupPublicKey *ecdsa.PublicKey, operatingMembersIndexes []group.MemberIndex, misbehavedMembersIndexes []group.MemberIndex, signatures map[group.MemberIndex][]byte, groupSelectionResult *tbtc.GroupSelectionResult, ) (*tbtc.DKGChainResult, error)
AssembleDKGResult assembles the DKG chain result according to the rules expected by the given chain.
func (TbtcChain) AverageBlockTime ¶ added in v1.21.0
func (TbtcChain) BlockCounter ¶ added in v1.21.0
func (bc TbtcChain) BlockCounter() (chain.BlockCounter, error)
func (*TbtcChain) BuildDepositKey ¶ added in v1.21.0
func (*TbtcChain) BuildRedemptionKey ¶ added in v1.21.0
func (*TbtcChain) CalculateDKGResultSignatureHash ¶ added in v1.21.0
func (tc *TbtcChain) CalculateDKGResultSignatureHash( groupPublicKey *ecdsa.PublicKey, misbehavedMembersIndexes []group.MemberIndex, startBlock uint64, ) (dkg.ResultSignatureHash, error)
CalculateDKGResultSignatureHash calculates a 32-byte hash that is used to produce a signature supporting the given groupPublicKey computed as result of the given DKG process. The misbehavedMembersIndexes parameter should contain indexes of members that were considered as misbehaved during the DKG process. The startBlock argument is the block at which the given DKG process started.
func (*TbtcChain) CanRestoreRewardEligibility ¶ added in v1.21.0
Checks whether the operator is able to restore their eligibility for rewards right away.
func (*TbtcChain) ChallengeDKGResult ¶ added in v1.21.0
func (tc *TbtcChain) ChallengeDKGResult(dkgResult *tbtc.DKGChainResult) error
func (*TbtcChain) ComputeMainUtxoHash ¶ added in v1.21.0
func (tc *TbtcChain) ComputeMainUtxoHash( mainUtxo *bitcoin.UnspentTransactionOutput, ) [32]byte
func (*TbtcChain) DKGParameters ¶ added in v1.21.0
func (tc *TbtcChain) DKGParameters() (*tbtc.DKGParameters, error)
func (*TbtcChain) EligibleStake ¶ added in v1.21.0
EligibleStake returns the current value of the staking provider's eligible stake. Eligible stake is defined as the currently authorized stake minus the pending authorization decrease. Eligible stake is what is used for operator's weight in the sortition pool. If the authorized stake minus the pending authorization decrease is below the minimum authorization, eligible stake is 0.
func (TbtcChain) GetBlockHashByNumber ¶ added in v1.21.0
GetBlockHashByNumber gets the block hash for the given block number.
func (TbtcChain) GetBlockNumberByTimestamp ¶ added in v1.21.0
GetBlockNumberByTimestamp gets the block number for the given timestamp. In the best case, the block with the exact same timestamp is returned. If the aforementioned is not possible, it tries to return the closest possible block.
WARNING: THIS FUNCTION MAY NOT BE PERFORMANT FOR BLOCKS EARLIER THAN 15537393 (SEPTEMBER 15, 2022, AT 1:42:42 EST) BEFORE THE ETH2 MERGE. PRE-MERGE AVERAGE BLOCK TIME WAS HIGHER THAN THE VALUE ASSUMED WITHIN THIS FUNCTION SO MORE OVERSHOOTS WILL BE DONE DURING THE BLOCK PREDICTION. OVERSHOOTS MUST BE COMPENSATED BY ADDITIONAL CLIENT CALLS THAT TAKE TIME.
func (*TbtcChain) GetDKGState ¶ added in v1.21.0
func (*TbtcChain) GetDepositParameters ¶ added in v1.21.0
func (*TbtcChain) GetDepositRequest ¶ added in v1.21.0
func (*TbtcChain) GetDepositSweepMaxSize ¶ added in v1.21.0
func (*TbtcChain) GetOperatorID ¶ added in v1.21.0
GetOperatorID returns the ID number of the given operator address. An ID number of 0 means the operator has not been allocated an ID number yet.
func (*TbtcChain) GetPendingRedemptionRequest ¶ added in v1.21.0
func (*TbtcChain) GetRedemptionMaxSize ¶ added in v1.21.0
func (*TbtcChain) GetRedemptionParameters ¶ added in v1.21.0
func (*TbtcChain) GetRedemptionRequestMinAge ¶ added in v1.21.0
func (*TbtcChain) GetWallet ¶ added in v1.21.0
func (tc *TbtcChain) GetWallet( walletPublicKeyHash [20]byte, ) (*tbtc.WalletChainData, error)
func (*TbtcChain) IsBetaOperator ¶ added in v1.21.0
Returns true if operator is a beta operator, false otherwise. Chaosnet status does not matter.
func (*TbtcChain) IsChaosnetActive ¶ added in v1.21.0
Returns true if the chaosnet phase is active, false otherwise.
func (*TbtcChain) IsDKGResultValid ¶ added in v1.21.0
func (tc *TbtcChain) IsDKGResultValid( dkgResult *tbtc.DKGChainResult, ) (bool, error)
func (*TbtcChain) IsEligibleForRewards ¶ added in v1.21.0
IsEligibleForRewards checks whether the operator is eligible for rewards or not.
func (*TbtcChain) IsOperatorInPool ¶ added in v1.21.0
IsOperatorInPool returns true if the operator is registered in the sortition pool.
func (*TbtcChain) IsOperatorUpToDate ¶ added in v1.21.0
IsOperatorUpToDate checks if the operator's authorized stake is in sync with operator's weight in the sortition pool. If the operator's authorized stake is not in sync with sortition pool weight, function returns false. If the operator is not in the sortition pool and their authorized stake is non-zero, function returns false.
func (*TbtcChain) IsPoolLocked ¶ added in v1.21.0
IsPoolLocked returns true if the sortition pool is locked and no state changes are allowed.
func (*TbtcChain) IsRecognized ¶ added in v1.21.0
IsRecognized checks whether the given operator is recognized by the TbtcChain as eligible to join the network. If the operator has a stake delegation or had a stake delegation in the past, it will be recognized.
func (*TbtcChain) JoinSortitionPool ¶ added in v1.21.0
JoinSortitionPool executes a transaction to have the operator join the sortition pool.
func (*TbtcChain) OnDKGResultApproved ¶ added in v1.21.0
func (tc *TbtcChain) OnDKGResultApproved( handler func(event *tbtc.DKGResultApprovedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnDKGResultChallenged ¶ added in v1.21.0
func (tc *TbtcChain) OnDKGResultChallenged( handler func(event *tbtc.DKGResultChallengedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnDKGResultSubmitted ¶ added in v1.21.0
func (tc *TbtcChain) OnDKGResultSubmitted( handler func(event *tbtc.DKGResultSubmittedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnDKGStarted ¶ added in v1.21.0
func (tc *TbtcChain) OnDKGStarted( handler func(event *tbtc.DKGStartedEvent), ) subscription.EventSubscription
func (TbtcChain) OperatorKeyPair ¶ added in v1.21.0
func (bc TbtcChain) OperatorKeyPair() ( *operator.PrivateKey, *operator.PublicKey, error, )
OperatorKeyPair returns the key pair of the operator assigned to this chain handle.
func (*TbtcChain) OperatorToStakingProvider ¶ added in v1.21.0
OperatorToStakingProvider returns the staking provider address for the operator. If the staking provider has not been registered for the operator, the returned address is empty and the boolean flag is set to false. If the staking provider has been registered, the address is not empty and the boolean flag indicates true.
func (*TbtcChain) PastDKGStartedEvents ¶ added in v1.21.0
func (tc *TbtcChain) PastDKGStartedEvents( filter *tbtc.DKGStartedEventFilter, ) ([]*tbtc.DKGStartedEvent, error)
func (*TbtcChain) PastDepositRevealedEvents ¶ added in v1.21.0
func (tc *TbtcChain) PastDepositRevealedEvents( filter *tbtc.DepositRevealedEventFilter, ) ([]*tbtc.DepositRevealedEvent, error)
func (*TbtcChain) PastNewWalletRegisteredEvents ¶ added in v1.21.0
func (tc *TbtcChain) PastNewWalletRegisteredEvents( filter *tbtc.NewWalletRegisteredEventFilter, ) ([]*tbtc.NewWalletRegisteredEvent, error)
func (*TbtcChain) PastRedemptionRequestedEvents ¶ added in v1.21.0
func (tc *TbtcChain) PastRedemptionRequestedEvents( filter *tbtc.RedemptionRequestedEventFilter, ) ([]*tbtc.RedemptionRequestedEvent, error)
func (*TbtcChain) RestoreRewardEligibility ¶ added in v1.21.0
Restores reward eligibility for the operator.
func (TbtcChain) RolesOf ¶ added in v1.21.0
func (bc TbtcChain) RolesOf(stakingProvider chain.Address) ( owner, beneficiary, authorizer chain.Address, hasStake bool, err error, )
RolesOf returns the stake owner, the beneficiary and the authorizer for the specified staking provider address. If the owner is set, the function considers the staking provider to have a stake delegation and returns the boolean flag set to true.
func (*TbtcChain) SelectGroup ¶ added in v1.21.0
func (tc *TbtcChain) SelectGroup() (*tbtc.GroupSelectionResult, error)
SelectGroup returns the group members selected for the current group selection. The function returns an error if the chain's state does not allow for group selection at the moment.
func (*TbtcChain) Staking ¶ added in v1.21.0
Staking returns address of the TokenStaking contract the WalletRegistry is connected to.
func (*TbtcChain) SubmitDKGResult ¶ added in v1.21.0
func (tc *TbtcChain) SubmitDKGResult( dkgResult *tbtc.DKGChainResult, ) error
func (*TbtcChain) SubmitDepositSweepProofWithReimbursement ¶ added in v1.21.0
func (tc *TbtcChain) SubmitDepositSweepProofWithReimbursement( transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, mainUTXO bitcoin.UnspentTransactionOutput, vault common.Address, ) error
func (*TbtcChain) SubmitRedemptionProofWithReimbursement ¶ added in v1.21.0
func (tc *TbtcChain) SubmitRedemptionProofWithReimbursement( transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, mainUTXO bitcoin.UnspentTransactionOutput, walletPublicKeyHash [20]byte, ) error
func (*TbtcChain) TxProofDifficultyFactor ¶ added in v1.21.0
func (*TbtcChain) UpdateOperatorStatus ¶ added in v1.21.0
UpdateOperatorStatus executes a transaction to update the operator's state in the sortition pool.
func (*TbtcChain) ValidateDepositSweepProposal ¶ added in v1.21.0
func (tc *TbtcChain) ValidateDepositSweepProposal( walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, depositsExtraInfo []struct { *tbtc.Deposit FundingTx *bitcoin.Transaction }, ) error
func (*TbtcChain) ValidateHeartbeatProposal ¶ added in v1.21.0
func (tc *TbtcChain) ValidateHeartbeatProposal( walletPublicKeyHash [20]byte, proposal *tbtc.HeartbeatProposal, ) error
func (*TbtcChain) ValidateRedemptionProposal ¶ added in v1.21.0
func (tc *TbtcChain) ValidateRedemptionProposal( walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal, ) error