mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-28 14:17:17 +00:00
Fix attestation inclusion (#1715)
This commit is contained in:
parent
40c0daf343
commit
c4ebb0a522
@ -8,8 +8,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
gethTypes "github.com/ethereum/go-ethereum/core/types"
|
gethTypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
b "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
b "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||||
@ -18,6 +16,7 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
||||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/event"
|
"github.com/prysmaticlabs/prysm/shared/event"
|
||||||
|
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -373,8 +373,8 @@ func isSurroundVote(data1 *pb.AttestationData, data2 *pb.AttestationData) bool {
|
|||||||
// Verify that len(block.body.attestations) <= MAX_ATTESTATIONS.
|
// Verify that len(block.body.attestations) <= MAX_ATTESTATIONS.
|
||||||
//
|
//
|
||||||
// For each attestation in block.body.attestations:
|
// For each attestation in block.body.attestations:
|
||||||
// Verify that attestation.data.slot <= state.slot - MIN_ATTESTATION_INCLUSION_DELAY <
|
// Verify that `attestation.data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot`.
|
||||||
// attestation.data.slot + SLOTS_PER_EPOCH.
|
// Verify that `state.slot < attestation.data.slot + SLOTS_PER_EPOCH.
|
||||||
// Verify that attestation.data.justified_epoch is equal to state.justified_epoch
|
// Verify that attestation.data.justified_epoch is equal to state.justified_epoch
|
||||||
// if attestation.data.slot >= get_epoch_start_slot(get_current_epoch(state)) else state.previous_justified_epoch.
|
// if attestation.data.slot >= get_epoch_start_slot(get_current_epoch(state)) else state.previous_justified_epoch.
|
||||||
// Verify that attestation.data.justified_block_root is equal to
|
// Verify that attestation.data.justified_block_root is equal to
|
||||||
@ -424,7 +424,7 @@ func verifyAttestation(beaconState *pb.BeaconState, att *pb.Attestation, verifyS
|
|||||||
beaconState.Slot-params.BeaconConfig().GenesisSlot,
|
beaconState.Slot-params.BeaconConfig().GenesisSlot,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if att.Data.Slot+params.BeaconConfig().SlotsPerEpoch < beaconState.Slot {
|
if att.Data.Slot+params.BeaconConfig().SlotsPerEpoch <= beaconState.Slot {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"attestation slot (slot %d) + epoch length (%d) less than current beacon state slot (%d)",
|
"attestation slot (slot %d) + epoch length (%d) less than current beacon state slot (%d)",
|
||||||
att.Data.Slot-params.BeaconConfig().GenesisSlot,
|
att.Data.Slot-params.BeaconConfig().GenesisSlot,
|
||||||
|
@ -790,7 +790,7 @@ func TestProcessBlockAttestations_PreviousJustifiedEpochVerificationFailure(t *t
|
|||||||
attestations := []*pb.Attestation{
|
attestations := []*pb.Attestation{
|
||||||
{
|
{
|
||||||
Data: &pb.AttestationData{
|
Data: &pb.AttestationData{
|
||||||
Slot: params.BeaconConfig().SlotsPerEpoch,
|
Slot: params.BeaconConfig().SlotsPerEpoch + 1,
|
||||||
JustifiedEpoch: 3,
|
JustifiedEpoch: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -801,7 +801,7 @@ func TestProcessBlockAttestations_PreviousJustifiedEpochVerificationFailure(t *t
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
state := &pb.BeaconState{
|
state := &pb.BeaconState{
|
||||||
Slot: params.BeaconConfig().SlotsPerEpoch * 2,
|
Slot: 2 * params.BeaconConfig().SlotsPerEpoch,
|
||||||
PreviousJustifiedEpoch: 2,
|
PreviousJustifiedEpoch: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user