keeper

package
v7.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 73 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConsPrivKeys generate ed25519 ConsPrivKeys to be used for validator operator keys
	ConsPrivKeys = []ccrypto.PrivKey{
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
	}

	// ConsPubKeys holds the consensus public keys to be used for validator operator keys
	ConsPubKeys = []ccrypto.PubKey{
		ConsPrivKeys[0].PubKey(),
		ConsPrivKeys[1].PubKey(),
		ConsPrivKeys[2].PubKey(),
		ConsPrivKeys[3].PubKey(),
		ConsPrivKeys[4].PubKey(),
	}

	// AccPrivKeys generate secp256k1 pubkeys to be used for account pub keys
	AccPrivKeys = []ccrypto.PrivKey{
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
	}

	// AccPubKeys holds the pub keys for the account keys
	AccPubKeys = []ccrypto.PubKey{
		AccPrivKeys[0].PubKey(),
		AccPrivKeys[1].PubKey(),
		AccPrivKeys[2].PubKey(),
		AccPrivKeys[3].PubKey(),
		AccPrivKeys[4].PubKey(),
	}

	// AccAddrs holds the sdk.AccAddresses
	AccAddrs = []sdk.AccAddress{
		sdk.AccAddress(AccPubKeys[0].Address()),
		sdk.AccAddress(AccPubKeys[1].Address()),
		sdk.AccAddress(AccPubKeys[2].Address()),
		sdk.AccAddress(AccPubKeys[3].Address()),
		sdk.AccAddress(AccPubKeys[4].Address()),
	}

	// ValAddrs holds the sdk.ValAddresses
	ValAddrs = []sdk.ValAddress{
		sdk.ValAddress(AccPubKeys[0].Address()),
		sdk.ValAddress(AccPubKeys[1].Address()),
		sdk.ValAddress(AccPubKeys[2].Address()),
		sdk.ValAddress(AccPubKeys[3].Address()),
		sdk.ValAddress(AccPubKeys[4].Address()),
	}

	// EthAddrs holds etheruem addresses
	EthAddrs = []gethcommon.Address{
		gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(1)}, 20)),
		gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(2)}, 20)),
		gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(3)}, 20)),
		gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(4)}, 20)),
		gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(5)}, 20)),
	}

	// TokenContractAddrs holds example token contract addresses
	TokenContractAddrs = []string{
		"0x6b175474e89094c44da98b954eedeac495271d0f",
		"0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",
		"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
		"0xc00e94cb662c3520282e6f5717214004a7f26888",
		"0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",
	}

	// InitTokens holds the number of tokens to initialize an account with
	InitTokens = sdk.TokensFromConsensusPower(110, sdk.DefaultPowerReduction)

	// InitCoins holds the number of coins to initialize an account with
	InitCoins = sdk.NewCoins(sdk.NewCoin(TestingStakeParams.BondDenom, InitTokens))

	// StakingAmount holds the staking power to start a validator with
	StakingAmount = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)

	// StakingCoins holds the staking coins to start a validator with
	StakingCoins = sdk.NewCoins(sdk.NewCoin(TestingStakeParams.BondDenom, StakingAmount))

	// TestingStakeParams is a set of staking params for testing
	TestingStakeParams = stakingtypes.Params{
		UnbondingTime:     100,
		MaxValidators:     10,
		MaxEntries:        10,
		HistoricalEntries: 10000,
		BondDenom:         "stake",
	}

	// TestingcorkParams is a set of gravity params for testing
	TestingcorkParams = types.Params{
		VoteThreshold: sdk.MustNewDecFromStr(corkVoteThresholdStr),
	}
)

Functions

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState

ExportGenesis writes the current store values to a genesis file, which can be imported again with InitGenesis

func HandleAddManagedCellarsProposal

func HandleAddManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.AddManagedCellarIDsProposal) error

HandleAddManagedCellarsProposal is a handler for executing a passed community cellar addition proposal

func HandleRemoveManagedCellarsProposal

func HandleRemoveManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.RemoveManagedCellarIDsProposal) error

HandleRemoveManagedCellarsProposal is a handler for executing a passed community cellar removal proposal

func HandleScheduledCorkProposal

func HandleScheduledCorkProposal(ctx sdk.Context, k Keeper, p types.ScheduledCorkProposal) error

HandleScheduledCorkProposal is a handler for executing a passed scheduled cork proposal

func InitGenesis

func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState)

InitGenesis initialize default parameters and the keeper's address to pubkey map

func MakeTestCodec

func MakeTestCodec() *codec.LegacyAmino

MakeTestCodec creates a legacy amino codec for testing

func MakeTestMarshaler

func MakeTestMarshaler() codec.Codec

MakeTestMarshaler creates a proto codec for use in testing

func NewEthereumSubscriptionID

func NewEthereumSubscriptionID(address common.Address) string

Types

type AlwaysPanicStakingMock

type AlwaysPanicStakingMock struct{}

AlwaysPanicStakingMock is a mock staking keeper that panics on usage

func (AlwaysPanicStakingMock) GetBondedValidatorsByPower

func (s AlwaysPanicStakingMock) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator

GetBondedValidatorsByPower implements the interface for staking keeper required by gravity

func (AlwaysPanicStakingMock) GetLastTotalPower

func (s AlwaysPanicStakingMock) GetLastTotalPower(ctx sdk.Context) (power math.Int)

GetLastTotalPower implements the interface for staking keeper required by gravity

func (AlwaysPanicStakingMock) GetLastValidatorPower

func (s AlwaysPanicStakingMock) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) int64

GetLastValidatorPower implements the interface for staking keeper required by gravity

func (AlwaysPanicStakingMock) IterateBondedValidatorsByPower

func (s AlwaysPanicStakingMock) IterateBondedValidatorsByPower(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))

IterateBondedValidatorsByPower satisfies the interface

func (AlwaysPanicStakingMock) IterateLastValidators

func (s AlwaysPanicStakingMock) IterateLastValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))

IterateLastValidators satisfies the interface

func (AlwaysPanicStakingMock) IterateValidators

func (s AlwaysPanicStakingMock) IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))

IterateValidators satisfies the interface

func (AlwaysPanicStakingMock) Jail

Jail satisfies the interface

func (AlwaysPanicStakingMock) PowerReduction

func (s AlwaysPanicStakingMock) PowerReduction(sdk.Context) math.Int

PowerReduction satisfies the interface

func (AlwaysPanicStakingMock) Slash

Slash satisfies the interface

func (AlwaysPanicStakingMock) Validator

Validator satisfies the interface

func (AlwaysPanicStakingMock) ValidatorByConsAddr

ValidatorByConsAddr satisfies the interface

type Hooks

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

func (Hooks) AfterBatchExecutedEvent

func (h Hooks) AfterBatchExecutedEvent(ctx sdk.Context, event gravitytypes.BatchExecutedEvent)

func (Hooks) AfterContractCallExecutedEvent

func (h Hooks) AfterContractCallExecutedEvent(ctx sdk.Context, event gravitytypes.ContractCallExecutedEvent)

func (Hooks) AfterERC20DeployedEvent

func (h Hooks) AfterERC20DeployedEvent(ctx sdk.Context, event gravitytypes.ERC20DeployedEvent)

func (Hooks) AfterSendToCosmosEvent

func (h Hooks) AfterSendToCosmosEvent(ctx sdk.Context, event gravitytypes.SendToCosmosEvent)

func (Hooks) AfterSignerSetExecutedEvent

func (h Hooks) AfterSignerSetExecutedEvent(ctx sdk.Context, event gravitytypes.SignerSetTxExecutedEvent)

type Keeper

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

Keeper of the oracle store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
	stakingKeeper corktypes.StakingKeeper, gravityKeeper corktypes.GravityKeeper, pubsubKeeper corktypes.PubsubKeeper,
) Keeper

NewKeeper creates a new x/cork Keeper instance

func (Keeper) BeginBlocker

func (k Keeper) BeginBlocker(ctx sdk.Context)

BeginBlocker is called at the beginning of every block

func (Keeper) DecrementValidatorCorkCount

func (k Keeper) DecrementValidatorCorkCount(ctx sdk.Context, val sdk.ValAddress)

func (Keeper) DeleteCorkResult

func (k Keeper) DeleteCorkResult(ctx sdk.Context, id []byte)

func (Keeper) DeleteScheduledCork

func (k Keeper) DeleteScheduledCork(ctx sdk.Context, blockHeight uint64, id []byte, val sdk.ValAddress, contract common.Address)

DeleteScheduledCork deletes the scheduled cork for a given validator CONTRACT: must provide the validator address here not the delegate address

func (Keeper) EndBlocker

func (k Keeper) EndBlocker(ctx sdk.Context)

func (Keeper) GetApprovedScheduledCorks

func (k Keeper) GetApprovedScheduledCorks(ctx sdk.Context) (approvedCorks []types.Cork)

func (Keeper) GetCellarIDs

func (k Keeper) GetCellarIDs(ctx sdk.Context) (cellars []common.Address)

func (Keeper) GetCorkResult

func (k Keeper) GetCorkResult(ctx sdk.Context, id []byte) (types.CorkResult, bool)

func (Keeper) GetCorkResults

func (k Keeper) GetCorkResults(ctx sdk.Context) []*types.CorkResult

GetCorkResults returns CorkResults

func (Keeper) GetLatestInvalidationNonce

func (k Keeper) GetLatestInvalidationNonce(ctx sdk.Context) uint64

func (Keeper) GetParamSet

func (k Keeper) GetParamSet(ctx sdk.Context) types.Params

GetParamSet returns the vote period from the parameters

func (Keeper) GetScheduledBlockHeights

func (k Keeper) GetScheduledBlockHeights(ctx sdk.Context) []uint64

func (Keeper) GetScheduledCork

func (k Keeper) GetScheduledCork(ctx sdk.Context, blockHeight uint64, id []byte, val sdk.ValAddress, contract common.Address) (types.Cork, bool)

GetScheduledCork gets the scheduled cork for a given validator CONTRACT: must provide the validator address here not the delegate address

func (Keeper) GetScheduledCorks

func (k Keeper) GetScheduledCorks(ctx sdk.Context) []*types.ScheduledCork

func (Keeper) GetScheduledCorksByBlockHeight

func (k Keeper) GetScheduledCorksByBlockHeight(ctx sdk.Context, height uint64) []*types.ScheduledCork

func (Keeper) GetScheduledCorksByID

func (k Keeper) GetScheduledCorksByID(ctx sdk.Context, queriedID []byte) []*types.ScheduledCork

func (Keeper) GetValidatorCorkCount

func (k Keeper) GetValidatorCorkCount(ctx sdk.Context, val sdk.ValAddress) (count uint64)

func (Keeper) HasCellarID

func (k Keeper) HasCellarID(ctx sdk.Context, address common.Address) (found bool)

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Hooks Return the wrapper struct

func (Keeper) IncrementInvalidationNonce

func (k Keeper) IncrementInvalidationNonce(ctx sdk.Context) uint64

func (Keeper) IncrementValidatorCorkCount

func (k Keeper) IncrementValidatorCorkCount(ctx sdk.Context, val sdk.ValAddress)

func (Keeper) IterateCorkResults

func (k Keeper) IterateCorkResults(ctx sdk.Context, cb func(id []byte, blockHeight uint64, approved bool, approvalPercentage string, corkResult types.CorkResult) (stop bool))

IterateCorksResult iterates over all cork results in the store

func (Keeper) IterateScheduledCorks

func (k Keeper) IterateScheduledCorks(ctx sdk.Context, cb func(val sdk.ValAddress, blockHeight uint64, id []byte, cel common.Address, cork types.Cork) (stop bool))

IterateScheduledCorks iterates over all scheduled corks in the store

func (Keeper) IterateScheduledCorksByBlockHeight

func (k Keeper) IterateScheduledCorksByBlockHeight(ctx sdk.Context, blockHeight uint64, cb func(val sdk.ValAddress, blockHeight uint64, id []byte, cel common.Address, cork types.Cork) (stop bool))

func (Keeper) IterateScheduledCorksByPrefix

func (k Keeper) IterateScheduledCorksByPrefix(ctx sdk.Context, prefix []byte, cb func(val sdk.ValAddress, blockHeight uint64, id []byte, cel common.Address, cork types.Cork) (stop bool))

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) QueryParams

QueryParams implements QueryServer

func (Keeper) ScheduleCork

ScheduleCork implements types.MsgServer

func (Keeper) SetCellarIDs

func (k Keeper) SetCellarIDs(ctx sdk.Context, c types.CellarIDSet)

func (Keeper) SetCorkResult

func (k Keeper) SetCorkResult(ctx sdk.Context, id []byte, corkResult types.CorkResult)

func (Keeper) SetLatestInvalidationNonce

func (k Keeper) SetLatestInvalidationNonce(ctx sdk.Context, invalidationNonce uint64)

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

setParams sets the parameters in the store

func (Keeper) SetScheduledCork

func (k Keeper) SetScheduledCork(ctx sdk.Context, blockHeight uint64, val sdk.ValAddress, cork types.Cork) []byte

func (Keeper) SetValidatorCorkCount

func (k Keeper) SetValidatorCorkCount(ctx sdk.Context, val sdk.ValAddress, count uint64)

type Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper Keeper) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2

func (m Migrator) Migrate1to2(ctx sdk.Context) error

Migrate1to2 migrates from consensus version 1 to 2.

type MockStakingValidatorData

type MockStakingValidatorData struct {
	Operator sdk.ValAddress
	Power    int64
}

MockStakingValidatorData creates mock validator data

type StakingKeeperMock

type StakingKeeperMock struct {
	BondedValidators []stakingtypes.Validator
	ValidatorPower   map[string]int64
}

StakingKeeperMock is a mock staking keeper for use in the tests

func NewStakingKeeperWeightedMock

func NewStakingKeeperWeightedMock(t ...MockStakingValidatorData) *StakingKeeperMock

NewStakingKeeperWeightedMock creates a new mock staking keeper with some mock validator data

func (*StakingKeeperMock) GetBondedValidatorsByPower

func (s *StakingKeeperMock) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator

GetBondedValidatorsByPower implements the interface for staking keeper required by gravity

func (*StakingKeeperMock) GetLastTotalPower

func (s *StakingKeeperMock) GetLastTotalPower(ctx sdk.Context) (power math.Int)

GetLastTotalPower implements the interface for staking keeper required by gravity

func (*StakingKeeperMock) GetLastValidatorPower

func (s *StakingKeeperMock) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) int64

GetLastValidatorPower implements the interface for staking keeper required by gravity

func (*StakingKeeperMock) GetParams

func (s *StakingKeeperMock) GetParams(ctx sdk.Context) stakingtypes.Params

func (*StakingKeeperMock) GetValidator

func (s *StakingKeeperMock) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool)

func (*StakingKeeperMock) IterateBondedValidatorsByPower

func (s *StakingKeeperMock) IterateBondedValidatorsByPower(ctx sdk.Context, cb func(index int64, validator stakingtypes.ValidatorI) (stop bool))

IterateBondedValidatorsByPower staisfies the interface

func (*StakingKeeperMock) IterateLastValidators

func (s *StakingKeeperMock) IterateLastValidators(ctx sdk.Context, cb func(index int64, validator stakingtypes.ValidatorI) (stop bool))

IterateLastValidators staisfies the interface

func (*StakingKeeperMock) IterateValidators

func (s *StakingKeeperMock) IterateValidators(ctx sdk.Context, cb func(index int64, validator stakingtypes.ValidatorI) (stop bool))

IterateValidators staisfies the interface

func (*StakingKeeperMock) Jail

Jail satisfies the interface

func (*StakingKeeperMock) PowerReduction

func (s *StakingKeeperMock) PowerReduction(sdk.Context) math.Int

PowerReduction satisfies the interface

func (*StakingKeeperMock) Slash

Slash satisfies the interface

func (*StakingKeeperMock) Validator

Validator staisfies the interface

func (*StakingKeeperMock) ValidatorByConsAddr

func (s *StakingKeeperMock) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) stakingtypes.ValidatorI

ValidatorByConsAddr staisfies the interface

func (*StakingKeeperMock) ValidatorQueueIterator

func (s *StakingKeeperMock) ValidatorQueueIterator(ctx sdk.Context, endTime time.Time, endHeight int64) sdk.Iterator

type TestInput

type TestInput struct {
	GravityKeeper  gravitykeeper.Keeper
	AccountKeeper  authkeeper.AccountKeeper
	StakingKeeper  stakingkeeper.Keeper
	SlashingKeeper slashingkeeper.Keeper
	DistKeeper     distrkeeper.Keeper
	BankKeeper     bankkeeper.BaseKeeper
	GovKeeper      govkeeper.Keeper
	Context        sdk.Context
	Marshaler      codec.Codec
	LegacyAmino    *codec.LegacyAmino
	// contains filtered or unexported fields
}

TestInput stores the various keepers required to test gravity TODO This file is mostly unused. Ask Eric/Collin about whether it's needed.

func CreateTestEnv

func CreateTestEnv(t *testing.T) TestInput

CreateTestEnv creates the keeper testing environment for gravity

Jump to

Keyboard shortcuts

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