genesis

package
v0.0.1-pre-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 13 Imported by: 0

README

shared/types/genesis

!!! IMPORTANT !!!

This directory was created for the purposes of integration between the four core modules and is not intended to store all the core shared types in the long-term.

Speak to @andrewnguyen22 or @Olshansk for more details.

!!! IMPORTANT !!!

Documentation

Index

Constants

View Source
const (
	ServiceNodeStakePoolName = "SERVICE_NODE_STAKE_POOL"
	AppStakePoolName         = "APP_STAKE_POOL"
	ValidatorStakePoolName   = "VALIDATOR_STAKE_POOL"
	FishermanStakePoolName   = "FISHERMAN_STAKE_POOL"
	DAOPoolName              = "DAO_POOL"
	FeePoolName              = "FEE_POOL"
)

Variables

View Source
var (
	// NOTE: this is for fun illustration purposes... The addresses begin with DA0, DA0, and FEE :)
	// Of course, in a production network the params / owners must be set in the genesis file
	DefaultParamsOwner, _          = crypto.NewPrivateKey("ff538589deb7f28bbce1ba68b37d2efc0eaa03204b36513cf88422a875559e38d6cbe0430ddd85a5e48e0c99ef3dea47bf0d1a83c6e6ad1640f72201dc8a0120")
	DefaultDAOPool, _              = crypto.NewPrivateKey("b1dfb25a67dadf9cdd39927b86166149727649af3a3143e66e558652f8031f3faacaa24a69bcf2819ed97ab5ed8d1e490041e5c7ef9e1eddba8b5678f997ae58")
	DefaultFeeCollector, _         = crypto.NewPrivateKey("bdc02826b5da77b90a5d1550443b3f007725cc654c10002aa01e65a131f3464b826f8e7911fa89b4bd6659c3175114d714c60bac63acc63817c0d3a4ed2fdab8")
	DefaultFishermanStakePool, _   = crypto.NewPrivateKey("f3dd5c8ccd9a7c8d0afd36424c6fbe8ead55315086ef3d0d03ce8c7357e5e306733a711adb6fc8fbef6a3e2ac2db7842433053a23c751d19573ab85b52316f67")
	DefaultServiceNodeStakePool, _ = crypto.NewPrivateKey("b4e4426ed014d5ee89949e6f60c406c328e4fce466cd25f4697a41046b34313097a8cc38033822da010422851062ae6b21b8e29d4c34193b7d8fa0f37b6593b6")
	DefaultValidatorStakePool, _   = crypto.NewPrivateKey("e0b8b7cdb33f11a8d70eb05070e53b02fe74f4499aed7b159bd2dd256e356d67664b5b682e40ee218e5feea05c2a1bb595ec15f3850c92b571cdf950b4d9ba23")
	DefaultAppStakePool, _         = crypto.NewPrivateKey("429627bac8dc322f0aeeb2b8f25b329899b7ebb9605d603b5fb74557b13357e50834e9575c19d9d7d664ec460a98abb2435ece93440eb482c87d5b7259a8d271")
)
View Source
var (
	DefaultChains         = []string{"0001"}
	DefaultServiceUrl     = "https://foo.bar"
	DefaultStakeBig       = big.NewInt(1000000000000000)
	DefaultStake          = types.BigIntToString(DefaultStakeBig)
	DefaultAccountBalance = DefaultStake
	DefaultStakeStatus    = int32(2)
)

Functions

func ValidatorListToMap

func ValidatorListToMap(validators []*Validator) (m map[string]*Validator)

Types

type Genesis

type Genesis struct {
	// TODO(olshansky): Discuss this structure with Andrew.
	GenesisStateConfig *NewGenesisStateConfigs `json:"genesis_state_configs"`

	GenesisTime time.Time    `json:"genesis_time"`
	AppHash     string       `json:"app_hash"`
	Validators  []*Validator `json:"validators"`
}

func PocketGenesisFromFile

func PocketGenesisFromFile(file string) (*Genesis, error)

func PocketGenesisFromFileOrJSON

func PocketGenesisFromFileOrJSON(fileOrJson string) (*Genesis, error)

TODO: This is a temporary hack that can load Genesis from a single string that may be either a JSON blob or a file.

func PocketGenesisFromJSON

func PocketGenesisFromJSON(jsonBlob []byte) (*Genesis, error)

func (*Genesis) Validate

func (genesis *Genesis) Validate() error

type NewGenesisStateConfigs

type NewGenesisStateConfigs struct {
	NumValidators    uint16 `json:"num_validators"`
	NumAppplications uint16 `json:"num_applications"`
	NumFisherman     uint16 `json:"num_fisherman"`
	NumServicers     uint16 `json:"num_servicers"`

	SeedStart          uint32 `json:"keys_seed_start"`
	ValidatorUrlFormat string `json:"validator_url_format"`
}

TODO(team): NewGenesisStateConfigs is ONLY used for development purposes and disregards the other configs in the genesis file if specified. it is used to seed and configure data in `NewGenesisState`.

type NodeState

type NodeState struct {
	GenesisState *GenesisState

	BlockHeight      uint64
	AppHash          string                // TODO: Why not call this a BlockHash or StateHash? SHould it be a []byte or string?
	ValidatorMap     map[string]*Validator // TODO: Need to update this on every validator pause/stake/unstake/etc.
	TotalVotingPower uint64                // TODO: Need to update this on every send transaction.
}

TODO(team): This structure is a proxy into the current / active state of the network containing information such as the current validator map. As a next step, we can move all of this data over into the persistence module.

func GetNodeState

func GetNodeState(cfg *config.Config) *NodeState

TODO(team): Passing both config and genesis to `GetNodeState` is a hack and only used for integration purposes

func (*NodeState) PrintGlobalState

func (ps *NodeState) PrintGlobalState()

func (*NodeState) UpdateAppHash

func (ps *NodeState) UpdateAppHash(appHash string)

func (*NodeState) UpdateBlockHeight

func (ps *NodeState) UpdateBlockHeight(blockHeight uint64)

Jump to

Keyboard shortcuts

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