epochs

package
v0.31.13-compress-badg... Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: AGPL-3.0 Imports: 31 Imported by: 6

Documentation

Index

Constants

View Source
const (

	// TransactionSubmissionTimeout is the time after which we return an error.
	TransactionSubmissionTimeout = 5 * time.Minute

	// TransactionStatusRetryTimeout is the time after which the status of a
	// transaction is checked again
	TransactionStatusRetryTimeout = 1 * time.Second
)

Variables

This section is empty.

Functions

func CheckMachineAccountInfo added in v0.22.0

func CheckMachineAccountInfo(
	log zerolog.Logger,
	conf MachineAccountValidatorConfig,
	role flow.Role,
	info bootstrap.NodeMachineAccountInfo,
	account *sdk.Account,
) error

CheckMachineAccountInfo checks a node machine account config, logging anything noteworthy but not critical, and returning an error if the machine account is not configured correctly, or the configuration cannot be checked.

This function checks most aspects of correct configuration EXCEPT for confirming that the account contains the relevant QCVoter or DKGParticipant resource. This is omitted because it is not possible to query private account info from a script.

func EncodeClusterAssignments added in v0.20.0

func EncodeClusterAssignments(clusterAssignments flow.AssignmentList) []byte

EncodeClusterAssignments encodes a slice of QuorumCertificates into an encoded transaction argument for the deployEpoch transaction used during execution state bootstrapping.

The resulting argument has type [{String: UInt64}] which represents a list of weight mappings for each cluster. The full Cluster struct is constructed within the transaction in Cadence for simplicity here.

func IsClusterQCNoVoteError added in v0.29.0

func IsClusterQCNoVoteError(err error) bool

func WithoutBalanceChecks added in v0.23.9

func WithoutBalanceChecks(conf *MachineAccountValidatorConfig)

WithoutBalanceChecks sets minimum balances to 0 to effectively disable minimum balance checks. This is useful for test networks where transaction fees are disabled.

Types

type BaseClient added in v0.20.0

type BaseClient struct {
	Log zerolog.Logger // default logger

	ContractAddress string                  // contract address
	FlowClient      module.SDKClientWrapper // flow access node client

	AccountAddress  sdk.Address      // account belonging to node interacting with the contract
	AccountKeyIndex uint             // account key index
	Signer          sdkcrypto.Signer // signer used to sign transactions
}

BaseClient represents the core fields and methods needed to create a client to a contract on the Flow Network.

func NewBaseClient added in v0.20.0

func NewBaseClient(
	log zerolog.Logger,
	flowClient module.SDKClientWrapper,
	accountAddress string,
	accountKeyIndex uint,
	signer sdkcrypto.Signer,
	contractAddress string,
) *BaseClient

NewBaseClient creates a instance of BaseClient

func (*BaseClient) GetAccount added in v0.20.0

func (c *BaseClient) GetAccount(ctx context.Context) (*sdk.Account, error)

GetAccount returns the current state for the account associated with the BaseClient. Error returns:

  • network.TransientError for any errors from the underlying client
  • generic error in case of unexpected critical failure

func (*BaseClient) SendTransaction added in v0.20.0

func (c *BaseClient) SendTransaction(ctx context.Context, tx *sdk.Transaction) (sdk.Identifier, error)

SendTransaction submits a transaction to Flow. Requires transaction to be signed. Error returns:

  • network.TransientError for any errors from the underlying client
  • generic error in case of unexpected critical failure

func (*BaseClient) WaitForSealed added in v0.20.0

func (c *BaseClient) WaitForSealed(ctx context.Context, txID sdk.Identifier, started time.Time) error

WaitForSealed waits for a transaction to be sealed Error returns:

  • network.TransientError for any errors from the underlying client, if the retry period has been exceeded
  • errTransactionExpired if the transaction has expired
  • errTransactionReverted if the transaction execution reverted
  • generic error in case of unexpected critical failure

type ClusterQCNoVoteError added in v0.29.0

type ClusterQCNoVoteError struct {
	Err error
}

ClusterQCNoVoteError is returned when a ClusterRootQCVoter fails to submit a vote for reasons we consider benign, either:

  • we have reached a retry limit for transient failures
  • we have decided to not submit the vote, for example because we are not in the EpochSetup phase

func NewClusterQCNoVoteErrorf added in v0.29.0

func NewClusterQCNoVoteErrorf(msg string, args ...interface{}) ClusterQCNoVoteError

func (ClusterQCNoVoteError) Error added in v0.29.0

func (err ClusterQCNoVoteError) Error() string

func (ClusterQCNoVoteError) Unwrap added in v0.29.0

func (err ClusterQCNoVoteError) Unwrap() error

type EpochConfig added in v0.20.0

type EpochConfig struct {
	EpochTokenPayout             cadence.UFix64
	RewardCut                    cadence.UFix64
	CurrentEpochCounter          cadence.UInt64
	NumViewsInEpoch              cadence.UInt64
	NumViewsInStakingAuction     cadence.UInt64
	NumViewsInDKGPhase           cadence.UInt64
	NumCollectorClusters         cadence.UInt16
	FLOWsupplyIncreasePercentage cadence.UFix64
	RandomSource                 cadence.String
	CollectorClusters            flow.AssignmentList
	ClusterQCs                   []*flow.QuorumCertificate
	DKGPubKeys                   []crypto.PublicKey
}

EpochConfig is a placeholder for config values used to deploy the epochs smart-contract.

func DefaultEpochConfig added in v0.20.0

func DefaultEpochConfig() EpochConfig

DefaultEpochConfig returns an EpochConfig with default values used for testing.

type EpochLookup added in v0.20.0

type EpochLookup struct {
	events.Noop // implements protocol.Consumer
	component.Component
	// contains filtered or unexported fields
}

EpochLookup implements the EpochLookup interface using protocol state to match views to epochs. CAUTION: EpochLookup should only be used for querying the previous, current, or next epoch.

func NewEpochLookup added in v0.20.0

func NewEpochLookup(state protocol.State) (*EpochLookup, error)

NewEpochLookup instantiates a new EpochLookup

func (*EpochLookup) EpochCommittedPhaseStarted added in v0.29.0

func (lookup *EpochLookup) EpochCommittedPhaseStarted(_ uint64, first *flow.Header)

EpochCommittedPhaseStarted informs the `committee.Consensus` that the block starting the Epoch Committed Phase has been finalized.

func (*EpochLookup) EpochEmergencyFallbackTriggered added in v0.29.0

func (lookup *EpochLookup) EpochEmergencyFallbackTriggered()

EpochEmergencyFallbackTriggered passes the protocol event to the worker thread.

func (*EpochLookup) EpochForViewWithFallback added in v0.21.1

func (lookup *EpochLookup) EpochForViewWithFallback(view uint64) (uint64, error)

EpochForViewWithFallback returns the counter of the epoch that the input view belongs to. If epoch fallback has been triggered, returns the last committed epoch counter in perpetuity for any inputs beyond the last committed epoch view range. For example, if we trigger epoch fallback during epoch 10, and reach the final view of epoch 10 before epoch 11 has finished being setup, this function will return 10 even for input views beyond the final view of epoch 10.

Returns model.ErrViewForUnknownEpoch if the input does not fall within the range of a known epoch.

type MachineAccountConfigValidator added in v0.22.0

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

MachineAccountConfigValidator is used to validate that a machine account is configured correctly.

func NewMachineAccountConfigValidator added in v0.22.0

func NewMachineAccountConfigValidator(
	log zerolog.Logger,
	flowClient *client.Client,
	role flow.Role,
	info bootstrap.NodeMachineAccountInfo,
	opts ...MachineAccountValidatorConfigOption,
) (*MachineAccountConfigValidator, error)

func (*MachineAccountConfigValidator) Done added in v0.22.0

func (validator *MachineAccountConfigValidator) Done() <-chan struct{}

Done will cancel the context of the unit, which will end the validator goroutine, if it is still running.

func (*MachineAccountConfigValidator) Ready added in v0.22.0

func (validator *MachineAccountConfigValidator) Ready() <-chan struct{}

Ready will launch the validator function in a goroutine.

type MachineAccountValidatorConfig added in v0.23.9

type MachineAccountValidatorConfig struct {
	SoftMinBalanceLN cadence.UFix64
	HardMinBalanceLN cadence.UFix64
	SoftMinBalanceSN cadence.UFix64
	HardMinBalanceSN cadence.UFix64
}

MachineAccountValidatorConfig defines configuration options for MachineAccountConfigValidator.

func DefaultMachineAccountValidatorConfig added in v0.23.9

func DefaultMachineAccountValidatorConfig() MachineAccountValidatorConfig

type MachineAccountValidatorConfigOption added in v0.23.9

type MachineAccountValidatorConfigOption func(*MachineAccountValidatorConfig)

type MockQCContractClient added in v0.20.0

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

func NewMockQCContractClient added in v0.20.0

func NewMockQCContractClient(log zerolog.Logger) *MockQCContractClient

func (*MockQCContractClient) SubmitVote added in v0.20.0

func (c *MockQCContractClient) SubmitVote(ctx context.Context, vote *model.Vote) error

func (*MockQCContractClient) Voted added in v0.20.0

func (c *MockQCContractClient) Voted(ctx context.Context) (bool, error)

type QCContractClient added in v0.20.0

type QCContractClient struct {
	BaseClient
	// contains filtered or unexported fields
}

QCContractClient is a client to the Quorum Certificate contract. Allows the client to functionality to submit a vote and check if collection node has voted already.

func NewQCContractClient added in v0.20.0

func NewQCContractClient(
	log zerolog.Logger,
	flowClient module.SDKClientWrapper,
	flowClientANID flow.Identifier,
	nodeID flow.Identifier,
	accountAddress string,
	accountKeyIndex uint,
	qcContractAddress string,
	signer sdkcrypto.Signer,
) *QCContractClient

NewQCContractClient returns a new client to the Quorum Certificate contract

func (*QCContractClient) SubmitVote added in v0.20.0

func (c *QCContractClient) SubmitVote(ctx context.Context, vote *model.Vote) error

SubmitVote submits the given vote to the cluster QC aggregator smart contract. This function returns only once the transaction has been processed by the network. An error is returned if the transaction has failed and should be re-submitted. Error returns:

  • network.TransientError for any errors from the underlying client, if the retry period has been exceeded
  • errTransactionExpired if the transaction has expired
  • errTransactionReverted if the transaction execution reverted
  • generic error in case of unexpected critical failure

func (*QCContractClient) Voted added in v0.20.0

func (c *QCContractClient) Voted(ctx context.Context) (bool, error)

Voted returns true if we have successfully submitted a vote to the cluster QC aggregator smart contract for the current epoch. Error returns:

  • network.TransientError for any errors from the underlying Flow client
  • generic error in case of unexpected critical failures

type RootQCVoter

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

RootQCVoter is responsible for generating and submitting votes for the root quorum certificate of the upcoming epoch for this node's cluster.

func NewRootQCVoter

func NewRootQCVoter(
	log zerolog.Logger,
	me module.Local,
	signer hotstuff.Signer,
	state protocol.State,
	contractClients []module.QCContractClient,
) *RootQCVoter

NewRootQCVoter returns a new root QC voter, configured for a particular epoch.

func (*RootQCVoter) Vote

func (voter *RootQCVoter) Vote(ctx context.Context, epoch protocol.Epoch) error

Vote handles the full procedure of generating a vote, submitting it to the epoch smart contract, and verifying submission. It is safe to run multiple times within a single setup phase.

Error returns:

  • ErrWontVote if we fail to vote for a benign reason
  • generic error in case of critical unexpected failure

Jump to

Keyboard shortcuts

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