Documentation
¶
Index ¶
- Constants
- func SortValidators(validators []abcitypes.ValidatorUpdate)
- type Accusation
- type Apology
- type BatchConfig
- type BatchState
- type CheckTxState
- type ConfigVoting
- type DKGInstance
- type DecryptionSignature
- type EonStartVoting
- type EpochSecretKeyShare
- type GenesisAppState
- type NonceTracker
- type PolyCommitment
- type PolyEval
- type Powermap
- type SenderReceiverPair
- type ShutterApp
- func (ShutterApp) ApplySnapshotChunk(abcitypes.RequestApplySnapshotChunk) abcitypes.ResponseApplySnapshotChunk
- func (ShutterApp) BeginBlock(_ abcitypes.RequestBeginBlock) abcitypes.ResponseBeginBlock
- func (app *ShutterApp) CheckTx(req abcitypes.RequestCheckTx) abcitypes.ResponseCheckTx
- func (app *ShutterApp) Commit() abcitypes.ResponseCommit
- func (app *ShutterApp) CurrentValidators() Powermap
- func (app *ShutterApp) DeliverTx(req abcitypes.RequestDeliverTx) abcitypes.ResponseDeliverTx
- func (app *ShutterApp) EndBlock(req abcitypes.RequestEndBlock) abcitypes.ResponseEndBlock
- func (app *ShutterApp) Info(_ abcitypes.RequestInfo) abcitypes.ResponseInfo
- func (app *ShutterApp) InitChain(req abcitypes.RequestInitChain) abcitypes.ResponseInitChain
- func (app *ShutterApp) LastConfig() *BatchConfig
- func (ShutterApp) ListSnapshots(abcitypes.RequestListSnapshots) abcitypes.ResponseListSnapshots
- func (ShutterApp) LoadSnapshotChunk(abcitypes.RequestLoadSnapshotChunk) abcitypes.ResponseLoadSnapshotChunk
- func (ShutterApp) OfferSnapshot(abcitypes.RequestOfferSnapshot) abcitypes.ResponseOfferSnapshot
- func (app *ShutterApp) PersistToDisk() error
- func (app *ShutterApp) Query(_ abcitypes.RequestQuery) abcitypes.ResponseQuery
- func (ShutterApp) SetOption(_ abcitypes.RequestSetOption) abcitypes.ResponseSetOption
- func (app *ShutterApp) ShouldStartDKG(config BatchConfig) bool
- func (app *ShutterApp) StartDKG(config BatchConfig) *DKGInstance
- type ValidatorPubkey
- type Voting
Constants ¶
const MaxTxsPerBlock = 10
MaxTxsPerBlock is the maximum number of txs by a single sender per block.
Variables ¶
This section is empty.
Functions ¶
func SortValidators ¶
func SortValidators(validators []abcitypes.ValidatorUpdate)
SortValidators sorts a slice of ValidatorUpdates in a determistic way suitable for updating the validators in tendermint.
Types ¶
type Accusation ¶
type Accusation = shutterevents.Accusation
func ParseAccusationMsg ¶
func ParseAccusationMsg(msg *shmsg.Accusation, sender common.Address) (*Accusation, error)
ParseAccusationMsg converts a shmsg.AccusationMsg to an app.AccusationMsg.
type Apology ¶
type Apology = shutterevents.Apology
type BatchConfig ¶
type BatchConfig = shutterevents.BatchConfig
type BatchState ¶
type BatchState struct { BatchIndex uint64 Config *BatchConfig DecryptionSignatures []DecryptionSignature }
BatchState is used to manage the key generation process for a certain batch.
func (*BatchState) AddDecryptionSignature ¶
func (bs *BatchState) AddDecryptionSignature(ds DecryptionSignature) error
AddDecryptionSignature adds a decryption signature to the batch.
type CheckTxState ¶
type CheckTxState struct { Members map[common.Address]bool TxCounts map[common.Address]int NonceTracker *NonceTracker }
CheckTxState is a part of the state used by CheckTx calls that is reset at every commit.
func NewCheckTxState ¶
func NewCheckTxState() *CheckTxState
NewCheckTxState returns a new check tx state.
func (*CheckTxState) AddTx ¶
func (s *CheckTxState) AddTx(sender common.Address, msg *shmsg.MessageWithNonce) bool
AddTx checks if a tx can be added and updates the internal state accordingly. Returns true if the sender is a member (or the member set is empty) and has not exceeded their tx limit yet.
func (*CheckTxState) Reset ¶
func (s *CheckTxState) Reset()
Reset should be called at every block commit so that all nodes get the same value no matter their view on the network.
func (*CheckTxState) SetMembers ¶
func (s *CheckTxState) SetMembers(members []common.Address)
SetMembers sets the member set allowed to send txs. Duplicate addresses are ignored.
type ConfigVoting ¶
type ConfigVoting struct { Voting Candidates []BatchConfig }
ConfigVoting is used to let the keypers vote on new BatchConfigs to be added Each keyper can vote exactly once.
func NewConfigVoting ¶
func NewConfigVoting() ConfigVoting
NewConfigVoting creates a ConfigVoting struct.
func (*ConfigVoting) AddVote ¶
func (cfgv *ConfigVoting) AddVote(sender common.Address, batchConfig BatchConfig) error
AddVote adds a vote from the given sender for the given batchConfig. It returns an error if the sender tries to vote twice.
func (*ConfigVoting) Outcome ¶
func (cfgv *ConfigVoting) Outcome(numRequiredVotes int) (BatchConfig, bool)
Outcome checks if one of the candidates has more than numRequiredVotes.
type DKGInstance ¶
type DKGInstance struct { Config BatchConfig Eon uint64 PolyEvalsSeen map[SenderReceiverPair]struct{} PolyCommitmentsSeen map[common.Address]struct{} AccusationsSeen map[common.Address]struct{} ApologiesSeen map[common.Address]struct{} }
DKGInstance manages the state of one eon key generation instance.
func NewDKGInstance ¶
func NewDKGInstance(config BatchConfig, eon uint64) DKGInstance
NewDKGInstance creates a new DKGInstance.
func (*DKGInstance) RegisterAccusationMsg ¶
func (dkg *DKGInstance) RegisterAccusationMsg(msg Accusation) error
RegisterAccusationMsg adds an accusation message to the instance.
func (*DKGInstance) RegisterApologyMsg ¶
func (dkg *DKGInstance) RegisterApologyMsg(msg Apology) error
RegisterApologyMsg adds an apology message to the instance.
func (*DKGInstance) RegisterPolyCommitmentMsg ¶
func (dkg *DKGInstance) RegisterPolyCommitmentMsg(msg PolyCommitment) error
RegisterPolyCommitmentMsg adds a polynomial commitment message to the instance.
func (*DKGInstance) RegisterPolyEvalMsg ¶
func (dkg *DKGInstance) RegisterPolyEvalMsg(msg PolyEval) error
RegisterPolyEvalMsg adds a polynomial evaluation message to the instance. It makes sure the message meets the basic requirements, i.e. the sender and receivers are keypers and we do not send multiple messages from one sender to one receiver.
type DecryptionSignature ¶
DecryptionSignature stores the decryption key signature created by one of the keypers.
type EonStartVoting ¶
EonStartVoting is used to vote on the batch index at which the next eon should be started.
func NewEonStartVoting ¶
func NewEonStartVoting() *EonStartVoting
NewEonStartVoting creates a new EonStartVoting struct.
type EpochSecretKeyShare ¶
type EpochSecretKeyShare = shutterevents.EpochSecretKeyShare
func ParseEpochSecretKeyShareMsg ¶
func ParseEpochSecretKeyShareMsg(msg *shmsg.EpochSecretKeyShare, sender common.Address) (*EpochSecretKeyShare, error)
ParseEpochSecretKeyShareMsg converts a shmsg.EpochSecretKeyShareMsg to an app.EpochSecretShareMsg.
type GenesisAppState ¶
type GenesisAppState struct { Keypers []common.MixedcaseAddress `json:"keypers"` Threshold uint64 `json:"threshold"` }
GenesisAppState is used to hold the initial list of keypers, who will bootstrap the system by providing the first real BatchConfig to be used. We use common.MixedcaseAddress to hold the list of keypers as that one serializes as checksum address.
func NewGenesisAppState ¶
func NewGenesisAppState(keypers []common.Address, threshold int) GenesisAppState
func (*GenesisAppState) GetKeypers ¶
func (appState *GenesisAppState) GetKeypers() []common.Address
GetKeypers returns the keypers defined in the GenesisAppState.
type NonceTracker ¶
NonceTracker tracks which nonces have been used and which have not.
func NewNonceTracker ¶
func NewNonceTracker() *NonceTracker
NewNonceTracker creates a new NonceTracker.
type PolyCommitment ¶
type PolyCommitment = shutterevents.PolyCommitment
func ParsePolyCommitmentMsg ¶
func ParsePolyCommitmentMsg(msg *shmsg.PolyCommitment, sender common.Address) (*PolyCommitment, error)
ParsePolyCommitmentMsg converts a shmsg.PolyCommitmentMsg to an app.PolyCommitmentMsg.
type PolyEval ¶
type PolyEval = shutterevents.PolyEval
type Powermap ¶
type Powermap map[ValidatorPubkey]int64
Powermap maps a ValidatorPubkey to the validators voting power.
func DiffPowermaps ¶
DiffPowermaps computes the diff to be applied by tendermint to change the old validators into the new validators.
func MakePowermap ¶
func MakePowermap(validators []abcitypes.ValidatorUpdate) (Powermap, error)
MakePowermap creates a new Powermap with voting powers as specified in validators.
func (Powermap) ValidatorUpdates ¶
func (pm Powermap) ValidatorUpdates() []abcitypes.ValidatorUpdate
ValidatorUpdates computes a deterministic slice of ValidatorUpdate structs.
type SenderReceiverPair ¶
type ShutterApp ¶
type ShutterApp struct { Configs []*BatchConfig BatchStates map[uint64]BatchState DKGMap map[uint64]*DKGInstance ConfigVoting ConfigVoting EonStartVotings map[uint64]*EonStartVoting Gobpath string LastSaved time.Time LastBlockHeight int64 Identities map[common.Address]ValidatorPubkey StartedVotes map[common.Address]struct{} Validators Powermap EONCounter uint64 DevMode bool CheckTxState *CheckTxState NonceTracker *NonceTracker ChainID string }
ShutterApp holds our data structures used for the tendermint app.
func LoadShutterAppFromFile ¶
func LoadShutterAppFromFile(gobpath string) (ShutterApp, error)
LoadShutterAppFromFile loads a shutter app from a file.
func (ShutterApp) ApplySnapshotChunk ¶
func (ShutterApp) ApplySnapshotChunk(abcitypes.RequestApplySnapshotChunk) abcitypes.ResponseApplySnapshotChunk
func (ShutterApp) BeginBlock ¶
func (ShutterApp) BeginBlock(_ abcitypes.RequestBeginBlock) abcitypes.ResponseBeginBlock
func (*ShutterApp) CheckTx ¶
func (app *ShutterApp) CheckTx(req abcitypes.RequestCheckTx) abcitypes.ResponseCheckTx
CheckTx checks if a transaction is valid. If return Code != 0, it will be rejected from the mempool and hence not broadcasted to other peers and not included in a proposal block.
func (*ShutterApp) Commit ¶
func (app *ShutterApp) Commit() abcitypes.ResponseCommit
func (*ShutterApp) CurrentValidators ¶
func (app *ShutterApp) CurrentValidators() Powermap
CurrentValidators returns a powermap of current validators.
func (*ShutterApp) DeliverTx ¶
func (app *ShutterApp) DeliverTx(req abcitypes.RequestDeliverTx) abcitypes.ResponseDeliverTx
func (*ShutterApp) EndBlock ¶
func (app *ShutterApp) EndBlock(req abcitypes.RequestEndBlock) abcitypes.ResponseEndBlock
func (*ShutterApp) Info ¶
func (app *ShutterApp) Info(_ abcitypes.RequestInfo) abcitypes.ResponseInfo
Info should return the latest committed state of the app. On startup, tendermint calls the Info method and will replay blocks that are not yet committed. See https://github.com/tendermint/spec/blob/master/spec/abci/apps.md#crash-recovery
func (*ShutterApp) InitChain ¶
func (app *ShutterApp) InitChain(req abcitypes.RequestInitChain) abcitypes.ResponseInitChain
BlockExecution
The first time a new blockchain is started, Tendermint calls InitChain. From then on, the following sequence of methods is executed for each block:
BeginBlock, [DeliverTx], EndBlock, Commit
where one DeliverTx is called for each transaction in the block. The result is an updated application state. Cryptographic commitments to the results of DeliverTx, EndBlock, and Commit are included in the header of the next block.
func (*ShutterApp) LastConfig ¶
func (app *ShutterApp) LastConfig() *BatchConfig
LastConfig returns the config with the highest known index.
func (ShutterApp) ListSnapshots ¶
func (ShutterApp) ListSnapshots(abcitypes.RequestListSnapshots) abcitypes.ResponseListSnapshots
func (ShutterApp) LoadSnapshotChunk ¶
func (ShutterApp) LoadSnapshotChunk(abcitypes.RequestLoadSnapshotChunk) abcitypes.ResponseLoadSnapshotChunk
func (ShutterApp) OfferSnapshot ¶
func (ShutterApp) OfferSnapshot(abcitypes.RequestOfferSnapshot) abcitypes.ResponseOfferSnapshot
func (*ShutterApp) PersistToDisk ¶
func (app *ShutterApp) PersistToDisk() error
persistToDisk stores the ShutterApp on disk. This method first writes to a temporary file and renames the file later. Most probably this will not work on windows!
func (*ShutterApp) Query ¶
func (app *ShutterApp) Query(_ abcitypes.RequestQuery) abcitypes.ResponseQuery
func (ShutterApp) SetOption ¶
func (ShutterApp) SetOption(_ abcitypes.RequestSetOption) abcitypes.ResponseSetOption
func (*ShutterApp) ShouldStartDKG ¶
func (app *ShutterApp) ShouldStartDKG(config BatchConfig) bool
ShouldStartDKG checks if the DKG should be started, because the threshold or the list of keypers changed.
func (*ShutterApp) StartDKG ¶
func (app *ShutterApp) StartDKG(config BatchConfig) *DKGInstance
type ValidatorPubkey ¶
type ValidatorPubkey struct {
Ed25519pubkey string
}
ValidatorPubkey holds the raw 32 byte ed25519 public key to be used as tendermint validator key We use this is a map key, so don't use a byte slice.
var ( // PersistMinDuration is the minimum duration between two calls to persistToDisk // TODO we should probably increase the default here and we should have a way to collect // garbage to keep the persisted state small enough. // The variable is declared here, because we do not want to persist it as part of the // application. The same could be said about the Gobpath field though, which we persist as // part of the application. // If we set this to zero, the state will get saved on every call to Commit. PersistMinDuration time.Duration = 30 * time.Second // NonExistentValidator is an artificial key used to replace the voting power of validators // that haven't sent their CheckIn message yet. NonExistentValidator ValidatorPubkey )
func NewValidatorPubkey ¶
func NewValidatorPubkey(pubkey []byte) (ValidatorPubkey, error)
NewValidatorPubkey creates a new ValidatorPubkey from a 32 byte ed25519 raw pubkey. See https://docs.tendermint.com/master/spec/abci/apps.html#validator-updates for more information
func (ValidatorPubkey) String ¶
func (vp ValidatorPubkey) String() string
type Voting ¶
Voting is a struct storing votes for arbitrary indices.
func (*Voting) AddVoteForIndex ¶
AddVoteForIndex adds a vote from the given sender for the given index.