Documentation
¶
Overview ¶
Package staking contains the definitions and operations related to active participant staking mechanism in the system. The package provides two main types: ActiveParticipants and activeParticipantsQuerier. ActiveParticipants is an interface that represents the active participants of the system and their operations. activeParticipantsQuerier is an implementation of the ActiveParticipants interface that queries the active participants.
Index ¶
- Variables
- func BeginDisputeResolutionTx(from types.Address, probationAddr types.Address, gasLimit uint64) (*types.Transaction, error)
- func DecodeParticipants(method *abi.Method, returnValue []byte) ([]types.Address, error)
- func EndDisputeResolutionTx(from types.Address, probationAddr types.Address, gasLimit uint64) (*types.Transaction, error)
- func GetMaximumParticipantsTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func GetMaximumSequencersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func GetMaximumWatchtowersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func GetMinimumParticipantsTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func GetMinimumSequencersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func GetMinimumWatchtowersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func GetThresholdTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func IsBeginDisputeResolutionTx(tx *types.Transaction) (bool, error)
- func NewVerifier(as ActiveParticipants, logger hclog.Logger) blockchain.Verifier
- func QueryActiveSequencers(blockchain *blockchain.Blockchain, executor *state.Executor, ...) ([]types.Address, error)
- func QueryDisputedSequencerAddr(t *state.Transition, gasLimit uint64, from types.Address, ...) (types.Address, error)
- func QueryDisputedWatchtowerAddr(t *state.Transition, gasLimit uint64, from types.Address, ...) (types.Address, error)
- func QueryDisputedWatchtowers(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
- func QueryParticipantBalance(t *state.Transition, gasLimit uint64, from types.Address, addr types.Address) (*big.Int, error)
- func QueryParticipantTotalStakedAmount(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
- func QueryParticipants(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
- func QuerySequencers(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
- func QuerySequencersInProbation(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
- func QueryWatchtower(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
- func SetMaximumParticipantsTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
- func SetMaximumSequencersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
- func SetMaximumWatchtowersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
- func SetMinimumParticipantsTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
- func SetMinimumSequencersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
- func SetMinimumWatchtowersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
- func SetThresholdTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
- func Slash(bh *blockchain.Blockchain, exec *state.Executor, logger hclog.Logger, ...) error
- func SlashStakerTx(activeSequencerAddr types.Address, maliciousStakerAddr types.Address, ...) (*types.Transaction, error)
- func Stake(bh *blockchain.Blockchain, exec *state.Executor, sender Sender, ...) error
- func StakeTx(from types.Address, amount *big.Int, nodeType string, gasLimit uint64) (*types.Transaction, error)
- func UnStake(bh *blockchain.Blockchain, exec *state.Executor, sender Sender, ...) error
- func UnStakeTx(from types.Address, gasLimit uint64) (*types.Transaction, error)
- type ActiveParticipants
- type ActiveSequencers
- type DisputeResolution
- type DumbActiveParticipants
- func (dasq *DumbActiveParticipants) Contains(_ types.Address, nodeType NodeType) (bool, error)
- func (dasq *DumbActiveParticipants) Get(nodeType NodeType) ([]types.Address, error)
- func (dasq *DumbActiveParticipants) GetBalance(_ types.Address) (*big.Int, error)
- func (dasq *DumbActiveParticipants) GetTotalStakedAmount() (*big.Int, error)
- func (dasq *DumbActiveParticipants) InProbation(_ types.Address) (bool, error)
- type Node
- type NodeType
- type ParticipantRate
- type RandomSeedFn
- type Sender
- type SequencerRate
- type Threshold
- type WatchtowerRate
Constants ¶
This section is empty.
Variables ¶
var AddrStakingContract = types.StringToAddress("0x0110000000000000000000000000000000000001")
AddrStakingContract represents the staking contract address.
var MaxSequencerCount = common.MaxSafeJSInt
MaxSequencerCount is the maximum number of sequencers allowed.
var MinSequencerCount = uint64(1)
MinSequencerCount is the minimum number of sequencers required.
Functions ¶
func BeginDisputeResolutionTx ¶
func BeginDisputeResolutionTx(from types.Address, probationAddr types.Address, gasLimit uint64) (*types.Transaction, error)
BeginDisputeResolutionTx constructs a transaction to initiate the dispute resolution process on the Staking contract.
It takes in the initiator's address, the probation address and a gas limit.
The function generates a selector for the BeginDisputeResolution method from the Staking contract ABI. Then, it encodes the probation address as an input for this method and includes this data in the newly created transaction.
This transaction can be submitted to the network to initiate the dispute resolution process.
Parameters:
from - The address of the transaction initiator. probationAddr - The address of the probation sequencer. gasLimit - The gas limit for the transaction.
Returns:
A pointer to the newly created transaction. An error if there was an issue creating the transaction.
Example:
tx, err := BeginDisputeResolutionTx(fromAddress, probationAddress, 50000)
if err != nil {
log.Fatalf("failed to create dispute resolution transaction: %s", err)
}
func DecodeParticipants ¶
DecodeParticipants decodes the returned results from the staking contract into addresses. It takes a method object and the returned value as parameters. It returns a slice of addresses decoded from the returned value and an error if the operation fails.
func EndDisputeResolutionTx ¶
func EndDisputeResolutionTx(from types.Address, probationAddr types.Address, gasLimit uint64) (*types.Transaction, error)
EndDisputeResolutionTx constructs a transaction to conclude the dispute resolution process on the Staking contract.
Similarly to BeginDisputeResolutionTx, it creates a transaction which includes the EndDisputeResolution method selector and the encoded input parameters.
Parameters:
from - The address of the transaction initiator. probationAddr - The address of the probation sequencer. gasLimit - The gas limit for the transaction.
Returns:
A pointer to the newly created transaction. An error if there was an issue creating the transaction.
Example:
tx, err := EndDisputeResolutionTx(fromAddress, probationAddress, 50000)
if err != nil {
log.Fatalf("failed to create dispute resolution conclusion transaction: %s", err)
}
func GetMaximumParticipantsTx ¶
func GetMaximumParticipantsTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
GetMaximumParticipantsTx retrieves the current maximum number of participants from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns the current maximum value as a big.Int and an error if the operation fails.
func GetMaximumSequencersTx ¶
func GetMaximumSequencersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
GetMaximumSequencersTx retrieves the current maximum number of sequencers from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns the current maximum value as a big.Int and an error if the operation fails.
func GetMaximumWatchtowersTx ¶
func GetMaximumWatchtowersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
GetMaximumWatchtowersTx retrieves the maximum number of watchtowers from the staking system. It takes a state transition, gas limit, and sender address as parameters. The maximum number of watchtowers is returned as a *big.Int or an error if the operation fails.
func GetMinimumParticipantsTx ¶
func GetMinimumParticipantsTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
GetMinimumParticipantsTx retrieves the current minimum number of participants from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns the current minimum value as a big.Int and an error if the operation fails.
func GetMinimumSequencersTx ¶
func GetMinimumSequencersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
GetMinimumSequencersTx retrieves the current minimum number of sequencers from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns the current minimum value as a big.Int and an error if the operation fails.
func GetMinimumWatchtowersTx ¶
func GetMinimumWatchtowersTx(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
GetMinimumWatchtowersTx retrieves the minimum number of watchtowers from the staking system. It takes a state transition, gas limit, and sender address as parameters. The minimum number of watchtowers is returned as a *big.Int or an error if the operation fails.
func GetThresholdTx ¶
GetThresholdTx returns the current staking threshold from the transition state.
func IsBeginDisputeResolutionTx ¶
func IsBeginDisputeResolutionTx(tx *types.Transaction) (bool, error)
IsBeginDisputeResolutionTx checks if the given transaction is a dispute resolution initiation transaction.
This is done by decoding the input data in the transaction and comparing it with the expected method selector and parameters.
Parameters:
tx - The transaction to check.
Returns:
true if the transaction is a dispute resolution initiation transaction, false otherwise. An error if there was an issue checking the transaction.
Example:
isDisputeTx, err := IsBeginDisputeResolutionTx(tx)
if err != nil {
log.Fatalf("failed to check dispute resolution transaction: %s", err)
}
func NewVerifier ¶
func NewVerifier(as ActiveParticipants, logger hclog.Logger) blockchain.Verifier
NewVerifier returns a new instance of the blockchain.Verifier. It takes ActiveParticipants and a logger as parameters.
func QueryActiveSequencers ¶
func QueryActiveSequencers(blockchain *blockchain.Blockchain, executor *state.Executor, t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
QueryActiveSequencers queries the current active sequencers from the staking contract. It takes a blockchain, an executor, a transaction transition, gas limit, and the address of the sender as parameters. It returns a slice of addresses representing the current active sequencers and an error if the operation fails.
func QueryDisputedSequencerAddr ¶
func QueryDisputedSequencerAddr(t *state.Transition, gasLimit uint64, from types.Address, watchtowerAddr types.Address) (types.Address, error)
QueryDisputedSequencerAddr calls the GetDisputedSequencerAddrs method on the Staking contract.
It sends a transaction to query the contract and returns the result.
Parameters:
t - The state transition object. gasLimit - The gas limit for the transaction. from - The address of the query initiator. watchtowerAddr - The address of the watchtower.
Returns:
The disputed sequencer address. An error if there was an issue querying the address.
Example:
disputedSequencer, err := QueryDisputedSequencerAddr(transition, 50000, fromAddress, watchtowerAddress)
if err != nil {
log.Fatalf("failed to query disputed sequencer address: %s", err)
}
func QueryDisputedWatchtowerAddr ¶
func QueryDisputedWatchtowerAddr(t *state.Transition, gasLimit uint64, from types.Address, sequencerAddr types.Address) (types.Address, error)
QueryDisputedWatchtowerAddr calls the GetDisputedWatchtowerAddr method on the Staking contract.
It sends a transaction to query the contract and returns the result.
Parameters:
t - The state transition object. gasLimit - The gas limit for the transaction. from - The address of the query initiator. sequencerAddr - The address of the sequencer.
Returns:
The disputed watchtower address. An error if there was an issue querying the address.
Example:
disputedWatchtower, err := QueryDisputedWatchtowerAddr(transition, 50000, fromAddress, sequencerAddress)
if err != nil {
log.Fatalf("failed to query disputed watchtower address: %s", err)
}
func QueryDisputedWatchtowers ¶
func QueryDisputedWatchtowers(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
QueryDisputedWatchtowers calls the GetCurrentDisputeWatchtowers method on the Staking contract.
It sends a transaction to query the contract and returns the result.
Parameters:
t - The state transition object. gasLimit - The gas limit for the transaction. from - The address of the query initiator.
Returns:
An array of disputed watchtower addresses. An error if there was an issue querying the addresses.
Example:
disputedWatchtowers, err := QueryDisputedWatchtowers(transition, 50000, fromAddress)
if err != nil {
log.Fatalf("failed to query disputed watchtower addresses: %s", err)
}
func QueryParticipantBalance ¶
func QueryParticipantBalance(t *state.Transition, gasLimit uint64, from types.Address, addr types.Address) (*big.Int, error)
QueryParticipantBalance queries the staked amount of a participant from the staking contract. It takes a transaction transition, gas limit, the address of the sender, and the address of the participant as parameters. It returns the staked amount as a big.Int value and an error if the operation fails.
func QueryParticipantTotalStakedAmount ¶
func QueryParticipantTotalStakedAmount(t *state.Transition, gasLimit uint64, from types.Address) (*big.Int, error)
QueryParticipantTotalStakedAmount queries the total staked amount from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns the total staked amount as a big.Int value and an error if the operation fails.
func QueryParticipants ¶
func QueryParticipants(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
QueryParticipants queries the current participants from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns a slice of addresses representing the current participants and an error if the operation fails.
func QuerySequencers ¶
func QuerySequencers(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
QuerySequencers queries the current sequencers from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns a slice of addresses representing the current sequencers and an error if the operation fails.
func QuerySequencersInProbation ¶
func QuerySequencersInProbation(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
QuerySequencersInProbation queries the current sequencers in probation from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns a slice of addresses representing the sequencers in probation and an error if the operation fails.
func QueryWatchtower ¶
func QueryWatchtower(t *state.Transition, gasLimit uint64, from types.Address) ([]types.Address, error)
QueryWatchtower queries the current watchtowers from the staking contract. It takes a transaction transition, gas limit, and the address of the sender as parameters. It returns a slice of addresses representing the current watchtowers and an error if the operation fails.
func SetMaximumParticipantsTx ¶
func SetMaximumParticipantsTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
SetMaximumParticipantsTx creates a transaction to set the maximum number of participants. It takes the sender address, the new maximum value, and the gas limit as parameters. It returns the transaction and an error if the operation fails.
func SetMaximumSequencersTx ¶
func SetMaximumSequencersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
SetMaximumSequencersTx creates a transaction to set the maximum number of sequencers. It takes the sender address, the new maximum value, and the gas limit as parameters. It returns the transaction and an error if the operation fails.
func SetMaximumWatchtowersTx ¶
func SetMaximumWatchtowersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
SetMaximumWatchtowersTx creates a transaction to set the maximum number of watchtowers. It takes the sender address, the new maximum value, and the gas limit as parameters. The transaction is returned or an error if it fails.
func SetMinimumParticipantsTx ¶
func SetMinimumParticipantsTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
SetMinimumParticipantsTx creates a transaction to set the minimum number of participants. It takes the sender address, the new minimum value, and the gas limit as parameters. It returns the transaction and an error if the operation fails.
func SetMinimumSequencersTx ¶
func SetMinimumSequencersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
SetMinimumSequencersTx creates a transaction to set the minimum number of sequencers. It takes the sender address, the new minimum value, and the gas limit as parameters. It returns the transaction and an error if the operation fails.
func SetMinimumWatchtowersTx ¶
func SetMinimumWatchtowersTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
SetMinimumWatchtowersTx creates a transaction to set the minimum number of watchtowers. It takes the sender address, the new minimum value, and the gas limit as parameters. The transaction is returned or an error if it fails.
func SetThresholdTx ¶
func SetThresholdTx(from types.Address, amount *big.Int, gasLimit uint64) (*types.Transaction, error)
SetThresholdTx returns a transaction to set the staking threshold.
func Slash ¶
func Slash(bh *blockchain.Blockchain, exec *state.Executor, logger hclog.Logger, activeSequencerAddr types.Address, activeSequencerSignKey *ecdsa.PrivateKey, maliciousStakerAddr types.Address, gasLimit uint64, nodeType string) error
Slash slashes the malicious staker address by the active sequencer. It builds a block, signs it with the active sequencer's key, adds the slash transaction, and writes the block to the blockchain.
func SlashStakerTx ¶
func SlashStakerTx(activeSequencerAddr types.Address, maliciousStakerAddr types.Address, gasLimit uint64) (*types.Transaction, error)
SlashStakerTx returns a slash transaction to slash the malicious staker address.
func Stake ¶
func Stake(bh *blockchain.Blockchain, exec *state.Executor, sender Sender, logger hclog.Logger, nodeType string, stakerAddr types.Address, stakerKey *ecdsa.PrivateKey, amount *big.Int, gasLimit uint64, src string) error
Stake stakes the specified amount for the given staker address and node type. It builds a block, signs it with the staker's key, adds the stake transaction, sends the block to the sender, and writes the block to the blockchain.
func StakeTx ¶
func StakeTx(from types.Address, amount *big.Int, nodeType string, gasLimit uint64) (*types.Transaction, error)
StakeTx returns a stake transaction with the specified parameters.
func UnStake ¶
func UnStake(bh *blockchain.Blockchain, exec *state.Executor, sender Sender, logger hclog.Logger, stakerAddr types.Address, stakerKey *ecdsa.PrivateKey, gasLimit uint64, src string) error
UnStake unstakes the given staker address. It builds a block, signs it with the staker's key, adds the unstake transaction, sends the block to the sender, and writes the block to the blockchain.
Types ¶
type ActiveParticipants ¶
type ActiveParticipants interface {
Get(nodeType NodeType) ([]types.Address, error)
Contains(addr types.Address, nodeType NodeType) (bool, error)
InProbation(address types.Address) (bool, error)
GetBalance(addr types.Address) (*big.Int, error)
GetTotalStakedAmount() (*big.Int, error)
}
ActiveParticipants is an interface for obtaining details about active participants in the network. It includes methods for getting participant addresses, checking participant existence, checking probation status, and getting balances.
func NewActiveParticipantsQuerier ¶
func NewActiveParticipantsQuerier(blockchain *blockchain.Blockchain, executor *state.Executor, logger hclog.Logger) ActiveParticipants
NewActiveParticipantsQuerier creates a new instance of activeParticipantsQuerier. It takes a blockchain, executor, and logger as parameters. It returns the ActiveParticipants interface.
type ActiveSequencers ¶
type ActiveSequencers interface {
// Get returns the list of currently active sequencers.
// It deterministically randomizes the list using the provided seed and returns it.
// An error is returned if the operation fails.
Get() ([]types.Address, error)
// Contains checks if the given address is in the list of currently active sequencers.
// It returns true if the address is found, false otherwise.
// An error is returned if the operation fails.
Contains(addr types.Address) (bool, error)
}
ActiveSequencers is an interface for managing the list of currently active sequencers.
func NewCachingRandomizedActiveSequencersQuerier ¶
func NewCachingRandomizedActiveSequencersQuerier(rngSeedFn RandomSeedFn, activeParticipants ActiveParticipants) ActiveSequencers
NewCachingRandomizedActiveSequencersQuerier creates a new cachingRandomizedActiveSequencersQuerier instance. It returns an implementation of the ActiveSequencers interface that deterministically randomizes the list of currently active sequencers. The return value of the Get method will be the same for the same seed and list of addresses from ActiveSequencers.
func NewRandomizedActiveSequencersQuerier ¶
func NewRandomizedActiveSequencersQuerier(rngSeedFn RandomSeedFn, activeParticipants ActiveParticipants) ActiveSequencers
NewRandomizedActiveSequencersQuerier creates a new instance of randomizedActiveSequencersQuerier. It returns an implementation of the ActiveSequencers interface that deterministically randomizes the list of currently active sequencers. The return value of the Get method will be the same for the same seed and list of addresses from ActiveParticipants.
type DisputeResolution ¶
type DisputeResolution interface {
// Get retrieves the addresses of nodes of the given node type
// that are currently under dispute.
Get(nodeType NodeType) ([]types.Address, error)
// Contains checks if a given address is in dispute for a specific node type.
Contains(addr types.Address, nodeType NodeType) (bool, error)
// GetSequencerAddr gets the address of a sequencer that's under dispute
// for a given watchtower address.
GetSequencerAddr(watchtowerAddr types.Address) (types.Address, error)
// GetWatchtowerAddr gets the address of a watchtower that's under dispute
// for a given sequencer address.
GetWatchtowerAddr(sequencerAddr types.Address) (types.Address, error)
// Begin initiates a dispute resolution process for a node with a specific address.
// The process is signed with the provided private key.
Begin(probationAddr types.Address, signKey *ecdsa.PrivateKey) error
// End finalizes a dispute resolution process for a node with a specific address.
// The process is signed with the provided private key.
End(probationAddr types.Address, signKey *ecdsa.PrivateKey) error
}
DisputeResolution defines the methods required for interacting with the dispute resolution smart contract. It provides functionality for querying and manipulating the contract's state.
func NewDisputeResolution ¶
func NewDisputeResolution(blockchain *blockchain.Blockchain, executor *state.Executor, sender Sender, logger hclog.Logger) DisputeResolution
NewDisputeResolution creates a new instance of disputeResolution with the provided blockchain, executor, sender, and logger.
Parameters:
blockchain - The blockchain instance. executor - The executor instance. sender - The sender instance. logger - The logger instance.
Returns:
A new instance of disputeResolution.
Example:
dr := NewDisputeResolution(blockchain, executor, sender, logger)
type DumbActiveParticipants ¶
type DumbActiveParticipants struct{}
DumbActiveParticipants is a struct with no behavior, intended for testing purposes. All its methods return nil values.
func (*DumbActiveParticipants) Contains ¶
Contains method of DumbActiveParticipants struct always returns true. It satisfies the ActiveParticipants interface.
func (*DumbActiveParticipants) Get ¶
func (dasq *DumbActiveParticipants) Get(nodeType NodeType) ([]types.Address, error)
Get method of DumbActiveParticipants struct always returns nil values. It satisfies the ActiveParticipants interface.
func (*DumbActiveParticipants) GetBalance ¶
GetBalance method of DumbActiveParticipants struct always returns nil values. It satisfies the ActiveParticipants interface.
func (*DumbActiveParticipants) GetTotalStakedAmount ¶
func (dasq *DumbActiveParticipants) GetTotalStakedAmount() (*big.Int, error)
GetTotalStakedAmount method of DumbActiveParticipants struct always returns nil values. It satisfies the ActiveParticipants interface.
func (*DumbActiveParticipants) InProbation ¶
func (dasq *DumbActiveParticipants) InProbation(_ types.Address) (bool, error)
InProbation method of DumbActiveParticipants struct always returns true. It satisfies the ActiveParticipants interface.
type Node ¶
type Node interface {
ShouldStake(pkey *ecdsa.PrivateKey) bool
Stake(amount *big.Int, pkey *ecdsa.PrivateKey) error
UnStake(pkey *ecdsa.PrivateKey) error
}
Node interface represents the staking-related operations a node can perform.
func NewNode ¶
func NewNode(blockchain *blockchain.Blockchain, executor *state.Executor, sender Sender, logger hclog.Logger, nodeType NodeType) Node
NewNode creates a new instance of node with the provided blockchain, executor, sender, logger, and node type.
Parameters:
blockchain - The blockchain instance. executor - The executor instance. sender - The sender instance. logger - The logger instance. nodeType - The type of the node (sequencer or watchtower).
Returns:
A new instance of node.
Example:
n := NewNode(blockchain, executor, sender, logger, Sequencer)
type NodeType ¶
type NodeType string
NodeType represents a type of node, either Sequencer or Watchtower.
type ParticipantRate ¶
type ParticipantRate interface {
// CurrentMinimum returns the current minimum number of participants.
// It retrieves the value from the staking system and returns it as a *big.Int.
// An error is returned if the operation fails.
CurrentMinimum() (*big.Int, error)
// CurrentMaximum returns the current maximum number of participants.
// It retrieves the value from the staking system and returns it as a *big.Int.
// An error is returned if the operation fails.
CurrentMaximum() (*big.Int, error)
// SetMinimum sets the minimum number of participants.
// It takes the new minimum value and a signing key as parameters.
// An error is returned if the operation fails.
SetMinimum(newMin *big.Int, signKey *ecdsa.PrivateKey) error
// SetMaximum sets the maximum number of participants.
// It takes the new maximum value and a signing key as parameters.
// An error is returned if the operation fails.
SetMaximum(newMin *big.Int, signKey *ecdsa.PrivateKey) error
}
ParticipantRate is an interface for managing the minimum and maximum number of participants.
func NewParticipantRater ¶
func NewParticipantRater(blockchain *blockchain.Blockchain, executor *state.Executor, logger hclog.Logger) ParticipantRate
NewParticipantRater creates a new instance of participantRate. It takes a blockchain, executor, and logger as parameters and returns a ParticipantRate interface.
type RandomSeedFn ¶
type RandomSeedFn func() int64
RandomSeedFn is a function interface to provide a seed to the deterministic RNG used to shuffle sequencer addresses.
type Sender ¶
type Sender interface {
// Send sends the given block.
// It takes a *types.Block as a parameter and returns an error if the operation fails.
Send(blk *types.Block) error
}
Sender is an interface for sending blocks.
func NewTestAvailSender ¶
func NewTestAvailSender() Sender
NewTestAvailSender creates a new instance of the testAvailSender. It returns a Sender interface that can be used for testing purposes.
type SequencerRate ¶
type SequencerRate interface {
// CurrentMinimum returns the current minimum number of sequencers.
// It retrieves the value from the staking system and returns it as a *big.Int.
// An error is returned if the operation fails.
CurrentMinimum() (*big.Int, error)
// CurrentMaximum returns the current maximum number of sequencers.
// It retrieves the value from the staking system and returns it as a *big.Int.
// An error is returned if the operation fails.
CurrentMaximum() (*big.Int, error)
// SetMinimum sets the minimum number of sequencers.
// It takes the new minimum value and a signing key as parameters.
// An error is returned if the operation fails.
SetMinimum(newMin *big.Int, signKey *ecdsa.PrivateKey) error
// SetMaximum sets the maximum number of sequencers.
// It takes the new maximum value and a signing key as parameters.
// An error is returned if the operation fails.
SetMaximum(newMin *big.Int, signKey *ecdsa.PrivateKey) error
}
SequencerRate is an interface for managing the minimum and maximum number of sequencers.
func NewSequencerRater ¶
func NewSequencerRater(blockchain *blockchain.Blockchain, executor *state.Executor, logger hclog.Logger) SequencerRate
NewSequencerRater creates a new instance of sequencerRate. It takes a blockchain, executor, and logger as parameters and returns a SequencerRate interface.
type Threshold ¶
type Threshold interface {
// Set sets the new staking threshold value.
// It takes the new amount and a signing key as parameters.
// An error is returned if the operation fails.
Set(newAmount *big.Int, signKey *ecdsa.PrivateKey) error
// Current returns the current staking threshold value.
// It retrieves the value from the staking system and returns it as a *big.Int.
// An error is returned if the operation fails.
Current() (*big.Int, error)
}
Threshold represents an interface for managing the staking threshold.
func NewStakingThresholdQuerier ¶
func NewStakingThresholdQuerier(blockchain *blockchain.Blockchain, executor *state.Executor, logger hclog.Logger) Threshold
NewStakingThresholdQuerier returns a new instance of the staking threshold querier.
type WatchtowerRate ¶
type WatchtowerRate interface {
// CurrentMinimum returns the current minimum number of watchtowers.
// It retrieves the value from the staking system and returns it as a *big.Int.
// An error is returned if the operation fails.
CurrentMinimum() (*big.Int, error)
// CurrentMaximum returns the current maximum number of watchtowers.
// It retrieves the value from the staking system and returns it as a *big.Int.
// An error is returned if the operation fails.
CurrentMaximum() (*big.Int, error)
// SetMinimum sets the minimum number of watchtowers.
// It takes the new minimum value and a signing key as parameters.
// An error is returned if the operation fails.
SetMinimum(newMin *big.Int, signKey *ecdsa.PrivateKey) error
// SetMaximum sets the maximum number of watchtowers.
// It takes the new maximum value and a signing key as parameters.
// An error is returned if the operation fails.
SetMaximum(newMax *big.Int, signKey *ecdsa.PrivateKey) error
}
WatchtowerRate is an interface for managing the minimum and maximum number of watchtowers.
func NewWatchtowerRater ¶
func NewWatchtowerRater(blockchain *blockchain.Blockchain, executor *state.Executor, logger hclog.Logger) WatchtowerRate
NewWatchtowerRater creates a new instance of the WatchtowerRate interface.