Documentation ¶
Index ¶
- Variables
- func AbortETHDKG(ethdkg *EthDKGState)
- func ETHDKGInProgress(ethdkg *EthDKGState, currentBlock uint64) bool
- func RetrieveParticipants(eth blockchain.Ethereum, callOpts *bind.CallOpts) (dkg.ParticipantList, int, error)
- type Bus
- type Database
- type EthDKGPhase
- type EthDKGSchedule
- type EthDKGState
- type Monitor
- type Services
- func (svcs *Services) DoDistributeShares(state *State, block uint64) error
- func (svcs *Services) DoGroupAccusationGPKj(state *State, block uint64) error
- func (svcs *Services) DoSubmitDispute(state *State, block uint64) error
- func (svcs *Services) DoSubmitGPKj(state *State, block uint64) error
- func (svcs *Services) DoSubmitKeyShare(state *State, block uint64) error
- func (svcs *Services) DoSubmitMasterPublicKey(state *State, block uint64) error
- func (svcs *Services) DoSuccessfulCompletion(state *State, block uint64) error
- func (svcs *Services) EndpointInSync(ctx context.Context, state *State) error
- func (svcs *Services) PersistSnapshot(blockHeader *objs.BlockHeader) error
- func (svcs *Services) ProcessDepositReceived(state *State, log types.Log) error
- func (svcs *Services) ProcessKeyShareSubmission(state *State, log types.Log) error
- func (svcs *Services) ProcessRegistrationOpen(state *State, log types.Log) error
- func (svcs *Services) ProcessShareDistribution(state *State, log types.Log) error
- func (svcs *Services) ProcessSnapshotTaken(state *State, log types.Log) error
- func (svcs *Services) ProcessValidatorMember(state *State, log types.Log) error
- func (svcs *Services) ProcessValidatorSet(state *State, log types.Log) error
- func (svcs *Services) RegisterEvent(selector string, name string, fn func(*State, types.Log) error) error
- func (svcs *Services) SetBN256PrivateKey(pk []byte) error
- func (svcs *Services) SetSECP256K1PrivateKey(pk []byte) error
- func (svcs *Services) UpdateProgress(state *State) error
- func (svcs *Services) WatchEthereum(state *State) error
- type Share
- type State
- type Validator
- type ValidatorSet
Constants ¶
This section is empty.
Variables ¶
var ( // SvcProcessEvents Uses the current state to process more events SvcWatchEthereum = "SvcWatchEthereum" // SvcEndpointInSync Checks if the Ethereum endpoint is ready for use SvcEndpointInSync = "SvcEndpointInSync" // SvcGetEvents Checks known contracts for recently emitted events SvcGetEvents = "SvcGetEvents" // SvcGetValidators Calls contract to get current list of validators SvcGetValidators = "SvcGetValidators" // SvcGetSnapShot Calls contract to get snapshots SvcGetSnapShot = "SvcGetSnapShot" )
These are pseudo-constants for registering services on bus
var ( // ErrUnknownRequest a service was invoked but couldn't figure out which ErrUnknownRequest = errors.New("unknown request") // ErrUnknownResponse only used when response to a service is not of the expected type ErrUnknownResponse = errors.New("response isn't in expected form") )
var ErrCanNotContinue = errors.New("can not continue distributed key generation")
ErrCanNotContinue standard error if we must drop out of ETHDKG
Functions ¶
func AbortETHDKG ¶
func AbortETHDKG(ethdkg *EthDKGState)
AbortETHDKG does the required cleanup to stop a round of ETHDKG
func ETHDKGInProgress ¶
func ETHDKGInProgress(ethdkg *EthDKGState, currentBlock uint64) bool
ETHDKGInProgress indicates if ETHDKG is currently running
func RetrieveParticipants ¶
func RetrieveParticipants(eth blockchain.Ethereum, callOpts *bind.CallOpts) (dkg.ParticipantList, int, error)
RetrieveParticipants retrieves participant details from ETHDKG contract
Types ¶
type Bus ¶
type Bus interface { StartLoop() (chan<- bool, error) StopLoop() error Register(serviceName string, capacity uint16) (<-chan rbus.Request, error) Request(serviceName string, timeOut time.Duration, request interface{}) (rbus.Response, error) }
Bus basic functionality required for monitor system
type Database ¶
Database describes required functionality for monitor persistence
func NewDatabase ¶
NewDatabase initializes a new monitor database
func NewDatabaseFromExisting ¶
func NewDatabaseFromExisting(db *badger.DB) Database
type EthDKGPhase ¶
type EthDKGPhase int
EthDKGPhase is used to indicate what phase we are currently in
const ( Registration EthDKGPhase = iota Dispute MPKSubmission GPKJSubmission GPKJGroupAccusation )
These are the valid phases of ETHDKG
type EthDKGSchedule ¶
type EthDKGSchedule struct { RegistrationStart uint64 RegistrationEnd uint64 DisputeStart uint64 DisputeEnd uint64 MPKSubmissionStart uint64 MPKSubmissionEnd uint64 GPKJSubmissionStart uint64 GPKJSubmissionEnd uint64 GPKJGroupAccusationStart uint64 GPKJGroupAccusationEnd uint64 CompleteStart uint64 CompleteEnd uint64 }
EthDKGSchedule RegistrationOpen event publishes phase schedule, so we record that here
type EthDKGState ¶
type EthDKGState struct { // Local validator info Address common.Address Index int GroupPrivateKey *big.Int GroupPublicKey [4]*big.Int MasterPublicKey [4]*big.Int NumberOfValidators int PrivateCoefficients []*big.Int Schedule *EthDKGSchedule SecretValue *big.Int ValidatorThreshold int TransportPrivateKey *big.Int TransportPublicKey [2]*big.Int // Remote validator info Commitments map[common.Address][][2]*big.Int // ShareDistribution Event Participants dkg.ParticipantList // Index, Address & PublicKey // Handlers RegistrationTH tasks.TaskHandler DisputeTH tasks.TaskHandler MPKSubmissionTH tasks.TaskHandler GPKJSubmissionTH tasks.TaskHandler GPKJGroupAccusationTH tasks.TaskHandler CompleteTH tasks.TaskHandler }
EthDKGState is used to track the state of the ETHDKG
func NewEthDKGState ¶
func NewEthDKGState() *EthDKGState
NewEthDKGState creates a new EthDKGState with maps initialized
type Services ¶
type Services struct {
// contains filtered or unexported fields
}
Services just a bundle of requirements common for monitoring functionality
func NewServices ¶
func NewServices(eth blockchain.Ethereum, db *db.Database, dph *deposit.Handler, ah *admin.Handlers, batchSize int, chainID uint32) *Services
NewServices creates a new Services struct
func (*Services) DoDistributeShares ¶
DoDistributeShares this should happen when it's time to distribute shares
func (*Services) DoGroupAccusationGPKj ¶
DoGroupAccusationGPKj does something
func (*Services) DoSubmitDispute ¶
DoSubmitDispute submits a dispute if any of the shares we've seen are bad
func (*Services) DoSubmitGPKj ¶
DoSubmitGPKj does something
func (*Services) DoSubmitKeyShare ¶
DoSubmitKeyShare does something
func (*Services) DoSubmitMasterPublicKey ¶
DoSubmitMasterPublicKey does something
func (*Services) DoSuccessfulCompletion ¶
DoSuccessfulCompletion does something
func (*Services) EndpointInSync ¶
EndpointInSync Checks if our endpoint is good to use -- This function is different. Because we need to be aware of errors, state is always updated
func (*Services) PersistSnapshot ¶
func (svcs *Services) PersistSnapshot(blockHeader *objs.BlockHeader) error
PersistSnapshot records the given block header on Ethereum and increments epoch TODO Returning an error kills the main loop, retry forever instead
func (*Services) ProcessDepositReceived ¶
ProcessDepositReceived handles logic around receiving a deposit event
func (*Services) ProcessKeyShareSubmission ¶
ProcessKeyShareSubmission ETHDKG
func (*Services) ProcessRegistrationOpen ¶
ProcessRegistrationOpen when we see ETHDKG has initialized we need to start
func (*Services) ProcessShareDistribution ¶
ProcessShareDistribution accumulates everyones shares ETHDKG
func (*Services) ProcessSnapshotTaken ¶
ProcessSnapshotTaken handles receiving snapshots
func (*Services) ProcessValidatorMember ¶
ProcessValidatorMember handles receiving keys for a specific validator
func (*Services) ProcessValidatorSet ¶
ProcessValidatorSet handles receiving validatorSet changes
func (*Services) RegisterEvent ¶
func (svcs *Services) RegisterEvent(selector string, name string, fn func(*State, types.Log) error) error
RegisterEvent registers a handler for when an interesting event shows up
func (*Services) SetBN256PrivateKey ¶
SetBN256PrivateKey informs the admin bus of the BN256 private key
func (*Services) SetSECP256K1PrivateKey ¶
SetSECP256K1PrivateKey informs the admin bus of the SECP256K1 private key
func (*Services) UpdateProgress ¶
UpdateProgress updates what we know of Ethereum chain height
func (*Services) WatchEthereum ¶
WatchEthereum checks for state of Ethereum and processes interesting conditions
type State ¶
type State struct { // TODO decide if a mutex is required Version uint8 CommunicationFailures uint32 EthereumInSync bool HighestBlockProcessed uint64 HighestBlockFinalized uint64 HighestEpochProcessed uint32 HighestEpochSeen uint32 InSync bool LatestDepositProcessed uint32 LatestDepositSeen uint32 PeerCount uint32 ValidatorSets map[uint32]ValidatorSet Validators map[uint32][]Validator // contains filtered or unexported fields }
State contains info required to monitor Ethereum