Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(x int32) int32
- func AggregateDataTransactions(SortedAndSelecteDataTx []protocol.Transaction, block *protocol.Block) error
- func AggregateRelativeState(stateRelPrev map[[32]byte]*protocol.RelativeAccount, ...) map[[32]byte]*protocol.RelativeAccount
- func AggregateTransactions(SortedAndSelectedFundsTx []protocol.Transaction, block *protocol.Block) error
- func AssignValidatorsToShards() map[[64]byte]int
- func CheckAndChangeParameters(parameters *Parameters, configTxSlice *[]*protocol.ConfigTx) (change bool)
- func ChooseCommitteeLeader() (committeeLeader [32]byte)
- func CommitteeMining(height int)
- func CommitteeValidateBlock(b *protocol.Block) (err error)
- func CopyState(state map[[32]byte]*protocol.Account) map[[32]byte]protocol.Account
- func DeleteTransactionFromMempool(acctTxData [][32]byte, contractData [][32]byte, fundsData [][32]byte, ...)
- func DetNumberOfCommittees() (numberOfCommittees int)
- func DetNumberOfShards() (numberOfShards int)
- func DetNumberOfVotersForSlashing(numberOfCommittees int) int
- func GetCommitteesCount() (validatorsCount int)
- func GetLatestProofs(n int, block *protocol.Block) (prevProofs [][crypto.COMM_PROOF_LENGTH]byte)
- func GetValidatorsCount() (validatorsCount int)
- func Init(validatorWallet, multisigWallet, rootWallet *ecdsa.PublicKey, ...) error
- func InitCommittee(committeeWallet *ecdsa.PublicKey, committeePrivKey *ecdsa.PrivateKey, ...)
- func InitFirstStart(validatorWallet, multisigWallet, rootWallet *ecdsa.PublicKey, ...) error
- func InvertBlockArray(array []*protocol.Block) []*protocol.Block
- func IsInSameChain(b1, b2 *protocol.Block) bool
- func OrderedBy(less ...lessFunc) *multiSorter
- func OrderedByData(less ...lessDataFunc) *multiDataSorter
- func ReconstructRelativeState(b *protocol.Block, accTxs []*protocol.AccTx, stakeTxs []*protocol.StakeTx, ...) *protocol.RelativeState
- func SlashCommittee(address [32]byte)
- func SlashShard(address [32]byte)
- func UpdateSummary(dataTxs []*protocol.DataTx)
- func ValidateBlockSender(b *protocol.Block) bool
- func ValidateEpochBlockSender(b *protocol.EpochBlock) bool
- type ByHash
- type ByTxCount
- type ByTxCountData
- type Parameters
- type SlashingProof
Constants ¶
const ( //How many blocks can we verify dynamically (e.g. proper time check) until we are too far behind //that this dynamic check is not possible anymore?! DELAYED_BLOCKS = 10 TXFETCH_TIMEOUT = 2 //Sec BLOCKFETCH_TIMEOUT = 40 //Sec GENESISFETCH_TIMEOUT = 40 //Sec //Some prominent programming languages (e.g., Java) have not unsigned integer types //Neglecting MSB simplifies compatibility MAX_MONEY = 9223372036854775807 //(2^63)-1 //Default Block params BLOCKHASH_SIZE = 32 //Byte FEE_MINIMUM = 1 //Coins BLOCK_SIZE = 800 //Byte DIFF_INTERVAL = 10 //Blocks BLOCK_INTERVAL = 15 //Sec BLOCK_REWARD = 0 //Coins STAKING_MINIMUM = 100 //Coins STAKING_FIX = 100000 WAITING_MINIMUM = 0 //Blocks ACCEPTED_TIME_DIFF = 60 //Sec SLASHING_WINDOW_SIZE = 100 //Blocks SLASH_REWARD = 2 //Coins NUM_INCL_PREV_PROOFS = 5 //Number of previous proofs included in the PoS condition NO_EMPTYING_LENGTH = 100 //Number of blocks after the newest block which are not moved to the empty block bucket EPOCH_LENGTH = 1 //blocks VALIDATORS_PER_SHARD = 1 //validators EPOCHBLOCKFETCH_TIMEOUT = 20 //Sec PERCENTAGE_NEEDED_FOR_SLASHING = 0.6667 //use a number between 0 and 1 as percentage, where 0 is 0% and 1 is 100%. 0.6667 stands for 66.67% DEFAULT_FINE_SHARD = 10 //standard fine if a shard is fined DEFAULT_FINE_COMMITTEE = 25 //standard fine if a committee is fined )
Variables ¶
var ( ActiveParameters *Parameters ValidatorAccAddress [64]byte // This map keeps track of the validator assignment to the shards ValidatorShardMap *protocol.ValShardMapping NumberOfShards int // This slice stores the hashes of the last blocks from the other shards, needed to create the next epoch block. LastShardHashes [][32]byte FirstStartCommittee bool FirstStartAfterEpoch bool NumberOfShardsDelayed int //Committee Slashing Extras ShardsToBePunished [][32]byte CommitteesToBePunished [][32]byte )
var (
FirstEpochBlock *protocol.EpochBlock
)
var SameChainMutex = sync.Mutex{}
Functions ¶
func AggregateDataTransactions ¶
func AggregateDataTransactions(SortedAndSelecteDataTx []protocol.Transaction, block *protocol.Block) error
func AggregateRelativeState ¶
func AggregateRelativeState(stateRelPrev map[[32]byte]*protocol.RelativeAccount, stateRel map[[32]byte]*protocol.RelativeAccount) map[[32]byte]*protocol.RelativeAccount
func AggregateTransactions ¶
func AggregateTransactions(SortedAndSelectedFundsTx []protocol.Transaction, block *protocol.Block) error
Here, I already made sure that TX will be aggregated according to sender. Maybe make code slimmer to improve performance
func AssignValidatorsToShards ¶
* This function assigns the validators to the single shards in a random fashion. In case multiple validators per shard are supported, they would be assigned to the shards uniformly.
func CheckAndChangeParameters ¶
func CheckAndChangeParameters(parameters *Parameters, configTxSlice *[]*protocol.ConfigTx) (change bool)
Separate function to reuse mechanism in client implementation
func ChooseCommitteeLeader ¶
func ChooseCommitteeLeader() (committeeLeader [32]byte)
func CommitteeMining ¶
func CommitteeMining(height int)
func CommitteeValidateBlock ¶
func DeleteTransactionFromMempool ¶
func DeleteTransactionFromMempool(acctTxData [][32]byte, contractData [][32]byte, fundsData [][32]byte, configData [][32]byte, stakeData [][32]byte, aggTxData [][32]byte)
* During the synchronisation phase at every block height, the validator also receives the transaction hashes which were validated by the other shards. To avoid starvation, delete those transactions from the mempool
func DetNumberOfCommittees ¶
func DetNumberOfCommittees() (numberOfCommittees int)
func DetNumberOfShards ¶
func DetNumberOfShards() (numberOfShards int)
* Number of Shards is determined based on the total number of validators in the network. Currently, the system supports only one validator per shard, thus Number of Shards = Number of Validators.
func GetCommitteesCount ¶
func GetCommitteesCount() (validatorsCount int)
func GetLatestProofs ¶
TODO uncomment
func GetValidatorsCount ¶
func GetValidatorsCount() (validatorsCount int)
* Retrieve total number of participants from the network which are staking
func Init ¶
func Init(validatorWallet, multisigWallet, rootWallet *ecdsa.PublicKey, validatorCommitment, rootCommitment *rsa.PrivateKey) error
Miner entry point
func InitCommittee ¶
func InitCommittee(committeeWallet *ecdsa.PublicKey, committeePrivKey *ecdsa.PrivateKey, committeeKey *rsa.PrivateKey)
func InitFirstStart ¶
func InitFirstStart(validatorWallet, multisigWallet, rootWallet *ecdsa.PublicKey, validatorCommitment, rootCommitment *rsa.PrivateKey) error
Doesnt do much, just bootstraps the system with the things that are needed for the first start, i.e. a genesis block and a first epoch block.
func IsInSameChain ¶
Check if two blocks are part of the same chain or if they appear in two competing chains
func OrderedByData ¶
func OrderedByData(less ...lessDataFunc) *multiDataSorter
func SlashCommittee ¶
func SlashCommittee(address [32]byte)
func SlashShard ¶
func SlashShard(address [32]byte)
func UpdateSummary ¶
func ValidateBlockSender ¶
func ValidateEpochBlockSender ¶
func ValidateEpochBlockSender(b *protocol.EpochBlock) bool
Types ¶
type ByTxCountData ¶
func (ByTxCountData) Len ¶
func (a ByTxCountData) Len() int
func (ByTxCountData) Less ¶
func (a ByTxCountData) Less(i, j int) bool
func (ByTxCountData) Swap ¶
func (a ByTxCountData) Swap(i, j int)
type Parameters ¶
type Parameters struct { BlockHash [BLOCKHASH_SIZE]byte Fee_minimum uint64 //Paid minimum fee for sending a tx. Block_size uint64 //Block size in bytes. Diff_interval uint64 Block_interval uint64 Block_reward uint64 //Reward for delivering the correct PoS. Staking_minimum uint64 //Minimum amount a validator must own for staking. Waiting_minimum uint64 //Number of blocks that must a new validator must wait before it can start validating. Accepted_time_diff uint64 //Number of seconds that a block can be received in the future. Slashing_window_size uint64 //Number of blocks that a validator cannot vote on two competing chains. Slash_reward uint64 //Reward for providing the correct slashing proof. Epoch_length int // contains filtered or unexported fields }
An instance of this datastructure is created whenever system parameters change. The blockhash is additionally recorded to know which blocks the parameter change belongs to. This is necessary, because the system records ALL config txs (even those who have no corresponding code to execute [e.g., when they're running an older version of the code]).
func NewDefaultParameters ¶
func NewDefaultParameters() Parameters
func (Parameters) String ¶
func (param Parameters) String() string
type SlashingProof ¶
TODO uncomment