genesis

package
v2.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInitialBalance = 1e15 // 1 billion TIA
)

Variables

This section is empty.

Functions

func Document

func Document(
	ecfg encoding.Config,
	params *tmproto.ConsensusParams,
	chainID string,
	gentxs []json.RawMessage,
	accounts []Account,
	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 {
	PubKey  cryptotypes.PubKey
	Balance int64
}

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(account 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) NewAccount

func (g *Genesis) NewAccount(acc KeyringAccount) error

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) 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) WithKeyringAccounts

func (g *Genesis) WithKeyringAccounts(accs ...KeyringAccount) *Genesis

WithKeyringAccounts adds the given keyring accounts to the genesis. If an account with the same name already exists, it panics.

func (*Genesis) WithModifiers

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

func (*Genesis) WithValidators

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

type KeyringAccount

type KeyringAccount struct {
	Name          string
	InitialTokens int64
}

KeyringAccount represents a user account on the Celestia network. Either the name, if using the genesis keyring, or an address needs to be provided

func NewKeyringAccounts

func NewKeyringAccounts(initBal int64, names ...string) []KeyringAccount

func (*KeyringAccount) ValidateBasic

func (ga *KeyringAccount) ValidateBasic() error

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 blobstream module's genesis state.

type Validator

type Validator struct {
	KeyringAccount
	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