mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 03:01:19 +00:00
14b3181e67
* more spanner additions * implement iface * begin implement * wrapped up spanner functions * rem interface * added in necessary comments * comments on enums * begin adding tests * plug in surround vote detection * saved indexed db implementation * finally plugin slashing for historical data * Small fixes * add in all gazelle * save incoming new functions * resolve todo * fix broken test channel item * tests passing when fixing certain arguments and setups * Add comment and change unimplemented * find surround * added in gazelle * gazz * feedback from shay * fixed up naming * Update * Add tests for detectSurroundVotes * Remove logs * Fix slasher test * formatting * Remove unneeded condition * Test indices better * fixing broken build * pass tests * skip tests * imports * Update slasher/detection/attestations/attestations_test.go * Update slasher/beaconclient/historical_data_retrieval_test.go * Address comments * Rename function * Add comment for future optimization * Fix comment Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>
46 lines
1.7 KiB
Go
46 lines
1.7 KiB
Go
package kv
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/slasher/db/types"
|
|
)
|
|
|
|
const (
|
|
latestEpochKey = "LATEST_EPOCH_DETECTED"
|
|
chainHeadKey = "CHAIN_HEAD"
|
|
)
|
|
|
|
var (
|
|
indexedAttestationsRootsByTargetBucket = []byte("indexed-attestations-roots-by-target")
|
|
indexedAttestationsBucket = []byte("indexed-attestations")
|
|
// Slasher-related buckets.
|
|
historicIndexedAttestationsBucket = []byte("historic-indexed-attestations-bucket")
|
|
historicBlockHeadersBucket = []byte("historic-block-headers-bucket")
|
|
slashingBucket = []byte("slashing-bucket")
|
|
chainDataBucket = []byte("chain-data-bucket")
|
|
compressedIdxAttsBucket = []byte("compressed-idx-atts-bucket")
|
|
validatorsPublicKeysBucket = []byte("validators-public-keys-bucket")
|
|
// In order to quickly detect surround and surrounded attestations we need to store
|
|
// 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")
|
|
)
|
|
|
|
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...)
|
|
}
|
|
|
|
func encodeEpochSig(targetEpoch uint64, sig []byte) []byte {
|
|
return append(bytesutil.Bytes8(targetEpoch), sig...)
|
|
}
|
|
func encodeType(st types.SlashingType) []byte {
|
|
return []byte{byte(st)}
|
|
}
|
|
func encodeTypeRoot(st types.SlashingType, root [32]byte) []byte {
|
|
return append([]byte{byte(st)}, root[:]...)
|
|
}
|