2020-02-13 16:19:46 +00:00
|
|
|
package kv
|
2019-09-02 15:36:29 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
2020-02-13 16:19:46 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/slasher/db/types"
|
2019-09-02 15:36:29 +00:00
|
|
|
)
|
|
|
|
|
2020-02-19 22:26:14 +00:00
|
|
|
const (
|
|
|
|
latestEpochKey = "LATEST_EPOCH_DETECTED"
|
|
|
|
chainHeadKey = "CHAIN_HEAD"
|
|
|
|
)
|
2020-01-29 01:44:51 +00:00
|
|
|
|
2019-09-02 15:36:29 +00:00
|
|
|
var (
|
2020-02-19 22:26:14 +00:00
|
|
|
// Slasher-related buckets.
|
2019-10-19 03:35:09 +00:00
|
|
|
historicIndexedAttestationsBucket = []byte("historic-indexed-attestations-bucket")
|
|
|
|
historicBlockHeadersBucket = []byte("historic-block-headers-bucket")
|
2020-01-14 02:13:25 +00:00
|
|
|
slashingBucket = []byte("slashing-bucket")
|
2020-02-19 22:26:14 +00:00
|
|
|
chainDataBucket = []byte("chain-data-bucket")
|
2020-02-10 05:57:20 +00:00
|
|
|
compressedIdxAttsBucket = []byte("compressed-idx-atts-bucket")
|
2019-11-05 13:54:27 +00:00
|
|
|
validatorsPublicKeysBucket = []byte("validators-public-keys-bucket")
|
2019-12-10 19:45:14 +00:00
|
|
|
// In order to quickly detect surround and surrounded attestations we need to store
|
2019-11-06 20:08:20 +00:00
|
|
|
// the min and max span for each validator for each epoch.
|
|
|
|
// see https://github.com/protolambda/eth2-surround/blob/master/README.md#min-max-surround
|
|
|
|
validatorsMinMaxSpanBucket = []byte("validators-min-max-span-bucket")
|
2019-09-02 15:36:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func encodeEpochValidatorID(epoch uint64, validatorID uint64) []byte {
|
|
|
|
return append(bytesutil.Bytes8(epoch), bytesutil.Bytes8(validatorID)...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func encodeEpochValidatorIDSig(epoch uint64, validatorID uint64, sig []byte) []byte {
|
|
|
|
return append(append(bytesutil.Bytes8(epoch), bytesutil.Bytes8(validatorID)...), sig...)
|
|
|
|
}
|
2019-10-19 03:35:09 +00:00
|
|
|
|
2019-11-15 16:48:45 +00:00
|
|
|
func encodeEpochSig(targetEpoch uint64, sig []byte) []byte {
|
|
|
|
return append(bytesutil.Bytes8(targetEpoch), sig...)
|
2019-10-19 03:35:09 +00:00
|
|
|
}
|
2020-02-13 16:19:46 +00:00
|
|
|
func encodeType(st types.SlashingType) []byte {
|
2020-01-14 02:13:25 +00:00
|
|
|
return []byte{byte(st)}
|
|
|
|
}
|
2020-02-13 16:19:46 +00:00
|
|
|
func encodeTypeRoot(st types.SlashingType, root [32]byte) []byte {
|
2020-01-14 02:13:25 +00:00
|
|
|
return append([]byte{byte(st)}, root[:]...)
|
|
|
|
}
|