epochs

package
v0.37.3-pr6376 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 30 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

	FlowClient module.SDKClientWrapper // flow access node client

	AccountAddress  sdk.Address      // account belonging to node interacting with the contract
	AccountKeyIndex uint32           // 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 uint32,
	signer sdkcrypto.Signer,
) *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                   []encodable.RandomBeaconPubKey
}

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 ingests the respective protocol notifications which the Protocol State emits when we finalize the first block whose Protocol State further extends the current epoch. The notification is queued for async processing by the worker. Specifically, we cache the next epoch in the EpochLookup. We must process _all_ `EpochCommittedPhaseStarted` notifications. No errors are expected to be returned by the process callback during normal operation.

func (*EpochLookup) EpochExtended added in v0.37.1

func (lookup *EpochLookup) EpochExtended(epochCounter uint64, _ *flow.Header, extension flow.EpochExtension)

EpochExtended listens to `EpochExtended` protocol notifications which the Protocol State emits when we finalize the first block whose Protocol State further extends the current epoch. The next epoch should not be committed so far, because epoch extension are only added when there is no subsequent epoch that we could transition into but the current epoch is nearing its end. The notification is queued for async processing by the worker. Specifically, we update the final view of the latest epoch range with the final view of the current epoch, which will now be updated because the epoch has extensions. We must process _all_ `EpochExtended` notifications. No errors are expected to be returned by the process callback during normal operation.

func (*EpochLookup) EpochForView added in v0.20.0

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

EpochForView returns the counter of the epoch that the input view belongs to. Note: The EpochLookup component processes EpochExtended notifications which will extend the view range for the latest epoch.

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 {
	component.Component
	// 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,
	metrics module.MachineAccountMetrics,
	opts ...MachineAccountValidatorConfigOption,
) (*MachineAccountConfigValidator, error)

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 uint32,
	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:

  • epochs.ClusterQCNoVoteError 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