Documentation
¶
Index ¶
- type Application
- type Config
- type State
- func (s *State) Commit() (uint64, error)
- func (s *State) Export() ([]byte, uint64, []byte, error)
- func (s *State) Finalize() []byte
- func (s *State) Get(key string) string
- func (s *State) GetHash() []byte
- func (s *State) Import(height uint64, jsonBytes []byte) error
- func (s *State) Info() (uint64, []byte)
- func (s *State) MarshalJSON() ([]byte, error)
- func (s *State) Query(key string) (string, uint64)
- func (s *State) Rollback() error
- func (s *State) Set(key, value string)
- func (s *State) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
avsi.BaseApplication
// contains filtered or unexported fields
}
Application is an AVSI application for use by end-to-end tests. It is a simple key/value store for strings, storing data in memory and persisting to disk as JSON, taking state sync snapshots if requested.
func NewApplication ¶
func NewApplication(cfg *Config) (*Application, error)
NewApplication creates the application.
func (*Application) Info ¶
func (app *Application) Info(context.Context, *avsi.RequestInfo) (*avsi.ResponseInfo, error)
Info implements AVSI.
func (*Application) Query ¶
func (app *Application) Query(_ context.Context, req *avsi.RequestQuery) (*avsi.ResponseQuery, error)
Query implements AVSI.
type Config ¶
type Config struct {
// The directory with which state.json will be persisted in. Usually $HOME/.pelldvs/data
Dir string `toml:"dir"`
// SnapshotInterval specifies the height interval at which the application
// will take state sync snapshots. Defaults to 0 (disabled).
SnapshotInterval uint64 `toml:"snapshot_interval"`
// RetainBlocks specifies the number of recent blocks to retain. Defaults to
// 0, which retains all blocks. Must be greater that PersistInterval,
// SnapshotInterval and EvidenceAgeHeight.
RetainBlocks uint64 `toml:"retain_blocks"`
// KeyType sets the curve that will be used by validators.
// Options are ed25519 & secp256k1
KeyType string `toml:"key_type"`
// PersistInterval specifies the height interval at which the application
// will persist state to disk. Defaults to 1 (every height), setting this to
// 0 disables state persistence.
PersistInterval uint64 `toml:"persist_interval"`
// ValidatorUpdates is a map of heights to validator names and their power,
// and will be returned by the AVSI application. For example, the following
// changes the power of validator01 and validator02 at height 1000:
//
// [validator_update.1000]
// validator01 = 20
// validator02 = 10
//
// Specifying height 0 returns the validator update during InitChain. The
// application returns the validator updates as-is, i.e. removing a
// validator must be done by returning it with power 0, and any validators
// not specified are not changed.
//
// height <-> pubkey <-> voting power
ValidatorUpdates map[string]map[string]uint8 `toml:"validator_update"`
// Add artificial delays to each of the main AVSI calls to mimic computation time
// of the application
PrepareProposalDelay time.Duration `toml:"prepare_proposal_delay"`
ProcessProposalDelay time.Duration `toml:"process_proposal_delay"`
CheckTxDelay time.Duration `toml:"check_tx_delay"`
FinalizeBlockDelay time.Duration `toml:"finalize_block_delay"`
VoteExtensionDelay time.Duration `toml:"vote_extension_delay"`
// VoteExtensionsEnableHeight configures the first height during which
// the chain will use and require vote extension data to be present
// in precommit messages.
VoteExtensionsEnableHeight int64 `toml:"vote_extensions_enable_height"`
// VoteExtensionsUpdateHeight configures the height at which consensus
// param VoteExtensionsEnableHeight will be set.
// -1 denotes it is set at genesis.
// 0 denotes it is set at InitChain.
VoteExtensionsUpdateHeight int64 `toml:"vote_extensions_update_height"`
}
Config allows for the setting of high level parameters for running the e2e Application KeyType and ValidatorUpdates must be the same for all nodes running the same application.
func DefaultConfig ¶
type State ¶
State is the application state.
func (*State) Export ¶
Export exports key/value pairs as JSON, used for state sync snapshots. Additionally returns the current height and hash of the state.
func (*State) Finalize ¶
Finalize is called after applying a block, updating the height and returning the new app_hash
func (*State) GetHash ¶
GetHash provides a thread-safe way of accessing a copy of the current state hash.
func (*State) Import ¶
Import imports key/value pairs from JSON bytes, used for InitChain.AppStateBytes and state sync snapshots. It also saves the state once imported.
func (*State) Info ¶
Info returns both the height and hash simultaneously, and is used in the AVSI Info call.
func (*State) MarshalJSON ¶
func (*State) Query ¶
Query is used in the AVSI Query call, and provides both the current height and the value associated with the given key.