gnoland

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package gnoland contains the bootstrapping code to launch a gno.land node.

Index

Constants

View Source
const (
	ParamKindString = "string"
	ParamKindInt64  = "int64"
	ParamKindUint64 = "uint64"
	ParamKindBool   = "bool"
	ParamKindBytes  = "bytes"
)

Variables

View Source
var (
	ErrBalanceEmptyAddress = errors.New("balance address is empty")
	ErrBalanceEmptyAmount  = errors.New("balance amount is empty")
)
View Source
var Package = amino.RegisterPackage(amino.NewPackage(
	"github.com/gnolang/gno/gno.land/pkg/gnoland",
	"gno",
	amino.GetCallersDirname(),
).WithDependencies().WithTypes(
	&GnoAccount{}, "Account",
	GnoGenesisState{}, "GenesisState",
	TxWithMetadata{}, "TxWithMetadata",
	GnoTxMetadata{}, "GnoTxMetadata",
))

Functions

func EndBlocker

func EndBlocker(
	collector *collector[validatorUpdate],
	vmk vm.VMKeeperI,
	app endBlockerApp,
) func(
	ctx sdk.Context,
	req abci.RequestEndBlock,
) abci.ResponseEndBlock

EndBlocker defines the logic executed after every block. Currently, it parses events that happened during execution to calculate validator set changes

func LoadPackage

func LoadPackage(pkg gnomod.Pkg, creator bft.Address, fee std.Fee, deposit std.Coins) (std.Tx, error)

LoadPackage loads a single package into a `std.Tx`

func NewApp

func NewApp(
	dataRootDir string,
	skipFailingGenesisTxs bool,
	evsw events.EventSwitch,
	logger *slog.Logger,
) (abci.Application, error)

NewApp creates the gno.land application.

func NewAppWithOptions

func NewAppWithOptions(cfg *AppOptions) (abci.Application, error)

NewAppWithOptions creates the gno.land application with specified options.

func NewDefaultGenesisConfig

func NewDefaultGenesisConfig(chainid string) *bft.GenesisDoc

NewDefaultGenesisConfig creates a default configuration for an in-memory node.

func NewDefaultTMConfig

func NewDefaultTMConfig(rootdir string) *tmcfg.Config

func NewInMemoryNode

func NewInMemoryNode(logger *slog.Logger, cfg *InMemoryNodeConfig) (*node.Node, error)

NewInMemoryNode creates an in-memory gnoland node. In this mode, the node does not persist any data and uses an in-memory database. The `InMemoryNodeConfig.TMConfig.RootDir` should point to the correct gno repository to load the stdlibs.

func NewMockedPrivValidator

func NewMockedPrivValidator() bft.PrivValidator

NewMockedPrivValidator generate a new key

func NoopGenesisTxResultHandler

func NoopGenesisTxResultHandler(_ sdk.Context, _ std.Tx, _ sdk.Result)

NoopGenesisTxResultHandler is a no-op GenesisTxResultHandler.

func PanicOnFailingTxResultHandler

func PanicOnFailingTxResultHandler(_ sdk.Context, _ std.Tx, res sdk.Result)

PanicOnFailingTxResultHandler handles genesis transactions by panicking if res.IsErr() returns true.

func ProtoGnoAccount

func ProtoGnoAccount() std.Account

Types

type AppOptions

type AppOptions struct {
	DB                dbm.DB             // required
	Logger            *slog.Logger       // required
	EventSwitch       events.EventSwitch // required
	VMOutput          io.Writer          // optional
	InitChainerConfig                    // options related to InitChainer
}

AppOptions contains the options to create the gno.land ABCI application.

func TestAppOptions

func TestAppOptions(db dbm.DB) *AppOptions

TestAppOptions provides a "ready" default AppOptions for use with NewAppWithOptions, using the provided db.

type Balance

type Balance struct {
	Address bft.Address
	Amount  std.Coins
}

func LoadGenesisBalancesFile

func LoadGenesisBalancesFile(path string) ([]Balance, error)

LoadGenesisBalancesFile loads genesis balances from the provided file path.

func (Balance) MarshalAmino

func (b Balance) MarshalAmino() (string, error)

func (*Balance) Parse

func (b *Balance) Parse(entry string) error

func (Balance) String

func (b Balance) String() string

func (*Balance) UnmarshalAmino

func (b *Balance) UnmarshalAmino(rep string) error

func (*Balance) Verify

func (b *Balance) Verify() error

type Balances

type Balances map[crypto.Address]Balance

func GetBalancesFromEntries

func GetBalancesFromEntries(entries ...string) (Balances, error)

func GetBalancesFromSheet

func GetBalancesFromSheet(sheet io.Reader) (Balances, error)

func NewBalances

func NewBalances() Balances

func (Balances) Get

func (bs Balances) Get(address crypto.Address) (balance Balance, ok bool)

func (Balances) LeftMerge

func (bs Balances) LeftMerge(from Balances)

LeftMerge left-merges the two maps

func (Balances) List

func (bs Balances) List() []Balance

func (Balances) LoadFromEntries

func (bs Balances) LoadFromEntries(entries ...string) error

LoadFromEntries extracts the balance entries in the form of <address>=<amount>

func (Balances) LoadFromSheet

func (bs Balances) LoadFromSheet(sheet io.Reader) error

LoadFromSheet extracts the balance sheet from the passed in balance sheet file, that has the format of <address>=<amount>ugnot

func (Balances) Set

func (bs Balances) Set(address crypto.Address, amount std.Coins)

type GenesisTxResultHandler

type GenesisTxResultHandler func(ctx sdk.Context, tx std.Tx, res sdk.Result)

GenesisTxResultHandler is called in the InitChainer after a genesis transaction is executed.

type GnoAccount

type GnoAccount struct {
	std.BaseAccount
}

type GnoGenesisState

type GnoGenesisState struct {
	Balances []Balance        `json:"balances"`
	Txs      []TxWithMetadata `json:"txs"`
	Params   []Param          `json:"params"`
}

type GnoTxMetadata

type GnoTxMetadata struct {
	Timestamp int64 `json:"timestamp"`
}

type InMemoryNodeConfig

type InMemoryNodeConfig struct {
	PrivValidator bft.PrivValidator // identity of the validator
	Genesis       *bft.GenesisDoc
	TMConfig      *tmcfg.Config
	DB            *memdb.MemDB // will be initialized if nil
	VMOutput      io.Writer    // optional

	// If StdlibDir not set, then it's filepath.Join(TMConfig.RootDir, "gnovm", "stdlibs")
	InitChainerConfig
}

type InitChainerConfig

type InitChainerConfig struct {
	// Handles the results of each genesis transaction.
	GenesisTxResultHandler

	// Standard library directory.
	StdlibDir string
	// Whether to keep a record of the DB operations to load standard libraries,
	// so they can be quickly replicated on additional genesis executions.
	// This should be used for integration testing, where InitChainer will be
	// called several times.
	CacheStdlibLoad bool
	// contains filtered or unexported fields
}

InitChainerConfig keeps the configuration for the InitChainer. NewAppWithOptions will set InitChainerConfig.InitChainer as its InitChainer function.

func (InitChainerConfig) InitChainer

InitChainer is the function that can be used as a sdk.InitChainer.

type Param

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

func LoadGenesisParamsFile

func LoadGenesisParamsFile(path string) ([]Param, error)

LoadGenesisParamsFile loads genesis params from the provided file path.

func (Param) MarshalAmino

func (p Param) MarshalAmino() (string, error)

func (*Param) Parse

func (p *Param) Parse(entry string) error

func (Param) String

func (p Param) String() string

func (*Param) UnmarshalAmino

func (p *Param) UnmarshalAmino(rep string) error

func (Param) Verify

func (p Param) Verify() error

type TxWithMetadata

type TxWithMetadata struct {
	Tx       std.Tx         `json:"tx"`
	Metadata *GnoTxMetadata `json:"metadata,omitempty"`
}

func LoadGenesisTxsFile

func LoadGenesisTxsFile(path string, chainID string, genesisRemote string) ([]TxWithMetadata, error)

LoadGenesisTxsFile loads genesis transactions from the provided file path. XXX: Improve the way we generate and load this file

func LoadPackagesFromDir

func LoadPackagesFromDir(dir string, creator bft.Address, fee std.Fee) ([]TxWithMetadata, error)

LoadPackagesFromDir loads gno packages from a directory. It creates and returns a list of transactions based on these packages.

func ReadGenesisTxs

func ReadGenesisTxs(ctx context.Context, path string) ([]TxWithMetadata, error)

ReadGenesisTxs reads the genesis txs from the given file path

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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