mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-11 00:18:06 -05:00
Address spec adherence feedbacks (#6365)
* Addressed 1 * Address 2. * Addressed 3. and 4. * Addressed 6. * Addressed 7 * Addressed 8 * Addressed 9. * Addressed 10. * Addressed 11. * Addressed 12. * Addressed 13. * Delete old test * Merge refs/heads/master into spec-feedbacks * Change comment "pure" to "stateless" * Fmt * Typo * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks * Merge refs/heads/master into spec-feedbacks
This commit is contained in:
@@ -20,7 +20,8 @@ import (
|
||||
var ErrTargetRootNotInDB = errors.New("target root does not exist in db")
|
||||
|
||||
// onAttestation is called whenever an attestation is received, verifies the attestation is valid and saves
|
||||
/// it to the DB.
|
||||
// it to the DB. As a stateless function, this does not hold nor delay attestation based on the spec descriptions.
|
||||
// The delay is handled by the caller in `processAttestation`.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
// def on_attestation(store: Service, attestation: Attestation) -> None:
|
||||
|
||||
@@ -3,7 +3,6 @@ package blockchain
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -113,40 +112,7 @@ func (s *Service) verifyAttestation(ctx context.Context, baseState *stateTrie.Be
|
||||
}
|
||||
indexedAtt := attestationutil.ConvertToIndexed(ctx, a, committee)
|
||||
if err := blocks.VerifyIndexedAttestation(ctx, baseState, indexedAtt); err != nil {
|
||||
if err == helpers.ErrSigFailedToVerify {
|
||||
// When sig fails to verify, check if there's a differences in committees due to
|
||||
// different seeds.
|
||||
if !s.stateGen.HasState(ctx, bytesutil.ToBytes32(a.Data.BeaconBlockRoot)) {
|
||||
if err := s.beaconDB.SaveBlocks(ctx, s.getInitSyncBlocks()); err != nil {
|
||||
return nil, errors.Wrap(err, "could not save initial sync blocks")
|
||||
}
|
||||
s.clearInitSyncBlocks()
|
||||
}
|
||||
aState, err := s.stateGen.StateByRoot(ctx, bytesutil.ToBytes32(a.Data.BeaconBlockRoot))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if aState == nil {
|
||||
return nil, fmt.Errorf("nil state for block root %#x", a.Data.BeaconBlockRoot)
|
||||
}
|
||||
epoch := helpers.SlotToEpoch(a.Data.Slot)
|
||||
origSeed, err := helpers.Seed(baseState, epoch, params.BeaconConfig().DomainBeaconAttester)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get original seed")
|
||||
}
|
||||
|
||||
aSeed, err := helpers.Seed(aState, epoch, params.BeaconConfig().DomainBeaconAttester)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get attester's seed")
|
||||
}
|
||||
if origSeed != aSeed {
|
||||
return nil, fmt.Errorf("could not verify indexed attestation due to differences in seeds: %v != %v",
|
||||
hex.EncodeToString(bytesutil.Trunc(origSeed[:])), hex.EncodeToString(bytesutil.Trunc(aSeed[:])))
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrap(err, "could not verify indexed attestation")
|
||||
}
|
||||
|
||||
return indexedAtt, nil
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (s *Service) getBlockPreState(ctx context.Context, b *ethpb.BeaconBlock) (*
|
||||
return nil, errors.Wrapf(err, "nil pre state for slot %d", b.Slot)
|
||||
}
|
||||
|
||||
// Verify block slot time is not from the feature.
|
||||
// Verify block slot time is not from the future.
|
||||
if err := helpers.VerifySlotTime(preState.GenesisTime(), b.Slot, params.BeaconNetworkConfig().MaximumGossipClockDisparity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func (s *Service) finalizedImpliesNewJustified(ctx context.Context, state *state
|
||||
return nil
|
||||
}
|
||||
|
||||
// This retrieves missing blocks from DB (ie. the blocks that couldn't received over sync) and inserts them to fork choice store.
|
||||
// This retrieves missing blocks from DB (ie. the blocks that couldn't be received over sync) and inserts them to fork choice store.
|
||||
// This is useful for block tree visualizer and additional vote accounting.
|
||||
func (s *Service) fillInForkChoiceMissingBlocks(ctx context.Context, blk *ethpb.BeaconBlock, state *stateTrie.BeaconState) error {
|
||||
pendingNodes := make([]*ethpb.BeaconBlock, 0)
|
||||
|
||||
@@ -151,7 +151,7 @@ func Eth1DataHasEnoughSupport(beaconState *stateTrie.BeaconState, data *ethpb.Et
|
||||
// # Verify that proposer index is the correct index
|
||||
// assert block.proposer_index == get_beacon_proposer_index(state)
|
||||
// # Verify that the parent matches
|
||||
// assert block.parent_root == signing_root(state.latest_block_header)
|
||||
// assert block.parent_root == hash_tree_root(state.latest_block_header)
|
||||
// # Save current block as the new latest block
|
||||
// state.latest_block_header = BeaconBlockHeader(
|
||||
// slot=block.slot,
|
||||
@@ -211,7 +211,7 @@ func VerifyBlockSignature(beaconState *stateTrie.BeaconState, block *ethpb.Signe
|
||||
// # Verify that proposer index is the correct index
|
||||
// assert block.proposer_index == get_beacon_proposer_index(state)
|
||||
// # Verify that the parent matches
|
||||
// assert block.parent_root == signing_root(state.latest_block_header)
|
||||
// assert block.parent_root == hash_tree_root(state.latest_block_header)
|
||||
// # Save current block as the new latest block
|
||||
// state.latest_block_header = BeaconBlockHeader(
|
||||
// slot=block.slot,
|
||||
@@ -285,19 +285,14 @@ func ProcessBlockHeaderNoVerify(
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
// def process_randao(state: BeaconState, body: BeaconBlockBody) -> None:
|
||||
// proposer = state.validator_registry[get_beacon_proposer_index(state)]
|
||||
// # Verify that the provided randao value is valid
|
||||
// assert bls_verify(
|
||||
// proposer.pubkey,
|
||||
// hash_tree_root(get_current_epoch(state)),
|
||||
// body.randao_reveal,
|
||||
// get_domain(state, DOMAIN_RANDAO),
|
||||
// )
|
||||
// # Mix it in
|
||||
// state.latest_randao_mixes[get_current_epoch(state) % LATEST_RANDAO_MIXES_LENGTH] = (
|
||||
// xor(get_randao_mix(state, get_current_epoch(state)),
|
||||
// hash(body.randao_reveal))
|
||||
// )
|
||||
// epoch = get_current_epoch(state)
|
||||
// # Verify RANDAO reveal
|
||||
// proposer = state.validators[get_beacon_proposer_index(state)]
|
||||
// signing_root = compute_signing_root(epoch, get_domain(state, DOMAIN_RANDAO))
|
||||
// assert bls.Verify(proposer.pubkey, signing_root, body.randao_reveal)
|
||||
// # Mix in RANDAO reveal
|
||||
// mix = xor(get_randao_mix(state, epoch), hash(body.randao_reveal))
|
||||
// state.randao_mixes[epoch % EPOCHS_PER_HISTORICAL_VECTOR] = mix
|
||||
func ProcessRandao(
|
||||
beaconState *stateTrie.BeaconState,
|
||||
body *ethpb.BeaconBlockBody,
|
||||
@@ -740,24 +735,17 @@ func ProcessAttestationNoVerify(
|
||||
// Spec pseudocode definition:
|
||||
// def is_valid_indexed_attestation(state: BeaconState, indexed_attestation: IndexedAttestation) -> bool:
|
||||
// """
|
||||
// Check if ``indexed_attestation`` has valid indices and signature.
|
||||
// Check if ``indexed_attestation`` is not empty, has sorted and unique indices and has a valid aggregate signature.
|
||||
// """
|
||||
// indices = indexed_attestation.attesting_indices
|
||||
//
|
||||
// # Verify max number of indices
|
||||
// if not len(indices) <= MAX_VALIDATORS_PER_COMMITTEE:
|
||||
// return False
|
||||
// # Verify indices are sorted and unique
|
||||
// if not indices == sorted(set(indices)):
|
||||
// # Verify aggregate signature
|
||||
// if not bls_verify(
|
||||
// pubkey=bls_aggregate_pubkeys([state.validators[i].pubkey for i in indices]),
|
||||
// message_hash=hash_tree_root(indexed_attestation.data),
|
||||
// signature=indexed_attestation.signature,
|
||||
// domain=get_domain(state, DOMAIN_BEACON_ATTESTER, indexed_attestation.data.target.epoch),
|
||||
// ):
|
||||
// indices = indexed_attestation.attesting_indices
|
||||
// if len(indices) == 0 or not indices == sorted(set(indices)):
|
||||
// return False
|
||||
// return True
|
||||
// # Verify aggregate signature
|
||||
// pubkeys = [state.validators[i].pubkey for i in indices]
|
||||
// domain = get_domain(state, DOMAIN_BEACON_ATTESTER, indexed_attestation.data.target.epoch)
|
||||
// signing_root = compute_signing_root(indexed_attestation.data, domain)
|
||||
// return bls.FastAggregateVerify(pubkeys, signing_root, indexed_attestation.signature)
|
||||
func VerifyIndexedAttestation(ctx context.Context, beaconState *stateTrie.BeaconState, indexedAtt *ethpb.IndexedAttestation) error {
|
||||
ctx, span := trace.StartSpan(ctx, "core.VerifyIndexedAttestation")
|
||||
defer span.End()
|
||||
|
||||
@@ -14,8 +14,9 @@ import (
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
// def get_slot_signature(state: BeaconState, slot: Slot, privkey: int) -> BLSSignature:
|
||||
// domain = get_domain(state, DOMAIN_BEACON_ATTESTER, compute_epoch_at_slot(slot))
|
||||
// return bls_sign(privkey, hash_tree_root(slot), domain)
|
||||
// domain = get_domain(state, DOMAIN_SELECTION_PROOF, compute_epoch_at_slot(slot))
|
||||
// signing_root = compute_signing_root(slot, domain)
|
||||
// return bls.Sign(privkey, signing_root)
|
||||
func SlotSignature(state *stateTrie.BeaconState, slot uint64, privKey *bls.SecretKey) (*bls.Signature, error) {
|
||||
d, err := Domain(state.Fork(), CurrentEpoch(state), params.BeaconConfig().DomainBeaconAttester, state.GenesisValidatorRoot())
|
||||
if err != nil {
|
||||
|
||||
@@ -59,12 +59,11 @@ func SlotCommitteeCount(activeValidatorCount uint64) uint64 {
|
||||
// Return the beacon committee at ``slot`` for ``index``.
|
||||
// """
|
||||
// epoch = compute_epoch_at_slot(slot)
|
||||
// committees_per_slot = get_committee_count_at_slot(state, slot)
|
||||
// epoch_offset = index + (slot % SLOTS_PER_EPOCH) * committees_per_slot
|
||||
// committees_per_slot = get_committee_count_per_slot(state, epoch)
|
||||
// return compute_committee(
|
||||
// indices=get_active_validator_indices(state, epoch),
|
||||
// seed=get_seed(state, epoch, DOMAIN_BEACON_ATTESTER),
|
||||
// index=epoch_offset,
|
||||
// index=(slot % SLOTS_PER_EPOCH) * committees_per_slot + index,
|
||||
// count=committees_per_slot * SLOTS_PER_EPOCH,
|
||||
// )
|
||||
func BeaconCommitteeFromState(state *stateTrie.BeaconState, slot uint64, committeeIndex uint64) ([]uint64, error) {
|
||||
@@ -345,11 +344,12 @@ func UpdateProposerIndicesInCache(state *stateTrie.BeaconState, epoch uint64) er
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester)
|
||||
proposerIndices, err := precomputeProposerIndices(state, indices)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposerIndices, err := precomputeProposerIndices(state, indices)
|
||||
// The committee cache uses attester domain seed as key.
|
||||
seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ func TotalBalance(state *stateTrie.BeaconState, indices []uint64) uint64 {
|
||||
total += val.EffectiveBalance()
|
||||
}
|
||||
|
||||
// Return EFFECTIVE_BALANCE_INCREMENT to avoid divisions by zero.
|
||||
if total == 0 {
|
||||
// EFFECTIVE_BALANCE_INCREMENT is the lower bound for total balance.
|
||||
if total < params.BeaconConfig().EffectiveBalanceIncrement {
|
||||
return params.BeaconConfig().EffectiveBalanceIncrement
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ func ActiveValidatorCount(state *stateTrie.BeaconState, epoch uint64) (uint64, e
|
||||
// """
|
||||
// Return the epoch during which validator activations and exits initiated in ``epoch`` take effect.
|
||||
// """
|
||||
// return Epoch(epoch + 1 + MIN_SEED_LOOKAHEAD)
|
||||
// return Epoch(epoch + 1 + MAX_SEED_LOOKAHEAD)
|
||||
func ActivationExitEpoch(epoch uint64) uint64 {
|
||||
return epoch + 1 + params.BeaconConfig().MaxSeedLookahead
|
||||
}
|
||||
|
||||
@@ -28,13 +28,17 @@ import (
|
||||
// ExecuteStateTransition defines the procedure for a state transition function.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
// def state_transition(state: BeaconState, block: BeaconBlock, validate_state_root: bool=False) -> BeaconState:
|
||||
// def state_transition(state: BeaconState, signed_block: SignedBeaconBlock, validate_result: bool=True) -> BeaconState:
|
||||
// block = signed_block.message
|
||||
// # Process slots (including those with no blocks) since block
|
||||
// process_slots(state, block.slot)
|
||||
// # Verify signature
|
||||
// if validate_result:
|
||||
// assert verify_block_signature(state, signed_block)
|
||||
// # Process block
|
||||
// process_block(state, block)
|
||||
// # Validate state root (`validate_state_root == True` in production)
|
||||
// if validate_state_root:
|
||||
// # Verify state root
|
||||
// if validate_result:
|
||||
// assert block.state_root == hash_tree_root(state)
|
||||
// # Return post-state
|
||||
// return state
|
||||
@@ -191,7 +195,7 @@ func CalculateStateRoot(
|
||||
// state.latest_block_header.state_root = previous_state_root
|
||||
//
|
||||
// # Cache block root
|
||||
// previous_block_root = signing_root(state.latest_block_header)
|
||||
// previous_block_root = hash_tree_root(state.latest_block_header)
|
||||
// state.block_roots[state.slot % SLOTS_PER_HISTORICAL_ROOT] = previous_block_root
|
||||
func ProcessSlot(ctx context.Context, state *stateTrie.BeaconState) (*stateTrie.BeaconState, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "beacon-chain.ChainService.state.ProcessSlot")
|
||||
|
||||
@@ -111,10 +111,11 @@ func InitiateValidatorExit(state *stateTrie.BeaconState, idx uint64) (*stateTrie
|
||||
// # Apply proposer and whistleblower rewards
|
||||
// proposer_index = get_beacon_proposer_index(state)
|
||||
// if whistleblower_index is None:
|
||||
// whistleblower_index = proposer_index
|
||||
// whistleblower_reward = Gwei(validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT)
|
||||
// proposer_reward = Gwei(whistleblower_reward // PROPOSER_REWARD_QUOTIENT)
|
||||
// increase_balance(state, proposer_index, proposer_reward)
|
||||
// increase_balance(state, whistleblower_index, whistleblower_reward - proposer_reward)
|
||||
// increase_balance(state, whistleblower_index, Gwei(whistleblower_reward - proposer_reward))
|
||||
func SlashValidator(state *stateTrie.BeaconState, slashedIdx uint64) (*stateTrie.BeaconState, error) {
|
||||
state, err := InitiateValidatorExit(state, slashedIdx)
|
||||
if err != nil {
|
||||
@@ -133,6 +134,7 @@ func SlashValidator(state *stateTrie.BeaconState, slashedIdx uint64) (*stateTrie
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// The slashing amount is represented by epochs per slashing vector. The validator's effective balance is then applied to that amount.
|
||||
slashings := state.Slashings()
|
||||
currentSlashing := slashings[currentEpoch%params.BeaconConfig().EpochsPerSlashingsVector]
|
||||
if err := state.UpdateSlashingsAtIndex(
|
||||
|
||||
@@ -22,8 +22,6 @@ type NetworkEncoding interface {
|
||||
// DecodeWithMaxLength a bytes from a reader with a varint length prefix. The interface must be a pointer to the
|
||||
// decoding destination. The length of the message should not be more than the provided limit.
|
||||
DecodeWithMaxLength(io.Reader, interface{}, uint64) error
|
||||
// Encode an arbitrary message to the provided writer. The interface must be a pointer object to encode.
|
||||
Encode(io.Writer, interface{}) (int, error)
|
||||
// EncodeGossip an arbitrary gossip message to the provided writer. The interface must be a pointer object to encode.
|
||||
EncodeGossip(io.Writer, interface{}) (int, error)
|
||||
// EncodeWithLength an arbitrary message to the provided writer with a varint length prefix. The interface must be
|
||||
|
||||
@@ -43,21 +43,6 @@ func (e SszNetworkEncoder) doEncode(msg interface{}) ([]byte, error) {
|
||||
return ssz.Marshal(msg)
|
||||
}
|
||||
|
||||
// Encode the proto message to the io.Writer.
|
||||
func (e SszNetworkEncoder) Encode(w io.Writer, msg interface{}) (int, error) {
|
||||
if msg == nil {
|
||||
return 0, nil
|
||||
}
|
||||
b, err := e.doEncode(msg)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if e.UseSnappyCompression {
|
||||
return writeSnappyBuffer(w, b)
|
||||
}
|
||||
return w.Write(b)
|
||||
}
|
||||
|
||||
// EncodeGossip the proto gossip message to the io.Writer.
|
||||
func (e SszNetworkEncoder) EncodeGossip(w io.Writer, msg interface{}) (int, error) {
|
||||
if msg == nil {
|
||||
|
||||
@@ -13,38 +13,16 @@ import (
|
||||
|
||||
func TestSszNetworkEncoder_RoundTrip(t *testing.T) {
|
||||
e := &encoder.SszNetworkEncoder{UseSnappyCompression: false}
|
||||
testRoundTrip(t, e)
|
||||
testRoundTripWithLength(t, e)
|
||||
testRoundTripWithGossip(t, e)
|
||||
}
|
||||
|
||||
func TestSszNetworkEncoder_RoundTrip_Snappy(t *testing.T) {
|
||||
e := &encoder.SszNetworkEncoder{UseSnappyCompression: true}
|
||||
testRoundTrip(t, e)
|
||||
testRoundTripWithLength(t, e)
|
||||
testRoundTripWithGossip(t, e)
|
||||
}
|
||||
|
||||
func testRoundTrip(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
Foo: []byte("fooooo"),
|
||||
Bar: 9001,
|
||||
}
|
||||
_, err := e.Encode(buf, msg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
decoded := &testpb.TestSimpleMessage{}
|
||||
if err := e.Decode(buf.Bytes(), decoded); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !proto.Equal(decoded, msg) {
|
||||
t.Logf("decoded=%+v\n", decoded)
|
||||
t.Error("Decoded message is not the same as original")
|
||||
}
|
||||
}
|
||||
|
||||
func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &testpb.TestSimpleMessage{
|
||||
@@ -111,7 +89,7 @@ func TestSszNetworkEncoder_DecodeWithMaxLength(t *testing.T) {
|
||||
}
|
||||
e := &encoder.SszNetworkEncoder{UseSnappyCompression: false}
|
||||
maxLength := uint64(5)
|
||||
_, err := e.Encode(buf, msg)
|
||||
_, err := e.EncodeGossip(buf, msg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ func TestValidateAggregateAndProof_NoBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, signedAggregateAndProof); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, signedAggregateAndProof); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func TestValidateAggregateAndProof_NotWithinSlotRange(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, signedAggregateAndProof); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, signedAggregateAndProof); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ func TestValidateAggregateAndProof_NotWithinSlotRange(t *testing.T) {
|
||||
att.Data.Slot = 1<<32 - 1
|
||||
|
||||
buf = new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, signedAggregateAndProof); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, signedAggregateAndProof); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ func TestValidateAggregateAndProof_ExistedInPool(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, signedAggregateAndProof); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, signedAggregateAndProof); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ func TestValidateAggregateAndProofWithNewStateMgmt_CanValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, signedAggregateAndProof); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, signedAggregateAndProof); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ func TestVerifyIndexInCommittee_SeenAggregatorEpoch(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, signedAggregateAndProof); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, signedAggregateAndProof); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ func TestVerifyIndexInCommittee_SeenAggregatorEpoch(t *testing.T) {
|
||||
// Should fail with another attestation in the same epoch.
|
||||
signedAggregateAndProof.Message.Aggregate.Data.Slot++
|
||||
buf = new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, signedAggregateAndProof); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, signedAggregateAndProof); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
msg = &pubsub.Message{
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestValidateAttesterSlashing_ValidSlashing(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, slashing); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, slashing); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func TestValidateAttesterSlashing_ContextTimeout(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, slashing); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, slashing); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func TestValidateAttesterSlashing_Syncing(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, slashing); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, slashing); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
msg := &pubsub.Message{
|
||||
|
||||
@@ -205,7 +205,7 @@ func TestService_validateCommitteeIndexBeaconAttestation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
_, err := p.Encoding().Encode(buf, tt.msg)
|
||||
_, err := p.Encoding().EncodeGossip(buf, tt.msg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestValidateBeaconBlockPubSub_InvalidSignature(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -114,7 +114,7 @@ func TestValidateBeaconBlockPubSub_BlockAlreadyPresentInDB(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ func TestValidateBeaconBlockPubSub_ValidProposerSignature(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -304,7 +304,7 @@ func TestValidateBeaconBlockPubSub_AdvanceEpochsForState(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -355,7 +355,7 @@ func TestValidateBeaconBlockPubSub_Syncing(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -407,7 +407,7 @@ func TestValidateBeaconBlockPubSub_RejectBlocksFromFuture(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -462,7 +462,7 @@ func TestValidateBeaconBlockPubSub_RejectBlocksFromThePast(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -547,7 +547,7 @@ func TestValidateBeaconBlockPubSub_SeenProposerSlot(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, msg); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -601,7 +601,7 @@ func TestValidateBeaconBlockPubSub_FilterByFinalizedEpoch(t *testing.T) {
|
||||
Block: ðpb.BeaconBlock{Slot: 1, ParentRoot: parentRoot[:], Body: ðpb.BeaconBlockBody{}},
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, b); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -619,7 +619,7 @@ func TestValidateBeaconBlockPubSub_FilterByFinalizedEpoch(t *testing.T) {
|
||||
hook.Reset()
|
||||
b.Block.Slot = params.BeaconConfig().SlotsPerEpoch
|
||||
buf = new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, b); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m = &pubsub.Message{
|
||||
|
||||
@@ -142,7 +142,7 @@ func TestValidateProposerSlashing_ValidSlashing(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, slashing); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, slashing); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -185,7 +185,7 @@ func TestValidateProposerSlashing_ContextTimeout(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, slashing); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, slashing); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -215,7 +215,7 @@ func TestValidateProposerSlashing_Syncing(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, slashing); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, slashing); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestValidateVoluntaryExit_ValidExit(t *testing.T) {
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, exit); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, exit); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
@@ -136,7 +136,7 @@ func TestValidateVoluntaryExit_ValidExit_Syncing(t *testing.T) {
|
||||
initialSync: &mockSync.Sync{IsSyncing: true},
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
if _, err := p.Encoding().Encode(buf, exit); err != nil {
|
||||
if _, err := p.Encoding().EncodeGossip(buf, exit); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := &pubsub.Message{
|
||||
|
||||
Reference in New Issue
Block a user