genesis

package
v3.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 38 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,
	genesisTime time.Time,
	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(
	rootDir string,
	tmConfig *config.Config,
	appCfg *srvconfig.Config,
	genesis *Genesis,
	validatorIndex int,
) error

InitFiles initializes the files for a new Comet 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
	Name    string
}

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

Accounts getter

func (*Genesis) AddAccount

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

AddAccount adds an existing account to the genesis.

func (*Genesis) AddValidator

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

AddValidator verifies and adds a given validator to the genesis.

func (*Genesis) EncodingConfig

func (g *Genesis) EncodingConfig() encoding.Config

func (*Genesis) Export

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

Export returns the genesis document of the network.

func (*Genesis) Keyring

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

Keyring getter

func (*Genesis) NewAccount

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

NewAccount creates a new account and adds it to the genesis.

func (*Genesis) NewValidator

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

NewValidator creates a new validator account and adds it to the genesis.

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

Validators getter

func (*Genesis) WithChainID

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

WithChainID sets the chain ID of the genesis.

func (*Genesis) WithConsensusParams

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

WithConsensusParams sets the consensus parameters of the genesis.

func (*Genesis) WithGenesisTime

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

WithGenesisTime sets the genesis time of the genesis.

func (*Genesis) WithKeyring

func (g *Genesis) WithKeyring(kr keyring.Keyring) *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

WithModifiers adds a genesis modifier to the genesis.

func (*Genesis) WithValidators

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

WithValidators adds the given validators to the 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.

func SetSlashingParams

func SetSlashingParams(codec codec.Codec, parans slashingtypes.Params) Modifier

SetSlashingParams will set the provided slashing params as 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