keeper

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 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 added in v0.1.9

func AttestationFromDB(att *Attestation, 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
	BlockOffset     uint64 `protobuf:"varint,4,opt,name=block_offset,json=blockOffset,proto3" json:"block_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
	AttestationRoot []byte `protobuf:"bytes,7,opt,name=attestation_root,json=attestationRoot,proto3" json:"attestation_root,omitempty"`  // Attestation merkle root of the cross-chain Block
	KeyHash         []byte `protobuf:"bytes,8,opt,name=key_hash,json=keyHash,proto3" json:"key_hash,omitempty"`                          // Hash of the above fields uniquely identifying an attestation
	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) GetAttestationRoot added in v0.1.1

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

func (*Attestation) GetBlockHash added in v0.1.9

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

func (*Attestation) GetBlockHeight added in v0.1.9

func (x *Attestation) GetBlockHeight() uint64

func (*Attestation) GetBlockOffset added in v0.1.9

func (x *Attestation) GetBlockOffset() uint64

func (*Attestation) GetChainId

func (x *Attestation) GetChainId() uint64

func (*Attestation) GetConfLevel added in v0.1.8

func (x *Attestation) GetConfLevel() uint32

func (*Attestation) GetCreatedHeight added in v0.1.2

func (x *Attestation) GetCreatedHeight() uint64

func (*Attestation) GetFinalizedAttId added in v0.1.9

func (x *Attestation) GetFinalizedAttId() uint64

func (*Attestation) GetId

func (x *Attestation) GetId() uint64

func (*Attestation) GetKeyHash added in v0.1.9

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

func (*Attestation) GetStatus

func (x *Attestation) GetStatus() uint32

func (*Attestation) GetValidatorSetId added in v0.1.2

func (x *Attestation) GetValidatorSetId() uint64

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 added in v0.1.9

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

type AttestationCreatedHeightIndexKey added in v0.1.2

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

func (AttestationCreatedHeightIndexKey) WithCreatedHeight added in v0.1.2

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 AttestationKeyHashIndexKey added in v0.1.9

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

func (AttestationKeyHashIndexKey) WithKeyHash added in v0.1.9

func (this AttestationKeyHashIndexKey) WithKeyHash(key_hash []byte) AttestationKeyHashIndexKey

type AttestationPrimaryKey

type AttestationPrimaryKey = AttestationIdIndexKey

primary key starting index..

type AttestationStatusChainIdConfLevelBlockOffsetIndexKey added in v0.1.9

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

func (AttestationStatusChainIdConfLevelBlockOffsetIndexKey) WithStatus added in v0.1.9

func (AttestationStatusChainIdConfLevelBlockOffsetIndexKey) WithStatusChainId added in v0.1.9

func (AttestationStatusChainIdConfLevelBlockOffsetIndexKey) WithStatusChainIdConfLevel added in v0.1.9

func (AttestationStatusChainIdConfLevelBlockOffsetIndexKey) WithStatusChainIdConfLevelBlockOffset added in v0.1.9

func (this AttestationStatusChainIdConfLevelBlockOffsetIndexKey) WithStatusChainIdConfLevelBlockOffset(status uint32, chain_id uint64, conf_level uint32, block_offset uint64) AttestationStatusChainIdConfLevelBlockOffsetIndexKey

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)
	HasByKeyHash(ctx context.Context, key_hash []byte) (found bool, err error)
	// GetByKeyHash returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	GetByKeyHash(ctx context.Context, key_hash []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,
	voteWindow uint64,
	voteExtLimit uint64,
	trimLag 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 added in v0.1.2

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 added in v0.1.2

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 added in v0.1.1

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

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 added in v0.1.9

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

SetPortalRegistry sets the portal registry.

func (*Keeper) SetValidatorProvider added in v0.1.2

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.

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.
	// 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) 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

type SignatureAttIdIndexKey

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

func (SignatureAttIdIndexKey) WithAttId

func (this SignatureAttIdIndexKey) WithAttId(att_id uint64) SignatureAttIdIndexKey

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 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)
	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 added in v0.1.2

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

func (ValSet) Contains added in v0.1.2

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

func (ValSet) TotalPower added in v0.1.2

func (s ValSet) TotalPower() int64

Jump to

Keyboard shortcuts

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