testmigration

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MorseUnstakedActor = MorseAccountActorType(iota)
	MorseApplicationActor
	MorseSupplierActor

	// NumMorseAccountActorTypes is the number of MorseAccountActorTypes.
	// It takes advantage of the fact that the enum is zero-indexed.
	NumMorseAccountActorTypes
)

Variables

View Source
var BcryptSecurityParameter = 12

BcryptSecurityParameter is a var so that it can be changed within the lcd test Making the bcrypt security parameter a var shouldn't be a security issue: One can't verify an invalid key by maliciously changing the bcrypt parameter during a runtime vulnerability. The main security threat this then exposes would be something that changes this during runtime before the user creates their key. This vulnerability must succeed to update this to that same value before every subsequent call to the keys command in future startups / or the attacker must get access to the filesystem. However, with a similar threat model (changing variables in runtime), one can cause the user to sign a different tx than what they see, which is a significantly cheaper attack then breaking a bcrypt hash. (Recall that the nonce still exists to break rainbow tables) For further notes on security parameter choice, see README.md

Functions

func EncryptAESGCM added in v0.1.2

func EncryptAESGCM(key []byte, src []byte) ([]byte, error)

func EncryptArmorPrivKey added in v0.1.2

func EncryptArmorPrivKey(privKey ed25519.PrivKey, passphrase string, hint string) (string, error)

EncryptArmorPrivKey encrypts the given private key using a random salt and the given passphrase with the AES-256-GCM algorithm. It then encapsulates the ciphertext, salt, and hint in an ArmoredJson struct and returns it as a JSON-encoded string.

func GenMorseAccount added in v0.0.14

func GenMorseAccount(index uint64) *migrationtypes.MorseAccount

GenMorseAccount returns a new MorseAccount fixture. The given index is used to deterministically generate the account's address and unstaked balance.

func GenMorseApplication added in v0.0.14

func GenMorseApplication(idx uint64) *migrationtypes.MorseApplication

GenMorseApplication returns a new MorseApplication fixture. The given index is used to deterministically generate the application's address and staked tokens.

func GenMorseApplicationStakeAmount added in v0.0.14

func GenMorseApplicationStakeAmount(index uint64) int64

GenMorseApplicationStakeAmount returns an amount by applying the given index to a pattern such that the generated amount is unique to the application stake (as opposed to the unstaked balance or supplier stake) and the given index. E.g.: - GenMorseApplicationStakeAmount(0) = 100010 - GenMorseApplicationStakeAmount(1) = 200020 - GenMorseApplicationStakeAmount(10) = 1000100

func GenMorseClaimableAccount added in v0.0.14

func GenMorseClaimableAccount(
	index uint64,
	distributionFn func(uint64) MorseAccountActorType,
) (*migrationtypes.MorseClaimableAccount, error)

GenMorseClaimableAccount returns a new MorseClaimableAccount fixture. The given index is used to deterministically generate the account's address and staked tokens. The given distribution function is used to determine the account's actor type (and stake if applicable).

func GenMorsePrivateKey added in v0.0.14

func GenMorsePrivateKey(seed uint64) cometcrypto.PrivKey

GenMorsePrivateKey creates a new ed25519 private key from the given seed.

func GenMorseSupplierStakeAmount added in v0.0.14

func GenMorseSupplierStakeAmount(index uint64) int64

GenMorseSupplierStakeAmount returns an amount by applying the given index to a pattern such that the generated amount is unique to the supplier stake (as opposed to the unstaked balance or application stake) and the given index. E.g.: - GenMorseApplicationStakeAmount(0) = 10100 - GenMorseApplicationStakeAmount(1) = 20200 - GenMorseApplicationStakeAmount(10) = 101000

func GenMorseUnstakedBalanceAmount added in v0.0.14

func GenMorseUnstakedBalanceAmount(index uint64) int64

GenMorseUnstakedBalanceAmount returns an amount by applying the given index to a pattern such that the generated amount is unique to the unstaked balance (as opposed to actor stake(s)) and the given index. E.g.: - GenMorseApplicationStakeAmount(0) = 1000001 - GenMorseApplicationStakeAmount(1) = 2000002 - GenMorseApplicationStakeAmount(10) = 10000010

func GenMorseValidator added in v0.0.14

func GenMorseValidator(idx uint64) *migrationtypes.MorseValidator

GenMorseValidator returns a new MorseValidator fixture. The given index is used to deterministically generate the validator's address and staked tokens.

func NewArmoredJson added in v0.1.2

func NewArmoredJson(kdf, salt, hint, ciphertext string) cmd.ArmoredJson

NewArmoredJson returns a new ArmoredJson struct with the given fields.

func NewMorseStateExportAndAccountState

func NewMorseStateExportAndAccountState(
	numAccounts int,
	distributionFn MorseAccountActorTypeDistributionFn,
) (export *migrationtypes.MorseStateExport, state *migrationtypes.MorseAccountState, err error)

NewMorseStateExportAndAccountState returns MorseStateExport and MorseAccountState structs populated with: - Random account addresses - Monotonically increasing balances/stakes - Unstaked, application, supplier accounts are distributed according to the given distribution function.

func NewMorseStateExportAndAccountStateBytes

func NewMorseStateExportAndAccountStateBytes(
	numAccounts int,
	distributionFn MorseAccountActorTypeDistributionFn,
) (morseStateExportBz []byte, morseAccountStateBz []byte, err error)

NewMorseStateExportAndAccountStateBytes returns:

  • A serialized MorseStateExport. This is the JSON output of `pocket util export-genesis-for-reset`. It is used to generate the MorseAccountState.
  • Its corresponding MorseAccountState. This is the JSON output of `pocketd migrate collect-morse-accounts`. It is used to persist the canonical Morse migration state (snapshot) from on Shannon.

The states are populated with: - Random account addresses - Monotonically increasing balances/stakes - Unstaked, application, supplier accounts are distributed according to the given distribution function.

Types

type MorseAccountActorType added in v0.0.14

type MorseAccountActorType int

MorseAccountActorType is an enum which represents all possible staked and unstaked actor types which are considered in the migration module.

func AllApplicationMorseAccountActorType added in v0.0.14

func AllApplicationMorseAccountActorType(index uint64) MorseAccountActorType

AllApplicationMorseAccountActorType returns MorseApplicationActor for every index.

func AllSupplierMorseAccountActorType added in v0.0.14

func AllSupplierMorseAccountActorType(index uint64) MorseAccountActorType

AllSupplierMorseAccountActorType returns MorseSupplierActor for every index.

func AllUnstakedMorseAccountActorType added in v0.0.14

func AllUnstakedMorseAccountActorType(index uint64) MorseAccountActorType

AllUnstakedMorseAccountActorType returns MorseUnstakedActor for every index.

func GetRoundRobinMorseAccountActorType added in v0.1.2

func GetRoundRobinMorseAccountActorType(idx uint64) MorseAccountActorType

GetRoundRobinMorseAccountActorType returns the actor type for the given index, given a round-robin distribution.

func RoundRobinAllMorseAccountActorTypes added in v0.0.14

func RoundRobinAllMorseAccountActorTypes(index uint64) MorseAccountActorType

RoundRobinAllMorseAccountActorTypes cyclically returns each MorseAccountActorType, one after the other, as the index increases. It is used to map a test account index to the test actor that's generated.

type MorseAccountActorTypeDistributionFn added in v0.0.14

type MorseAccountActorTypeDistributionFn func(index uint64) MorseAccountActorType

MorseAccountActorTypeDistributionFn is a function which returns a MorseAccountActorType derived from the given index. It is intended to be used in conjunction with MorseStateExport and MorseAccountState fixture generation logic.

func NewSingleMorseAccountActorTypeFn added in v0.0.14

func NewSingleMorseAccountActorTypeFn(actorType MorseAccountActorType) MorseAccountActorTypeDistributionFn

NewSingleMorseAccountActorTypeFn returns a MorseAccountActorTypeDistributionFn which returns the given actor type for every index.

Jump to

Keyboard shortcuts

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