keeper

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: GPL-3.0 Imports: 35 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 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
	Height          uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"`                                         // Height of the block
	Hash            []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"`                                              // Hash of the block
	AttestationRoot []byte `protobuf:"bytes,5,opt,name=attestation_root,json=attestationRoot,proto3" json:"attestation_root,omitempty"` // Attestation merkle root of the cross-chain Block
	Status          int32  `protobuf:"varint,6,opt,name=status,proto3" json:"status,omitempty"`                                         // Status of the block; pending, approved.
	ValidatorSetId  uint64 `protobuf:"varint,7,opt,name=validator_set_id,json=validatorSetId,proto3" json:"validator_set_id,omitempty"` // Validator set that approved this attestation.
	CreatedHeight   uint64 `protobuf:"varint,8,opt,name=created_height,json=createdHeight,proto3" json:"created_height,omitempty"`      // Consensus height at which this attestation was created.
	// 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) GetChainId

func (x *Attestation) GetChainId() uint64

func (*Attestation) GetCreatedHeight added in v0.1.2

func (x *Attestation) GetCreatedHeight() uint64

func (*Attestation) GetHash

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

func (*Attestation) GetHeight

func (x *Attestation) GetHeight() uint64

func (*Attestation) GetId

func (x *Attestation) GetId() uint64

func (*Attestation) GetStatus

func (x *Attestation) GetStatus() int32

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

type AttestationChainIdHeightHashAttestationRootIndexKey added in v0.1.1

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

func (AttestationChainIdHeightHashAttestationRootIndexKey) WithChainId added in v0.1.1

func (AttestationChainIdHeightHashAttestationRootIndexKey) WithChainIdHeight added in v0.1.1

func (AttestationChainIdHeightHashAttestationRootIndexKey) WithChainIdHeightHash added in v0.1.1

func (AttestationChainIdHeightHashAttestationRootIndexKey) WithChainIdHeightHashAttestationRoot added in v0.1.1

func (this AttestationChainIdHeightHashAttestationRootIndexKey) WithChainIdHeightHashAttestationRoot(chain_id uint64, height uint64, hash []byte, attestation_root []byte) AttestationChainIdHeightHashAttestationRootIndexKey

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 AttestationPrimaryKey

type AttestationPrimaryKey = AttestationIdIndexKey

primary key starting index..

type AttestationStatusChainIdHeightIndexKey

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

func (AttestationStatusChainIdHeightIndexKey) WithStatus

func (AttestationStatusChainIdHeightIndexKey) WithStatusChainId

func (AttestationStatusChainIdHeightIndexKey) WithStatusChainIdHeight

func (this AttestationStatusChainIdHeightIndexKey) WithStatusChainIdHeight(status int32, chain_id uint64, height uint64) AttestationStatusChainIdHeightIndexKey

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)
	HasByChainIdHeightHashAttestationRoot(ctx context.Context, chain_id uint64, height uint64, hash []byte, attestation_root []byte) (found bool, err error)
	// GetByChainIdHeightHashAttestationRoot returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	GetByChainIdHeightHashAttestationRoot(ctx context.Context, chain_id uint64, height uint64, hash []byte, 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.ChainNameFunc,
	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 pen 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, height uint64, max uint64) ([]*types.Attestation, error)

ListAttestationsFrom returns the subsequent approved attestations from the provided height (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) SetValidatorProvider added in v0.1.2

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

SetValidatorProvider sets the validator provider.

func (*Keeper) SetVoter

func (k *Keeper) SetVoter(voter types.Voter)

SetVoter sets the voter.

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