keeper

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Status_name = map[int32]string{
		0: "Unknown",
		1: "Pending",
		2: "Approved",
	}
	Status_value = map[string]int32{
		"Unknown":  0,
		"Pending":  1,
		"Approved": 2,
	}
)

Enum value maps for Status.

View Source
var File_halo_attest_keeper_attestation_proto protoreflect.FileDescriptor

Functions

func AttestationFromDB

func AttestationFromDB(att *Attestation, consensusChainID uint64, sigs []*Signature) *types.Attestation

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServiceServer

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

func NewProposalServer

func NewProposalServer(keeper *Keeper) types.MsgServiceServer

NewProposalServer returns an implementation of the MsgServer interface for the provided Keeper.

Types

type Attestation

type Attestation struct {
	Id              uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`                                                  // Auto-incremented ID
	ChainId         uint64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`                         // Chain ID as per https://chainlist.org
	ConfLevel       uint32 `protobuf:"varint,3,opt,name=conf_level,json=confLevel,proto3" json:"conf_level,omitempty"`                   // Confirmation level of the cross-chain block
	AttestOffset    uint64 `protobuf:"varint,4,opt,name=attest_offset,json=attestOffset,proto3" json:"attest_offset,omitempty"`          // Offset of the cross-chain block
	BlockHeight     uint64 `protobuf:"varint,5,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"`             // Height of the source-chain block
	BlockHash       []byte `protobuf:"bytes,6,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"`                    // Hash of the source-chain block
	MsgRoot         []byte `protobuf:"bytes,7,opt,name=msg_root,json=msgRoot,proto3" json:"msg_root,omitempty"`                          // Merkle root of all the messages in the cross-chain Block
	AttestationRoot []byte `protobuf:"bytes,8,opt,name=attestation_root,json=attestationRoot,proto3" json:"attestation_root,omitempty"`  // Attestation merkle root of the cross-chain Block
	Status          uint32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"`                                          // Status of the block; pending, approved.
	ValidatorSetId  uint64 `protobuf:"varint,10,opt,name=validator_set_id,json=validatorSetId,proto3" json:"validator_set_id,omitempty"` // Validator set that approved this attestation.
	CreatedHeight   uint64 `protobuf:"varint,11,opt,name=created_height,json=createdHeight,proto3" json:"created_height,omitempty"`      // Consensus height at which this attestation was created.
	FinalizedAttId  uint64 `protobuf:"varint,12,opt,name=finalized_att_id,json=finalizedAttId,proto3" json:"finalized_att_id,omitempty"` // Approved finalized attestation for same chain_id and offset.
	// contains filtered or unexported fields
}

func (*Attestation) Descriptor deprecated

func (*Attestation) Descriptor() ([]byte, []int)

Deprecated: Use Attestation.ProtoReflect.Descriptor instead.

func (*Attestation) GetAttestOffset

func (x *Attestation) GetAttestOffset() uint64

func (*Attestation) GetAttestationRoot

func (x *Attestation) GetAttestationRoot() []byte

func (*Attestation) GetBlockHash

func (x *Attestation) GetBlockHash() []byte

func (*Attestation) GetBlockHeight

func (x *Attestation) GetBlockHeight() uint64

func (*Attestation) GetChainId

func (x *Attestation) GetChainId() uint64

func (*Attestation) GetConfLevel

func (x *Attestation) GetConfLevel() uint32

func (*Attestation) GetCreatedHeight

func (x *Attestation) GetCreatedHeight() uint64

func (*Attestation) GetFinalizedAttId

func (x *Attestation) GetFinalizedAttId() uint64

func (*Attestation) GetId

func (x *Attestation) GetId() uint64

func (*Attestation) GetMsgRoot

func (x *Attestation) GetMsgRoot() []byte

func (*Attestation) GetStatus

func (x *Attestation) GetStatus() uint32

func (*Attestation) GetValidatorSetId

func (x *Attestation) GetValidatorSetId() uint64

func (*Attestation) IsFuzzy

func (a *Attestation) IsFuzzy() bool

func (*Attestation) ProtoMessage

func (*Attestation) ProtoMessage()

func (*Attestation) ProtoReflect

func (x *Attestation) ProtoReflect() protoreflect.Message

func (*Attestation) Reset

func (x *Attestation) Reset()

func (*Attestation) String

func (x *Attestation) String() string

func (*Attestation) XChainVersion

func (a *Attestation) XChainVersion() xchain.ChainVersion

type AttestationAttestationRootIndexKey

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

func (AttestationAttestationRootIndexKey) WithAttestationRoot

func (this AttestationAttestationRootIndexKey) WithAttestationRoot(attestation_root []byte) AttestationAttestationRootIndexKey

type AttestationCreatedHeightIndexKey

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

func (AttestationCreatedHeightIndexKey) WithCreatedHeight

func (this AttestationCreatedHeightIndexKey) WithCreatedHeight(created_height uint64) AttestationCreatedHeightIndexKey

type AttestationIdIndexKey

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

func (AttestationIdIndexKey) WithId

type AttestationIndexKey

type AttestationIndexKey interface {
	// contains filtered or unexported methods
}

type AttestationIterator

type AttestationIterator struct {
	ormtable.Iterator
}

func (AttestationIterator) Value

func (i AttestationIterator) Value() (*Attestation, error)

type AttestationPrimaryKey

type AttestationPrimaryKey = AttestationIdIndexKey

primary key starting index..

type AttestationStatusChainIdConfLevelAttestOffsetIndexKey

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

func (AttestationStatusChainIdConfLevelAttestOffsetIndexKey) WithStatus

func (AttestationStatusChainIdConfLevelAttestOffsetIndexKey) WithStatusChainId

func (AttestationStatusChainIdConfLevelAttestOffsetIndexKey) WithStatusChainIdConfLevel

func (AttestationStatusChainIdConfLevelAttestOffsetIndexKey) WithStatusChainIdConfLevelAttestOffset

func (this AttestationStatusChainIdConfLevelAttestOffsetIndexKey) WithStatusChainIdConfLevelAttestOffset(status uint32, chain_id uint64, conf_level uint32, attest_offset uint64) AttestationStatusChainIdConfLevelAttestOffsetIndexKey

type AttestationStore

type AttestationStore interface {
	AttestationTable() AttestationTable
	SignatureTable() SignatureTable
	// contains filtered or unexported methods
}

func NewAttestationStore

func NewAttestationStore(db ormtable.Schema) (AttestationStore, error)

type AttestationTable

type AttestationTable interface {
	Insert(ctx context.Context, attestation *Attestation) error
	InsertReturningId(ctx context.Context, attestation *Attestation) (uint64, error)
	LastInsertedSequence(ctx context.Context) (uint64, error)
	Update(ctx context.Context, attestation *Attestation) error
	Save(ctx context.Context, attestation *Attestation) error
	Delete(ctx context.Context, attestation *Attestation) error
	Has(ctx context.Context, id uint64) (found bool, err error)
	// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	Get(ctx context.Context, id uint64) (*Attestation, error)
	HasByAttestationRoot(ctx context.Context, attestation_root []byte) (found bool, err error)
	// GetByAttestationRoot returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	GetByAttestationRoot(ctx context.Context, attestation_root []byte) (*Attestation, error)
	List(ctx context.Context, prefixKey AttestationIndexKey, opts ...ormlist.Option) (AttestationIterator, error)
	ListRange(ctx context.Context, from, to AttestationIndexKey, opts ...ormlist.Option) (AttestationIterator, error)
	DeleteBy(ctx context.Context, prefixKey AttestationIndexKey) error
	DeleteRange(ctx context.Context, from, to AttestationIndexKey) error
	// contains filtered or unexported methods
}

func NewAttestationTable

func NewAttestationTable(db ormtable.Schema) (AttestationTable, error)

type Keeper

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

Keeper is the attestation keeper. It keeps tracks of all attestations included on-chain and detects when they are approved.

func New

func New(
	cdc codec.BinaryCodec,
	storeSvc store.KVStoreService,
	skeeper baseapp.ValidatorStore,
	namer types.ChainVerNameFunc,
	voter types.Voter,
	voteWindowUp uint64,
	voteWindowDown uint64,
	voteExtLimit uint64,
	trimLag uint64,
	cTrimLag uint64,
) (*Keeper, error)

New returns a new attestation keeper.

func (*Keeper) Add

func (k *Keeper) Add(ctx context.Context, msg *types.MsgAddVotes) error

Add adds the given aggregate votes as pending attestations to the store. It merges the votes with attestations it already exists.

func (*Keeper) Approve

func (k *Keeper) Approve(ctx context.Context, valset ValSet) error

Approve approves any pending attestations that have quorum signatures from the provided set.

func (*Keeper) AttestationsFrom

func (*Keeper) BeginBlock

func (k *Keeper) BeginBlock(ctx context.Context) error

func (*Keeper) EndBlock

func (k *Keeper) EndBlock(ctx context.Context) error

func (*Keeper) ExtendVote

func (k *Keeper) ExtendVote(ctx sdk.Context, _ *abci.RequestExtendVote) (*abci.ResponseExtendVote, error)

ExtendVote extends a vote with application-injected data (vote extensions).

func (*Keeper) LatestAttestation

func (*Keeper) ListAttestationsFrom

func (k *Keeper) ListAttestationsFrom(ctx context.Context, chainID uint64, confLevel uint32, offset uint64, max uint64) ([]*types.Attestation, error)

ListAttestationsFrom returns the subsequent approved attestations from the provided offset (inclusive).

func (*Keeper) PrepareVotes

func (k *Keeper) PrepareVotes(ctx context.Context, commit abci.ExtendedCommitInfo, commitHeight uint64) ([]sdk.Msg, error)

PrepareVotes returns the cosmosSDK transaction MsgAddVotes that will include all the validator votes included in the previous block's vote extensions into the attest module.

Note that the commit is assumed to be valid and only contains valid VEs from the previous block as provided by a trusted cometBFT. Some votes (contained inside VE) may however be invalid, they are discarded.

func (*Keeper) RegisterProposalService

func (k *Keeper) RegisterProposalService(server grpc1.Server)

RegisterProposalService registers the proposal service on the provided router. This implements abci.ProcessProposal verification of new proposals.

func (*Keeper) SetPortalRegistry

func (k *Keeper) SetPortalRegistry(portalRegistry rtypes.PortalRegistry)

SetPortalRegistry sets the portal registry.

func (*Keeper) SetValidatorProvider

func (k *Keeper) SetValidatorProvider(valProvider vtypes.ValidatorProvider)

SetValidatorProvider sets the validator provider.

func (*Keeper) VerifyVoteExtension

func (k *Keeper) VerifyVoteExtension(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (
	*abci.ResponseVerifyVoteExtension, error,
)

VerifyVoteExtension verifies a vote extension.

Note this code assumes that cometBFT will only call this function for an active validator in the current set.

func (*Keeper) WindowCompare

type Signature

type Signature struct {
	Id               uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`                                                    // Auto-incremented ID
	Signature        []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`                                       // Validator signature over XBlockRoot; Ethereum 65 bytes [R || S || V] format.
	ValidatorAddress []byte `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` // Validator ethereum address; 20 bytes.
	AttId            uint64 `protobuf:"varint,4,opt,name=att_id,json=attId,proto3" json:"att_id,omitempty"`                                 // Attestation ID to which this signature belongs.
	ChainId          uint64 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`                           // Chain ID as per https://chainlist.org
	ConfLevel        uint32 `protobuf:"varint,6,opt,name=conf_level,json=confLevel,proto3" json:"conf_level,omitempty"`                     // Confirmation level of the cross-chain block
	AttestOffset     uint64 `protobuf:"varint,7,opt,name=attest_offset,json=attestOffset,proto3" json:"attest_offset,omitempty"`            // Offset of the cross-chain block
	// contains filtered or unexported fields
}

Signature is the attestation signature of the validator over the block root.

func (*Signature) Descriptor deprecated

func (*Signature) Descriptor() ([]byte, []int)

Deprecated: Use Signature.ProtoReflect.Descriptor instead.

func (*Signature) GetAttId

func (x *Signature) GetAttId() uint64

func (*Signature) GetAttestOffset

func (x *Signature) GetAttestOffset() uint64

func (*Signature) GetChainId

func (x *Signature) GetChainId() uint64

func (*Signature) GetConfLevel

func (x *Signature) GetConfLevel() uint32

func (*Signature) GetId

func (x *Signature) GetId() uint64

func (*Signature) GetSignature

func (x *Signature) GetSignature() []byte

func (*Signature) GetValidatorAddress

func (x *Signature) GetValidatorAddress() []byte

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) ProtoReflect

func (x *Signature) ProtoReflect() protoreflect.Message

func (*Signature) Reset

func (x *Signature) Reset()

func (*Signature) String

func (x *Signature) String() string

func (*Signature) ValidatorEthAddress added in v0.10.0

func (s *Signature) ValidatorEthAddress() (common.Address, error)

type SignatureAttIdValidatorAddressIndexKey

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

func (SignatureAttIdValidatorAddressIndexKey) WithAttId

func (SignatureAttIdValidatorAddressIndexKey) WithAttIdValidatorAddress

func (this SignatureAttIdValidatorAddressIndexKey) WithAttIdValidatorAddress(att_id uint64, validator_address []byte) SignatureAttIdValidatorAddressIndexKey

type SignatureChainIdConfLevelAttestOffsetValidatorAddressIndexKey

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

func (SignatureChainIdConfLevelAttestOffsetValidatorAddressIndexKey) WithChainId

func (SignatureChainIdConfLevelAttestOffsetValidatorAddressIndexKey) WithChainIdConfLevel

func (SignatureChainIdConfLevelAttestOffsetValidatorAddressIndexKey) WithChainIdConfLevelAttestOffset

func (SignatureChainIdConfLevelAttestOffsetValidatorAddressIndexKey) WithChainIdConfLevelAttestOffsetValidatorAddress

func (this SignatureChainIdConfLevelAttestOffsetValidatorAddressIndexKey) WithChainIdConfLevelAttestOffsetValidatorAddress(chain_id uint64, conf_level uint32, attest_offset uint64, validator_address []byte) SignatureChainIdConfLevelAttestOffsetValidatorAddressIndexKey

type SignatureIdIndexKey

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

func (SignatureIdIndexKey) WithId

type SignatureIndexKey

type SignatureIndexKey interface {
	// contains filtered or unexported methods
}

type SignatureIterator

type SignatureIterator struct {
	ormtable.Iterator
}

func (SignatureIterator) Value

func (i SignatureIterator) Value() (*Signature, error)

type SignaturePrimaryKey

type SignaturePrimaryKey = SignatureIdIndexKey

primary key starting index..

type SignatureTable

type SignatureTable interface {
	Insert(ctx context.Context, signature *Signature) error
	InsertReturningId(ctx context.Context, signature *Signature) (uint64, error)
	LastInsertedSequence(ctx context.Context) (uint64, error)
	Update(ctx context.Context, signature *Signature) error
	Save(ctx context.Context, signature *Signature) error
	Delete(ctx context.Context, signature *Signature) error
	Has(ctx context.Context, id uint64) (found bool, err error)
	// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	Get(ctx context.Context, id uint64) (*Signature, error)
	HasByAttIdValidatorAddress(ctx context.Context, att_id uint64, validator_address []byte) (found bool, err error)
	// GetByAttIdValidatorAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	GetByAttIdValidatorAddress(ctx context.Context, att_id uint64, validator_address []byte) (*Signature, error)
	HasByChainIdConfLevelAttestOffsetValidatorAddress(ctx context.Context, chain_id uint64, conf_level uint32, attest_offset uint64, validator_address []byte) (found bool, err error)
	// GetByChainIdConfLevelAttestOffsetValidatorAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	GetByChainIdConfLevelAttestOffsetValidatorAddress(ctx context.Context, chain_id uint64, conf_level uint32, attest_offset uint64, validator_address []byte) (*Signature, error)
	List(ctx context.Context, prefixKey SignatureIndexKey, opts ...ormlist.Option) (SignatureIterator, error)
	ListRange(ctx context.Context, from, to SignatureIndexKey, opts ...ormlist.Option) (SignatureIterator, error)
	DeleteBy(ctx context.Context, prefixKey SignatureIndexKey) error
	DeleteRange(ctx context.Context, from, to SignatureIndexKey) error
	// contains filtered or unexported methods
}

func NewSignatureTable

func NewSignatureTable(db ormtable.Schema) (SignatureTable, error)

type Status

type Status int32
const (
	Status_Unknown  Status = 0
	Status_Pending  Status = 1
	Status_Approved Status = 2
)

func (Status) Descriptor

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

func (Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use Status.Descriptor instead.

func (Status) Number

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

func (Status) Type

func (Status) Type() protoreflect.EnumType

type ValSet

type ValSet struct {
	ID   uint64
	Vals map[common.Address]int64
}

func (ValSet) Contains

func (s ValSet) Contains(addr common.Address) bool

func (ValSet) TotalPower

func (s ValSet) TotalPower() int64

Jump to

Keyboard shortcuts

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