genesis

package
v1.0.0-rc51 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 34 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConsensusParams

func DefaultConsensusParams() *tmproto.ConsensusParams

func Document

func Document(
	ecfg encoding.Config,
	params *tmproto.ConsensusParams,
	chainID string,
	gentxs []json.RawMessage,
	addrs []string,
	pubkeys []cryptotypes.PubKey,
	mods ...Modifier,
) (*coretypes.GenesisDoc, error)

Document will create a valid genesis doc with funded addresses.

func GenerateEd25519

func GenerateEd25519(seed []byte) crypto.PrivKey

func InitFiles

func InitFiles(
	dir string,
	tmCfg *config.Config,
	g *Genesis,
	validatorIndex int,
) (string, error)

InitFiles initializes the files for a new tendermint node with the provided genesis. It will use the validatorIndex to save the validator's consensus key.

func NewSeed

func NewSeed(r *mrand.Rand) []byte

Types

type Account

type Account struct {
	Name          string
	InitialTokens int64
}

func NewAccounts

func NewAccounts(initBal int64, names ...string) []Account

func (*Account) ValidateBasic

func (ga *Account) ValidateBasic() error

type Genesis

type Genesis struct {

	// ConsensusParams are the consensus parameters of the network.
	ConsensusParams *tmproto.ConsensusParams
	// ChainID is the chain ID of the network.
	ChainID string
	// GenesisTime is the genesis time of the network.
	GenesisTime time.Time
	// contains filtered or unexported fields
}

Genesis manages the creation of the genesis state of a network. It is meant to be used as the first step to any test that requires a network.

func NewDefaultGenesis

func NewDefaultGenesis() *Genesis

NewDefaultGenesis creates a new default genesis with no accounts or validators.

func (*Genesis) Accounts

func (g *Genesis) Accounts() []Account

func (*Genesis) AddAccount

func (g *Genesis) AddAccount(acc Account) error

func (*Genesis) AddValidator

func (g *Genesis) AddValidator(val Validator) error

func (*Genesis) Export

func (g *Genesis) Export() (*coretypes.GenesisDoc, error)

func (*Genesis) Keyring

func (g *Genesis) Keyring() keyring.Keyring

func (*Genesis) Validator

func (g *Genesis) Validator(i int) (Validator, bool)

Validator returns the validator at the given index. False is returned if the index is out of bounds.

func (*Genesis) Validators

func (g *Genesis) Validators() []Validator

func (*Genesis) WithAccounts

func (g *Genesis) WithAccounts(accs ...Account) *Genesis

func (*Genesis) WithChainID

func (g *Genesis) WithChainID(chainID string) *Genesis

func (*Genesis) WithConsensusParams

func (g *Genesis) WithConsensusParams(params *tmproto.ConsensusParams) *Genesis

func (*Genesis) WithGenesisTime

func (g *Genesis) WithGenesisTime(genesisTime time.Time) *Genesis

func (*Genesis) WithModifiers

func (g *Genesis) WithModifiers(ops ...Modifier) *Genesis

func (*Genesis) WithValidators

func (g *Genesis) WithValidators(vals ...Validator) *Genesis

type Modifier

type Modifier func(state map[string]json.RawMessage) map[string]json.RawMessage

Modifier allows for arbitrary changes to be made on the genesis state after initial accounts have been added. It accepts the genesis state as input and is expected to return the modified genesis as output.

func FundAccounts

func FundAccounts(codec codec.Codec, addresses []sdk.AccAddress, balance sdk.Coin) Modifier

FundAccounts adds a set of accounts to the genesis and then sets their balance as provided. This is good in the case where you have a separate keyring you want to test against and not use the one generated by the testnet infra.

func ImmediateProposals

func ImmediateProposals(codec codec.Codec) Modifier

ImmediateProposals sets the thresholds for getting a gov proposal to very low levels.

func SetBlobParams

func SetBlobParams(codec codec.Codec, params blobtypes.Params) Modifier

SetBlobParams will set the provided blob params as genesis state.

func SetDataCommitmentWindow

func SetDataCommitmentWindow(codec codec.Codec, window uint64) Modifier

SetDataCommitmentWindow will set the provided data commitment window in the qgb module's genesis state.

type Validator

type Validator struct {
	Account
	Stake int64

	// ConsensusKey is the key used by the validator to sign votes.
	ConsensusKey crypto.PrivKey
	NetworkKey   crypto.PrivKey
}

func NewDefaultValidator

func NewDefaultValidator(name string) Validator

func (*Validator) GenTx

func (v *Validator) GenTx(ecfg encoding.Config, kr keyring.Keyring, chainID string) (sdk.Tx, error)

GenTx generates a genesis transaction to create a validator as configured by the validator struct. It assumes the validator's genesis account has already been added to the keyring and that the sequence for that account is 0.

func (*Validator) ValidateBasic

func (v *Validator) ValidateBasic() error

ValidateBasic performs stateless validation on the validitor

Jump to

Keyboard shortcuts

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