keeper

package
v0.0.0-...-4334f35 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 69 Imported by: 0

Documentation

Index

Constants

View Source
const BatchTxSize = 100

BatchTxSize TODO: should we make this a parameter or a a call arg?

View Source
const HubDecimals = 18

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",
	}

	TokenIds = []uint64{
		1,
		2,
		3,
		4,
		5,
	}

	// 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",
	}

	// TestingMhub2Params is a set of mhub2 params for testing
	TestingMhub2Params = types.Params{
		GravityId:                                 "testgravityid",
		ContractSourceHash:                        "62328f7bc12efb28f86111d08c29b39285680a906ea0e524e0209d6f6657b713",
		BridgeEthereumAddress:                     "0x8858eeb3dfffa017d4bce9801d340d36cf895ccf",
		BridgeChainId:                             11,
		SignedSignerSetTxsWindow:                  10,
		SignedBatchesWindow:                       10,
		EthereumSignaturesWindow:                  10,
		TargetEthTxTimeout:                        60001,
		AverageBlockTime:                          5000,
		AverageEthereumBlockTime:                  15000,
		AverageBscBlockTime:                       5000,
		SlashFractionSignerSetTx:                  sdk.NewDecWithPrec(1, 2),
		SlashFractionBatch:                        sdk.NewDecWithPrec(1, 2),
		SlashFractionEthereumSignature:            sdk.NewDecWithPrec(1, 2),
		SlashFractionConflictingEthereumSignature: sdk.NewDecWithPrec(1, 2),
		UnbondSlashingSignerSetTxsWindow:          15,
		Chains:                                    []string{"ethereum", "hub"},
		OutgoingTxTimeout:                         60001,
	}
)
View Source
var ErrTokenNotFound = errors.New("token not found")

Functions

func ExportGenesis

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

ExportGenesis exports all the state needed to restart the chain from the current state of the chain

func InitGenesis

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

InitGenesis starts a chain from a genesis state

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 MintVouchersFromAir

func MintVouchersFromAir(t *testing.T, ctx sdk.Context, k Keeper, dest sdk.AccAddress, amount types.ExternalToken) sdk.Coin

MintVouchersFromAir creates new mhub2 vouchers given erc20tokens

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the gov MsgServer interface for the provided Keeper.

func NewTestMsgCreateValidator

func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey ccrypto.PubKey, amt sdk.Int) *stakingtypes.MsgCreateValidator

func NewTestMsgUnDelegateValidator

func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt sdk.Int) *stakingtypes.MsgUndelegate

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 mhub2

func (AlwaysPanicStakingMock) GetLastTotalPower

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

GetLastTotalPower implements the interface for staking keeper required by mhub2

func (AlwaysPanicStakingMock) GetLastValidatorPower

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

GetLastValidatorPower implements the interface for staking keeper required by mhub2

func (AlwaysPanicStakingMock) IterateBondedValidatorsByPower

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

IterateBondedValidatorsByPower staisfies the interface

func (AlwaysPanicStakingMock) IterateLastValidators

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

IterateLastValidators staisfies the interface

func (AlwaysPanicStakingMock) IterateValidators

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

IterateValidators staisfies the interface

func (AlwaysPanicStakingMock) Jail

Jail staisfies the interface

func (AlwaysPanicStakingMock) Slash

Slash staisfies the interface

func (AlwaysPanicStakingMock) Validator

Validator staisfies the interface

func (AlwaysPanicStakingMock) ValidatorByConsAddr

ValidatorByConsAddr staisfies the interface

type ExternalEventProcessor

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

ExternalEventProcessor processes `accepted` EthereumEvents

func (ExternalEventProcessor) DetectMaliciousSupply

func (a ExternalEventProcessor) DetectMaliciousSupply(ctx sdk.Context, denom string, amount sdk.Int) (err error)

func (ExternalEventProcessor) Handle

func (a ExternalEventProcessor) Handle(ctx sdk.Context, chainId types.ChainID, eve types.ExternalEvent) (err error)

Handle is the entry point for ExternalEvent processing

type Hooks

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

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)

func (Hooks) AfterValidatorCreated

func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(_ sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress)

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec)

type Keeper

type Keeper struct {
	StakingKeeper          types.StakingKeeper
	ExternalEventProcessor interface {
		Handle(sdk.Context, types.ChainID, types.ExternalEvent) error
	}

	SlashingKeeper types.SlashingKeeper

	PowerReduction sdk.Int
	// contains filtered or unexported fields
}

Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	storeKey sdk.StoreKey,
	paramSpace paramtypes.Subspace,
	accKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	slashingKeeper types.SlashingKeeper,
	oracleKeeper types.OracleKeeper,
	powerReduction sdk.Int,
) Keeper

NewKeeper returns a new instance of the mhub2 keeper

func (Keeper) AfterBatchExecutedEvent

func (k Keeper) AfterBatchExecutedEvent(ctx sdk.Context, event types.BatchExecutedEvent)

func (Keeper) AfterContractCallExecutedEvent

func (k Keeper) AfterContractCallExecutedEvent(ctx sdk.Context, event types.ContractCallExecutedEvent)

func (Keeper) AfterSendToHubEvent

func (k Keeper) AfterSendToHubEvent(ctx sdk.Context, event types.SendToHubEvent)

func (Keeper) AfterSignerSetExecutedEvent

func (k Keeper) AfterSignerSetExecutedEvent(ctx sdk.Context, event types.SignerSetTxExecutedEvent)

func (Keeper) BatchTx

func (Keeper) BatchTxFees

func (Keeper) BatchTxs

func (Keeper) BuildBatchTx

func (k Keeper) BuildBatchTx(ctx sdk.Context, chainId types.ChainID, externalTokenId string, maxElements int) *types.BatchTx

BuildBatchTx starts the following process chain:

  • find bridged denominator for given voucher type
  • determine if a an unexecuted batch is already waiting for this token type, if so confirm the new batch would have a higher total fees. If not exit withtout creating a batch
  • select available transactions from the outgoing transaction pool sorted by fee desc
  • persist an outgoing batch object with an incrementing ID = nonce
  • emit an event

func (Keeper) CancelBatchTx

func (k Keeper) CancelBatchTx(ctx sdk.Context, chainId types.ChainID, externalTokenId string, nonce uint64)

CancelBatchTx releases all TX in the batch and deletes the batch

func (Keeper) CheckChainID

func (k Keeper) CheckChainID(ctx sdk.Context, id types.ChainID) error

func (Keeper) ColdStorageTransfer

func (k Keeper) ColdStorageTransfer(ctx sdk.Context, c *types.ColdStorageTransferProposal) error

func (Keeper) ConvertFromExternalValue

func (k Keeper) ConvertFromExternalValue(ctx sdk.Context, chainId types.ChainID, externalId string, amount sdk.Int) sdk.Int

func (Keeper) ConvertToExternalValue

func (k Keeper) ConvertToExternalValue(ctx sdk.Context, chainId types.ChainID, externalId string, amount sdk.Int) sdk.Int

func (Keeper) CreateContractCallTx

func (k Keeper) CreateContractCallTx(ctx sdk.Context, chainId types.ChainID, invalidationNonce uint64, invalidationScope tmbytes.HexBytes,
	payload []byte, tokens []types.ExternalToken, fees []types.ExternalToken) *types.ContractCallTx

CreateContractCallTx xxx

func (Keeper) CreateSignerSetTx

func (k Keeper) CreateSignerSetTx(ctx sdk.Context, chainId types.ChainID) *types.SignerSetTx

CreateSignerSetTx gets the current signer set from the staking keeper, increments the nonce, creates the signer set tx object, emits an event and sets the signer set in state

func (Keeper) CurrentSignerSet

func (k Keeper) CurrentSignerSet(ctx sdk.Context, chainId types.ChainID) types.ExternalSigners

CurrentSignerSet gets powers from the store and normalizes them into an integer percentage with a resolution of uint32 Max meaning a given validators 'mhub2 power' is computed as Cosmos power / total cosmos power = x / uint32 Max where x is the voting power on the mhub2 contract. This allows us to only use integer division which produces a known rounding error from truncation equal to the ratio of the validators Cosmos power / total cosmos power ratio, leaving us at uint32 Max - 1 total voting power. This is an acceptable rounding error since floating point may cause consensus problems if different floating point unit implementations are involved.

func (Keeper) DelegateKeys

func (Keeper) DeleteOutgoingTx

func (k Keeper) DeleteOutgoingTx(ctx sdk.Context, chainId types.ChainID, storeIndex []byte)

DeleteOutgoingTx deletes a given outgoingtx

func (Keeper) DenomToTokenInfoLookup

func (k Keeper) DenomToTokenInfoLookup(ctx sdk.Context, chainId types.ChainID, denom string) (*types.TokenInfo, error)

func (Keeper) DiscountForHolder

func (Keeper) ExternalIdToTokenInfoLookup

func (k Keeper) ExternalIdToTokenInfoLookup(ctx sdk.Context, chainId types.ChainID, externalId string) (*types.TokenInfo, error)

func (Keeper) GetBatchFeesByTokenType

func (k Keeper) GetBatchFeesByTokenType(ctx sdk.Context, chainId types.ChainID, externalTokenId string, maxElements int) sdk.Int

GetBatchFeesByTokenType gets the fees the next batch of a given token type would have if created. This info is both presented to relayers for the purpose of determining when to request batches and also used by the batch creation process to decide not to create a new batch

func (Keeper) GetChains

func (k Keeper) GetChains(ctx sdk.Context) []types.ChainID

func (Keeper) GetColdStorageAddr

func (k Keeper) GetColdStorageAddr(ctx sdk.Context, chainId types.ChainID) string

func (Keeper) GetCommissionForHolder

func (k Keeper) GetCommissionForHolder(ctx sdk.Context, addresses []string, commission sdk.Dec) sdk.Dec

func (Keeper) GetExternalEventVoteRecord

func (k Keeper) GetExternalEventVoteRecord(ctx sdk.Context, chainId types.ChainID, eventNonce uint64, claimHash []byte) *types.ExternalEventVoteRecord

GetExternalEventVoteRecord return a vote record given a nonce

func (Keeper) GetExternalEventVoteRecordMapping

func (k Keeper) GetExternalEventVoteRecordMapping(ctx sdk.Context, chainId types.ChainID) (out map[uint64][]*types.ExternalEventVoteRecord)

GetExternalEventVoteRecordMapping returns a mapping of eventnonce -> attestations at that nonce

func (Keeper) GetExternalOrchestratorAddress

func (k Keeper) GetExternalOrchestratorAddress(ctx sdk.Context, chainId types.ChainID, ethAddr common.Address) sdk.AccAddress

GetExternalOrchestratorAddress gets the orch address for a given eth address

func (Keeper) GetExternalSignatures

func (k Keeper) GetExternalSignatures(ctx sdk.Context, chainId types.ChainID, storeIndex []byte) map[string][]byte

GetExternalSignatures returns all external signatures for a given outgoing tx by store index

func (Keeper) GetLastObservedEventNonce

func (k Keeper) GetLastObservedEventNonce(ctx sdk.Context, chainId types.ChainID) uint64

GetLastObservedEventNonce returns the latest observed event nonce

func (Keeper) GetLastObservedExternalBlockHeight

func (k Keeper) GetLastObservedExternalBlockHeight(ctx sdk.Context, chainId types.ChainID) types.LatestBlockHeight

GetLastObservedExternalBlockHeight height gets the block height to of the last observed attestation from the store

func (Keeper) GetLastObservedSignerSetTx

func (k Keeper) GetLastObservedSignerSetTx(ctx sdk.Context, chainId types.ChainID) *types.SignerSetTx

GetLastObservedSignerSetTx retrieves the last observed validator set from the store

func (Keeper) GetLastSlashedOutgoingTxBlockHeight

func (k Keeper) GetLastSlashedOutgoingTxBlockHeight(ctx sdk.Context, chainId types.ChainID) uint64

GetLastSlashedOutgoingTxBlockHeight returns the latest slashed Batch block

func (Keeper) GetLastUnbondingBlockHeight

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

GetLastUnbondingBlockHeight returns the last unbonding block height

func (Keeper) GetLatestSignerSetTx

func (k Keeper) GetLatestSignerSetTx(ctx sdk.Context, chainId types.ChainID) *types.SignerSetTx

GetLatestSignerSetTx returns the latest validator set in state

func (Keeper) GetLatestSignerSetTxNonce

func (k Keeper) GetLatestSignerSetTxNonce(ctx sdk.Context, chainId types.ChainID) uint64

GetLatestSignerSetTxNonce returns the latest valset nonce

func (Keeper) GetOrchestratorValidatorAddress

func (k Keeper) GetOrchestratorValidatorAddress(ctx sdk.Context, chainId types.ChainID, orchAddr sdk.AccAddress) sdk.ValAddress

GetOrchestratorValidatorAddress returns the validator key associated with an orchestrator key.

func (Keeper) GetOutgoingTx

func (k Keeper) GetOutgoingTx(ctx sdk.Context, chainId types.ChainID, storeIndex []byte) (out types.OutgoingTx)

func (Keeper) GetOutgoingTxTimeout

func (k Keeper) GetOutgoingTxTimeout(ctx sdk.Context) time.Duration

func (Keeper) GetParams

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

GetParams returns the parameters from the store

func (Keeper) GetSignerSetTxs

func (k Keeper) GetSignerSetTxs(ctx sdk.Context, chainId types.ChainID) (out []*types.SignerSetTx)

GetSignerSetTxs returns all the signer set txs from the store

func (Keeper) GetTokenInfos

func (k Keeper) GetTokenInfos(ctx sdk.Context) *types.TokenInfos

func (Keeper) GetTxFeeRecord

func (k Keeper) GetTxFeeRecord(ctx sdk.Context, inTxHash string) *types.TxFeeRecord

func (Keeper) GetTxStatus

func (k Keeper) GetTxStatus(ctx sdk.Context, inTxHash string) *types.TxStatus

func (Keeper) GetUnSlashedOutgoingTxs

func (k Keeper) GetUnSlashedOutgoingTxs(ctx sdk.Context, chainId types.ChainID, maxHeight uint64) (out []types.OutgoingTx)

func (Keeper) GetUnbondingvalidators

func (k Keeper) GetUnbondingvalidators(unbondingVals []byte) stakingtypes.ValAddresses

GetUnbondingvalidators returns UnbondingValidators. Adding here in mhub2 keeper as cdc is available inside endblocker.

func (Keeper) GetValidatorExternalAddress

func (k Keeper) GetValidatorExternalAddress(ctx sdk.Context, chainId types.ChainID, valAddr sdk.ValAddress) common.Address

GetValidatorExternalAddress returns the eth address for a given mhub2 validator.

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Hooks Create new mhub2 hooks

func (Keeper) IterateOutgoingTxsByType

func (k Keeper) IterateOutgoingTxsByType(ctx sdk.Context, chainId types.ChainID, prefixByte byte, cb func(key []byte, outgoing types.OutgoingTx) (stop bool))

IterateOutgoingTxsByType iterates over a specific type of outgoing transaction denoted by the chosen prefix byte

func (Keeper) IterateUnbatchedSendToExternals

func (k Keeper) IterateUnbatchedSendToExternals(ctx sdk.Context, chainId types.ChainID, cb func(*types.SendToExternal) bool)

func (Keeper) LastObservedSignerSetTx

func (k Keeper) LastObservedSignerSetTx(c context.Context, request *types.LastObservedSignerSetTxRequest) (*types.SignerSetTxResponse, error)

func (Keeper) LatestSignerSetTx

func (Keeper) Logger

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

func (Keeper) OnOutgoingTransactionTimeouts

func (k Keeper) OnOutgoingTransactionTimeouts(ctx sdk.Context, chainId types.ChainID, txId uint64, sender string)

func (Keeper) PaginateOutgoingTxsByType

func (k Keeper) PaginateOutgoingTxsByType(ctx sdk.Context, chainId types.ChainID, pageReq *query.PageRequest, prefixByte byte, cb func(key []byte, outgoing types.OutgoingTx) bool) (*query.PageResponse, error)

func (Keeper) Params

func (Keeper) SetExternalSignature

func (k Keeper) SetExternalSignature(ctx sdk.Context, chainId types.ChainID, sig types.ExternalTxConfirmation, val sdk.ValAddress) []byte

SetExternalSignature sets a valset confirmation

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(sh types.MhubHooks) *Keeper

func (Keeper) SetLastObservedExternalBlockHeight

func (k Keeper) SetLastObservedExternalBlockHeight(ctx sdk.Context, chainId types.ChainID, externalHeight uint64)

SetLastObservedExternalBlockHeight sets the block height in the store.

func (Keeper) SetLastSlashedOutgoingTxBlockHeight

func (k Keeper) SetLastSlashedOutgoingTxBlockHeight(ctx sdk.Context, chainId types.ChainID, blockHeight uint64)

SetLastSlashedOutgoingTxBlockHeight sets the latest slashed Batch block height

func (Keeper) SetOrchestratorValidatorAddress

func (k Keeper) SetOrchestratorValidatorAddress(ctx sdk.Context, chainId types.ChainID, val sdk.ValAddress, orchAddr sdk.AccAddress)

SetOrchestratorValidatorAddress sets the Orchestrator key for a given validator.

func (Keeper) SetOutgoingTx

func (k Keeper) SetOutgoingTx(ctx sdk.Context, chainId types.ChainID, outgoing types.OutgoingTx)

func (Keeper) SetStakingKeeper

func (k Keeper) SetStakingKeeper(keeper types.StakingKeeper) Keeper

func (Keeper) SetTokenInfos

func (k Keeper) SetTokenInfos(ctx sdk.Context, tokenInfos *types.TokenInfos)

func (Keeper) SetTxFeeRecord

func (k Keeper) SetTxFeeRecord(ctx sdk.Context, inTxHash string, record types.TxFeeRecord)

func (Keeper) SetTxStatus

func (k Keeper) SetTxStatus(ctx sdk.Context, inTxHash string, status types.TxStatusType, outTxHash string)

func (Keeper) SignerSetTx

func (Keeper) SignerSetTxs

func (Keeper) TokenIdToTokenInfoLookup

func (k Keeper) TokenIdToTokenInfoLookup(ctx sdk.Context, tokenId uint64) (*types.TokenInfo, error)

func (Keeper) TokenInfos

func (Keeper) TransactionStatus

func (Keeper) TryEventVoteRecord

func (k Keeper) TryEventVoteRecord(ctx sdk.Context, chainId types.ChainID, eventVoteRecord *types.ExternalEventVoteRecord)

TryEventVoteRecord checks if an event vote record has enough votes to be applied to the consensus state and has not already been marked Observed, then calls processExternalEvent to actually apply it to the state, and then marks it Observed and emits an event.

type MockOracleKeeper

type MockOracleKeeper struct {
}

func (MockOracleKeeper) GetHolderValue

func (m MockOracleKeeper) GetHolderValue(ctx sdk.Context, address string) sdk.Int

func (MockOracleKeeper) GetTokenPrice

func (m MockOracleKeeper) GetTokenPrice(ctx sdk.Context, denom string) (sdk.Dec, error)

func (MockOracleKeeper) MustGetTokenPrice

func (m MockOracleKeeper) MustGetTokenPrice(ctx sdk.Context, denom string) sdk.Dec

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 NewStakingKeeperMock

func NewStakingKeeperMock(operators ...sdk.ValAddress) *StakingKeeperMock

NewStakingKeeperMock creates a new mock staking keeper

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 mhub2

func (*StakingKeeperMock) GetLastTotalPower

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

GetLastTotalPower implements the interface for staking keeper required by mhub2

func (*StakingKeeperMock) GetLastValidatorPower

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

GetLastValidatorPower implements the interface for staking keeper required by mhub2

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 staisfies the interface

func (*StakingKeeperMock) Slash

Slash staisfies 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 {
	Mhub2Keeper    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
}

TestInput stores the various keepers required to test mhub2

func CreateTestEnv

func CreateTestEnv(t *testing.T) TestInput

CreateTestEnv creates the keeper testing environment for mhub2

func SetupFiveValChain

func SetupFiveValChain(t *testing.T) (TestInput, sdk.Context)

SetupFiveValChain does all the initialization for a 5 Validator chain using the keys here

func (TestInput) AddBalanceToBank

func (input TestInput) AddBalanceToBank(ctx sdk.Context, addr sdk.AccAddress, balances sdk.Coins) error

func (TestInput) AddSendToEthTxsToPool

func (input TestInput) AddSendToEthTxsToPool(t *testing.T, ctx sdk.Context, chainId types.ChainID, tokenId uint64, externalTokenId string, sender sdk.AccAddress, receiver gethcommon.Address, ids ...uint64)

Jump to

Keyboard shortcuts

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