Make Prysm VC compatible with the version v5.3.0 of the slashing protections interchange tests. (#13232)

* `TestStore_GenesisValidatorsRoot_ReadAndWrite`: Make all test cases independents.

In a test with multiple test cases, each test case should be independents.
(aka: Removing test case `A` should not impact test case `B`)

* `SaveGenesisValidatorsRoot`: Allow to overwrite the genesis validator root if the root is the same.

* `ProposalHistoryForSlot`: Add `signingRootExists`

Currently, it is not possible with `ProposalHistoryForSlot` to know if a
proposal is stored with and `0x00000....` signing root or with an empty
signing root. Both cases result to `proposalExists == true` and
`signingRoot == 0x00000`.

This commit adds a new return boolean: `signingRootExists`.

If a proposal has been saved with a `0x00000...` signing root, then:
- `proposalExists` is set to `true`, and
- `signingRootExists` is set to `true`, and
- `signingRoot` is set to `0x00000...`

If a proposal has been saved with an empty signing root, then:
- `proposalExists` is set to `true`, and
- `signingRootExists` is set to `false`, and
- (`signingRoot` is set to `0x00000...`)

* `ImportStandardProtectionJSON`: When importing EIP-3076 Slashing Protection Interchange Format, do not filter any more slashable keys.
Note: Those keys are still saved into the black-listed public keys list.

There is two reason not to do so:
- The EIP-3076 test cases do not know about Prysm's internal black-listed public keys list.
  Tests will expect, without looking into this internal black-listed public keys list,
  to deny a further signature. If we filter these keys from the DB (even if we keep them
  into the black-listed keys list), then some tests will fail.
- If we import a interchange file containing slashable keys and we filter them, then,
  if we re-export the DB, those slashing offences won't appear in the exported interchange
  file.

* `transformSignedBlocks`: Store an 0-len byte slice

When importing an EIP-3076 interchange format, and when no
signing root is specified into the file, we currently store a
`0x00000.....` signing root.

In such a case, instead storing `0x00000...`, this commit stores
a 0-len byte array, so we can differentiate real `0x000.....` signing
root and no signing-root at all.

* `slashableProposalCheck`: Manage lack of sign root

Currently, `slashableProposalCheck` does not really make a difference
between a `0x0000.....` signing root and a missing signing root.

(Signing roots can be missing when importing an EIP-3076 interchange
file.)

This commit differentiate, for  `slashableProposalCheck`, `0x0000....`
signing root and a missing signing root.

* `AttestationRecord.SigningRoot`: ==> `[]byte`

When importing attestations from EIP-3076 interchange format,
the signing root of an attestation may be missing.

Currently, Prysm consider any missing attestation signing root as
`0x000...`.
However, it may conflict with signing root which really are equal to
`0x000...`.

This commit transforms `AttestationRecord.SigningRoot` from `[32]byte` to
`[]byte`, and change the minimal set of functions (sic) to support this
new type.

* `CheckSlashableAttestation`: Empty signing root

Regarding slashing roots, 2 attestations are slashable, if:
- both signing roots are defined and differs, or
- one attestation exists, but without a signing root

* `filterSlashablePubKeysFromAttestations`: Err sort

Rergarding `CheckSlashableAttestation`, we consider that:
- If slashable == NotSlashable and err != nil, then CheckSlashableAttestation
failed.
- If slashable != NotSlashable, then err contains the reason why the attestation
is slashable.

* `setupEIP3076SpecTests`: Update to `v5.3.0`

This commit:
- Updates the version of EIP-3076 tests to `v.5.2.1`.
- Setups on anti-slashing DB per test case, instead per step.

* `ImportStandardProtectionJSON`: Reduce cycl cmplxt

* `AttestationHistoryForPubKey`: copy signing root

BoltDB documentation specifies:
| Byte slices returned from Bolt are only valid during a transaction.
| Once the transaction has been committed or rolled back then the memory
| they point to can be reused by a new page or can be unmapped
| from virtual memory and you'll see an unexpected fault address panic
| when accessing it.
This commit is contained in:
Manu NALEPA
2023-12-04 18:10:32 +01:00
committed by GitHub
parent 243bcb03ce
commit 1112e01c06
23 changed files with 319 additions and 156 deletions

View File

@@ -34,7 +34,7 @@ type ValidatorDB interface {
HighestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)
LowestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)
ProposalHistoryForPubKey(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) ([]*kv.Proposal, error)
ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([32]byte, bool, error)
ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([32]byte, bool, bool, error)
SaveProposalHistoryForSlot(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, slot primitives.Slot, signingRoot []byte) error
ProposedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
@@ -43,18 +43,18 @@ type ValidatorDB interface {
// slashing protection imports.
EIPImportBlacklistedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
SaveEIPImportBlacklistedPublicKeys(ctx context.Context, publicKeys [][fieldparams.BLSPubkeyLength]byte) error
SigningRootAtTargetEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, target primitives.Epoch) ([32]byte, error)
SigningRootAtTargetEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, target primitives.Epoch) ([]byte, error)
LowestSignedTargetEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)
LowestSignedSourceEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)
AttestedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
CheckSlashableAttestation(
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation,
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot []byte, att *ethpb.IndexedAttestation,
) (kv.SlashingKind, error)
SaveAttestationForPubKey(
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation,
) error
SaveAttestationsForPubKey(
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoots [][32]byte, atts []*ethpb.IndexedAttestation,
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoots [][]byte, atts []*ethpb.IndexedAttestation,
) error
AttestationHistoryForPubKey(
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte,

View File

@@ -33,7 +33,7 @@ type AttestationRecord struct {
PubKey [fieldparams.BLSPubkeyLength]byte
Source primitives.Epoch
Target primitives.Epoch
SigningRoot [32]byte
SigningRoot []byte
}
// NewQueuedAttestationRecords constructor allocates the underlying slice and
@@ -127,8 +127,9 @@ func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [fieldpa
Target: targetEpoch,
}
signingRoot := signingRootsBucket.Get(bytesutil.EpochToBytesBigEndian(targetEpoch))
if signingRoot != nil {
copy(record.SigningRoot[:], signingRoot)
if len(signingRoot) != 0 {
record.SigningRoot = make([]byte, fieldparams.RootLength)
copy(record.SigningRoot, signingRoot)
}
records = append(records, record)
}
@@ -141,7 +142,7 @@ func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [fieldpa
// CheckSlashableAttestation verifies an incoming attestation is
// not a double vote for a validator public key nor a surround vote.
func (s *Store) CheckSlashableAttestation(
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation,
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot []byte, att *ethpb.IndexedAttestation,
) (SlashingKind, error) {
ctx, span := trace.StartSpan(ctx, "Validator.CheckSlashableAttestation")
defer span.End()
@@ -161,13 +162,12 @@ func (s *Store) CheckSlashableAttestation(
if signingRootsBucket != nil {
targetEpochBytes := bytesutil.EpochToBytesBigEndian(att.Data.Target.Epoch)
existingSigningRoot := signingRootsBucket.Get(targetEpochBytes)
if existingSigningRoot != nil {
var existing [32]byte
copy(existing[:], existingSigningRoot)
if slashings.SigningRootsDiffer(existing, signingRoot) {
slashKind = DoubleVote
return fmt.Errorf(doubleVoteMessage, att.Data.Target.Epoch, existingSigningRoot)
}
// If a signing root exists in the database, and if this database signing root is empty => We consider the new attestation as a double vote.
// If a signing root exists in the database, and if this database signing differs from the signing root of the new attestation => We consider the new attestation as a double vote.
if existingSigningRoot != nil && (len(existingSigningRoot) == 0 || slashings.SigningRootsDiffer(existingSigningRoot, signingRoot)) {
slashKind = DoubleVote
return fmt.Errorf(doubleVoteMessage, att.Data.Target.Epoch, existingSigningRoot)
}
}
@@ -281,7 +281,7 @@ func (_ *Store) checkSurroundingVote(
// SaveAttestationsForPubKey stores a batch of attestations all at once.
func (s *Store) SaveAttestationsForPubKey(
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoots [][32]byte, atts []*ethpb.IndexedAttestation,
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoots [][]byte, atts []*ethpb.IndexedAttestation,
) error {
ctx, span := trace.StartSpan(ctx, "Validator.SaveAttestationsForPubKey")
defer span.End()
@@ -317,7 +317,7 @@ func (s *Store) SaveAttestationForPubKey(
PubKey: pubKey,
Source: att.Data.Source.Epoch,
Target: att.Data.Target.Epoch,
SigningRoot: signingRoot,
SigningRoot: signingRoot[:],
},
}
@@ -448,7 +448,7 @@ func (s *Store) saveAttestationRecords(ctx context.Context, atts []*AttestationR
if err != nil {
return errors.Wrap(err, "could not create signing roots bucket")
}
if err := signingRootsBucket.Put(targetEpochBytes, att.SigningRoot[:]); err != nil {
if err := signingRootsBucket.Put(targetEpochBytes, att.SigningRoot); err != nil {
return errors.Wrapf(err, "could not save signing root for epoch %d", att.Target)
}
sourceEpochsBucket, err := pkBucket.CreateBucketIfNotExists(attestationSourceEpochsBucket)
@@ -537,24 +537,48 @@ func (s *Store) AttestedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubke
// SigningRootAtTargetEpoch checks for an existing signing root at a specified
// target epoch for a given validator public key.
func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, target primitives.Epoch) ([32]byte, error) {
func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, target primitives.Epoch) ([]byte, error) {
ctx, span := trace.StartSpan(ctx, "Validator.SigningRootAtTargetEpoch")
defer span.End()
var signingRoot [32]byte
var (
signingRoot32 [32]byte
signingRootExists bool
)
signingRoot := make([]byte, 0, 32)
err := s.view(func(tx *bolt.Tx) error {
bucket := tx.Bucket(pubKeysBucket)
// If no bucket exists for this public key, we return nil.
pkBucket := bucket.Bucket(pubKey[:])
if pkBucket == nil {
return nil
}
// If no attestation bucket exists for this public key, we return nil.
signingRootsBucket := pkBucket.Bucket(attestationSigningRootsBucket)
if signingRootsBucket == nil {
return nil
}
// If no signing root exists for this target epoch, we return nil.
sr := signingRootsBucket.Get(bytesutil.EpochToBytesBigEndian(target))
copy(signingRoot[:], sr)
if len(sr) == 0 {
return nil
}
signingRootExists = true
copy(signingRoot32[:], sr)
return nil
})
if signingRootExists {
signingRoot = signingRoot32[:]
}
return signingRoot, err
}

View File

@@ -100,7 +100,7 @@ func TestStore_CheckSlashableAttestation_DoubleVote(t *testing.T) {
slashingKind, err := validatorDB.CheckSlashableAttestation(
ctx,
pubKeys[0],
tt.incomingSigningRoot,
tt.incomingSigningRoot[:],
tt.incomingAttestation,
)
if tt.want {
@@ -133,7 +133,7 @@ func TestStore_CheckSlashableAttestation_SurroundVote_MultipleTargetsPerSource(t
// our first attestation. Given there can be multiple attested target epochs per
// source epoch, we expect our logic to be able to catch this slashable offense.
evilAtt := createAttestation(firstAtt.Data.Source.Epoch-1, firstAtt.Data.Target.Epoch+1)
slashable, err := validatorDB.CheckSlashableAttestation(ctx, pubKeys[0], [32]byte{2}, evilAtt)
slashable, err := validatorDB.CheckSlashableAttestation(ctx, pubKeys[0], []byte{2}, evilAtt)
require.NotNil(t, err)
assert.Equal(t, SurroundingVote, slashable)
}
@@ -171,31 +171,31 @@ func TestStore_CheckSlashableAttestation_SurroundVote_54kEpochs(t *testing.T) {
tests := []struct {
name string
signingRoot [32]byte
signingRoot []byte
attestation *ethpb.IndexedAttestation
want SlashingKind
}{
{
name: "surround vote at half of the weak subjectivity period",
signingRoot: [32]byte{},
signingRoot: []byte{},
attestation: createAttestation(numEpochs/2, numEpochs),
want: SurroundingVote,
},
{
name: "spanning genesis to weak subjectivity period surround vote",
signingRoot: [32]byte{},
signingRoot: []byte{},
attestation: createAttestation(0, numEpochs),
want: SurroundingVote,
},
{
name: "simple surround vote at end of weak subjectivity period",
signingRoot: [32]byte{},
signingRoot: []byte{},
attestation: createAttestation(numEpochs-3, numEpochs),
want: SurroundingVote,
},
{
name: "non-slashable vote",
signingRoot: [32]byte{},
signingRoot: []byte{},
attestation: createAttestation(numEpochs, numEpochs+1),
want: NotSlashable,
},
@@ -335,11 +335,11 @@ func TestStore_SaveAttestationsForPubKey(t *testing.T) {
pubKeys := make([][fieldparams.BLSPubkeyLength]byte, numValidators)
validatorDB := setupDB(t, pubKeys)
atts := make([]*ethpb.IndexedAttestation, 0)
signingRoots := make([][32]byte, 0)
signingRoots := make([][]byte, 0)
for i := primitives.Epoch(1); i < 10; i++ {
atts = append(atts, createAttestation(i-1, i))
var sr [32]byte
copy(sr[:], fmt.Sprintf("%d", i))
var sr []byte
copy(sr, fmt.Sprintf("%d", i))
signingRoots = append(signingRoots, sr)
}
err := validatorDB.SaveAttestationsForPubKey(
@@ -361,7 +361,7 @@ func TestStore_SaveAttestationsForPubKey(t *testing.T) {
slashingKind, err := validatorDB.CheckSlashableAttestation(
ctx,
pubKeys[0],
[32]byte{},
[]byte{},
att,
)
require.NotNil(t, err)
@@ -544,7 +544,7 @@ func benchCheckSurroundVote(
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, pubKey := range pubKeys {
slashingKind, err := validatorDB.CheckSlashableAttestation(ctx, pubKey, [32]byte{}, surroundingVote)
slashingKind, err := validatorDB.CheckSlashableAttestation(ctx, pubKey, []byte{}, surroundingVote)
if shouldSurround {
require.NotNil(b, err)
assert.Equal(b, SurroundingVote, slashingKind)

View File

@@ -88,13 +88,15 @@ func TestStore_NestedBackup(t *testing.T) {
require.NoError(t, err)
require.DeepEqual(t, root[:], genesisRoot)
signingRoot32 := [32]byte{'C'}
hist, err := backedDB.AttestationHistoryForPubKey(context.Background(), keys[0])
require.NoError(t, err)
require.DeepEqual(t, &AttestationRecord{
PubKey: keys[0],
Source: 10,
Target: 0,
SigningRoot: [32]byte{'C'},
SigningRoot: signingRoot32[:],
}, hist[0])
hist, err = backedDB.AttestationHistoryForPubKey(context.Background(), keys[1])
@@ -103,7 +105,7 @@ func TestStore_NestedBackup(t *testing.T) {
PubKey: keys[1],
Source: 10,
Target: 0,
SigningRoot: [32]byte{'C'},
SigningRoot: signingRoot32[:],
}, hist[0])
ep, exists, err := backedDB.LowestSignedSourceEpoch(context.Background(), keys[0])

View File

@@ -1,6 +1,7 @@
package kv
import (
"bytes"
"context"
"fmt"
@@ -12,7 +13,7 @@ func (s *Store) SaveGenesisValidatorsRoot(_ context.Context, genValRoot []byte)
err := s.db.Update(func(tx *bolt.Tx) error {
bkt := tx.Bucket(genesisInfoBucket)
enc := bkt.Get(genesisValidatorsRootKey)
if len(enc) != 0 {
if len(enc) != 0 && !bytes.Equal(enc, genValRoot) {
return fmt.Errorf("cannot overwrite existing genesis validators root: %#x", enc)
}
return bkt.Put(genesisValidatorsRootKey, genValRoot)

View File

@@ -11,34 +11,62 @@ import (
func TestStore_GenesisValidatorsRoot_ReadAndWrite(t *testing.T) {
ctx := context.Background()
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
tests := []struct {
name string
init []byte
want []byte
write []byte
wantErr bool
}{
{
name: "empty then write",
want: nil,
write: params.BeaconConfig().ZeroHash[:],
name: "empty then write",
init: nil,
want: params.BeaconConfig().ZeroHash[:],
write: params.BeaconConfig().ZeroHash[:],
wantErr: false,
},
{
name: "zero then overwrite rejected",
name: "zero then overwrite with the same value",
init: params.BeaconConfig().ZeroHash[:],
want: params.BeaconConfig().ZeroHash[:],
write: params.BeaconConfig().ZeroHash[:],
wantErr: false,
},
{
name: "zero then overwrite with a different value",
init: params.BeaconConfig().ZeroHash[:],
want: params.BeaconConfig().ZeroHash[:],
write: []byte{5},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Initialize the database with the initial value.
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
err := db.SaveGenesisValidatorsRoot(ctx, tt.init)
require.NoError(t, err)
// Read the value from the database (just to ensure our setup is OK).
got, err := db.GenesisValidatorsRoot(ctx)
require.NoError(t, err)
require.DeepEqual(t, tt.want, got)
require.DeepEqual(t, tt.init, got)
// Write the value to the database.
err = db.SaveGenesisValidatorsRoot(ctx, tt.write)
if (err != nil) != tt.wantErr {
t.Errorf("GenesisValidatorsRoot() error = %v, wantErr %v", err, tt.wantErr)
}
// Read the value from the database.
got, err = db.GenesisValidatorsRoot(ctx)
require.NoError(t, err)
require.DeepEqual(t, tt.want, got)
// Close the database.
require.NoError(t, db.Close())
})
}
}

View File

@@ -44,30 +44,42 @@ func (s *Store) ProposedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubke
}
// ProposalHistoryForSlot accepts a validator public key and returns the corresponding signing root as well
// as a boolean that tells us if we have a proposal history stored at the slot. It is possible we have proposed
// a slot but stored a nil signing root, so the boolean helps give full information.
func (s *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([32]byte, bool, error) {
// as a boolean that tells us if we have a proposal history stored at the slot and a boolean that tells us if we have
// a signed root at the slot.
func (s *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([32]byte, bool, bool, error) {
ctx, span := trace.StartSpan(ctx, "Validator.ProposalHistoryForSlot")
defer span.End()
var err error
var proposalExists bool
var signingRoot [32]byte
var (
err error
proposalExists, signingRootExists bool
signingRoot [32]byte
)
err = s.view(func(tx *bolt.Tx) error {
bucket := tx.Bucket(historicProposalsBucket)
valBucket := bucket.Bucket(publicKey[:])
if valBucket == nil {
return nil
}
signingRootBytes := valBucket.Get(bytesutil.SlotToBytesBigEndian(slot))
if signingRootBytes == nil {
return nil
}
// If we are at this point, we are sure we have a proposal history for the slot.
proposalExists = true
if len(signingRootBytes) == 0 {
return nil
}
// If we are at this point, we are sure we have a signing root for the slot.
signingRootExists = true
copy(signingRoot[:], signingRootBytes)
return nil
})
return signingRoot, proposalExists, err
return signingRoot, proposalExists, signingRootExists, err
}
// ProposalHistoryForPubKey returns the entire proposal history for a given public key.

View File

@@ -12,25 +12,41 @@ import (
"github.com/prysmaticlabs/prysm/v4/testing/require"
)
func TestNewProposalHistoryForSlot_ReturnsNilIfNoHistory(t *testing.T) {
valPubkey := [fieldparams.BLSPubkeyLength]byte{1, 2, 3}
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), valPubkey, 0)
require.NoError(t, err)
assert.Equal(t, false, proposalExists)
assert.Equal(t, false, signingRootExists)
}
func TestProposalHistoryForSlot_InitializesNewPubKeys(t *testing.T) {
pubkeys := [][fieldparams.BLSPubkeyLength]byte{{30}, {25}, {20}}
db := setupDB(t, pubkeys)
for _, pub := range pubkeys {
signingRoot, _, err := db.ProposalHistoryForSlot(context.Background(), pub, 0)
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), pub, 0)
require.NoError(t, err)
expected := bytesutil.PadTo([]byte{}, 32)
require.DeepEqual(t, expected, signingRoot[:], "Expected proposal history slot signing root to be empty")
assert.Equal(t, false, proposalExists)
assert.Equal(t, false, signingRootExists)
}
}
func TestNewProposalHistoryForSlot_ReturnsNilIfNoHistory(t *testing.T) {
valPubkey := [fieldparams.BLSPubkeyLength]byte{1, 2, 3}
func TestNewProposalHistoryForSlot_SigningRootNil(t *testing.T) {
pubkey := [fieldparams.BLSPubkeyLength]byte{1, 2, 3}
slot := primitives.Slot(2)
db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{})
_, proposalExists, err := db.ProposalHistoryForSlot(context.Background(), valPubkey, 0)
err := db.SaveProposalHistoryForSlot(context.Background(), pubkey, slot, nil)
require.NoError(t, err, "Saving proposal history failed: %v")
_, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), pubkey, slot)
require.NoError(t, err)
assert.Equal(t, false, proposalExists)
assert.Equal(t, true, proposalExists)
assert.Equal(t, false, signingRootExists)
}
func TestSaveProposalHistoryForSlot_OK(t *testing.T) {
@@ -41,8 +57,10 @@ func TestSaveProposalHistoryForSlot_OK(t *testing.T) {
err := db.SaveProposalHistoryForSlot(context.Background(), pubkey, slot, []byte{1})
require.NoError(t, err, "Saving proposal history failed: %v")
signingRoot, _, err := db.ProposalHistoryForSlot(context.Background(), pubkey, slot)
signingRoot, proposalExists, signingRootExists, err := db.ProposalHistoryForSlot(context.Background(), pubkey, slot)
require.NoError(t, err, "Failed to get proposal history")
assert.Equal(t, true, proposalExists)
assert.Equal(t, true, signingRootExists)
require.NotNil(t, signingRoot)
require.DeepEqual(t, bytesutil.PadTo([]byte{1}, 32), signingRoot[:], "Expected DB to keep object the same")