Documentation ¶
Index ¶
- Constants
- Variables
- func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k Keeper)
- func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState
- func FromBytes8(x []byte) uint64
- func GetSpanKey(id uint64) []byte
- func HandleMsgProposeSpan(ctx sdk.Context, msg types.MsgProposeSpan, k Keeper) sdk.Result
- func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState)
- func NewHandler(k Keeper) sdk.Handler
- func NewPostTxHandler(k Keeper, contractCaller helper.IContractCaller) hmTypes.PostTxHandler
- func NewQuerier(keeper Keeper) sdk.Querier
- func NewSideTxHandler(k Keeper, contractCaller helper.IContractCaller) hmTypes.SideTxHandler
- func PostHandleMsgEventSpan(ctx sdk.Context, k Keeper, msg types.MsgProposeSpan, ...) sdk.Result
- func SelectNextProducers(blkHash common.Hash, spanEligibleValidators []hmTypes.Validator, ...) ([]uint64, error)
- func ShuffleList(input []uint64, seed [32]byte) ([]uint64, error)
- func SideHandleMsgSpan(ctx sdk.Context, k Keeper, msg types.MsgProposeSpan, ...) (result abci.ResponseDeliverSideTx)
- func XXXSelectNextProducers(blkHash common.Hash, spanEligibleVals []hmTypes.Validator, ...) (selectedIDs []uint64, err error)
- type AppModule
- func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)
- func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
- func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
- func (AppModule) Name() string
- func (am AppModule) NewHandler() sdk.Handler
- func (am AppModule) NewPostTxHandler() hmTypes.PostTxHandler
- func (am AppModule) NewQuerierHandler() sdk.Querier
- func (am AppModule) NewSideTxHandler() hmTypes.SideTxHandler
- func (AppModule) QuerierRoute() string
- func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry)
- func (AppModule) Route() string
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis() json.RawMessage
- func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
- func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
- func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
- func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
- func (AppModuleBasic) VerifyGenesis(bz map[string]json.RawMessage) error
- type Keeper
- func (k *Keeper) AddNewRawSpan(ctx sdk.Context, span hmTypes.Span) error
- func (k *Keeper) AddNewSpan(ctx sdk.Context, span hmTypes.Span) error
- func (k Keeper) Codespace() sdk.CodespaceType
- func (k *Keeper) FreezeSet(ctx sdk.Context, id uint64, startBlock uint64, endBlock uint64, ...) error
- func (k *Keeper) GetAllSpans(ctx sdk.Context) (spans []*hmTypes.Span)
- func (k *Keeper) GetLastEthBlock(ctx sdk.Context) *big.Int
- func (k *Keeper) GetLastSpan(ctx sdk.Context) (*hmTypes.Span, error)
- func (k Keeper) GetNextSpanSeed(ctx sdk.Context) (common.Hash, error)
- func (k *Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k *Keeper) GetSpan(ctx sdk.Context, id uint64) (*hmTypes.Span, error)
- func (k *Keeper) GetSpanList(ctx sdk.Context, page uint64, limit uint64) ([]hmTypes.Span, error)
- func (k *Keeper) HasSpan(ctx sdk.Context, id uint64) bool
- func (k *Keeper) IncrementLastEthBlock(ctx sdk.Context)
- func (k *Keeper) IterateSpansAndApplyFn(ctx sdk.Context, f func(span hmTypes.Span) error)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k *Keeper) SelectNextProducers(ctx sdk.Context, seed common.Hash) (vals []hmTypes.Validator, err error)
- func (k *Keeper) SetLastEthBlock(ctx sdk.Context, blockNumber *big.Int)
- func (k *Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k *Keeper) UpdateLastSpan(ctx sdk.Context, id uint64)
- type ResponseWithHeight
Constants ¶
const (
ShuffleRoundCount = 90
)
Variables ¶
var ( LastSpanIDKey = []byte{0x35} // Key to store last span start block SpanPrefixKey = []byte{0x36} // prefix key to store span LastProcessedEthBlock = []byte{0x38} // key to store last processed eth block for seed )
Functions ¶
func BeginBlocker ¶ added in v0.2.8
func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k Keeper)
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState
ExportGenesis returns a GenesisState for a given context and keeper.
func FromBytes8 ¶ added in v0.3.2
FromBytes8 returns an integer which is stored in the little-endian format(8, 'little') from a byte array.
func HandleMsgProposeSpan ¶
HandleMsgProposeSpan handles proposeSpan msg
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState)
InitGenesis sets distribution information for genesis.
func NewHandler ¶
NewHandler returns a handler for "bor" type messages.
func NewPostTxHandler ¶ added in v0.1.7
func NewPostTxHandler(k Keeper, contractCaller helper.IContractCaller) hmTypes.PostTxHandler
NewPostTxHandler returns a side handler for "span" type messages.
func NewQuerier ¶
NewQuerier creates a querier for auth REST endpoints
func NewSideTxHandler ¶ added in v0.1.7
func NewSideTxHandler(k Keeper, contractCaller helper.IContractCaller) hmTypes.SideTxHandler
NewSideTxHandler returns a side handler for "span" type messages.
func PostHandleMsgEventSpan ¶ added in v0.1.7
func PostHandleMsgEventSpan(ctx sdk.Context, k Keeper, msg types.MsgProposeSpan, sideTxResult abci.SideTxResultType) sdk.Result
PostHandleMsgEventSpan handles state persisting span msg
func SelectNextProducers ¶
func SelectNextProducers(blkHash common.Hash, spanEligibleValidators []hmTypes.Validator, producerCount uint64) ([]uint64, error)
SelectNextProducers selects producers for next span by converting power to tickets
func ShuffleList ¶
ShuffleList returns list of shuffled indexes in a pseudorandom permutation `p` of `0...list_size - 1` with “seed“ as entropy. We utilize 'swap or not' shuffling in this implementation; we are allocating the memory with the seed that stays constant between iterations instead of reallocating it each iteration as in the spec. This implementation is based on the original implementation from protolambda, https://github.com/protolambda/eth2-shuffle
improvements: - seed is always the first 32 bytes of the hash input, we just copy it into the buffer one time. - add round byte to seed and hash that part of the buffer. - split up the for-loop in two: 1. Handle the part from 0 (incl) to pivot (incl). This is mirrored around (pivot / 2). 2. Handle the part from pivot (excl) to N (excl). This is mirrored around ((pivot / 2) + (size/2)). - hash source every 256 iterations. - change byteV every 8 iterations. - we start at the edges, and work back to the mirror point. this makes us process each pear exactly once (instead of unnecessarily twice, like in the spec).
func SideHandleMsgSpan ¶ added in v0.1.7
func SideHandleMsgSpan(ctx sdk.Context, k Keeper, msg types.MsgProposeSpan, contractCaller helper.IContractCaller) (result abci.ResponseDeliverSideTx)
SideHandleMsgSpan validates external calls required for processing proposed span
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule implements an application module for the supply module.
func NewAppModule ¶
func NewAppModule(keeper Keeper, contractCaller helper.IContractCaller) AppModule
NewAppModule creates a new AppModule object
func (AppModule) BeginBlock ¶
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)
BeginBlock returns the begin blocker for the auth module.
func (AppModule) EndBlock ¶
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
EndBlock returns the end blocker for the auth module. It returns no validator updates.
func (AppModule) ExportGenesis ¶
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
ExportGenesis returns the exported genesis state as raw bytes for the auth module.
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
InitGenesis performs genesis initialization for the auth module. It returns no validator updates.
func (AppModule) NewHandler ¶
NewHandler returns an sdk.Handler for the module.
func (AppModule) NewPostTxHandler ¶ added in v0.1.7
func (am AppModule) NewPostTxHandler() hmTypes.PostTxHandler
NewPostTxHandler side tx handler
func (AppModule) NewQuerierHandler ¶
NewQuerierHandler returns the auth module sdk.Querier.
func (AppModule) NewSideTxHandler ¶ added in v0.1.7
func (am AppModule) NewSideTxHandler() hmTypes.SideTxHandler
func (AppModule) QuerierRoute ¶
QuerierRoute returns the auth module's querier route name.
func (AppModule) RegisterInvariants ¶
func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry)
RegisterInvariants performs a no-op.
type AppModuleBasic ¶
type AppModuleBasic struct{}
AppModuleBasic defines the basic application module used by the auth module.
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis() json.RawMessage
DefaultGenesis returns default genesis state as raw bytes for the auth module.
func (AppModuleBasic) GetQueryCmd ¶
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
GetQueryCmd returns the root query command for the auth module.
func (AppModuleBasic) GetTxCmd ¶
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command
GetTxCmd returns the root tx command for the auth module.
func (AppModuleBasic) Name ¶
func (AppModuleBasic) Name() string
Name returns the auth module's name.
func (AppModuleBasic) RegisterCodec ¶
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
RegisterCodec registers the auth module's types for the given codec.
func (AppModuleBasic) RegisterRESTRoutes ¶
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
RegisterRESTRoutes registers the REST routes for the auth module.
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
ValidateGenesis performs genesis state validation for the auth module.
func (AppModuleBasic) VerifyGenesis ¶
func (AppModuleBasic) VerifyGenesis(bz map[string]json.RawMessage) error
VerifyGenesis performs verification on auth module state.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper stores all related data
func NewKeeper ¶
func NewKeeper( cdc *codec.Codec, storeKey sdk.StoreKey, paramSpace subspace.Subspace, codespace sdk.CodespaceType, chainKeeper chainmanager.Keeper, stakingKeeper staking.Keeper, caller helper.ContractCaller, ) Keeper
NewKeeper is the constructor of Keeper
func (*Keeper) AddNewRawSpan ¶
AddNewRawSpan adds new span for bor to store
func (*Keeper) AddNewSpan ¶
AddNewSpan adds new span for bor to store
func (Keeper) Codespace ¶
func (k Keeper) Codespace() sdk.CodespaceType
Codespace returns the codespace
func (*Keeper) FreezeSet ¶
func (k *Keeper) FreezeSet(ctx sdk.Context, id uint64, startBlock uint64, endBlock uint64, borChainID string, seed common.Hash) error
FreezeSet freezes validator set for next span
func (*Keeper) GetAllSpans ¶
GetAllSpans fetches all indexed by id from store
func (*Keeper) GetLastEthBlock ¶
GetLastEthBlock get last processed Eth block for seed
func (*Keeper) GetLastSpan ¶
GetLastSpan fetches last span using lastStartBlock
func (Keeper) GetNextSpanSeed ¶ added in v0.1.7
func (*Keeper) GetSpanList ¶
GetSpanList returns all spans with params like page and limit
func (*Keeper) IncrementLastEthBlock ¶
IncrementLastEthBlock increment last eth block
func (*Keeper) IterateSpansAndApplyFn ¶
IterateSpansAndApplyFn iterates spans and apply the given function.
func (*Keeper) SelectNextProducers ¶
func (k *Keeper) SelectNextProducers(ctx sdk.Context, seed common.Hash) (vals []hmTypes.Validator, err error)
SelectNextProducers selects producers for next span
func (*Keeper) SetLastEthBlock ¶
SetLastEthBlock sets last eth block number
type ResponseWithHeight ¶ added in v1.0.1
type ResponseWithHeight struct { Height string `json:"height"` Result jsoniter.RawMessage `json:"result"` }
ResponseWithHeight defines a response object type that wraps an original response with a height.