types

package
v0.2.11-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 23 Imported by: 27

Documentation

Overview

Package types defines the types used by go-spacemesh consensus algorithms and structs

Index

Constants

View Source
const (
	// LayerIDSize in bytes.
	LayerIDSize = 4

	// GenesisBeacon is the hex value of the beacon used during genesis.
	GenesisBeacon = "0xaeebad4a796fcc2e15dc4c6061b45ed9b373f26adfc798ca7d2d8cc58182718e" // sha256("genesis")

)
View Source
const (
	// ATXIDSize in bytes.
	ATXIDSize = Hash32Length
)
View Source
const (
	// AddressLength is the expected length of the address.
	AddressLength = 20
)
View Source
const (
	// BallotIDSize in bytes.
	// FIXME(dshulyak) why do we cast to hash32 when returning bytes?
	BallotIDSize = Hash32Length
)
View Source
const (
	// BeaconSize in bytes.
	BeaconSize = Hash32Length
)
View Source
const (
	// BlockIDSize in bytes.
	// FIXME(dshulyak) why do we cast to hash32 when returning bytes?
	// probably required for fetching by hash between peers.
	BlockIDSize = Hash32Length
)
View Source
const (
	// FirstRound is convenient for initializing the index in a loop.
	FirstRound = RoundID(0)
)
View Source
const (
	// Hash32Length is 32, the expected length of the hash.
	Hash32Length = 32
)
View Source
const (
	// ProposalIDSize in bytes.
	// FIXME(dshulyak) why do we cast to hash32 when returning bytes?
	// probably required for fetching by hash between peers.
	ProposalIDSize = Hash32Length
)
View Source
const (
	// TransactionIDSize in bytes.
	TransactionIDSize = Hash32Length
)

Variables

View Source
var (
	Big1   = big.NewInt(1)
	Big2   = big.NewInt(2)
	Big3   = big.NewInt(3)
	Big0   = big.NewInt(0)
	Big32  = big.NewInt(32)
	Big256 = big.NewInt(256)
	Big257 = big.NewInt(257)
)

Common big integers often used.

View Source
var (

	// InterfaceToBytes is an alias to codec.Encode.
	InterfaceToBytes = codec.Encode
	// BytesToInterface is an alias to codec.Decode.
	BytesToInterface = codec.Decode
)
View Source
var (

	// EmptyLayerHash is the layer hash for an empty layer.
	EmptyLayerHash = Hash32{}

	// GenesisBallotID is the BallotID for the genesis ballot.
	GenesisBallotID = BallotID(HexToHash32(genesisBallotIDHex).ToHash20())
	// GenesisBlockID is the BlockID for the genesis block.
	GenesisBlockID = BlockID(HexToHash32(genesisBlockIDHex).ToHash20())
)
View Source
var EmptyATXID = &ATXID{}

EmptyATXID is a canonical empty ATXID.

View Source
var EmptyBallotID = BallotID{}

EmptyBallotID is a canonical empty BallotID.

View Source
var EmptyBeacon = Beacon{}

EmptyBeacon is a canonical empty Beacon.

View Source
var EmptyBlockID = BlockID{}

EmptyBlockID is a canonical empty BlockID.

View Source
var EmptyProposalID = ProposalID{}

EmptyProposalID is a canonical empty ProposalID.

View Source
var EmptyTransactionID = TransactionID{}

EmptyTransactionID is a canonical empty TransactionID.

Functions

func BlockIdsField added in v1.0.0

func BlockIdsField(ids blockIDs) log.Field

BlockIdsField returns a list of loggable fields for a given list of BlockID.

func GetLayersPerEpoch added in v1.0.0

func GetLayersPerEpoch() uint32

GetLayersPerEpoch returns number of layers per epoch.

func InitGenesisData

func InitGenesisData()

InitGenesisData generate the genesis data.

func IsProcessingError

func IsProcessingError(err error) bool

IsProcessingError returns true if the given error is a processing error.

func NIPostChallengeToBytes

func NIPostChallengeToBytes(challenge *NIPostChallenge) ([]byte, error)

NIPostChallengeToBytes serializes a NIPostChallenge.

func RandomBytes added in v1.0.0

func RandomBytes(size int) []byte

RandomBytes generates random data in bytes for testing.

func SetLayersPerEpoch added in v0.1.15

func SetLayersPerEpoch(layers uint32)

SetLayersPerEpoch sets global parameter of layers per epoch, all conversions from layer to epoch use this param.

func Shorten added in v0.1.15

func Shorten(s string, maxlen int) string

Shorten shortens a string to a specified length.

func TxIdsField added in v0.1.15

func TxIdsField(ids []TransactionID) log.Field

TxIdsField returns a list of loggable fields for a given list of IDs.

Types

type ATXID added in v0.1.11

type ATXID Hash32

ATXID is a 32-bit hash used to identify an activation transaction.

func RandomATXID added in v1.0.0

func RandomATXID() ATXID

RandomATXID generates a random ATXID for testing.

func RandomActiveSet added in v1.0.0

func RandomActiveSet(size int) []ATXID

RandomActiveSet generates a random set of ATXIDs of the specified size.

func SortAtxIDs added in v0.1.15

func SortAtxIDs(ids []ATXID) []ATXID

SortAtxIDs sorts a list of atx IDs in lexicographic order, in-place.

func (ATXID) Bytes added in v0.1.11

func (t ATXID) Bytes() []byte

Bytes returns the ATXID as a byte slice.

func (ATXID) Compare added in v0.1.15

func (t ATXID) Compare(other ATXID) bool

Compare returns true if other (the given ATXID) is less than this ATXID, by lexicographic comparison.

func (ATXID) Field added in v0.1.11

func (t ATXID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (ATXID) Hash32 added in v0.1.11

func (t ATXID) Hash32() Hash32

Hash32 returns the ATXID as a Hash32.

func (ATXID) ShortString added in v0.1.11

func (t ATXID) ShortString() string

ShortString returns the first few characters of the ID, for logging purposes.

func (ATXID) String added in v1.0.0

func (t ATXID) String() string

String implements stringer interface.

type ATXIDList added in v1.0.0

type ATXIDList []ATXID

ATXIDList defines ATX ID list.

func (ATXIDList) Hash added in v1.0.0

func (atxList ATXIDList) Hash() Hash32

Hash returns ATX ID list hash.

type AccountState added in v0.1.16

type AccountState struct {
	Nonce   uint64 `json:"nonce"`
	Balance uint64 `json:"balance"`
}

AccountState struct represents basic account data: nonce and balance Todo: get rid of big.Int everywhere and replace with uint64 See https://github.com/spacemeshos/go-spacemesh/issues/2192

type ActivationTx

type ActivationTx struct {
	*InnerActivationTx
	Sig []byte
}

ActivationTx is a full, signed activation transaction. It includes (or references) everything a miner needs to prove they are eligible to actively participate in the Spacemesh protocol in the next epoch.

func BytesToAtx added in v0.1.15

func BytesToAtx(b []byte) (*ActivationTx, error)

BytesToAtx deserializes an ActivationTx.

func NewActivationTx

func NewActivationTx(challenge NIPostChallenge, coinbase Address, nipost *NIPost, numUnits uint, initialPost *Post) *ActivationTx

NewActivationTx returns a new activation transaction. The ATXID is calculated and cached.

func (*ActivationTx) CalcAndSetID added in v0.1.11

func (atx *ActivationTx) CalcAndSetID()

CalcAndSetID calculates and sets the cached ID field. This field must be set before calling the ID() method.

func (*ActivationTx) Fields added in v0.1.15

func (atx *ActivationTx) Fields(size int) []log.LoggableField

Fields returns an array of LoggableFields for logging.

func (*ActivationTx) GetPoetProofRef

func (atx *ActivationTx) GetPoetProofRef() Hash32

GetPoetProofRef returns the reference to the PoET proof.

func (*ActivationTx) GetShortPoetProofRef

func (atx *ActivationTx) GetShortPoetProofRef() []byte

GetShortPoetProofRef returns the first 5 characters of the PoET proof reference, for logging purposes.

func (*ActivationTx) InnerBytes added in v0.1.11

func (atx *ActivationTx) InnerBytes() ([]byte, error)

InnerBytes returns a byte slice of the serialization of the inner ATX (excluding the signature field).

type ActivationTxHeader

type ActivationTxHeader struct {
	NIPostChallenge

	Coinbase Address
	NumUnits uint
	// contains filtered or unexported fields
}

ActivationTxHeader is the header of an activation transaction. It includes all fields from the NIPostChallenge, as well as the coinbase address and total weight.

func (*ActivationTxHeader) GetWeight added in v1.0.0

func (atxh *ActivationTxHeader) GetWeight() uint64

GetWeight returns the ATX's weight = numUnits * ticks.

func (*ActivationTxHeader) Hash32

func (atxh *ActivationTxHeader) Hash32() Hash32

Hash32 returns the ATX's ID as a Hash32.

func (*ActivationTxHeader) ID added in v0.1.11

func (atxh *ActivationTxHeader) ID() ATXID

ID returns the ATX's ID.

func (*ActivationTxHeader) SetID added in v0.1.11

func (atxh *ActivationTxHeader) SetID(id *ATXID)

SetID sets the ATXID in this ATX's cache.

func (*ActivationTxHeader) ShortString

func (atxh *ActivationTxHeader) ShortString() string

ShortString returns the first 5 characters of the ID, for logging purposes.

func (*ActivationTxHeader) TargetEpoch

func (atxh *ActivationTxHeader) TargetEpoch() EpochID

TargetEpoch returns the target epoch of the activation transaction. This is the epoch in which the miner is eligible to participate thanks to the ATX.

type Address

type Address [AddressLength]byte

Address represents the 20 byte address of an spacemesh account.

func BigToAddress

func BigToAddress(b *big.Int) Address

BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.

func HexToAddress

func HexToAddress(s string) Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func StringToAddress

func StringToAddress(s string) (Address, error)

StringToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left. It is identical to HexToAddress, except decoding errors are returned instead of swallowed.

func (Address) Big

func (a Address) Big() *big.Int

Big converts an address to a big integer.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes gets the string representation of the underlying address.

func (Address) Field added in v0.1.15

func (a Address) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (Address) Format

func (a Address) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Address) Hash

func (a Address) Hash() Hash32

Hash converts an address to a hash by left-padding it with zeros.

func (Address) Hex

func (a Address) Hex() string

Hex returns an EIP55-compliant hex string representation of the address.

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.

func (Address) Short

func (a Address) Short() string

Short returns the first 7 characters of the address hex representation (incl. "0x"), for logging purposes.

func (Address) String

func (a Address) String() string

String implements fmt.Stringer.

type AnyReward added in v1.0.0

type AnyReward struct {
	Address   Address
	SmesherID NodeID
	// Amount == LayerReward + fee
	Amount      uint64
	LayerReward uint64
}

AnyReward contains the rewards inforamtion.

type Ballot added in v1.0.0

type Ballot struct {
	// the actual votes on the mesh history
	InnerBallot
	// smesher's signature on InnerBallot
	Signature []byte
	// contains filtered or unexported fields
}

Ballot contains the smesher's signed vote on the mesh history.

func GenLayerBallot

func GenLayerBallot(layerID LayerID) *Ballot

GenLayerBallot generates a Ballot with random content for testing.

func RandomBallot added in v1.0.0

func RandomBallot() *Ballot

RandomBallot generates a Ballot with random content for testing.

func (*Ballot) Bytes

func (b *Ballot) Bytes() []byte

Bytes returns the serialization of the InnerBallot.

func (*Ballot) Fields

func (b *Ballot) Fields() []log.LoggableField

Fields returns an array of LoggableFields for logging.

func (*Ballot) ID added in v1.0.0

func (b *Ballot) ID() BallotID

ID returns the BallotID.

func (*Ballot) Initialize added in v1.0.0

func (b *Ballot) Initialize() error

Initialize calculates and sets the Ballot's cached ballotID and smesherID. this should be called once all the other fields of the Ballot are set.

func (*Ballot) MarshalLogObject added in v1.0.0

func (b *Ballot) MarshalLogObject(encoder log.ObjectEncoder) error

MarshalLogObject implements logging encoder for Ballot.

func (*Ballot) SmesherID added in v1.0.0

func (b *Ballot) SmesherID() *signing.PublicKey

SmesherID returns the smesher's Edwards public key.

type BallotID added in v1.0.0

type BallotID Hash20

BallotID is a 20-byte sha256 sum of the serialized ballot used to identify a Ballot.

func RandomBallotID added in v1.0.0

func RandomBallotID() BallotID

RandomBallotID generates a random BallotID for testing.

func ToBallotIDs added in v1.0.0

func ToBallotIDs(ballots []*Ballot) []BallotID

ToBallotIDs turns a list of Ballot into a list of BallotID.

func (BallotID) AsHash32 added in v1.0.0

func (id BallotID) AsHash32() Hash32

AsHash32 returns a Hash32 whose first 20 bytes are the bytes of this BallotID, it is right-padded with zeros.

func (BallotID) Bytes added in v1.0.0

func (id BallotID) Bytes() []byte

Bytes returns the BallotID as a byte slice.

func (BallotID) Compare added in v1.0.0

func (id BallotID) Compare(other BallotID) bool

Compare returns true if other (the given BallotID) is less than this BallotID, by lexicographic comparison.

func (BallotID) Field added in v1.0.0

func (id BallotID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (BallotID) String added in v1.0.0

func (id BallotID) String() string

String returns a short prefix of the hex representation of the ID.

type Beacon added in v1.0.0

type Beacon Hash32

Beacon defines the beacon value. A beacon is generated once per epoch and is used to - verify smesher's VRF signature for proposal/ballot eligibility - determine good ballots in verifying tortoise.

func BytesToBeacon added in v1.0.0

func BytesToBeacon(b []byte) Beacon

BytesToBeacon sets b to the Beacon's data. If b is larger than len(h), b will be cropped from the left.

func HexToBeacon added in v1.0.0

func HexToBeacon(s string) Beacon

HexToBeacon sets byte representation of s to a Beacon.

func RandomBeacon added in v1.0.0

func RandomBeacon() Beacon

RandomBeacon generates random beacon in bytes for testing.

func (Beacon) Bytes added in v1.0.0

func (b Beacon) Bytes() []byte

Bytes gets the byte representation of the underlying hash.

func (Beacon) Field added in v1.0.0

func (b Beacon) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (Beacon) ShortString added in v1.0.0

func (b Beacon) ShortString() string

ShortString returns the first 5 characters of the Beacon, usually for logging purposes.

func (Beacon) String added in v1.0.0

func (b Beacon) String() string

String implements the stringer interface and is used also by the logger when doing full logging into a file.

type Block

type Block struct {
	InnerBlock
	// contains filtered or unexported fields
}

Block contains the content of a layer on the mesh history.

func GenLayerBlock

func GenLayerBlock(layerID LayerID, txs []TransactionID) *Block

GenLayerBlock returns a Block in the given layer with the given data.

func NewExistingBlock

func NewExistingBlock(id BlockID, inner InnerBlock) *Block

NewExistingBlock creates a block from existing data.

func SortBlocks

func SortBlocks(blks []*Block) []*Block

SortBlocks sort blocks by their IDs.

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes returns the serialization of the InnerBlock.

func (*Block) ID added in v0.1.11

func (b *Block) ID() BlockID

ID returns the BlockID.

func (*Block) Initialize added in v0.1.2

func (b *Block) Initialize()

Initialize calculates and sets the Block's cached blockID.

func (*Block) MarshalLogObject added in v1.0.0

func (b *Block) MarshalLogObject(encoder log.ObjectEncoder) error

MarshalLogObject implements logging encoder for Block.

type BlockID

type BlockID Hash20

BlockID is a 20-byte sha256 sum of the serialized block used to identify a Block.

func RandomBlockID added in v0.1.16

func RandomBlockID() BlockID

RandomBlockID generates a random ProposalID for testing.

func SortBlockIDs added in v0.1.11

func SortBlockIDs(ids blockIDs) []BlockID

SortBlockIDs sorts a list of BlockID in lexicographic order, in-place.

func ToBlockIDs added in v1.0.0

func ToBlockIDs(blocks []*Block) []BlockID

ToBlockIDs returns a slice of BlockID corresponding to the given list of Block.

func (BlockID) AsHash32

func (id BlockID) AsHash32() Hash32

AsHash32 returns a Hash32 whose first 20 bytes are the bytes of this BlockID, it is right-padded with zeros.

func (BlockID) Bytes added in v0.1.15

func (id BlockID) Bytes() []byte

Bytes returns the BlockID as a byte slice.

func (BlockID) Compare

func (id BlockID) Compare(other BlockID) bool

Compare returns true if other (the given BlockID) is less than this BlockID, by lexicographic comparison.

func (BlockID) Field added in v0.1.2

func (id BlockID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (BlockID) String

func (id BlockID) String() string

String implements the Stringer interface.

type DBBallot

type DBBallot struct {
	InnerBallot
	// NOTE(dshulyak) this is a bit redundant to store ID here as well but less likely
	// to break if in future key for database will be changed
	ID        BallotID
	Signature []byte
	SmesherID []byte // derived from signature when ballot is received
}

DBBallot is a Ballot structure as it is stored in DB.

func (*DBBallot) ToBallot

func (b *DBBallot) ToBallot() *Ballot

ToBallot creates a Ballot from data that is stored locally.

type DBBlock

type DBBlock struct {
	ID         BlockID
	InnerBlock InnerBlock
}

DBBlock is a Block structure stored in DB to skip ID hashing.

func (*DBBlock) ToBlock

func (dbb *DBBlock) ToBlock() *Block

ToBlock creates a Block from data that is stored locally.

type DBProposal

type DBProposal struct {
	// NOTE(dshulyak) this is a bit redundant to store ID here as well but less likely
	// to break if in future key for database will be changed
	ID         ProposalID
	BallotID   BallotID
	LayerIndex LayerID
	TxIDs      []TransactionID
	Signature  []byte
}

DBProposal is a Proposal structure stored in DB to skip signature verification.

func (*DBProposal) ToProposal

func (b *DBProposal) ToProposal(ballot *Ballot) *Proposal

ToProposal creates a Proposal from data that is stored locally.

type DoubleCache

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

DoubleCache is a structure for storing which keys have been encountered before. It's initialized with a size and it stores between size and 2*size keys. Every time the cache size reaches 2*size and a new value is added, the oldest size keys are discarded and the size drops back to size. DoubleCache is thread safe.

func NewDoubleCache

func NewDoubleCache(size uint) *DoubleCache

NewDoubleCache returns a new DoubleCache.

func (*DoubleCache) GetOrInsert

func (a *DoubleCache) GetOrInsert(key Hash12) bool

GetOrInsert checks if a value is already in the cache, otherwise it adds it. Returns bool whether or not the value was found in the cache (true - already in cache, false - wasn't in cache before this was called).

type EpochData added in v1.0.0

type EpochData struct {
	// from the smesher's view, the set of ATXs eligible to vote and propose block content in this epoch
	ActiveSet []ATXID
	// the beacon value the smesher recorded for this epoch
	Beacon Beacon
}

EpochData contains information that cannot be changed mid-epoch.

type EpochID added in v0.1.11

type EpochID uint32

EpochID is the running epoch number. It's zero-based, so the genesis epoch has EpochID == 0.

func (EpochID) Field added in v0.1.11

func (l EpochID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (EpochID) FirstLayer added in v0.1.11

func (l EpochID) FirstLayer() LayerID

FirstLayer returns the layer ID of the first layer in the epoch.

func (EpochID) IsGenesis added in v0.1.11

func (l EpochID) IsGenesis() bool

IsGenesis returns true if this epoch is in genesis. The first two epochs are considered genesis epochs.

func (EpochID) NeedsGoldenPositioningATX added in v0.1.28

func (l EpochID) NeedsGoldenPositioningATX() bool

NeedsGoldenPositioningATX returns true if ATXs in this epoch require positioning ATX to be equal to the Golden ATX. All ATXs in epoch 1 must have the Golden ATX as positioning ATX.

func (EpochID) String added in v1.0.0

func (l EpochID) String() string

String returns string representation of the epoch id numeric value.

func (EpochID) ToBytes added in v0.1.11

func (l EpochID) ToBytes() []byte

ToBytes returns a byte-slice representation of the EpochID, using little endian encoding.

type Hash12

type Hash12 [hash12Length]byte

Hash12 represents the first 12 bytes of sha256, mostly used for internal caches.

func CalcHash12

func CalcHash12(data []byte) (h Hash12)

CalcHash12 returns the 12-byte prefix of the sha256 sum of the given byte slice.

func CalcMessageHash12

func CalcMessageHash12(msg []byte, protocol string) Hash12

CalcMessageHash12 returns the 12-byte sha256 sum of the given msg suffixed with protocol.

func (Hash12) Field added in v0.1.2

func (h Hash12) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

type Hash20

type Hash20 [hash20Length]byte

Hash20 represents the 20-byte sha256 hash of arbitrary data.

func (Hash20) Big

func (h Hash20) Big() *big.Int

Big converts a hash to a big integer.

func (Hash20) Bytes

func (h Hash20) Bytes() []byte

Bytes gets the byte representation of the underlying hash.

func (Hash20) Field added in v0.1.2

func (h Hash20) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (Hash20) Format

func (h Hash20) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Hash20) Hex

func (h Hash20) Hex() string

Hex converts a hash to a hex string.

func (Hash20) MarshalText

func (h Hash20) MarshalText() ([]byte, error)

MarshalText returns the hex representation of h.

func (*Hash20) SetBytes

func (h *Hash20) SetBytes(b []byte)

SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.

func (Hash20) ShortString

func (h Hash20) ShortString() string

ShortString returns a the first 5 characters of the hash, for logging purposes.

func (Hash20) String

func (h Hash20) String() string

String implements the stringer interface and is used also by the logger when doing full logging into a file.

func (Hash20) ToHash32

func (h Hash20) ToHash32() (h32 Hash32)

ToHash32 returns a Hash32 whose first 20 bytes are the bytes of this Hash20, it is right-padded with zeros.

func (*Hash20) UnmarshalJSON

func (h *Hash20) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Hash20) UnmarshalText

func (h *Hash20) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

type Hash32

type Hash32 [Hash32Length]byte

Hash32 represents the 32-byte sha256 hash of arbitrary data.

func BallotIDsToHashes added in v1.0.0

func BallotIDsToHashes(ids []BallotID) []Hash32

BallotIDsToHashes turns a list of BallotID into their Hash32 representation.

func BlockIDsToHashes added in v1.0.0

func BlockIDsToHashes(ids []BlockID) []Hash32

BlockIDsToHashes turns a list of BlockID into their Hash32 representation.

func BytesToHash

func BytesToHash(b []byte) Hash32

BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.

func CalcATXHash32 added in v0.1.11

func CalcATXHash32(atx *ActivationTx) Hash32

CalcATXHash32 returns the 32-byte sha256 sum of serialization of the given ATX.

func CalcBlockHash32Presorted

func CalcBlockHash32Presorted(sortedView []BlockID, additionalBytes []byte) Hash32

CalcBlockHash32Presorted returns the 32-byte sha256 sum of the IDs, in the order given. The pre-image is prefixed with additionalBytes.

func CalcBlocksHash32

func CalcBlocksHash32(view []BlockID, additionalBytes []byte) Hash32

CalcBlocksHash32 returns the 32-byte sha256 sum of the IDs, sorted in lexicographic order. The pre-image is prefixed with additionalBytes.

func CalcHash32

func CalcHash32(data []byte) Hash32

CalcHash32 returns the 32-byte sha256 sum of the given data.

func CalcProposalHash32Presorted added in v1.0.0

func CalcProposalHash32Presorted(sortedView []ProposalID, additionalBytes []byte) Hash32

CalcProposalHash32Presorted returns the 32-byte sha256 sum of the IDs, in the order given. The pre-image is prefixed with additionalBytes.

func CalcProposalsHash32 added in v1.0.0

func CalcProposalsHash32(view []ProposalID, additionalBytes []byte) Hash32

CalcProposalsHash32 returns the 32-byte sha256 sum of the IDs, sorted in lexicographic order. The pre-image is prefixed with additionalBytes.

func HexToHash32

func HexToHash32(s string) Hash32

HexToHash32 sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.

func ProposalIDsToHashes added in v1.0.0

func ProposalIDsToHashes(ids []ProposalID) []Hash32

ProposalIDsToHashes turns a list of ProposalID into their Hash32 representation.

func RandomHash added in v1.0.0

func RandomHash() Hash32

RandomHash generates random Hash32 for testing.

func (Hash32) Bytes

func (h Hash32) Bytes() []byte

Bytes gets the byte representation of the underlying hash.

func (Hash32) Field added in v0.1.2

func (h Hash32) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (Hash32) Format

func (h Hash32) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Hash32) Generate

func (h Hash32) Generate(rand *rand.Rand, _ int) reflect.Value

Generate implements testing/quick.Generator.

func (Hash32) Hex

func (h Hash32) Hex() string

Hex converts a hash to a hex string.

func (Hash32) MarshalText

func (h Hash32) MarshalText() ([]byte, error)

MarshalText returns the hex representation of h.

func (*Hash32) Scan

func (h *Hash32) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Hash32) SetBytes

func (h *Hash32) SetBytes(b []byte)

SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.

func (Hash32) ShortString

func (h Hash32) ShortString() string

ShortString returns the first 5 characters of the hash, for logging purposes.

func (Hash32) String

func (h Hash32) String() string

String implements the stringer interface and is used also by the logger when doing full logging into a file.

func (Hash32) ToHash20

func (h Hash32) ToHash20() (h20 Hash20)

ToHash20 returns a Hash20, whose the 20-byte prefix of this Hash32.

func (*Hash32) UnmarshalJSON

func (h *Hash32) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Hash32) UnmarshalText

func (h *Hash32) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

type InnerActivationTx

type InnerActivationTx struct {
	*ActivationTxHeader
	NIPost      *NIPost
	InitialPost *Post
}

InnerActivationTx is a set of all of an ATX's fields, except the signature. To generate the ATX signature, this structure is serialized and signed. It includes the header fields, as well as the larger fields that are only used for validation: the NIPost and the initial Post.

type InnerBallot added in v1.0.0

type InnerBallot struct {
	// the smesher's ATX in the epoch this ballot is cast.
	AtxID ATXID
	// the proof of the smesher's eligibility to vote and propose block content in this epoch.
	EligibilityProof VotingEligibilityProof
	Votes            Votes

	// the first Ballot the smesher cast in the epoch. this Ballot is a special Ballot that contains information
	// that cannot be changed mid-epoch.
	RefBallot BallotID
	EpochData *EpochData

	// the layer ID in which this ballot is eligible for. this will be validated via EligibilityProof
	LayerIndex LayerID
}

InnerBallot contains all info about a smesher's votes on the mesh history. this structure is serialized and signed to produce the signature in Ballot.

type InnerBlock added in v1.0.0

type InnerBlock struct {
	LayerIndex LayerID
	Rewards    []AnyReward
	TxIDs      []TransactionID
}

InnerBlock contains the transactions and rewards of a block.

type InnerProposal added in v1.0.0

type InnerProposal struct {
	// smesher's votes on the mesh history
	Ballot
	// smesher's content proposal for a layer
	TxIDs []TransactionID
}

InnerProposal contains a smesher's content proposal for layer and its votes on the mesh history. this structure is serialized and signed to produce the signature in Proposal.

type InnerTransaction

type InnerTransaction struct {
	AccountNonce uint64
	Recipient    Address
	GasLimit     uint64
	Fee          uint64
	Amount       uint64
}

InnerTransaction includes all of a transaction's fields, except the signature (origin and id aren't stored).

type Layer

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

Layer contains a list of proposals and their corresponding LayerID.

func GenesisLayer

func GenesisLayer() *Layer

GenesisLayer returns the genesis layer.

func NewExistingLayer

func NewExistingLayer(idx LayerID, ballots []*Ballot, blocks []*Block) *Layer

NewExistingLayer returns a new layer with the given list of blocks without validation.

func NewLayer

func NewLayer(layerIndex LayerID) *Layer

NewLayer returns a layer with no proposals.

func (*Layer) AddBallot added in v1.0.0

func (l *Layer) AddBallot(b *Ballot)

AddBallot adds a ballot to this layer. Panics if the ballot's index doesn't match the layer.

func (*Layer) AddBlock

func (l *Layer) AddBlock(b *Block)

AddBlock adds a block to this layer. Panics if the block's index doesn't match the layer.

func (*Layer) BallotIDs added in v1.0.0

func (l *Layer) BallotIDs() []BallotID

BallotIDs returns the list of IDs for ballots in this layer.

func (*Layer) Ballots added in v1.0.0

func (l *Layer) Ballots() []*Ballot

Ballots returns the list of ballots in this layer.

func (*Layer) Blocks

func (l *Layer) Blocks() []*Block

Blocks returns the list of Block in this layer.

func (*Layer) BlocksIDs added in v1.0.0

func (l *Layer) BlocksIDs() []BlockID

BlocksIDs returns the list of IDs for blocks in this layer.

func (*Layer) Field added in v0.1.15

func (l *Layer) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (Layer) Hash

func (l Layer) Hash() Hash32

Hash returns the 32-byte sha256 sum of the block IDs in this layer, sorted in lexicographic order.

func (*Layer) Index

func (l *Layer) Index() LayerID

Index returns the layer's ID.

func (*Layer) SetBallots added in v1.0.0

func (l *Layer) SetBallots(ballots []*Ballot)

SetBallots sets the list of ballots for the layer without validation.

func (*Layer) SetBlocks

func (l *Layer) SetBlocks(blocks []*Block)

SetBlocks sets the list of blocks for the layer without validation.

type LayerID

type LayerID struct {
	// NOTE(dshulyak) it is made public for compatibility with encoding library.
	// Don't modify it directly, as it will likely to be made private in the future.
	Value uint32
}

LayerID is representing a layer number. Zero value is safe to use, and means 0. Internally it is a simple wrapper over uint32 and should be considered immutable the same way as any integer.

func BytesToLayerID

func BytesToLayerID(b []byte) LayerID

BytesToLayerID return uint64 layer IO.

func GetEffectiveGenesis added in v0.1.15

func GetEffectiveGenesis() LayerID

GetEffectiveGenesis returns when actual proposals would be created.

func NewLayerID

func NewLayerID(value uint32) LayerID

NewLayerID creates LayerID from uint32.

func (LayerID) Add

func (l LayerID) Add(layers uint32) LayerID

Add layers to the layer. Panics on wraparound.

func (LayerID) After added in v1.0.0

func (l LayerID) After(other LayerID) bool

After returns true if this layer is higher than the other.

func (LayerID) Before added in v1.0.0

func (l LayerID) Before(other LayerID) bool

Before returns true if this layer is lower than the other.

func (LayerID) Bytes added in v0.1.15

func (l LayerID) Bytes() []byte

Bytes returns the byte representation of the LayerID, using little endian encoding.

func (LayerID) Difference added in v1.0.0

func (l LayerID) Difference(other LayerID) uint32

Difference returns the difference between current and other layer.

func (LayerID) Field added in v0.1.2

func (l LayerID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (LayerID) FirstInEpoch added in v1.0.0

func (l LayerID) FirstInEpoch() bool

FirstInEpoch returns whether this LayerID is first in epoch.

func (LayerID) GetEpoch

func (l LayerID) GetEpoch() EpochID

GetEpoch returns the epoch number of this LayerID.

func (LayerID) Mul added in v1.0.0

func (l LayerID) Mul(layers uint32) LayerID

Mul layer by the layers. Panics on wraparound.

func (LayerID) OrdinalInEpoch added in v1.0.0

func (l LayerID) OrdinalInEpoch() uint32

OrdinalInEpoch returns layer ordinal in epoch.

func (LayerID) String added in v1.0.0

func (l LayerID) String() string

String returns string representation of the layer id numeric value.

func (LayerID) Sub added in v1.0.0

func (l LayerID) Sub(layers uint32) LayerID

Sub layers from the layer. Panics on wraparound.

func (LayerID) Uint32 added in v1.0.0

func (l LayerID) Uint32() uint32

Uint32 returns the LayerID as a uint32.

type MeshTransaction added in v1.0.0

type MeshTransaction struct {
	Transaction
	LayerID LayerID
	BlockID BlockID
}

MeshTransaction is stored in the mesh and included in the block.

type MultipleAccountsState added in v0.1.16

type MultipleAccountsState struct {
	Root     string                  `json:"root"`
	Accounts map[string]AccountState `json:"accounts"` // key is in hex string format e.g. 0x12...
}

MultipleAccountsState is a struct used to dump an entire state root.

type NIPost added in v1.0.0

type NIPost struct {
	// Challenge is the challenge for the PoET which is
	// constructed from fields in the activation transaction.
	Challenge *Hash32

	// Post is the proof that the prover data is still stored (or was recomputed) at
	// the time he learned the challenge constructed from the PoET.
	Post *Post

	// PostMetadata is the Post metadata, associated with the proof.
	// The proof should be verified upon the metadata during the syntactic validation,
	// while the metadata should be verified during the contextual validation.
	PostMetadata *PostMetadata
}

NIPost is Non-Interactive Proof of Space-Time. Given an id, a space parameter S, a duration D and a challenge C, it can convince a verifier that (1) the prover expended S * D space-time after learning the challenge C. (2) the prover did not know the NIPost until D time after the prover learned C.

type NIPostChallenge added in v1.0.0

type NIPostChallenge struct {
	NodeID             NodeID
	Sequence           uint64
	PrevATXID          ATXID
	PubLayerID         LayerID
	StartTick          uint64
	EndTick            uint64
	PositioningATX     ATXID
	InitialPostIndices []byte
}

NIPostChallenge is the set of fields that's serialized, hashed and submitted to the PoET service to be included in the PoET membership proof. It includes the node ID, ATX sequence number, the previous ATX's ID (for all but the first in the sequence), the intended publication layer ID, the PoET's start and end ticks, the positioning ATX's ID and for the first ATX in the sequence also the commitment Merkle root.

func (*NIPostChallenge) Hash added in v1.0.0

func (challenge *NIPostChallenge) Hash() (*Hash32, error)

Hash serializes the NIPostChallenge and returns its hash.

func (*NIPostChallenge) String added in v1.0.0

func (challenge *NIPostChallenge) String() string

String returns a string representation of the NIPostChallenge, for logging purposes. It implements the Stringer interface.

type NodeID added in v0.1.11

type NodeID struct {
	// Key is the miner's Edwards public key
	Key string

	// VRFPublicKey is the miner's public key used for VRF.
	VRFPublicKey []byte
}

NodeID contains a miner's two public keys.

func BytesToNodeID added in v0.1.28

func BytesToNodeID(b []byte) (*NodeID, error)

BytesToNodeID deserializes a byte slice into a NodeID TODO: length of the input will be made exact when the NodeID is compressed into one single key (https://github.com/spacemeshos/go-spacemesh/issues/2269)

func StringToNodeID added in v0.1.28

func StringToNodeID(s string) (*NodeID, error)

StringToNodeID deserializes a string into a NodeID TODO: length of the input will be made exact when the NodeID is compressed into one single key (https://github.com/spacemeshos/go-spacemesh/issues/2269)

func (NodeID) Field added in v0.1.11

func (id NodeID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (NodeID) ShortString added in v0.1.11

func (id NodeID) ShortString() string

ShortString returns a the first 5 characters of the ID, for logging purposes.

func (NodeID) String added in v0.1.11

func (id NodeID) String() string

String returns a string representation of the NodeID, for logging purposes. It implements the Stringer interface.

func (NodeID) ToBytes added in v0.1.11

func (id NodeID) ToBytes() []byte

ToBytes returns the byte representation of the Edwards public key.

type PoetProof

type PoetProof struct {
	poetShared.MerkleProof
	Members   [][]byte
	LeafCount uint64
}

PoetProof is the full PoET service proof of elapsed time. It includes the list of members, a leaf count declaration and the actual PoET Merkle proof.

type PoetProofMessage

type PoetProofMessage struct {
	PoetProof
	PoetServiceID []byte
	RoundID       string
	Signature     []byte
}

PoetProofMessage is the envelope which includes the PoetProof, service ID, round ID and signature.

func (PoetProofMessage) Ref

func (proofMessage PoetProofMessage) Ref() ([]byte, error)

Ref returns the reference to the PoET proof message. It's the sha256 sum of the entire proof message.

type PoetRound

type PoetRound struct {
	ID string
}

PoetRound includes the PoET's round ID.

type Post added in v1.0.0

type Post postShared.Proof

Post is an alias to postShared.Proof.

func (Post) String added in v1.0.0

func (p Post) String() string

String returns a string representation of the PostProof, for logging purposes. It implements the Stringer interface.

type PostMetadata added in v1.0.0

type PostMetadata struct {
	Challenge     []byte
	BitsPerLabel  uint
	LabelsPerUnit uint
	K1            uint
	K2            uint
}

PostMetadata is similar postShared.ProofMetadata, but without the fields which can be derived elsewhere in a given ATX (ID, NumUnits).

type ProcessingError

type ProcessingError string

ProcessingError is a type of error (implements the error interface) that is used to differentiate processing errors from validation errors.

func (ProcessingError) Error

func (s ProcessingError) Error() string

Error returns the processing error as a string. It implements the error interface.

type Proposal added in v1.0.0

type Proposal struct {
	// the content proposal for a given layer and the votes on the mesh history
	InnerProposal
	// smesher's signature on InnerProposal
	Signature []byte
	// contains filtered or unexported fields
}

Proposal contains the smesher's signed content proposal for a given layer and vote on the mesh history. Proposal is ephemeral and will be discarded after the unified content block is created. the Ballot within the Proposal will remain in the mesh.

func GenLayerProposal

func GenLayerProposal(layerID LayerID, txs []TransactionID) *Proposal

GenLayerProposal returns a Proposal in the given layer with the given data.

func SortProposals added in v1.0.0

func SortProposals(proposals []*Proposal) []*Proposal

SortProposals sorts a list of Proposal in their ID's lexicographic order, in-place.

func (*Proposal) Bytes

func (p *Proposal) Bytes() []byte

Bytes returns the serialization of the InnerProposal.

func (*Proposal) Fields

func (p *Proposal) Fields() []log.LoggableField

Fields returns an array of LoggableFields for logging.

func (*Proposal) ID added in v1.0.0

func (p *Proposal) ID() ProposalID

ID returns the ProposalID.

func (*Proposal) Initialize added in v1.0.0

func (p *Proposal) Initialize() error

Initialize calculates and sets the Proposal's cached proposalID. this should be called once all the other fields of the Proposal are set.

func (*Proposal) MarshalLogObject added in v1.0.0

func (p *Proposal) MarshalLogObject(encoder log.ObjectEncoder) error

MarshalLogObject implements logging interface.

type ProposalID added in v1.0.0

type ProposalID Hash20

ProposalID is a 20-byte sha256 sum of the serialized ballot used to identify a Proposal.

func RandomProposalID added in v1.0.0

func RandomProposalID() ProposalID

RandomProposalID generates a random ProposalID for testing.

func SortProposalIDs added in v1.0.0

func SortProposalIDs(ids []ProposalID) []ProposalID

SortProposalIDs sorts a list of ProposalID in lexicographic order, in-place.

func ToProposalIDs added in v1.0.0

func ToProposalIDs(proposals []*Proposal) []ProposalID

ToProposalIDs returns a slice of ProposalID corresponding to the given proposals.

func (ProposalID) AsHash32 added in v1.0.0

func (id ProposalID) AsHash32() Hash32

AsHash32 returns a Hash32 whose first 20 bytes are the bytes of this ProposalID, it is right-padded with zeros.

func (ProposalID) Bytes added in v1.0.0

func (id ProposalID) Bytes() []byte

Bytes returns the ProposalID as a byte slice.

func (ProposalID) Compare added in v1.0.0

func (id ProposalID) Compare(other ProposalID) bool

Compare returns true if other (the given ProposalID) is less than this ProposalID, by lexicographic comparison.

func (ProposalID) Field added in v1.0.0

func (id ProposalID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (ProposalID) String added in v1.0.0

func (id ProposalID) String() string

String returns a short prefix of the hex representation of the ID.

type RatVar added in v1.0.0

type RatVar big.Rat

RatVar is a wrapper for big.Rat to use it with the pflag package.

func (*RatVar) Set added in v1.0.0

func (r *RatVar) Set(s string) error

Set sets the value of big.Rat to a string.

func (*RatVar) String added in v1.0.0

func (r *RatVar) String() string

String returns a string representation of big.Rat.

func (*RatVar) Type added in v1.0.0

func (r *RatVar) Type() string

Type returns *big.Rat type.

type Reward

type Reward struct {
	Layer               LayerID
	TotalReward         uint64
	LayerRewardEstimate uint64
	SmesherID           NodeID
	Coinbase            Address
}

Reward is a virtual reward transaction, which the node keeps track of for the gRPC api.

type RoundID added in v1.0.0

type RoundID uint32

RoundID is the round ID used to run any protocol that requires multiple rounds.

func (RoundID) Field added in v1.0.0

func (r RoundID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

type StorageSize

type StorageSize float64

StorageSize is a wrapper around a float value that supports user friendly formatting.

func (StorageSize) String

func (s StorageSize) String() string

String implements the stringer interface.

func (StorageSize) TerminalString

func (s StorageSize) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

type Transaction

type Transaction struct {
	InnerTransaction
	Signature [64]byte
	// contains filtered or unexported fields
}

Transaction contains all transaction fields, including the signature and cached origin address and transaction ID.

func BytesToTransaction added in v0.1.15

func BytesToTransaction(buf []byte) (*Transaction, error)

BytesToTransaction deserializes a Transaction.

func NewSignedTx added in v0.1.15

func NewSignedTx(nonce uint64, rec Address, amount, gas, fee uint64, signer *signing.EdSigner) (*Transaction, error)

NewSignedTx is used in TESTS ONLY to generate signed txs.

func (*Transaction) CalcAndSetOrigin

func (t *Transaction) CalcAndSetOrigin() error

CalcAndSetOrigin extracts the public key from the transaction's signature and caches it as the transaction's origin address.

func (*Transaction) GetFee

func (t *Transaction) GetFee() uint64

GetFee returns the fee of the transaction.

func (*Transaction) GetRecipient

func (t *Transaction) GetRecipient() Address

GetRecipient returns the transaction recipient.

func (*Transaction) Hash32

func (t *Transaction) Hash32() Hash32

Hash32 returns the TransactionID as a Hash32.

func (*Transaction) ID added in v0.1.11

func (t *Transaction) ID() TransactionID

ID returns the transaction's ID. If it's not cached, it's calculated, cached and returned.

func (*Transaction) Origin

func (t *Transaction) Origin() Address

Origin returns the transaction's origin address: the public key extracted from the transaction signature.

func (*Transaction) SetOrigin

func (t *Transaction) SetOrigin(origin Address)

SetOrigin sets the cache of the transaction's origin address.

func (*Transaction) ShortString

func (t *Transaction) ShortString() string

ShortString returns the first 5 characters of the ID, for logging purposes.

func (*Transaction) String

func (t *Transaction) String() string

String returns a string representation of the Transaction, for logging purposes. It implements the fmt.Stringer interface.

type TransactionID added in v0.1.11

type TransactionID Hash32

TransactionID is a 32-byte sha256 sum of the transaction, used as an identifier.

func RandomTXSet added in v1.0.0

func RandomTXSet(size int) []TransactionID

RandomTXSet generates a random set of TransactionID of the specified size.

func RandomTransactionID added in v1.0.0

func RandomTransactionID() TransactionID

RandomTransactionID generates a random TransactionID for testing.

func SortTransactionIDs added in v1.0.0

func SortTransactionIDs(ids []TransactionID) []TransactionID

SortTransactionIDs sorts a list of TransactionID in their lexicographic order, in-place.

func ToTransactionIDs added in v1.0.0

func ToTransactionIDs(txs []*Transaction) []TransactionID

ToTransactionIDs returns a slice of TransactionID corresponding to the given transactions.

func (TransactionID) Bytes added in v0.1.11

func (id TransactionID) Bytes() []byte

Bytes returns the TransactionID as a byte slice.

func (TransactionID) Compare added in v1.0.0

func (id TransactionID) Compare(other TransactionID) bool

Compare returns true if other (the given TransactionID) is less than this TransactionID, by lexicographic comparison.

func (TransactionID) Field added in v0.1.11

func (id TransactionID) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (TransactionID) Hash32 added in v0.1.11

func (id TransactionID) Hash32() Hash32

Hash32 returns the TransactionID as a Hash32.

func (TransactionID) ShortString added in v0.1.11

func (id TransactionID) ShortString() string

ShortString returns a the first 10 characters of the ID, for logging purposes.

func (TransactionID) String added in v0.1.11

func (id TransactionID) String() string

String returns a hexadecimal representation of the TransactionID with "0x" prepended, for logging purposes. It implements the fmt.Stringer interface.

type TryMutex added in v0.1.2

type TryMutex struct {
	sync.Mutex
}

TryMutex is a simple sync.Mutex with the ability to try to Lock.

func (*TryMutex) TryLock added in v0.1.2

func (m *TryMutex) TryLock() bool

TryLock tries to lock m. It returns true in case of success, false otherwise.

type Votes added in v1.0.0

type Votes struct {
	// Base ballot.
	Base BallotID
	// Support and Against blocks that base ballot votes differently.
	Support, Against []BlockID
	// Abstain on layers until they are terminated.
	Abstain []LayerID
}

Votes is for encoding local votes to send over the wire.

a smesher creates votes in the following steps: - select a Ballot in the past as a base Ballot - calculate the opinion difference on history between the smesher and the base Ballot - encode the opinion difference in 3 list:

  • ForDiff contains blocks we support while the base ballot did not support (i.e. voted against) for blocks we support in layers later than the base ballot, we also add them to this list
  • AgainstDiff contains blocks we vote against while the base ballot explicitly supported
  • NeutralDiff contains layers we vote neutral while the base ballot explicitly supported or voted against

example: layer | unified content block -----------------------------------------------------------------------------------------------

N   | UCB_A (genesis)

-----------------------------------------------------------------------------------------------

N+1  | UCB_B base:UCB_A, for:[UCB_A], against:[], neutral:[]

-----------------------------------------------------------------------------------------------

N+2  | UCB_C base:UCB_B, for:[UCB_B], against:[], neutral:[]

-----------------------------------------------------------------------------------------------

(hare hasn't terminated for N+2)
N+3  | UCB_D base:UCB_B, for:[UCB_B], against:[], neutral:[N+2]

-----------------------------------------------------------------------------------------------

(hare succeeded for N+2 but failed for N+3)
N+4  | UCB_E base:UCB_C, for:[UCB_C], against:[], neutral:[]

----------------------------------------------------------------------------------------------- NOTE on neutral votes: a base block is by default neutral on all blocks and layers that come after it, so there's no need to explicitly add neutral votes for more recent layers.

TODO: maybe collapse Support and Against into a single list.

see https://github.com/spacemeshos/go-spacemesh/issues/2369.

type VotingEligibilityProof

type VotingEligibilityProof struct {
	// the counter value used to generate this eligibility proof. if the value of J is 3, this is the smesher's
	// eligibility proof of the 3rd ballot/proposal in the epoch.
	J uint32
	// the VRF signature of some epoch specific data and J. one can derive a Ballot's layerID from this signature.
	Sig []byte
}

VotingEligibilityProof includes the required values that, along with the smesher's VRF public key, allow non-interactive voting eligibility validation. this proof provides eligibility for both voting and making proposals.

Jump to

Keyboard shortcuts

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