mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
Fix slice out of bounds error in validator db migration (#8510)
* Fix slice out of bounds error in validator db migration #8509 * Add regression testing * make it double just in case * gofmt
This commit is contained in:
parent
eca8d85446
commit
6e831920bf
@ -132,7 +132,7 @@ func batchPublicKeys(publicKeys [][]byte, batchSize int) [][][]byte {
|
||||
}
|
||||
batch := make([][][]byte, 0)
|
||||
for i := 0; i < len(publicKeys); i += batchSize {
|
||||
if i+batchSize == len(publicKeys)+1 {
|
||||
if i+batchSize >= len(publicKeys)+1 {
|
||||
batch = append(batch, publicKeys[i:])
|
||||
} else {
|
||||
batch = append(batch, publicKeys[i:i+batchSize])
|
||||
|
@ -14,7 +14,9 @@ import (
|
||||
|
||||
func TestStore_migrateSourceTargetEpochsBucketUp(t *testing.T) {
|
||||
numEpochs := uint64(100)
|
||||
numKeys := 50
|
||||
// numKeys should be more than batch size for testing.
|
||||
// See: https://github.com/prysmaticlabs/prysm/issues/8509
|
||||
numKeys := 2*publicKeyMigrationBatchSize + 1
|
||||
pubKeys := make([][48]byte, numKeys)
|
||||
for i := 0; i < numKeys; i++ {
|
||||
var pk [48]byte
|
||||
@ -113,7 +115,9 @@ func TestStore_migrateSourceTargetEpochsBucketUp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStore_migrateSourceTargetEpochsBucketDown(t *testing.T) {
|
||||
numKeys := 50
|
||||
// numKeys should be more than batch size for testing.
|
||||
// See: https://github.com/prysmaticlabs/prysm/issues/8509
|
||||
numKeys := 2*publicKeyMigrationBatchSize + 1
|
||||
pubKeys := make([][48]byte, numKeys)
|
||||
for i := 0; i < numKeys; i++ {
|
||||
var pk [48]byte
|
||||
|
Loading…
Reference in New Issue
Block a user