Documentation
¶
Overview ¶
Package observe contains the MainChain and Shutter structs, which the keyper uses to fetch the necessary information from the ethereum node and the shuttermint node. The SyncToHead methods can be used to fetch the latest information. All other public methods do not modify the stored data. Do not mutate any of the data stored in these structs.
Index ¶
- func SyncMain(ctx context.Context, caller *contract.Caller, mainChain *MainChain, ...) error
- func SyncShutter(ctx context.Context, shmcl client.Client, shutter *Shutter, ...) error
- type Accusation
- type Batch
- type BatchData
- type Deposit
- type EncryptionPublicKey
- type Eon
- func (eon *Eon) ApplyFilter(syncHeight int64) *Eon
- func (eon *Eon) GetAccusations(syncHeight int64) []shutterevents.Accusation
- func (eon *Eon) GetApologies(syncHeight int64) []shutterevents.Apology
- func (eon *Eon) GetEpochSecretKeyShares(syncHeight int64) []shutterevents.EpochSecretKeyShare
- func (eon *Eon) GetPolyCommitments(syncHeight int64) []shutterevents.PolyCommitment
- func (eon *Eon) GetPolyEvals(syncHeight int64) []shutterevents.PolyEval
- type MainChain
- func (mainchain *MainChain) ActiveConfig(blocknum uint64) contract.BatchConfig
- func (mainchain *MainChain) ActiveConfigIndex(blocknum uint64) int
- func (mainchain *MainChain) ActiveConfigs() []contract.BatchConfig
- func (mainchain *MainChain) Clone() *MainChain
- func (mainchain *MainChain) ConfigForBatchIndex(batchIndex uint64) (contract.BatchConfig, bool)
- func (mainchain *MainChain) ConfigIndexForBatchIndex(batchIndex uint64) (int, bool)
- func (mainchain *MainChain) CurrentConfig() contract.BatchConfig
- func (mainchain *MainChain) GetDeposit(account common.Address) *Deposit
- func (mainchain *MainChain) IsActiveKeyper(addr common.Address) bool
- func (mainchain *MainChain) IsSynced() bool
- func (mainchain *MainChain) SyncToHead(ctx context.Context, cc *contract.Caller) (*MainChain, error)
- type Shutter
- func (shutter *Shutter) ApplyFilter(newFilter ShutterFilter) *Shutter
- func (shutter *Shutter) Clone() *Shutter
- func (shutter *Shutter) FindBatchConfigByBatchIndex(batchIndex uint64) shutterevents.BatchConfig
- func (shutter *Shutter) FindBatchConfigByConfigIndex(configIndex uint64) (shutterevents.BatchConfig, error)
- func (shutter *Shutter) FindEon(eon uint64) (*Eon, error)
- func (shutter *Shutter) FindEonByBatchIndex(batchIndex uint64) (*Eon, error)
- func (shutter *Shutter) GetLastCommittedHeight(ctx context.Context, shmcl client.Client) (int64, error)
- func (shutter *Shutter) IsCheckedIn(addr common.Address) bool
- func (shutter *Shutter) IsKeyper(addr common.Address) bool
- func (shutter *Shutter) IsSynced() bool
- func (shutter *Shutter) ShallowClone() *Shutter
- func (shutter *Shutter) SyncToHead(ctx context.Context, shmcl client.Client) (*Shutter, error)
- func (shutter *Shutter) SyncToHeight(ctx context.Context, shmcl client.Client, height int64) (*Shutter, error)
- type ShutterFilter
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SyncMain ¶
func SyncMain( ctx context.Context, caller *contract.Caller, mainChain *MainChain, mainChains chan<- *MainChain, ) error
SyncMain subscribes to new blocks on the main chain and syncs the main chain object with the head block in a loop. It writes newly synced main chain objects to the mainChains channel, as well as errors to the syncErrors channel.
func SyncShutter ¶
func SyncShutter(ctx context.Context, shmcl client.Client, shutter *Shutter, shutters chan<- *Shutter, filter <-chan ShutterFilter) error
SyncShutter subscribes to new blocks and syncs the shutter object with the head block in a loop. It writes newly synced shutter objects to the shutters channel, as well as errors to the syncErrors channel.
Types ¶
type Accusation ¶
type Accusation struct { Executor common.Address Accuser common.Address Appealed bool HalfStep uint64 BlockNumber uint64 }
Accusation represents an accusation against a keyper in the keyper slasher.
type Batch ¶
type Batch struct { BatchIndex uint64 EncryptedBatchHash common.Hash EncryptedTransactions [][]byte PlainTransactions [][]byte PlainBatchHash common.Hash }
Batch stores the encrypted and plain transactions submitted to the batching contract for a particular index.
func (*Batch) DecryptTransactions ¶
func (batch *Batch) DecryptTransactions(key *shcrypto.EpochSecretKey) [][]byte
DecryptTransactions decrypts and shuffles the encrypted transactions. It will log an error message for transactions that cannot be decrypted and skip over them.
type BatchData ¶
type BatchData struct { BatchIndex uint64 DecryptionSignatures []shutterevents.DecryptionSignature }
type Deposit ¶
type Deposit struct { Account common.Address Slashed bool Amount *big.Int WithdrawalDelayBlocks uint64 WithdrawalRequestedBlock uint64 }
Deposit represents a deposit in the deposit contract.
type EncryptionPublicKey ¶
EncryptionPublicKey is a gob serializable version of ecies.PublicKey.
func (*EncryptionPublicKey) GobDecode ¶
func (epk *EncryptionPublicKey) GobDecode(data []byte) error
func (*EncryptionPublicKey) GobEncode ¶
func (epk *EncryptionPublicKey) GobEncode() ([]byte, error)
type Eon ¶
type Eon struct { Eon uint64 StartHeight int64 StartEvent shutterevents.EonStarted Commitments []shutterevents.PolyCommitment PolyEvals []shutterevents.PolyEval Accusations []shutterevents.Accusation Apologies []shutterevents.Apology }
func (*Eon) ApplyFilter ¶
func (*Eon) GetAccusations ¶
func (eon *Eon) GetAccusations(syncHeight int64) []shutterevents.Accusation
func (*Eon) GetApologies ¶
func (eon *Eon) GetApologies(syncHeight int64) []shutterevents.Apology
func (*Eon) GetEpochSecretKeyShares ¶
func (eon *Eon) GetEpochSecretKeyShares(syncHeight int64) []shutterevents.EpochSecretKeyShare
func (*Eon) GetPolyCommitments ¶
func (eon *Eon) GetPolyCommitments(syncHeight int64) []shutterevents.PolyCommitment
func (*Eon) GetPolyEvals ¶
func (eon *Eon) GetPolyEvals(syncHeight int64) []shutterevents.PolyEval
type MainChain ¶
type MainChain struct { FollowDistance uint64 CurrentBlock uint64 NodeSyncProgress *ethereum.SyncProgress BatchConfigs []contract.BatchConfig Batches map[uint64]*Batch NumExecutionHalfSteps uint64 CipherExecutionReceipts map[uint64]*contract.CipherExecutionReceipt Deposits map[common.Address]*Deposit Accusations map[uint64]*Accusation }
MainChain let's a keyper fetch all necessary information from an ethereum node to do it's work. The only source for the data stored in this struct should be the ethereum node. The SyncToHead method can be used to update the data. All other accesses should be read-only.
func NewMainChain ¶
NewMainChain creates an empty MainChain struct.
func (*MainChain) ActiveConfig ¶
func (mainchain *MainChain) ActiveConfig(blocknum uint64) contract.BatchConfig
ActiveConfig returns the config that is active for the given block number.
func (*MainChain) ActiveConfigIndex ¶
ActiveConfigIndex returns the index of the config that is active for the given block number.
func (*MainChain) ActiveConfigs ¶
func (mainchain *MainChain) ActiveConfigs() []contract.BatchConfig
ActiveConfigs returns a slice of the active configs.
func (*MainChain) ConfigForBatchIndex ¶
func (mainchain *MainChain) ConfigForBatchIndex(batchIndex uint64) (contract.BatchConfig, bool)
ConfigForBatchIndex returns the config responsible for the given batch if it is active. Note that this config might change if the batch is too far into the future.
func (*MainChain) ConfigIndexForBatchIndex ¶
ConfigIndexForBatchIndex returns the index of the config responsible for the given batch if it is active. Note that this config might change if the batch is too far into the future.
func (*MainChain) CurrentConfig ¶
func (mainchain *MainChain) CurrentConfig() contract.BatchConfig
CurrentConfig returns the batch config active at the current block number.
func (*MainChain) GetDeposit ¶
GetDeposit returns the deposit of the given account or an empty one if it doesn't exist.
func (*MainChain) IsActiveKeyper ¶
IsActiveKeyper checks if the given address is registered as a keyper in one of the active batch configs.
type Shutter ¶
type Shutter struct { CurrentBlock int64 LastCommittedHeight int64 NodeStatus *rpctypes.ResultStatus KeyperEncryptionKeys map[common.Address]*EncryptionPublicKey BatchConfigs []shutterevents.BatchConfig Batches map[uint64]*BatchData Eons []Eon Filter ShutterFilter }
Shutter let's a keyper fetch all necessary information from a shuttermint node. The only source for the data stored in this struct should be the shutter node. The SyncToHead method can be used to update the data. All other accesses should be read-only.
func (*Shutter) ApplyFilter ¶
func (shutter *Shutter) ApplyFilter(newFilter ShutterFilter) *Shutter
ApplyFilter applies the given filter and returns a new shutter object with the filter applied.
func (*Shutter) FindBatchConfigByBatchIndex ¶
func (shutter *Shutter) FindBatchConfigByBatchIndex(batchIndex uint64) shutterevents.BatchConfig
func (*Shutter) FindBatchConfigByConfigIndex ¶
func (shutter *Shutter) FindBatchConfigByConfigIndex(configIndex uint64) (shutterevents.BatchConfig, error)
func (*Shutter) FindEonByBatchIndex ¶
func (*Shutter) GetLastCommittedHeight ¶
func (*Shutter) IsCheckedIn ¶
IsCheckedIn checks if the given address sent it's check-in message.
func (*Shutter) IsKeyper ¶
IsKeyper checks if the given address is a keyper in any of the given configs.
func (*Shutter) ShallowClone ¶
func (*Shutter) SyncToHead ¶
SyncToHead syncs the state with the remote state. It fetches events from new blocks since the last sync and updates the state by calling applyEvent for each event. This method does not mutate the object in place, it rather returns a new object.
type ShutterFilter ¶
ShutterFilter is used to filter the shutter state we do build. Filtering is done in Shutter.ApplyFilter.
func (ShutterFilter) NeedsUpdate ¶
func (filter ShutterFilter) NeedsUpdate(newFilter ShutterFilter) bool