github.com/prysmaticlabs/prysm@v1.4.4/slasher/db/kv/schema.go (about)

     1  package kv
     2  
     3  import (
     4  	types "github.com/prysmaticlabs/eth2-types"
     5  	"github.com/prysmaticlabs/prysm/shared/bytesutil"
     6  	dbtypes "github.com/prysmaticlabs/prysm/slasher/db/types"
     7  )
     8  
     9  const (
    10  	latestEpochKey = "LATEST_EPOCH_DETECTED"
    11  	chainHeadKey   = "CHAIN_HEAD"
    12  )
    13  
    14  var (
    15  	indexedAttestationsRootsByTargetBucket = []byte("indexed-attestations-roots-by-target")
    16  	indexedAttestationsBucket              = []byte("indexed-attestations")
    17  	// Slasher-related buckets.
    18  	historicIndexedAttestationsBucket = []byte("historic-indexed-attestations-bucket")
    19  	historicBlockHeadersBucket        = []byte("historic-block-headers-bucket")
    20  	highestAttestationBucket          = []byte("highest-attestation-bucket")
    21  	slashingBucket                    = []byte("slashing-bucket")
    22  	chainDataBucket                   = []byte("chain-data-bucket")
    23  	compressedIdxAttsBucket           = []byte("compressed-idx-atts-bucket")
    24  	validatorsPublicKeysBucket        = []byte("validators-public-keys-bucket")
    25  	// In order to quickly detect surround and surrounded attestations we need to store
    26  	// the min and max span for each validator for each epoch.
    27  	// see https://github.com/protolambda/eth2-surround/blob/master/README.md#min-max-surround
    28  	validatorsMinMaxSpanBucket    = []byte("validators-min-max-span-bucket")
    29  	validatorsMinMaxSpanBucketNew = []byte("validators-min-max-span-bucket-new")
    30  )
    31  
    32  func encodeSlotValidatorIndex(slot types.Slot, validatorIndex types.ValidatorIndex) []byte {
    33  	return append(bytesutil.Bytes8(uint64(slot)), bytesutil.Bytes8(uint64(validatorIndex))...)
    34  }
    35  
    36  func encodeSlotValidatorIndexSig(slot types.Slot, validatorIndex types.ValidatorIndex, sig []byte) []byte {
    37  	return append(append(bytesutil.Bytes8(uint64(slot)), bytesutil.Bytes8(uint64(validatorIndex))...), sig...)
    38  }
    39  
    40  func encodeEpochSig(targetEpoch types.Epoch, sig []byte) []byte {
    41  	return append(bytesutil.Bytes8(uint64(targetEpoch)), sig...)
    42  }
    43  func encodeType(st dbtypes.SlashingType) []byte {
    44  	return []byte{byte(st)}
    45  }
    46  func encodeTypeRoot(st dbtypes.SlashingType, root [32]byte) []byte {
    47  	return append([]byte{byte(st)}, root[:]...)
    48  }