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 (tc *TbtcChain) AssembleInactivityClaim(walletID [32]byte, inactiveMembersIndices []group.MemberIndex, ...) (*tbtc.InactivityClaim, 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) CalculateInactivityClaimHash(claim *inactivity.ClaimPreimage) (inactivity.ClaimHash, error)
- func (tc *TbtcChain) CalculateWalletID(walletPublicKey *ecdsa.PublicKey) ([32]byte, 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) ComputeMovingFundsCommitmentHash(targetWallets [][20]byte) [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) GetDepositMinAge() (uint32, 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) GetInactivityClaimNonce(walletID [32]byte) (*big.Int, error)
- func (tc *TbtcChain) GetLiveWalletsCount() (uint32, error)
- func (tc *TbtcChain) GetMovedFundsSweepRequest(movingFundsTxHash bitcoin.Hash, movingFundsTxOutpointIndex uint32) (*tbtc.MovedFundsSweepRequest, bool, error)
- func (tc *TbtcChain) GetMovingFundsParameters() (txMaxTotalFee uint64, dustThreshold uint64, timeoutResetDelay uint32, ...)
- 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) GetRedemptionDelay(walletPublicKeyHash [20]byte, redeemerOutputScript bitcoin.Script) (time.Duration, 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) GetWalletParameters() (creationPeriod uint32, creationMinBtcBalance uint64, ...)
- 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) IsWalletRegistered(EcdsaWalletID [32]byte) (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 (tc *TbtcChain) OnInactivityClaimed(handler func(event *tbtc.InactivityClaimedEvent)) subscription.EventSubscription
- func (tc *TbtcChain) OnWalletClosed(handler func(event *tbtc.WalletClosedEvent)) 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) PastMovingFundsCommitmentSubmittedEvents(filter *tbtc.MovingFundsCommitmentSubmittedEventFilter) ([]*tbtc.MovingFundsCommitmentSubmittedEvent, error)
- func (tc *TbtcChain) PastMovingFundsCompletedEvents(filter *tbtc.MovingFundsCompletedEventFilter) ([]*tbtc.MovingFundsCompletedEvent, 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) SubmitInactivityClaim(claim *tbtc.InactivityClaim, nonce *big.Int, groupMembers []uint32) error
- func (tc *TbtcChain) SubmitMovedFundsSweepProofWithReimbursement(transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, ...) error
- func (tc *TbtcChain) SubmitMovingFundsCommitment(walletPublicKeyHash [20]byte, walletMainUTXO bitcoin.UnspentTransactionOutput, ...) error
- func (tc *TbtcChain) SubmitMovingFundsProofWithReimbursement(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) ValidateMovedFundsSweepProposal(walletPublicKeyHash [20]byte, proposal *tbtc.MovedFundsSweepProposal) error
- func (tc *TbtcChain) ValidateMovingFundsProposal(walletPublicKeyHash [20]byte, mainUTXO *bitcoin.UnspentTransactionOutput, ...) 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 ¶
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 ¶
type BeaconChain struct {
// contains filtered or unexported fields
}
BeaconChain represents a beacon-specific chain handle.
func (BeaconChain) AverageBlockTime ¶
func (BeaconChain) BlockCounter ¶
func (bc BeaconChain) BlockCounter() (chain.BlockCounter, error)
func (*BeaconChain) CalculateDKGResultHash ¶
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 ¶
func (bc *BeaconChain) CanRestoreRewardEligibility() (bool, error)
Checks whether the operator is able to restore their eligibility for rewards right away.
func (*BeaconChain) CurrentRequestGroupPublicKey ¶
func (bc *BeaconChain) CurrentRequestGroupPublicKey() ([]byte, error)
TODO: Implement a real CurrentRequestGroupPublicKey function.
func (*BeaconChain) CurrentRequestPreviousEntry ¶
func (bc *BeaconChain) CurrentRequestPreviousEntry() ([]byte, error)
TODO: Implement a real CurrentRequestPreviousEntry function.
func (*BeaconChain) CurrentRequestStartBlock ¶
func (bc *BeaconChain) CurrentRequestStartBlock() (*big.Int, error)
TODO: Implement a real CurrentRequestStartBlock function.
func (*BeaconChain) EligibleStake ¶
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 ¶
GetBlockHashByNumber gets the block hash for the given block number.
func (BeaconChain) GetBlockNumberByTimestamp ¶
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 ¶
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 ¶
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 ¶
func (bc *BeaconChain) IsBetaOperator() (bool, error)
Returns true if operator is a beta operator, false otherwise. Chaosnet status does not matter.
func (*BeaconChain) IsChaosnetActive ¶
func (bc *BeaconChain) IsChaosnetActive() (bool, error)
Returns true if the chaosnet phase is active, false otherwise.
func (*BeaconChain) IsEligibleForRewards ¶
func (bc *BeaconChain) IsEligibleForRewards() (bool, error)
IsEligibleForRewards checks whether the operator is eligible for rewards or not.
func (*BeaconChain) IsEntryInProgress ¶
func (bc *BeaconChain) IsEntryInProgress() (bool, error)
TODO: Implement a real IsEntryInProgress function.
func (*BeaconChain) IsGroupRegistered ¶
func (bc *BeaconChain) IsGroupRegistered(groupPublicKey []byte) (bool, error)
TODO: Implement a real IsGroupRegistered function.
func (*BeaconChain) IsOperatorInPool ¶
func (bc *BeaconChain) IsOperatorInPool() (bool, error)
IsOperatorInPool returns true if the operator is registered in the sortition pool.
func (*BeaconChain) IsOperatorUpToDate ¶
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 ¶
func (bc *BeaconChain) IsPoolLocked() (bool, error)
IsPoolLocked returns true if the sortition pool is locked and no state changes are allowed.
func (*BeaconChain) IsRecognized ¶
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 ¶
func (bc *BeaconChain) IsStaleGroup(groupPublicKey []byte) (bool, error)
TODO: Implement a real IsStaleGroup function.
func (*BeaconChain) JoinSortitionPool ¶
func (bc *BeaconChain) JoinSortitionPool() error
JoinSortitionPool executes a transaction to have the operator join the sortition pool.
func (*BeaconChain) OnDKGResultSubmitted ¶
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 ¶
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 ¶
func (bc *BeaconChain) OnGroupRegistered( handler func(groupRegistration *event.GroupRegistration), ) subscription.EventSubscription
TODO: Implement a real OnGroupRegistered function.
func (*BeaconChain) OnRelayEntryRequested ¶
func (bc *BeaconChain) OnRelayEntryRequested( handler func(request *event.RelayEntryRequested), ) subscription.EventSubscription
TODO: Implement a real OnRelayEntryRequested function.
func (*BeaconChain) OnRelayEntrySubmitted ¶
func (bc *BeaconChain) OnRelayEntrySubmitted( handler func(entry *event.RelayEntrySubmitted), ) subscription.EventSubscription
TODO: Implement a real OnRelayEntrySubmitted function.
func (BeaconChain) OperatorKeyPair ¶
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 ¶
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 ¶
func (bc *BeaconChain) ReportRelayEntryTimeout() error
TODO: Implement a real ReportRelayEntryTimeout function.
func (*BeaconChain) RestoreRewardEligibility ¶
func (bc *BeaconChain) RestoreRewardEligibility() error
Restores reward eligibility for the operator.
func (BeaconChain) RolesOf ¶
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 ¶
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 ¶
func (bc *BeaconChain) Staking() (chain.Address, error)
Staking returns address of the TokenStaking contract the RandomBeacon is connected to.
func (*BeaconChain) SubmitDKGResult ¶
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 ¶
func (bc *BeaconChain) SubmitRelayEntry( entry []byte, ) error
TODO: Implement a real SubmitRelayEntry function.
func (*BeaconChain) UpdateOperatorStatus ¶
func (bc *BeaconChain) UpdateOperatorStatus() error
UpdateOperatorStatus executes a transaction to update the operator's state in the sortition pool.
type BitcoinDifficultyChain ¶
type BitcoinDifficultyChain struct {
// contains filtered or unexported fields
}
BitcoinDifficultyChain represents a Bitcoin difficulty-specific chain handle.
func ConnectBitcoinDifficulty ¶
func ConnectBitcoinDifficulty( ctx context.Context, ethereumConfig ethereum.Config, maintainerConfig maintainer.Config, ) ( *BitcoinDifficultyChain, error, )
ConnectBitcoinDifficulty creates Bitcoin difficulty chain handle.
func NewBitcoinDifficultyChain ¶
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 ¶
func (BitcoinDifficultyChain) BlockCounter ¶
func (bc BitcoinDifficultyChain) BlockCounter() (chain.BlockCounter, error)
func (*BitcoinDifficultyChain) CurrentEpoch ¶
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 ¶
GetBlockHashByNumber gets the block hash for the given block number.
func (BitcoinDifficultyChain) GetBlockNumberByTimestamp ¶
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 ¶
func (bdc *BitcoinDifficultyChain) GetCurrentAndPrevEpochDifficulty() ( *big.Int, *big.Int, error, )
GetCurrentAndPrevEpochDifficulty returns the difficulties of the current and previous Bitcoin epochs.
func (*BitcoinDifficultyChain) IsAuthorized ¶
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 ¶
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 ¶
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 ¶
func (bdc *BitcoinDifficultyChain) ProofLength() (uint64, error)
ProofLength returns the number of blocks required for each side of a retarget proof.
func (*BitcoinDifficultyChain) Ready ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (c *Command) GetConfig() *commonEthereum.Config
GetConfig returns the Ethereum config.
func (*Command) SetConfig ¶
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 ¶
type TbtcChain struct {
// contains filtered or unexported fields
}
TbtcChain represents a TBTC-specific chain handle.
func (*TbtcChain) ApproveDKGResult ¶
func (tc *TbtcChain) ApproveDKGResult(dkgResult *tbtc.DKGChainResult) error
func (*TbtcChain) AssembleDKGResult ¶
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) AssembleInactivityClaim ¶
func (tc *TbtcChain) AssembleInactivityClaim( walletID [32]byte, inactiveMembersIndices []group.MemberIndex, signatures map[group.MemberIndex][]byte, heartbeatFailed bool, ) ( *tbtc.InactivityClaim, error, )
func (TbtcChain) AverageBlockTime ¶
func (TbtcChain) BlockCounter ¶
func (bc TbtcChain) BlockCounter() (chain.BlockCounter, error)
func (*TbtcChain) BuildDepositKey ¶
func (*TbtcChain) BuildRedemptionKey ¶
func (*TbtcChain) CalculateDKGResultSignatureHash ¶
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) CalculateInactivityClaimHash ¶
func (tc *TbtcChain) CalculateInactivityClaimHash( claim *inactivity.ClaimPreimage, ) (inactivity.ClaimHash, error)
func (*TbtcChain) CalculateWalletID ¶
func (*TbtcChain) CanRestoreRewardEligibility ¶
Checks whether the operator is able to restore their eligibility for rewards right away.
func (*TbtcChain) ChallengeDKGResult ¶
func (tc *TbtcChain) ChallengeDKGResult(dkgResult *tbtc.DKGChainResult) error
func (*TbtcChain) ComputeMainUtxoHash ¶
func (tc *TbtcChain) ComputeMainUtxoHash( mainUtxo *bitcoin.UnspentTransactionOutput, ) [32]byte
func (*TbtcChain) ComputeMovingFundsCommitmentHash ¶
func (*TbtcChain) DKGParameters ¶
func (tc *TbtcChain) DKGParameters() (*tbtc.DKGParameters, error)
func (*TbtcChain) EligibleStake ¶
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 ¶
GetBlockHashByNumber gets the block hash for the given block number.
func (TbtcChain) GetBlockNumberByTimestamp ¶
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) GetDepositMinAge ¶
func (*TbtcChain) GetDepositParameters ¶
func (*TbtcChain) GetDepositRequest ¶
func (*TbtcChain) GetDepositSweepMaxSize ¶
func (*TbtcChain) GetInactivityClaimNonce ¶
func (*TbtcChain) GetLiveWalletsCount ¶
func (*TbtcChain) GetMovedFundsSweepRequest ¶
func (*TbtcChain) GetMovingFundsParameters ¶
func (tc *TbtcChain) GetMovingFundsParameters() ( txMaxTotalFee uint64, dustThreshold uint64, timeoutResetDelay uint32, timeout uint32, timeoutSlashingAmount *big.Int, timeoutNotifierRewardMultiplier uint32, commitmentGasOffset uint16, sweepTxMaxTotalFee uint64, sweepTimeout uint32, sweepTimeoutSlashingAmount *big.Int, sweepTimeoutNotifierRewardMultiplier uint32, err error, )
func (*TbtcChain) GetOperatorID ¶
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 ¶
func (*TbtcChain) GetRedemptionDelay ¶
func (*TbtcChain) GetRedemptionMaxSize ¶
func (*TbtcChain) GetRedemptionParameters ¶
func (*TbtcChain) GetRedemptionRequestMinAge ¶
func (*TbtcChain) GetWallet ¶
func (tc *TbtcChain) GetWallet( walletPublicKeyHash [20]byte, ) (*tbtc.WalletChainData, error)
func (*TbtcChain) GetWalletParameters ¶
func (*TbtcChain) IsBetaOperator ¶
Returns true if operator is a beta operator, false otherwise. Chaosnet status does not matter.
func (*TbtcChain) IsChaosnetActive ¶
Returns true if the chaosnet phase is active, false otherwise.
func (*TbtcChain) IsDKGResultValid ¶
func (tc *TbtcChain) IsDKGResultValid( dkgResult *tbtc.DKGChainResult, ) (bool, error)
func (*TbtcChain) IsEligibleForRewards ¶
IsEligibleForRewards checks whether the operator is eligible for rewards or not.
func (*TbtcChain) IsOperatorInPool ¶
IsOperatorInPool returns true if the operator is registered in the sortition pool.
func (*TbtcChain) IsOperatorUpToDate ¶
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 ¶
IsPoolLocked returns true if the sortition pool is locked and no state changes are allowed.
func (*TbtcChain) IsRecognized ¶
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) IsWalletRegistered ¶
func (*TbtcChain) JoinSortitionPool ¶
JoinSortitionPool executes a transaction to have the operator join the sortition pool.
func (*TbtcChain) OnDKGResultApproved ¶
func (tc *TbtcChain) OnDKGResultApproved( handler func(event *tbtc.DKGResultApprovedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnDKGResultChallenged ¶
func (tc *TbtcChain) OnDKGResultChallenged( handler func(event *tbtc.DKGResultChallengedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnDKGResultSubmitted ¶
func (tc *TbtcChain) OnDKGResultSubmitted( handler func(event *tbtc.DKGResultSubmittedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnDKGStarted ¶
func (tc *TbtcChain) OnDKGStarted( handler func(event *tbtc.DKGStartedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnInactivityClaimed ¶
func (tc *TbtcChain) OnInactivityClaimed( handler func(event *tbtc.InactivityClaimedEvent), ) subscription.EventSubscription
func (*TbtcChain) OnWalletClosed ¶
func (tc *TbtcChain) OnWalletClosed( handler func(event *tbtc.WalletClosedEvent), ) subscription.EventSubscription
func (TbtcChain) OperatorKeyPair ¶
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 ¶
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 ¶
func (tc *TbtcChain) PastDKGStartedEvents( filter *tbtc.DKGStartedEventFilter, ) ([]*tbtc.DKGStartedEvent, error)
func (*TbtcChain) PastDepositRevealedEvents ¶
func (tc *TbtcChain) PastDepositRevealedEvents( filter *tbtc.DepositRevealedEventFilter, ) ([]*tbtc.DepositRevealedEvent, error)
func (*TbtcChain) PastMovingFundsCommitmentSubmittedEvents ¶
func (tc *TbtcChain) PastMovingFundsCommitmentSubmittedEvents( filter *tbtc.MovingFundsCommitmentSubmittedEventFilter, ) ([]*tbtc.MovingFundsCommitmentSubmittedEvent, error)
func (*TbtcChain) PastMovingFundsCompletedEvents ¶
func (tc *TbtcChain) PastMovingFundsCompletedEvents( filter *tbtc.MovingFundsCompletedEventFilter, ) ([]*tbtc.MovingFundsCompletedEvent, error)
func (*TbtcChain) PastNewWalletRegisteredEvents ¶
func (tc *TbtcChain) PastNewWalletRegisteredEvents( filter *tbtc.NewWalletRegisteredEventFilter, ) ([]*tbtc.NewWalletRegisteredEvent, error)
func (*TbtcChain) PastRedemptionRequestedEvents ¶
func (tc *TbtcChain) PastRedemptionRequestedEvents( filter *tbtc.RedemptionRequestedEventFilter, ) ([]*tbtc.RedemptionRequestedEvent, error)
func (*TbtcChain) RestoreRewardEligibility ¶
Restores reward eligibility for the operator.
func (TbtcChain) RolesOf ¶
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 ¶
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 ¶
Staking returns address of the TokenStaking contract the WalletRegistry is connected to.
func (*TbtcChain) SubmitDKGResult ¶
func (tc *TbtcChain) SubmitDKGResult( dkgResult *tbtc.DKGChainResult, ) error
func (*TbtcChain) SubmitDepositSweepProofWithReimbursement ¶
func (tc *TbtcChain) SubmitDepositSweepProofWithReimbursement( transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, mainUTXO bitcoin.UnspentTransactionOutput, vault common.Address, ) error
func (*TbtcChain) SubmitInactivityClaim ¶
func (*TbtcChain) SubmitMovedFundsSweepProofWithReimbursement ¶
func (tc *TbtcChain) SubmitMovedFundsSweepProofWithReimbursement( transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, mainUTXO bitcoin.UnspentTransactionOutput, ) error
func (*TbtcChain) SubmitMovingFundsCommitment ¶
func (*TbtcChain) SubmitMovingFundsProofWithReimbursement ¶
func (tc *TbtcChain) SubmitMovingFundsProofWithReimbursement( transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, mainUTXO bitcoin.UnspentTransactionOutput, walletPublicKeyHash [20]byte, ) error
func (*TbtcChain) SubmitRedemptionProofWithReimbursement ¶
func (tc *TbtcChain) SubmitRedemptionProofWithReimbursement( transaction *bitcoin.Transaction, proof *bitcoin.SpvProof, mainUTXO bitcoin.UnspentTransactionOutput, walletPublicKeyHash [20]byte, ) error
func (*TbtcChain) TxProofDifficultyFactor ¶
func (*TbtcChain) UpdateOperatorStatus ¶
UpdateOperatorStatus executes a transaction to update the operator's state in the sortition pool.
func (*TbtcChain) ValidateDepositSweepProposal ¶
func (tc *TbtcChain) ValidateDepositSweepProposal( walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, depositsExtraInfo []struct { *tbtc.Deposit FundingTx *bitcoin.Transaction }, ) error
func (*TbtcChain) ValidateHeartbeatProposal ¶
func (tc *TbtcChain) ValidateHeartbeatProposal( walletPublicKeyHash [20]byte, proposal *tbtc.HeartbeatProposal, ) error
func (*TbtcChain) ValidateMovedFundsSweepProposal ¶
func (tc *TbtcChain) ValidateMovedFundsSweepProposal( walletPublicKeyHash [20]byte, proposal *tbtc.MovedFundsSweepProposal, ) error
func (*TbtcChain) ValidateMovingFundsProposal ¶
func (tc *TbtcChain) ValidateMovingFundsProposal( walletPublicKeyHash [20]byte, mainUTXO *bitcoin.UnspentTransactionOutput, proposal *tbtc.MovingFundsProposal, ) error
func (*TbtcChain) ValidateRedemptionProposal ¶
func (tc *TbtcChain) ValidateRedemptionProposal( walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal, ) error