feat: add header and comet info service (#15850)

Co-authored-by: Aaron Craelius <aaron@regen.network>
This commit is contained in:
Marko
2023-05-03 13:32:25 +00:00
committed by GitHub
co-authored by Aaron Craelius
parent 1d03f419f7
commit 1705615ef0
27 changed files with 659 additions and 107 deletions
+38 -8
View File
@@ -312,16 +312,46 @@ block headers, the runtime module for a specific version of Comet could provide
type ValidatorUpdateService interface {
SetValidatorUpdates(context.Context, []abci.ValidatorUpdate)
}
```
type BlockInfoService interface {
GetHeight() int64 // GetHeight returns the height of the block
Misbehavior() []abci.Misbehavior // Misbehavior returns the misbehavior of the block
GetHeaderHash() []byte // GetHeaderHash returns the hash of the block header
// GetValidatorsHash returns the hash of the validators
Header Service defines a way to get header information about a block. This information is generalized for all implementations:
```go
type Service interface {
GetHeaderInfo(context.Context) Info
}
type Info struct {
Height int64 // Height returns the height of the block
Hash []byte // Hash returns the hash of the block header
Time time.Time // Time returns the time of the block
ChainID string // ChainId returns the chain ID of the block
}
```
Comet Service provides a way to get comet specific information:
```go
type Service interface {
GetCometInfo(context.Context) Info
}
type CometInfo struct {
Evidence []abci.Misbehavior // Misbehavior returns the misbehavior of the block
// ValidatorsHash returns the hash of the validators
// For Comet, it is the hash of the next validators
GetValidatorsHash() []byte
GetProposerAddress() []byte // GetProposerAddress returns the address of the block proposer
GetDecidedLastCommit() abci.CommitInfo // GetDecidedLastCommit returns the last commit info
ValidatorsHash []byte
ProposerAddress []byte // ProposerAddress returns the address of the block proposer
DecidedLastCommit abci.CommitInfo // DecidedLastCommit returns the last commit info
}
```
If a user would like to provide a module other information they would need to implement another service like:
```go
type RollKit Interface {
...
}
```