Documentation ¶
Index ¶
- Constants
- func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState
- func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState)
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NormalizeGenesis(data *types.GenesisState)
- func PrefixRange(prefix []byte) ([]byte, []byte)
- type AttestationHandler
- type Hooks
- func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)
- func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)
- func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)
- func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)
- func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)
- func (h Hooks) BeforeDelegationCreated(_ sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)
- func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)
- func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)
- func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress)
- func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec)
- type Keeper
- func (k *Keeper) AddToOutgoingPool(ctx sdk.Context, sender sdk.AccAddress, counterpartReceiver common.Address, ...) (uint64, error)
- func (k *Keeper) Attest(ctx sdk.Context, claim types.EthereumClaim, anyClaim *codectypes.Any) (*types.Attestation, error)
- func (k *Keeper) AutoIncrementID(ctx sdk.Context, idKey []byte) uint64
- func (k *Keeper) BatchConfirms(c context.Context, req *types.QueryBatchConfirmsRequest) (*types.QueryBatchConfirmsResponse, error)
- func (k *Keeper) BatchFees(c context.Context, req *types.QueryBatchFeeRequest) (*types.QueryBatchFeeResponse, error)
- func (k *Keeper) BatchRequestByNonce(c context.Context, req *types.QueryBatchRequestByNonceRequest) (*types.QueryBatchRequestByNonceResponse, error)
- func (k *Keeper) BuildOutgoingTXBatch(ctx sdk.Context, contractAddress common.Address, maxElements int) (*types.OutgoingTxBatch, error)
- func (k *Keeper) CancelOutgoingTXBatch(ctx sdk.Context, tokenContract common.Address, nonce uint64) error
- func (k *Keeper) CheckBadSignatureEvidence(ctx sdk.Context, msg *types.MsgSubmitBadSignatureEvidence) error
- func (k *Keeper) CurrentValset(c context.Context, req *types.QueryCurrentValsetRequest) (*types.QueryCurrentValsetResponse, error)
- func (k *Keeper) DeleteAttestation(ctx sdk.Context, att *types.Attestation)
- func (k *Keeper) DeleteBatch(ctx sdk.Context, batch types.OutgoingTxBatch)
- func (k *Keeper) DeleteValset(ctx sdk.Context, nonce uint64)
- func (k *Keeper) DenomToERC20(c context.Context, req *types.QueryDenomToERC20Request) (*types.QueryDenomToERC20Response, error)
- func (k *Keeper) DenomToERC20Lookup(ctx sdk.Context, denom string) (bool, common.Address, error)
- func (k *Keeper) DeserializeValidatorIterator(vals []byte) stakingtypes.ValAddresses
- func (k *Keeper) ERC20ToDenom(c context.Context, req *types.QueryERC20ToDenomRequest) (*types.QueryERC20ToDenomResponse, error)
- func (k *Keeper) ERC20ToDenomLookup(ctx sdk.Context, tokenContract common.Address) (bool, string)
- func (k *Keeper) GetAllBatchFees(ctx sdk.Context) (batchFees []*types.BatchFees)
- func (k *Keeper) GetAttestation(ctx sdk.Context, eventNonce uint64, claimHash []byte) *types.Attestation
- func (k *Keeper) GetAttestationMapping(ctx sdk.Context) (out map[uint64][]*types.Attestation)
- func (k *Keeper) GetBatchConfirm(ctx sdk.Context, nonce uint64, tokenContract common.Address, ...) *types.MsgConfirmBatch
- func (k *Keeper) GetBatchConfirmByNonceAndTokenContract(ctx sdk.Context, nonce uint64, tokenContract common.Address) (out []*types.MsgConfirmBatch)
- func (k *Keeper) GetBatchFeesByTokenType(ctx sdk.Context, tokenContractAddr common.Address) *types.BatchFees
- func (k *Keeper) GetBridgeChainID(ctx sdk.Context) uint64
- func (k *Keeper) GetBridgeContractAddress(ctx sdk.Context) common.Address
- func (k *Keeper) GetCosmosOriginatedDenom(ctx sdk.Context, tokenContract common.Address) (string, bool)
- func (k *Keeper) GetCosmosOriginatedERC20(ctx sdk.Context, denom string) (common.Address, bool)
- func (k *Keeper) GetCurrentValset(ctx sdk.Context) *types.Valset
- func (k *Keeper) GetDelegateKeyByEth(c context.Context, req *types.QueryDelegateKeysByEthAddress) (*types.QueryDelegateKeysByEthAddressResponse, error)
- func (k *Keeper) GetDelegateKeyByOrchestrator(c context.Context, req *types.QueryDelegateKeysByOrchestratorAddress) (*types.QueryDelegateKeysByOrchestratorAddressResponse, error)
- func (k *Keeper) GetDelegateKeyByValidator(c context.Context, req *types.QueryDelegateKeysByValidatorAddress) (*types.QueryDelegateKeysByValidatorAddressResponse, error)
- func (k *Keeper) GetEthAddressByValidator(ctx sdk.Context, validator sdk.ValAddress) (common.Address, bool)
- func (k *Keeper) GetLastEventByValidator(ctx sdk.Context, validator sdk.ValAddress) (lastEvent types.LastClaimEvent)
- func (k *Keeper) GetLastObservedEthereumBlockHeight(ctx sdk.Context) types.LastObservedEthereumBlockHeight
- func (k *Keeper) GetLastObservedEventNonce(ctx sdk.Context) uint64
- func (k *Keeper) GetLastObservedValset(ctx sdk.Context) *types.Valset
- func (k *Keeper) GetLastOutgoingBatchByTokenType(ctx sdk.Context, token common.Address) *types.OutgoingTxBatch
- func (k *Keeper) GetLastOutgoingBatchID(ctx sdk.Context) uint64
- func (k *Keeper) GetLastOutgoingPoolID(ctx sdk.Context) uint64
- func (k *Keeper) GetLastSlashedBatchBlock(ctx sdk.Context) uint64
- func (k *Keeper) GetLastSlashedValsetNonce(ctx sdk.Context) uint64
- func (k *Keeper) GetLastUnbondingBlockHeight(ctx sdk.Context) uint64
- func (k *Keeper) GetLatestValset(ctx sdk.Context) (out *types.Valset)
- func (k *Keeper) GetLatestValsetNonce(ctx sdk.Context) uint64
- func (k *Keeper) GetOrchestratorAddresses(ctx sdk.Context) []*types.MsgSetOrchestratorAddresses
- func (k *Keeper) GetOrchestratorValidator(ctx sdk.Context, orch sdk.AccAddress) (sdk.ValAddress, bool)
- func (k *Keeper) GetOutgoingTXBatch(ctx sdk.Context, tokenContract common.Address, nonce uint64) *types.OutgoingTxBatch
- func (k *Keeper) GetOutgoingTxBatches(ctx sdk.Context) (out []*types.OutgoingTxBatch)
- func (k *Keeper) GetParams(ctx sdk.Context) *types.Params
- func (k *Keeper) GetPastEthSignatureCheckpoint(ctx sdk.Context, checkpoint common.Hash) (found bool)
- func (k *Keeper) GetPeggyID(ctx sdk.Context) string
- func (k *Keeper) GetPendingSendToEth(c context.Context, req *types.QueryPendingSendToEth) (*types.QueryPendingSendToEthResponse, error)
- func (k *Keeper) GetPoolTransactions(ctx sdk.Context) []*types.OutgoingTransferTx
- func (k *Keeper) GetUnslashedBatches(ctx sdk.Context, maxHeight uint64) (out []*types.OutgoingTxBatch)
- func (k *Keeper) GetUnslashedValsets(ctx sdk.Context, maxHeight uint64) (out []*types.Valset)
- func (k *Keeper) GetValidatorByEthAddress(ctx sdk.Context, ethAddr common.Address) (validator stakingtypes.Validator, found bool)
- func (k *Keeper) GetValset(ctx sdk.Context, nonce uint64) *types.Valset
- func (k *Keeper) GetValsetConfirm(ctx sdk.Context, nonce uint64, validator sdk.AccAddress) *types.MsgValsetConfirm
- func (k *Keeper) GetValsetConfirms(ctx sdk.Context, nonce uint64) (valsetConfirms []*types.MsgValsetConfirm)
- func (k *Keeper) GetValsets(ctx sdk.Context) (out []*types.Valset)
- func (k *Keeper) HasValsetRequest(ctx sdk.Context, nonce uint64) bool
- func (k *Keeper) Hooks() Hooks
- func (k *Keeper) IterateAttestations(ctx sdk.Context, cb func(k []byte, v *types.Attestation) (stop bool))
- func (k *Keeper) IterateBatchBySlashedBatchBlock(ctx sdk.Context, lastSlashedBatchBlock uint64, maxHeight uint64, ...)
- func (k *Keeper) IterateBatchConfirmByNonceAndTokenContract(ctx sdk.Context, nonce uint64, tokenContract common.Address, ...)
- func (k *Keeper) IterateERC20ToDenom(ctx sdk.Context, cb func(k []byte, v *types.ERC20ToDenom) (stop bool))
- func (k *Keeper) IterateOutgoingPoolByFee(ctx sdk.Context, tokenContract common.Address, ...)
- func (k *Keeper) IterateOutgoingTXBatches(ctx sdk.Context, cb func(key []byte, batch *types.OutgoingTxBatch) bool)
- func (k *Keeper) IterateValsetBySlashedValsetNonce(ctx sdk.Context, lastSlashedValsetNonce uint64, maxHeight uint64, ...)
- func (k *Keeper) IterateValsetConfirmByNonce(ctx sdk.Context, nonce uint64, ...)
- func (k *Keeper) IterateValsets(ctx sdk.Context, cb func(key []byte, val *types.Valset) bool)
- func (k *Keeper) LastEventByAddr(c context.Context, req *types.QueryLastEventByAddrRequest) (*types.QueryLastEventByAddrResponse, error)
- func (k *Keeper) LastPendingBatchRequestByAddr(c context.Context, req *types.QueryLastPendingBatchRequestByAddrRequest) (*types.QueryLastPendingBatchRequestByAddrResponse, error)
- func (k *Keeper) LastPendingValsetRequestByAddr(c context.Context, req *types.QueryLastPendingValsetRequestByAddrRequest) (*types.QueryLastPendingValsetRequestByAddrResponse, error)
- func (k *Keeper) LastValsetRequests(c context.Context, req *types.QueryLastValsetRequestsRequest) (*types.QueryLastValsetRequestsResponse, error)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k *Keeper) OutgoingTxBatchExecuted(ctx sdk.Context, tokenContract common.Address, nonce uint64)
- func (k *Keeper) OutgoingTxBatches(c context.Context, req *types.QueryOutgoingTxBatchesRequest) (*types.QueryOutgoingTxBatchesResponse, error)
- func (k *Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k *Keeper) PeggyModuleState(c context.Context, req *types.QueryModuleStateRequest) (*types.QueryModuleStateResponse, error)
- func (k *Keeper) RemoveFromOutgoingPoolAndRefund(ctx sdk.Context, txId uint64, sender sdk.AccAddress) error
- func (k *Keeper) RewardToERC20Lookup(ctx sdk.Context, coin sdk.Coin) (common.Address, sdk.Int)
- func (k *Keeper) SetAttestation(ctx sdk.Context, eventNonce uint64, claimHash []byte, att *types.Attestation)
- func (k *Keeper) SetBatchConfirm(ctx sdk.Context, batch *types.MsgConfirmBatch) []byte
- func (k *Keeper) SetCosmosOriginatedDenomToERC20(ctx sdk.Context, denom string, tokenContract common.Address)
- func (k *Keeper) SetEthAddressForValidator(ctx sdk.Context, validator sdk.ValAddress, ethAddr common.Address)
- func (k *Keeper) SetLastObservedEthereumBlockHeight(ctx sdk.Context, ethereumHeight uint64)
- func (k *Keeper) SetLastObservedValset(ctx sdk.Context, valset types.Valset)
- func (k *Keeper) SetLastOutgoingBatchID(ctx sdk.Context, lastOutgoingBatchID uint64)
- func (k *Keeper) SetLastOutgoingPoolID(ctx sdk.Context, lastOutgoingPoolID uint64)
- func (k *Keeper) SetLastSlashedBatchBlock(ctx sdk.Context, blockHeight uint64)
- func (k *Keeper) SetLastSlashedValsetNonce(ctx sdk.Context, nonce uint64)
- func (k *Keeper) SetLastUnbondingBlockHeight(ctx sdk.Context, unbondingBlockHeight uint64)
- func (k *Keeper) SetLatestValsetNonce(ctx sdk.Context, nonce uint64)
- func (k *Keeper) SetOrchestratorValidator(ctx sdk.Context, val sdk.ValAddress, orch sdk.AccAddress)
- func (k *Keeper) SetParams(ctx sdk.Context, params *types.Params)
- func (k *Keeper) SetPastEthSignatureCheckpoint(ctx sdk.Context, checkpoint common.Hash)
- func (k *Keeper) SetValsetConfirm(ctx sdk.Context, valset *types.MsgValsetConfirm) []byte
- func (k *Keeper) SetValsetRequest(ctx sdk.Context) *types.Valset
- func (k *Keeper) StoreBatch(ctx sdk.Context, batch *types.OutgoingTxBatch)
- func (k *Keeper) StoreBatchUnsafe(ctx sdk.Context, batch *types.OutgoingTxBatch)
- func (k *Keeper) StoreValset(ctx sdk.Context, valset *types.Valset)
- func (k *Keeper) StoreValsetUnsafe(ctx sdk.Context, valset *types.Valset)
- func (k *Keeper) TryAttestation(ctx sdk.Context, att *types.Attestation)
- func (k *Keeper) UnpackAttestationClaim(attestation *types.Attestation) (types.EthereumClaim, error)
- func (k *Keeper) ValsetConfirm(c context.Context, req *types.QueryValsetConfirmRequest) (*types.QueryValsetConfirmResponse, error)
- func (k *Keeper) ValsetConfirmsByNonce(c context.Context, req *types.QueryValsetConfirmsByNonceRequest) (*types.QueryValsetConfirmsByNonceResponse, error)
- func (k *Keeper) ValsetRequest(c context.Context, req *types.QueryValsetRequestRequest) (*types.QueryValsetRequestResponse, error)
Constants ¶
const MaxResults = 100 // todo: impl pagination
const OutgoingTxBatchSize = 100
Variables ¶
This section is empty.
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 NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the gov MsgServer interface for the provided Keeper.
func NormalizeGenesis ¶
func NormalizeGenesis(data *types.GenesisState)
NormalizeGenesis takes care of formatting in the internal structures, as they're used as values in the keeper eventually, while having raw strings in them.
func PrefixRange ¶
PrefixRange turns a prefix into a (start, end) range. The start is the given prefix value and the end is calculated by adding 1 bit to the start value. Nil is not allowed as prefix.
Example: []byte{1, 3, 4} becomes []byte{1, 3, 5} []byte{15, 42, 255, 255} becomes []byte{15, 43, 0, 0}
In case of an overflow the end is set to nil.
Example: []byte{255, 255, 255, 255} becomes nil
MARK finish-batches: this is where some crazy shit happens
Types ¶
type AttestationHandler ¶
type AttestationHandler struct {
// contains filtered or unexported fields
}
AttestationHandler processes `observed` Attestations
func NewAttestationHandler ¶
func NewAttestationHandler(bankKeeper types.BankKeeper, keeper Keeper) AttestationHandler
func (AttestationHandler) Handle ¶
func (a AttestationHandler) Handle(ctx sdk.Context, claim types.EthereumClaim) error
Handle is the entry point for Attestation processing.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Wrapper struct
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 ¶
type Keeper ¶
type Keeper struct { SlashingKeeper types.SlashingKeeper StakingKeeper types.StakingKeeper AttestationHandler interface { Handle(sdk.Context, types.EthereumClaim) error } // 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.BinaryCodec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, stakingKeeper types.StakingKeeper, bankKeeper types.BankKeeper, slashingKeeper types.SlashingKeeper, ) Keeper
NewKeeper returns a new instance of the peggy keeper.
func (*Keeper) AddToOutgoingPool ¶
func (k *Keeper) AddToOutgoingPool(ctx sdk.Context, sender sdk.AccAddress, counterpartReceiver common.Address, amount sdk.Coin, fee sdk.Coin) (uint64, error)
AddToOutgoingPool - checks a counterpart denominator exists for the given voucher type - burns the voucher for transfer amount and fees - persists an OutgoingTx - adds the TX to the `available` TX pool via a second index
func (*Keeper) Attest ¶
func (k *Keeper) Attest(ctx sdk.Context, claim types.EthereumClaim, anyClaim *codectypes.Any) (*types.Attestation, error)
func (*Keeper) AutoIncrementID ¶
func (*Keeper) BatchConfirms ¶
func (k *Keeper) BatchConfirms(c context.Context, req *types.QueryBatchConfirmsRequest) (*types.QueryBatchConfirmsResponse, error)
BatchConfirms returns the batch confirmations by nonce and token contract
func (*Keeper) BatchFees ¶
func (k *Keeper) BatchFees(c context.Context, req *types.QueryBatchFeeRequest) (*types.QueryBatchFeeResponse, error)
BatchFees queries the batch fees from unbatched pool
func (*Keeper) BatchRequestByNonce ¶
func (k *Keeper) BatchRequestByNonce(c context.Context, req *types.QueryBatchRequestByNonceRequest) (*types.QueryBatchRequestByNonceResponse, error)
BatchRequestByNonce queries the BatchRequestByNonce of the peggy module
func (*Keeper) BuildOutgoingTXBatch ¶
func (k *Keeper) BuildOutgoingTXBatch(ctx sdk.Context, contractAddress common.Address, maxElements int) (*types.OutgoingTxBatch, error)
BuildOutgoingTXBatch 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 without 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) CancelOutgoingTXBatch ¶
func (k *Keeper) CancelOutgoingTXBatch(ctx sdk.Context, tokenContract common.Address, nonce uint64) error
CancelOutgoingTXBatch releases all TX in the batch and deletes the batch
func (*Keeper) CheckBadSignatureEvidence ¶
func (*Keeper) CurrentValset ¶
func (k *Keeper) CurrentValset(c context.Context, req *types.QueryCurrentValsetRequest) (*types.QueryCurrentValsetResponse, error)
CurrentValset queries the CurrentValset of the peggy module
func (*Keeper) DeleteAttestation ¶
func (k *Keeper) DeleteAttestation(ctx sdk.Context, att *types.Attestation)
DeleteAttestation deletes an attestation given an event nonce and claim
func (*Keeper) DeleteBatch ¶
func (k *Keeper) DeleteBatch(ctx sdk.Context, batch types.OutgoingTxBatch)
DeleteBatch deletes an outgoing transaction batch
func (*Keeper) DeleteValset ¶
DeleteValset deletes the valset at a given nonce from state
func (*Keeper) DenomToERC20 ¶
func (k *Keeper) DenomToERC20(c context.Context, req *types.QueryDenomToERC20Request) (*types.QueryDenomToERC20Response, error)
DenomToERC20 queries the Cosmos Denom that maps to an Ethereum ERC20
func (*Keeper) DenomToERC20Lookup ¶
DenomToERC20Lookup returns an ERC20 token contract address and a boolean signaling if the denomination is a Cosmos native asset or not. It will return an error if it cannot parse the denom as a Peggy denom or if it cannot find the denom in an index of ERC20 contracts deployed on Ethereum to serve as synthetic Cosmos assets.
func (*Keeper) DeserializeValidatorIterator ¶
func (k *Keeper) DeserializeValidatorIterator(vals []byte) stakingtypes.ValAddresses
DeserializeValidatorIterator returns validators from the validator iterator. Adding here in gravity keeper as cdc is not available inside endblocker.
func (*Keeper) ERC20ToDenom ¶
func (k *Keeper) ERC20ToDenom(c context.Context, req *types.QueryERC20ToDenomRequest) (*types.QueryERC20ToDenomResponse, error)
ERC20ToDenom queries the ERC20 contract that maps to an Ethereum ERC20 if any
func (*Keeper) ERC20ToDenomLookup ¶
ERC20ToDenomLookup attempts to do a reverse lookup for denomination by an ERC20 token contract address and returns the corresponding denomination and a boolean signaling if the asset is a Cosmos native asset or not.
func (*Keeper) GetAllBatchFees ¶
GetAllBatchFees creates a fee entry for every batch type currently in the store this can be used by relayers to determine what batch types are desirable to request
func (*Keeper) GetAttestation ¶
func (k *Keeper) GetAttestation(ctx sdk.Context, eventNonce uint64, claimHash []byte) *types.Attestation
GetAttestation return an attestation given a nonce
func (*Keeper) GetAttestationMapping ¶
GetAttestationMapping returns a mapping of eventnonce -> attestations at that nonce
func (*Keeper) GetBatchConfirm ¶
func (k *Keeper) GetBatchConfirm(ctx sdk.Context, nonce uint64, tokenContract common.Address, validator sdk.AccAddress) *types.MsgConfirmBatch
GetBatchConfirm returns a batch confirmation given its nonce, the token contract, and a validator address
func (*Keeper) GetBatchConfirmByNonceAndTokenContract ¶
func (k *Keeper) GetBatchConfirmByNonceAndTokenContract(ctx sdk.Context, nonce uint64, tokenContract common.Address) (out []*types.MsgConfirmBatch)
GetBatchConfirmByNonceAndTokenContract returns the batch confirms
func (*Keeper) GetBatchFeesByTokenType ¶
func (k *Keeper) GetBatchFeesByTokenType(ctx sdk.Context, tokenContractAddr common.Address) *types.BatchFees
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) GetBridgeChainID ¶
GetBridgeChainID returns the chain id of the ETH chain we are running against
func (*Keeper) GetBridgeContractAddress ¶
GetBridgeContractAddress returns the bridge contract address on ETH
func (*Keeper) GetCosmosOriginatedDenom ¶
func (*Keeper) GetCosmosOriginatedERC20 ¶
func (*Keeper) GetCurrentValset ¶
GetCurrentValset gets powers from the store and normalizes them into an integer percentage with a resolution of uint32 Max meaning a given validators 'Peggy power' is computed as Cosmos power for that validator / total cosmos power = x / uint32 Max where x is the voting power on the Peggy 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.
'total cosmos power' has an edge case, if a validator has not set their Ethereum key they are not included in the total. If they where control of the bridge could be lost in the following situation.
If we have 100 total power, and 100 total power joins the validator set the new validators hold more than 33% of the bridge power, if we generate and submit a valset and they don't have their eth keys set they can never update the validator set again and the bridge and all its' funds are lost. For this reason we exclude validators with unset eth keys from validator sets
func (*Keeper) GetDelegateKeyByEth ¶
func (k *Keeper) GetDelegateKeyByEth(c context.Context, req *types.QueryDelegateKeysByEthAddress) (*types.QueryDelegateKeysByEthAddressResponse, error)
func (*Keeper) GetDelegateKeyByOrchestrator ¶
func (k *Keeper) GetDelegateKeyByOrchestrator(c context.Context, req *types.QueryDelegateKeysByOrchestratorAddress) (*types.QueryDelegateKeysByOrchestratorAddressResponse, error)
func (*Keeper) GetDelegateKeyByValidator ¶
func (k *Keeper) GetDelegateKeyByValidator(c context.Context, req *types.QueryDelegateKeysByValidatorAddress) (*types.QueryDelegateKeysByValidatorAddressResponse, error)
func (*Keeper) GetEthAddressByValidator ¶
func (k *Keeper) GetEthAddressByValidator(ctx sdk.Context, validator sdk.ValAddress) (common.Address, bool)
GetEthAddressByValidator returns the eth address for a given peggy validator
func (*Keeper) GetLastEventByValidator ¶
func (k *Keeper) GetLastEventByValidator(ctx sdk.Context, validator sdk.ValAddress) (lastEvent types.LastClaimEvent)
GetLastEventByValidator returns the latest event for a given validator
func (*Keeper) GetLastObservedEthereumBlockHeight ¶
func (k *Keeper) GetLastObservedEthereumBlockHeight(ctx sdk.Context) types.LastObservedEthereumBlockHeight
GetLastObservedEthereumBlockHeight height gets the block height to of the last observed attestation from the store
func (*Keeper) GetLastObservedEventNonce ¶
GetLastObservedEventNonce returns the latest observed event nonce
func (*Keeper) GetLastObservedValset ¶
GetLastObservedValset retrieves the last observed validator set from the store WARNING: This value is not an up to date validator set on Ethereum, it is a validator set that AT ONE POINT was the one in the Gravity bridge on Ethereum. If you assume that it's up to date you may break the bridge
func (*Keeper) GetLastOutgoingBatchByTokenType ¶
func (k *Keeper) GetLastOutgoingBatchByTokenType(ctx sdk.Context, token common.Address) *types.OutgoingTxBatch
GetLastOutgoingBatchByTokenType gets the latest outgoing tx batch by token type
func (*Keeper) GetLastOutgoingBatchID ¶
func (*Keeper) GetLastOutgoingPoolID ¶
func (*Keeper) GetLastSlashedBatchBlock ¶
GetLastSlashedBatchBlock returns the latest slashed Batch block
func (*Keeper) GetLastSlashedValsetNonce ¶
GetLastSlashedValsetNonce returns the latest slashed valset nonce
func (*Keeper) GetLastUnbondingBlockHeight ¶
GetLastUnbondingBlockHeight returns the last unbonding block height
func (*Keeper) GetLatestValset ¶
GetLatestValset returns the latest validator set in state
func (*Keeper) GetLatestValsetNonce ¶
GetLatestValsetNonce returns the latest valset nonce
func (*Keeper) GetOrchestratorAddresses ¶
func (k *Keeper) GetOrchestratorAddresses(ctx sdk.Context) []*types.MsgSetOrchestratorAddresses
GetOrchestratorAddresses iterates both the EthAddress and Orchestrator address indexes to produce a vector of MsgSetOrchestratorAddresses entires containing all the delgate keys for state export / import. This may seem at first glance to be excessively complicated, why not combine the EthAddress and Orchestrator address indexes and simply iterate one thing? The answer is that even though we set the Eth and Orchestrator address in the same place we use them differently we always go from Orchestrator address to Validator address and from validator address to Ethereum address we want to keep looking up the validator address for various reasons, so a direct Orchestrator to Ethereum address mapping will mean having to keep two of the same data around just to provide lookups.
For the time being this will serve
func (*Keeper) GetOrchestratorValidator ¶
func (k *Keeper) GetOrchestratorValidator(ctx sdk.Context, orch sdk.AccAddress) (sdk.ValAddress, bool)
GetOrchestratorValidator returns the validator key associated with an orchestrator key
func (*Keeper) GetOutgoingTXBatch ¶
func (k *Keeper) GetOutgoingTXBatch(ctx sdk.Context, tokenContract common.Address, nonce uint64) *types.OutgoingTxBatch
GetOutgoingTXBatch loads a batch object. Returns nil when not exists.
func (*Keeper) GetOutgoingTxBatches ¶
func (k *Keeper) GetOutgoingTxBatches(ctx sdk.Context) (out []*types.OutgoingTxBatch)
GetOutgoingTxBatches returns the outgoing tx batches
func (*Keeper) GetPastEthSignatureCheckpoint ¶
func (k *Keeper) GetPastEthSignatureCheckpoint(ctx sdk.Context, checkpoint common.Hash) (found bool)
GetPastEthSignatureCheckpoint tells you whether a given checkpoint has ever existed
func (*Keeper) GetPendingSendToEth ¶
func (k *Keeper) GetPendingSendToEth(c context.Context, req *types.QueryPendingSendToEth) (*types.QueryPendingSendToEthResponse, error)
func (*Keeper) GetPoolTransactions ¶
func (k *Keeper) GetPoolTransactions(ctx sdk.Context) []*types.OutgoingTransferTx
GetPoolTransactions, grabs all transactions from the tx pool, useful for queries or genesis save/load this does not include all transactions in batches, because it iterates using the second index key
func (*Keeper) GetUnslashedBatches ¶
func (k *Keeper) GetUnslashedBatches(ctx sdk.Context, maxHeight uint64) (out []*types.OutgoingTxBatch)
GetUnslashedBatches returns all the unslashed batches in state
func (*Keeper) GetUnslashedValsets ¶
GetUnslashedValsets returns all the unslashed validator sets in state
func (*Keeper) GetValidatorByEthAddress ¶
func (k *Keeper) GetValidatorByEthAddress(ctx sdk.Context, ethAddr common.Address) (validator stakingtypes.Validator, found bool)
GetValidatorByEthAddress returns the validator for a given eth address
func (*Keeper) GetValsetConfirm ¶
func (k *Keeper) GetValsetConfirm(ctx sdk.Context, nonce uint64, validator sdk.AccAddress) *types.MsgValsetConfirm
GetValsetConfirm returns a valset confirmation by a nonce and validator address
func (*Keeper) GetValsetConfirms ¶
func (k *Keeper) GetValsetConfirms(ctx sdk.Context, nonce uint64) (valsetConfirms []*types.MsgValsetConfirm)
GetValsetConfirms returns all validator set confirmations by nonce
func (*Keeper) GetValsets ¶
GetValsets returns all the validator sets in state
func (*Keeper) HasValsetRequest ¶
HasValsetRequest returns true if a valset defined by a nonce exists
func (*Keeper) IterateAttestations ¶
func (k *Keeper) IterateAttestations(ctx sdk.Context, cb func(k []byte, v *types.Attestation) (stop bool))
IterateAttestations iterates through all attestations
func (*Keeper) IterateBatchBySlashedBatchBlock ¶
func (k *Keeper) IterateBatchBySlashedBatchBlock(ctx sdk.Context, lastSlashedBatchBlock uint64, maxHeight uint64, cb func([]byte, *types.OutgoingTxBatch) bool)
IterateBatchBySlashedBatchBlock iterates through all Batch by last slashed Batch block in ASC order
func (*Keeper) IterateBatchConfirmByNonceAndTokenContract ¶
func (k *Keeper) IterateBatchConfirmByNonceAndTokenContract( ctx sdk.Context, nonce uint64, tokenContract common.Address, cb func(k []byte, v *types.MsgConfirmBatch) (stop bool), )
IterateBatchConfirmByNonceAndTokenContract iterates through all batch confirmations
func (*Keeper) IterateERC20ToDenom ¶
func (k *Keeper) IterateERC20ToDenom(ctx sdk.Context, cb func(k []byte, v *types.ERC20ToDenom) (stop bool))
IterateERC20ToDenom iterates over erc20 to denom relations
func (*Keeper) IterateOutgoingPoolByFee ¶
func (k *Keeper) IterateOutgoingPoolByFee(ctx sdk.Context, tokenContract common.Address, cb func(uint64, *types.OutgoingTransferTx) bool)
IterateOutgoingPoolByFee itetates over the outgoing pool which is sorted by fee
func (*Keeper) IterateOutgoingTXBatches ¶
func (k *Keeper) IterateOutgoingTXBatches(ctx sdk.Context, cb func(key []byte, batch *types.OutgoingTxBatch) bool)
IterateOutgoingTXBatches iterates through all outgoing batches in DESC order.
func (*Keeper) IterateValsetBySlashedValsetNonce ¶
func (k *Keeper) IterateValsetBySlashedValsetNonce( ctx sdk.Context, lastSlashedValsetNonce uint64, maxHeight uint64, cb func(k []byte, v *types.Valset) (stop bool), )
IterateValsetBySlashedValsetNonce iterates through all valset by last slashed valset nonce in ASC order
func (*Keeper) IterateValsetConfirmByNonce ¶
func (k *Keeper) IterateValsetConfirmByNonce(ctx sdk.Context, nonce uint64, cb func(k []byte, v *types.MsgValsetConfirm) (stop bool))
IterateValsetConfirmByNonce iterates through all valset confirms by validator set nonce in ASC order
func (*Keeper) IterateValsets ¶
IterateValsets retruns all valsetRequests
func (*Keeper) LastEventByAddr ¶
func (k *Keeper) LastEventByAddr(c context.Context, req *types.QueryLastEventByAddrRequest) (*types.QueryLastEventByAddrResponse, error)
LastEventByAddr returns the last event for the given validator address, this allows eth oracles to figure out where they left off
func (*Keeper) LastPendingBatchRequestByAddr ¶
func (k *Keeper) LastPendingBatchRequestByAddr(c context.Context, req *types.QueryLastPendingBatchRequestByAddrRequest) (*types.QueryLastPendingBatchRequestByAddrResponse, error)
LastPendingBatchRequestByAddr queries the LastPendingBatchRequestByAddr of the peggy module
func (*Keeper) LastPendingValsetRequestByAddr ¶
func (k *Keeper) LastPendingValsetRequestByAddr(c context.Context, req *types.QueryLastPendingValsetRequestByAddrRequest) (*types.QueryLastPendingValsetRequestByAddrResponse, error)
LastPendingValsetRequestByAddr queries the LastPendingValsetRequestByAddr of the peggy module
func (*Keeper) LastValsetRequests ¶
func (k *Keeper) LastValsetRequests(c context.Context, req *types.QueryLastValsetRequestsRequest) (*types.QueryLastValsetRequestsResponse, error)
LastValsetRequests queries the LastValsetRequests of the peggy module
func (*Keeper) OutgoingTxBatchExecuted ¶
func (k *Keeper) OutgoingTxBatchExecuted(ctx sdk.Context, tokenContract common.Address, nonce uint64)
OutgoingTxBatchExecuted is run when the Cosmos chain detects that a batch has been executed on Ethereum It frees all the transactions in the batch, then cancels all earlier batches, this function panics instead of returning errors because any failure will cause a double spend.
func (*Keeper) OutgoingTxBatches ¶
func (k *Keeper) OutgoingTxBatches(c context.Context, req *types.QueryOutgoingTxBatchesRequest) (*types.QueryOutgoingTxBatchesResponse, error)
OutgoingTxBatches queries the OutgoingTxBatches of the peggy module
func (*Keeper) Params ¶
func (k *Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params queries the params of the peggy module
func (*Keeper) PeggyModuleState ¶
func (k *Keeper) PeggyModuleState(c context.Context, req *types.QueryModuleStateRequest) (*types.QueryModuleStateResponse, error)
func (*Keeper) RemoveFromOutgoingPoolAndRefund ¶
func (k *Keeper) RemoveFromOutgoingPoolAndRefund(ctx sdk.Context, txId uint64, sender sdk.AccAddress) error
RemoveFromOutgoingPoolAndRefund - checks that the provided tx actually exists - deletes the un-batched tx from the pool - issues the tokens back to the sender
func (*Keeper) RewardToERC20Lookup ¶
RewardToERC20Lookup is a specialized function wrapping DenomToERC20Lookup designed to validate the validator set reward any time we generate a validator set
func (*Keeper) SetAttestation ¶
func (k *Keeper) SetAttestation(ctx sdk.Context, eventNonce uint64, claimHash []byte, att *types.Attestation)
SetAttestation sets the attestation in the store
func (*Keeper) SetBatchConfirm ¶
SetBatchConfirm sets a batch confirmation by a validator
func (*Keeper) SetCosmosOriginatedDenomToERC20 ¶
func (*Keeper) SetEthAddressForValidator ¶
func (k *Keeper) SetEthAddressForValidator(ctx sdk.Context, validator sdk.ValAddress, ethAddr common.Address)
SetEthAddressForValidator sets the ethereum address for a given validator
func (*Keeper) SetLastObservedEthereumBlockHeight ¶
SetLastObservedEthereumBlockHeight sets the block height in the store.
func (*Keeper) SetLastObservedValset ¶
SetLastObservedValset updates the last observed validator set in the store
func (*Keeper) SetLastOutgoingBatchID ¶
func (*Keeper) SetLastOutgoingPoolID ¶
func (*Keeper) SetLastSlashedBatchBlock ¶
SetLastSlashedBatchBlock sets the latest slashed Batch block height
func (*Keeper) SetLastSlashedValsetNonce ¶
setLastSlashedValsetNonce sets the latest slashed valset nonce
func (*Keeper) SetLastUnbondingBlockHeight ¶
SetLastUnbondingBlockHeight sets the last unbonding block height
func (*Keeper) SetLatestValsetNonce ¶
SetLatestValsetNonce sets the latest valset nonce
func (*Keeper) SetOrchestratorValidator ¶
func (k *Keeper) SetOrchestratorValidator(ctx sdk.Context, val sdk.ValAddress, orch sdk.AccAddress)
SetOrchestratorValidator sets the Orchestrator key for a given validator
func (*Keeper) SetPastEthSignatureCheckpoint ¶
SetPastEthSignatureCheckpoint puts the checkpoint of a valset, batch, or logic call into a set in order to prove later that it existed at one point.
func (*Keeper) SetValsetConfirm ¶
SetValsetConfirm sets a valset confirmation
func (*Keeper) SetValsetRequest ¶
SetValsetRequest returns a new instance of the Peggy BridgeValidatorSet i.e. {"nonce": 1, "memebers": [{"eth_addr": "foo", "power": 11223}]}
func (*Keeper) StoreBatch ¶
func (k *Keeper) StoreBatch(ctx sdk.Context, batch *types.OutgoingTxBatch)
StoreBatch stores a transaction batch
func (*Keeper) StoreBatchUnsafe ¶
func (k *Keeper) StoreBatchUnsafe(ctx sdk.Context, batch *types.OutgoingTxBatch)
StoreBatchUnsafe stores a transaction batch w/o setting the height
func (*Keeper) StoreValset ¶
StoreValset is for storing a valiator set at a given height
func (*Keeper) StoreValsetUnsafe ¶
StoreValsetUnsafe is for storing a valiator set at a given height
func (*Keeper) TryAttestation ¶
func (k *Keeper) TryAttestation(ctx sdk.Context, att *types.Attestation)
TryAttestation checks if an attestation has enough votes to be applied to the consensus state and has not already been marked Observed, then calls processAttestation to actually apply it to the state, and then marks it Observed and emits an event.
func (*Keeper) UnpackAttestationClaim ¶
func (k *Keeper) UnpackAttestationClaim(attestation *types.Attestation) (types.EthereumClaim, error)
func (*Keeper) ValsetConfirm ¶
func (k *Keeper) ValsetConfirm(c context.Context, req *types.QueryValsetConfirmRequest) (*types.QueryValsetConfirmResponse, error)
ValsetConfirm queries the ValsetConfirm of the peggy module
func (*Keeper) ValsetConfirmsByNonce ¶
func (k *Keeper) ValsetConfirmsByNonce(c context.Context, req *types.QueryValsetConfirmsByNonceRequest) (*types.QueryValsetConfirmsByNonceResponse, error)
ValsetConfirmsByNonce queries the ValsetConfirmsByNonce of the peggy module
func (*Keeper) ValsetRequest ¶
func (k *Keeper) ValsetRequest(c context.Context, req *types.QueryValsetRequestRequest) (*types.QueryValsetRequestResponse, error)
ValsetRequest queries the ValsetRequest of the peggy module