Compare commits

...

16 Commits

Author SHA1 Message Date
Manu NALEPA
e9e093d8a3 verifyRPCDataColumnSidecars: Integrate SidecarRootAndSignatureAligned test. 2025-11-04 22:53:40 +01:00
Manu NALEPA
c990d1d90c Implement SidecarRootAndSignatureAligned. 2025-11-04 22:52:28 +01:00
Manu NALEPA
a77a3a1740 rpc_send_request_test.go: Remove duplicated imports. 2025-11-04 22:51:04 +01:00
Manu NALEPA
fa616d4afd verifyRPCDataColumnSidecars and callers: Add roBlockByRoot parameter. 2025-11-04 22:51:04 +01:00
Manu NALEPA
9d0d0f524d TestComputeIndicesByRootByPeer: Simplify. 2025-11-04 22:51:04 +01:00
Manu NALEPA
f71b821f88 FetchDataColumnSidecars: switch slotByRoot to roBlockByRoot. 2025-11-04 22:51:04 +01:00
Manu NALEPA
f15cef7266 computeIndicesByRootByPeer: Rename internal variables (no functional change). 2025-11-04 22:51:04 +01:00
Manu NALEPA
90e49d5a7e verifyByRootDataColumnSidecars ==> verifyRPCDataColumnSidecars.
It is used for both by root and by range RPC requests.
2025-11-04 22:51:04 +01:00
Manu NALEPA
77d84f693e Remove unused ByRangeRequestDataColumnSidecarRequirements and rename ByRootRequestDataColumnSidecarRequirements to RPCDataColumnSidecarRequirements since it is used for both by root and by range RPC requests. 2025-11-04 22:51:04 +01:00
Manu NALEPA
7df60e8c9b SidecarProposerExpected: Add the slot in the single flight key. (#15976)
* `SidecarProposerExpected`: Add the slot in the single flight key.

* Fix Kasey's comment.

* Revert "Fix Kasey's comment."

This reverts commit 9e3b4b7acf.
2025-11-04 19:56:38 +00:00
Jun Song
165c4b0af1 Handle addition overflow in /eth/v1/beacon/rewards/attestations/{epoch} (#15970)
* Handle addition overflow in `/eth/v1/beacon/rewards/attestations/{epoch}`

* Changelog
2025-11-04 16:14:47 +00:00
terence
d0f5253b8d Update go-bitfield from prysmaticlabs to OffchainLabs (#15968) 2025-11-03 23:59:03 +00:00
terence
1f926142b8 Update spec test to v1.6.0-beta.2 (#15960) 2025-11-03 17:54:02 +00:00
Manu NALEPA
d394f00e9f beacon_data_column_sidecar_gossip_verification_milliseconds: Adjust buckets. (#15964)
* `beacon_data_column_sidecar_gossip_verification_milliseconds`: Divide by 10.

* Fix Kasey's comment.
2025-11-03 17:00:37 +00:00
Muzry
11c6325b54 use filepath to perform path operations correctly on Windows (#15953) 2025-11-03 15:14:08 +00:00
Manu NALEPA
ec524ce99c RODataColumnsVerifier.ValidProposerSignature: Ensure the expensive signature verification is only performed once for concurrent requests for the same signature data. (#15954)
* `signatureData`: Add `string` function.

* `RODataColumnsVerifier.ValidProposerSignature`: Ensure the expensive signature verification is only performed once for concurrent requests for the same signature data.

Share flight group

* `parentState` ==> `state`.

* `RODataColumnsVerifier.SidecarProposerExpected: Ensure the expensive index computation is only performed once for concurrent requests.`

* Add `wrapAttestationError`

* Fix Kasey's comment.

* Fix Terence's comment.
2025-11-03 14:48:41 +00:00
168 changed files with 674 additions and 381 deletions

View File

@@ -253,7 +253,7 @@ filegroup(
url = "https://github.com/ethereum/EIPs/archive/5480440fe51742ed23342b68cf106cefd427e39d.tar.gz",
)
consensus_spec_version = "v1.6.0-beta.1"
consensus_spec_version = "v1.6.0-beta.2"
load("@prysm//tools:download_spectests.bzl", "consensus_spec_tests")
@@ -278,7 +278,7 @@ filegroup(
visibility = ["//visibility:public"],
)
""",
integrity = "sha256-yrq3tdwPS8Ri+ueeLAHssIT3ssMrX7zvHiJ8Xf9GVYs=",
integrity = "sha256-MForEP9dTe0z3ZkTHjX4H6waSkSTghf3gQHPwrSCCro=",
strip_prefix = "consensus-specs-" + consensus_spec_version[1:],
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
)

View File

@@ -10,6 +10,7 @@ import (
"net/url"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
"github.com/OffchainLabs/prysm/v6/config/params"
@@ -22,7 +23,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
log "github.com/sirupsen/logrus"
)

View File

@@ -11,6 +11,7 @@ import (
"os"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
consensusblocks "github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
@@ -22,7 +23,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
func ezDecode(t *testing.T, s string) []byte {

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/blocks"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/peerdas"
@@ -29,7 +30,6 @@ import (
"github.com/OffchainLabs/prysm/v6/runtime/version"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
"github.com/sirupsen/logrus"
)

View File

@@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/cache"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/blocks"
@@ -49,7 +50,6 @@ import (
"github.com/ethereum/go-ethereum/common"
gethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@@ -3,6 +3,7 @@ package cache
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v6/crypto/bls/blst"
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
@@ -10,7 +11,6 @@ import (
"github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1/attestation"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/prysmaticlabs/go-bitfield"
)
func TestAdd(t *testing.T) {

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -22,7 +23,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
gofuzz "github.com/google/gofuzz"
"github.com/prysmaticlabs/go-bitfield"
)
func TestProcessAttestations_InclusionDelayFailure(t *testing.T) {

View File

@@ -4,6 +4,7 @@ import (
"math"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -19,7 +20,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/prysmaticlabs/go-bitfield"
)
func TestProcessSyncCommittee_PerfectParticipation(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package altair_test
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/time"
@@ -12,7 +13,6 @@ import (
"github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1/attestation"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestTranslateParticipation(t *testing.T) {

View File

@@ -5,6 +5,7 @@ import (
"os"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/blocks"
state_native "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
"github.com/OffchainLabs/prysm/v6/config/params"
@@ -12,7 +13,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
// Beaconfuzz discovered an off by one issue where an attestation could be produced which would pass

View File

@@ -4,6 +4,7 @@ import (
"context"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/blocks"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -20,7 +21,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package precompute_test
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/epoch/precompute"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/config/params"
@@ -12,7 +13,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestUpdateValidator_Works(t *testing.T) {

View File

@@ -1,6 +1,7 @@
package precompute
import (
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/time"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
@@ -8,7 +9,6 @@ import (
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
var errNilState = errors.New("nil state")

View File

@@ -3,6 +3,7 @@ package precompute_test
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/epoch/precompute"
state_native "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
@@ -12,7 +13,6 @@ import (
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/prysmaticlabs/go-bitfield"
)
func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package precompute
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/time"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
@@ -16,7 +17,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) {

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"sort"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/cache"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/time"
forkchoicetypes "github.com/OffchainLabs/prysm/v6/beacon-chain/forkchoice/types"
@@ -23,7 +24,6 @@ import (
"github.com/OffchainLabs/prysm/v6/runtime/version"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
var (

View File

@@ -5,6 +5,7 @@ import (
"strconv"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/time"
state_native "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
@@ -18,7 +19,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/prysmaticlabs/go-bitfield"
)
func TestComputeCommittee_WithoutCache(t *testing.T) {

View File

@@ -285,4 +285,3 @@ func genState(t *testing.T, valCount, avgBalance uint64) state.BeaconState {
return beaconState
}

View File

@@ -4,6 +4,7 @@ import (
"math"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -20,7 +21,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/prysmaticlabs/go-bitfield"
)
func TestExecuteAltairStateTransitionNoVerify_FullProcess(t *testing.T) {

View File

@@ -4,6 +4,7 @@ import (
"math"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -22,7 +23,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/prysmaticlabs/go-bitfield"
)
func TestExecuteBellatrixStateTransitionNoVerify_FullProcess(t *testing.T) {

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/blocks"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -23,7 +24,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func init() {

View File

@@ -4,12 +4,12 @@ import (
"bytes"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
"github.com/sirupsen/logrus"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@@ -3,11 +3,11 @@ package monitor
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@@ -4,6 +4,7 @@ import (
"sort"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v6/crypto/bls"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
@@ -13,7 +14,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/util"
c "github.com/patrickmn/go-cache"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
func TestKV_Aggregated_AggregateUnaggregatedAttestations(t *testing.T) {

View File

@@ -4,11 +4,11 @@ import (
"sort"
"testing"
"github.com/OffchainLabs/go-bitfield"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestKV_BlockAttestation_CanSaveRetrieve(t *testing.T) {

View File

@@ -4,11 +4,11 @@ import (
"sort"
"testing"
"github.com/OffchainLabs/go-bitfield"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestKV_Forkchoice_CanSaveRetrieve(t *testing.T) {

View File

@@ -1,11 +1,11 @@
package kv
import (
"github.com/OffchainLabs/go-bitfield"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1/attestation"
"github.com/patrickmn/go-cache"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
func (c *AttCaches) insertSeenBit(att ethpb.Att) error {

View File

@@ -3,11 +3,11 @@ package kv
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1/attestation"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestAttCaches_hasSeenBit(t *testing.T) {

View File

@@ -5,6 +5,7 @@ import (
"sort"
"testing"
"github.com/OffchainLabs/go-bitfield"
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
@@ -13,7 +14,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
c "github.com/patrickmn/go-cache"
"github.com/prysmaticlabs/go-bitfield"
)
func TestKV_Unaggregated_UnaggregatedAttestations(t *testing.T) {

View File

@@ -5,6 +5,7 @@ import (
"context"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/config/features"
"github.com/OffchainLabs/prysm/v6/config/params"
"github.com/OffchainLabs/prysm/v6/monitoring/tracing/trace"
@@ -13,7 +14,6 @@ import (
attaggregation "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1/attestation/aggregation/attestations"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
// This prepares fork choice attestations by running batchForkChoiceAtts

View File

@@ -5,13 +5,13 @@ import (
"sort"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/crypto/bls"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
attaggregation "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1/attestation/aggregation/attestations"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
"google.golang.org/protobuf/proto"
)

View File

@@ -5,6 +5,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/async"
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
"github.com/OffchainLabs/prysm/v6/config/params"
@@ -13,7 +14,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestPruneExpired_Ticker(t *testing.T) {

View File

@@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/kzg"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/peerdas"
@@ -31,7 +32,6 @@ import (
"github.com/OffchainLabs/prysm/v6/time/slots"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/host"
"github.com/prysmaticlabs/go-bitfield"
"google.golang.org/protobuf/proto"
)

View File

@@ -9,6 +9,7 @@ import (
"sync"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/cache"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/peerdas"
"github.com/OffchainLabs/prysm/v6/cmd/beacon-chain/flags"
@@ -24,7 +25,6 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
"github.com/sirupsen/logrus"
)

View File

@@ -16,6 +16,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/cache"
testDB "github.com/OffchainLabs/prysm/v6/beacon-chain/db/testing"
@@ -41,7 +42,6 @@ import (
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/prysmaticlabs/go-bitfield"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@@ -3,7 +3,7 @@ package peers
import (
"testing"
"github.com/prysmaticlabs/go-bitfield"
"github.com/OffchainLabs/go-bitfield"
)
func Benchmark_retrieveIndicesFromBitfield(b *testing.B) {

View File

@@ -30,6 +30,7 @@ import (
"strings"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/peers/peerdata"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/peers/scorers"
"github.com/OffchainLabs/prysm/v6/config/features"
@@ -47,7 +48,6 @@ import (
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
const (

View File

@@ -6,6 +6,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/peers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/peers/peerdata"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/peers/scorers"
@@ -21,7 +22,6 @@ import (
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr"
"github.com/prysmaticlabs/go-bitfield"
)
func TestStatus(t *testing.T) {

View File

@@ -8,6 +8,7 @@ import (
"sync"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/cache"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/peerdas"
@@ -24,7 +25,6 @@ import (
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/holiman/uint256"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
"github.com/sirupsen/logrus"
)

View File

@@ -7,6 +7,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/cache"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/peerdas"
testDB "github.com/OffchainLabs/prysm/v6/beacon-chain/db/testing"
@@ -23,7 +24,6 @@ import (
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/network"
"github.com/prysmaticlabs/go-bitfield"
)
func TestStartDiscV5_FindAndDialPeersWithSubnet(t *testing.T) {

View File

@@ -13,6 +13,7 @@ import (
"path"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/db"
"github.com/OffchainLabs/prysm/v6/beacon-chain/db/kv"
"github.com/OffchainLabs/prysm/v6/config/params"
@@ -28,7 +29,6 @@ import (
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
"github.com/sirupsen/logrus"
)

View File

@@ -10,6 +10,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api"
"github.com/OffchainLabs/prysm/v6/api/server"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
@@ -42,7 +43,6 @@ import (
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
func TestListAttestations(t *testing.T) {

View File

@@ -12,6 +12,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
"github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/kzg"
@@ -44,7 +45,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
ssz "github.com/prysmaticlabs/fastssz"
"github.com/prysmaticlabs/go-bitfield"
logTest "github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/mock"
"go.uber.org/mock/gomock"

View File

@@ -9,6 +9,7 @@ import (
"runtime"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p"
@@ -28,7 +29,6 @@ import (
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr"
"github.com/prysmaticlabs/go-bitfield"
)
type dummyIdentity enode.ID

View File

@@ -209,8 +209,13 @@ func (s *Server) attRewardsState(w http.ResponseWriter, r *http.Request) (state.
httputil.HandleError(w, "Attestation rewards are not supported for Phase 0", http.StatusNotFound)
return nil, false
}
currentEpoch := uint64(slots.ToEpoch(s.TimeFetcher.CurrentSlot()))
if requestedEpoch+1 >= currentEpoch {
currentEpoch := slots.ToEpoch(s.TimeFetcher.CurrentSlot())
bufferedEpoch, err := primitives.Epoch(requestedEpoch).SafeAdd(1)
if err != nil {
httputil.HandleError(w, "Could not increment epoch: "+err.Error(), http.StatusNotFound)
return nil, false
}
if bufferedEpoch >= currentEpoch {
httputil.HandleError(w,
"Attestation rewards are available after two epoch transitions to ensure all attestations have a chance of inclusion",
http.StatusNotFound)

View File

@@ -4,12 +4,14 @@ import (
"bytes"
"encoding/json"
"fmt"
"math"
"net/http"
"net/http/httptest"
"strconv"
"strings"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
@@ -34,7 +36,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
func BlockRewardTestSetup(t *testing.T, ver int) (state.BeaconState, interfaces.SignedBeaconBlock, error) {
@@ -747,6 +748,18 @@ func TestAttestationRewards(t *testing.T) {
assert.Equal(t, http.StatusNotFound, e.Code)
assert.Equal(t, "Attestation rewards are available after two epoch transitions to ensure all attestations have a chance of inclusion", e.Message)
})
t.Run("epoch overflow", func(t *testing.T) {
url := "http://only.the.epoch.number.at.the.end.is.important/" + strconv.FormatUint(math.MaxUint64, 10)
request := httptest.NewRequest("POST", url, nil)
writer := httptest.NewRecorder()
writer.Body = &bytes.Buffer{}
s.AttestationRewards(writer, request)
assert.Equal(t, http.StatusNotFound, writer.Code)
e := &httputil.DefaultJsonError{}
require.NoError(t, json.Unmarshal(writer.Body.Bytes(), e))
assert.Equal(t, http.StatusNotFound, e.Code)
})
}
func TestSyncCommiteeRewards(t *testing.T) {

View File

@@ -11,6 +11,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
mockChain "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
@@ -43,7 +44,6 @@ import (
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@@ -10,6 +10,7 @@ import (
"net/http/httptest"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
chainMock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
@@ -33,7 +34,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/go-bitfield"
)
func individualVotesHelper(t *testing.T, request *structs.GetIndividualVotesRequest, s *Server) (string, *structs.GetIndividualVotesResponse) {

View File

@@ -10,6 +10,7 @@ import (
"strings"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
chainMock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
@@ -24,7 +25,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/go-bitfield"
)
func TestQueryBeaconState(t *testing.T) {

View File

@@ -7,6 +7,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
chainMock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
dbTest "github.com/OffchainLabs/prysm/v6/beacon-chain/db/testing"
@@ -27,7 +28,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/prysmaticlabs/go-bitfield"
"google.golang.org/protobuf/proto"
)

View File

@@ -8,6 +8,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/epoch/precompute"
@@ -37,7 +38,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/util"
prysmTime "github.com/OffchainLabs/prysm/v6/time"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/prysmaticlabs/go-bitfield"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/emptypb"
)

View File

@@ -4,6 +4,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
dbTest "github.com/OffchainLabs/prysm/v6/beacon-chain/db/testing"
@@ -15,7 +16,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestServer_GetBlock(t *testing.T) {

View File

@@ -6,6 +6,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -25,7 +26,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestSubmitAggregateAndProof_Syncing(t *testing.T) {

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/config/params"
@@ -18,7 +19,6 @@ import (
"github.com/OffchainLabs/prysm/v6/runtime/version"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
func (vs *Server) setSyncAggregate(ctx context.Context, blk interfaces.SignedBeaconBlock, headState state.BeaconState) {

View File

@@ -3,6 +3,7 @@ package validator
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
chainmock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/operations/synccommittee"
@@ -16,7 +17,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestProposer_GetSyncAggregate_OK(t *testing.T) {

View File

@@ -8,6 +8,7 @@ import (
"slices"
"sort"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/blocks"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
@@ -23,7 +24,6 @@ import (
"github.com/OffchainLabs/prysm/v6/runtime/version"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
"github.com/sirupsen/logrus"
)

View File

@@ -4,10 +4,10 @@ import (
"cmp"
"slices"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v6/crypto/bls"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
)
// computeOnChainAggregate constructs a final aggregate form a list of network aggregates with equal attestation data.

View File

@@ -4,6 +4,7 @@ import (
"reflect"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/config/params"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v6/crypto/bls/blst"
@@ -11,7 +12,6 @@ import (
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/prysmaticlabs/go-bitfield"
)
func Test_computeOnChainAggregate(t *testing.T) {

View File

@@ -7,6 +7,7 @@ import (
"strconv"
"testing"
"github.com/OffchainLabs/go-bitfield"
chainMock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
@@ -21,7 +22,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/prysmaticlabs/go-bitfield"
)
func TestProposer_ProposerAtts_committeeAwareSort(t *testing.T) {

View File

@@ -6,6 +6,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
builderapi "github.com/OffchainLabs/prysm/v6/api/client/builder"
"github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/kzg"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
@@ -52,7 +53,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
logTest "github.com/sirupsen/logrus/hooks/test"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

View File

@@ -4,11 +4,11 @@ import (
"fmt"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/config/params"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
aggtesting "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1/attestation/aggregation/testing"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/prysmaticlabs/go-bitfield"
)
func BenchmarkProposerAtts_sortByProfitability(b *testing.B) {

View File

@@ -11,6 +11,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
@@ -37,7 +38,6 @@ import (
prysmTime "github.com/OffchainLabs/prysm/v6/time"
"github.com/OffchainLabs/prysm/v6/time/slots"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/prysmaticlabs/go-bitfield"
)
func addDefaultReplayerBuilder(s *Server, h stategen.HistoryAccessor) {

View File

@@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/api/server/structs"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/epoch/precompute"
@@ -23,7 +24,6 @@ import (
"github.com/OffchainLabs/prysm/v6/runtime/version"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestServer_GetValidatorPerformance(t *testing.T) {

View File

@@ -8,6 +8,7 @@ import (
"encoding/json"
"time"
"github.com/OffchainLabs/go-bitfield"
customtypes "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native/custom-types"
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
@@ -15,7 +16,6 @@ import (
"github.com/OffchainLabs/prysm/v6/crypto/bls"
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
)
// BeaconState has read and write access to beacon state methods.

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"sync"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state/fieldtrie"
customtypes "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native/custom-types"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native/types"
@@ -11,7 +12,6 @@ import (
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
)
// BeaconState defines a struct containing utilities for the Ethereum Beacon Chain state, defining

View File

@@ -3,9 +3,9 @@ package state_native
import (
"bytes"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
)
// JustificationBits marking which epochs have been justified in the beacon chain.

View File

@@ -3,10 +3,10 @@ package state_native
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
testtmpl "github.com/OffchainLabs/prysm/v6/beacon-chain/state/testing"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
)
func TestBeaconState_PreviousJustifiedCheckpointNil_Phase0(t *testing.T) {

View File

@@ -4,6 +4,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
statenative "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
"github.com/OffchainLabs/prysm/v6/config/params"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
@@ -13,7 +14,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestComputeFieldRootsWithHasher_Phase0(t *testing.T) {

View File

@@ -6,13 +6,13 @@ import (
"runtime/debug"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native/types"
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/prysmaticlabs/go-bitfield"
)
func TestStateReferenceSharing_Finalizer_Phase0(t *testing.T) {

View File

@@ -1,9 +1,9 @@
package state_native
import (
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native/types"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
)
// SetJustificationBits for the beacon state.

View File

@@ -6,6 +6,7 @@ import (
"sync"
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native/types"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state/stateutil"
@@ -16,7 +17,6 @@ import (
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/prysmaticlabs/go-bitfield"
)
func TestBeaconState_NoDeadlock_Phase0(t *testing.T) {

View File

@@ -3,12 +3,12 @@ package testing
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/prysmaticlabs/go-bitfield"
)
func VerifyBeaconStateJustificationBitsNil(t *testing.T, factory getState) {

View File

@@ -74,7 +74,7 @@ func FetchDataColumnSidecars(
// set as we retrieve them.
incompleteRoots := make(map[[fieldparams.RootLength]byte]bool, blockCount)
slotsWithCommitments := make(map[primitives.Slot]bool, blockCount)
slotByRoot := make(map[[fieldparams.RootLength]byte]primitives.Slot, blockCount)
roBlockByRoot := make(map[[fieldparams.RootLength]byte]blocks.ROBlock, blockCount)
storedIndicesByRoot := make(map[[fieldparams.RootLength]byte]map[uint64]bool, blockCount)
for _, roBlock := range roBlocks {
@@ -93,7 +93,7 @@ func FetchDataColumnSidecars(
slot := block.Slot()
incompleteRoots[root] = true
slotByRoot[root] = slot
roBlockByRoot[root] = roBlock
slotsWithCommitments[slot] = true
storedIndices := params.Storage.Summary(root).Stored()
@@ -118,7 +118,7 @@ func FetchDataColumnSidecars(
}
// Request direct sidecars from peers.
directSidecarsByRoot, err := requestDirectSidecarsFromPeers(params, slotByRoot, requestedIndices, slotsWithCommitments, storedIndicesByRoot, incompleteRoots)
directSidecarsByRoot, err := requestDirectSidecarsFromPeers(params, roBlockByRoot, requestedIndices, slotsWithCommitments, storedIndicesByRoot, incompleteRoots)
if err != nil {
return nil, nil, errors.Wrap(err, "request direct sidecars from peers")
}
@@ -139,7 +139,7 @@ func FetchDataColumnSidecars(
}
// Request all possible indirect sidecars from peers which are neither stored nor in `directSidecarsByRoot`
indirectSidecarsByRoot, err := requestIndirectSidecarsFromPeers(params, slotByRoot, slotsWithCommitments, storedIndicesByRoot, directSidecarsByRoot, requestedIndices, incompleteRoots)
indirectSidecarsByRoot, err := requestIndirectSidecarsFromPeers(params, roBlockByRoot, slotsWithCommitments, storedIndicesByRoot, directSidecarsByRoot, requestedIndices, incompleteRoots)
if err != nil {
return nil, nil, errors.Wrap(err, "request all sidecars from peers")
}
@@ -229,7 +229,7 @@ func requestSidecarsFromStorage(
// It returns a map from each root to its successfully retrieved sidecars.
func requestDirectSidecarsFromPeers(
params DataColumnSidecarsParams,
slotByRoot map[[fieldparams.RootLength]byte]primitives.Slot,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
requestedIndices map[uint64]bool,
slotsWithCommitments map[primitives.Slot]bool,
storedIndicesByRoot map[[fieldparams.RootLength]byte]map[uint64]bool,
@@ -266,7 +266,7 @@ func requestDirectSidecarsFromPeers(
initialMissingCount := computeTotalCount(missingIndicesByRoot)
indicesByRootByPeer, err := computeIndicesByRootByPeer(params.P2P, slotByRoot, missingIndicesByRoot, connectedPeers)
indicesByRootByPeer, err := computeIndicesByRootByPeer(params.P2P, roBlockByRoot, missingIndicesByRoot, connectedPeers)
if err != nil {
return nil, errors.Wrap(err, "explore peers")
}
@@ -285,10 +285,10 @@ func requestDirectSidecarsFromPeers(
}
// Fetch the sidecars from the chosen peers.
roDataColumnsByPeer := fetchDataColumnSidecarsFromPeers(params, slotByRoot, slotsWithCommitments, indicesByRootByPeerToQuery)
roDataColumnsByPeer := fetchDataColumnSidecarsFromPeers(params, roBlockByRoot, slotsWithCommitments, indicesByRootByPeerToQuery)
// Verify the received data column sidecars.
verifiedRoDataColumnSidecars, err := verifyDataColumnSidecarsByPeer(params.P2P, params.NewVerifier, roDataColumnsByPeer)
verifiedRoDataColumnSidecars, err := verifyDataColumnSidecarsByPeer(params.P2P, params.NewVerifier, roBlockByRoot, roDataColumnsByPeer)
if err != nil {
return nil, errors.Wrap(err, "verify data columns sidecars by peer")
}
@@ -300,7 +300,7 @@ func requestDirectSidecarsFromPeers(
}
// Compute indices by root by peers with the updated missing indices and connected peers.
indicesByRootByPeer, err = computeIndicesByRootByPeer(params.P2P, slotByRoot, missingIndicesByRoot, connectedPeers)
indicesByRootByPeer, err = computeIndicesByRootByPeer(params.P2P, roBlockByRoot, missingIndicesByRoot, connectedPeers)
if err != nil {
return nil, errors.Wrap(err, "explore peers")
}
@@ -323,7 +323,7 @@ func requestDirectSidecarsFromPeers(
// - all peers are exhausted.
func requestIndirectSidecarsFromPeers(
p DataColumnSidecarsParams,
slotByRoot map[[fieldparams.RootLength]byte]primitives.Slot,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
slotsWithCommitments map[primitives.Slot]bool,
storedIndicesByRoot map[[fieldparams.RootLength]byte]map[uint64]bool,
alreadyAvailableByRoot map[[fieldparams.RootLength]byte][]blocks.VerifiedRODataColumn,
@@ -370,7 +370,7 @@ func requestIndirectSidecarsFromPeers(
}
// Compute which peers have which of the missing indices.
indicesByRootByPeer, err := computeIndicesByRootByPeer(p.P2P, slotByRoot, indicesToRetrieveByRoot, connectedPeers)
indicesByRootByPeer, err := computeIndicesByRootByPeer(p.P2P, roBlockByRoot, indicesToRetrieveByRoot, connectedPeers)
if err != nil {
return nil, errors.Wrap(err, "explore peers")
}
@@ -395,10 +395,10 @@ func requestIndirectSidecarsFromPeers(
}
// Fetch the sidecars from the chosen peers.
roDataColumnsByPeer := fetchDataColumnSidecarsFromPeers(p, slotByRoot, slotsWithCommitments, indicesByRootByPeerToQuery)
roDataColumnsByPeer := fetchDataColumnSidecarsFromPeers(p, roBlockByRoot, slotsWithCommitments, indicesByRootByPeerToQuery)
// Verify the received data column sidecars.
verifiedRoDataColumnSidecars, err := verifyDataColumnSidecarsByPeer(p.P2P, p.NewVerifier, roDataColumnsByPeer)
verifiedRoDataColumnSidecars, err := verifyDataColumnSidecarsByPeer(p.P2P, p.NewVerifier, roBlockByRoot, roDataColumnsByPeer)
if err != nil {
return nil, errors.Wrap(err, "verify data columns sidecars by peer")
}
@@ -436,7 +436,7 @@ func requestIndirectSidecarsFromPeers(
}
// Compute indices by root by peers with the updated missing indices and connected peers.
indicesByRootByPeer, err = computeIndicesByRootByPeer(p.P2P, slotByRoot, indicesToRetrieveByRoot, connectedPeers)
indicesByRootByPeer, err = computeIndicesByRootByPeer(p.P2P, roBlockByRoot, indicesToRetrieveByRoot, connectedPeers)
if err != nil {
return nil, errors.Wrap(err, "explore peers")
}
@@ -709,7 +709,7 @@ func updateResults(
// fetchDataColumnSidecarsFromPeers retrieves data column sidecars from peers.
func fetchDataColumnSidecarsFromPeers(
params DataColumnSidecarsParams,
slotByRoot map[[fieldparams.RootLength]byte]primitives.Slot,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
slotsWithCommitments map[primitives.Slot]bool,
indicesByRootByPeer map[goPeer.ID]map[[fieldparams.RootLength]byte]map[uint64]bool,
) map[goPeer.ID][]blocks.RODataColumn {
@@ -736,7 +736,7 @@ func fetchDataColumnSidecarsFromPeers(
"totalRequestedCount": requestedCount,
})
roDataColumns, err := sendDataColumnSidecarsRequest(params, slotByRoot, slotsWithCommitments, peerID, indicesByRoot)
roDataColumns, err := sendDataColumnSidecarsRequest(params, roBlockByRoot, slotsWithCommitments, peerID, indicesByRoot)
if err != nil {
log.WithError(err).Debug("Failed to send data column sidecars request")
return
@@ -755,7 +755,7 @@ func fetchDataColumnSidecarsFromPeers(
func sendDataColumnSidecarsRequest(
params DataColumnSidecarsParams,
slotByRoot map[[fieldparams.RootLength]byte]primitives.Slot,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
slotsWithCommitments map[primitives.Slot]bool,
peerID goPeer.ID,
indicesByRoot map[[fieldparams.RootLength]byte]map[uint64]bool,
@@ -775,7 +775,7 @@ func sendDataColumnSidecarsRequest(
})
// Try to build a by range byRangeRequest first.
byRangeRequests, err := buildByRangeRequests(slotByRoot, slotsWithCommitments, indicesByRoot, batchSize)
byRangeRequests, err := buildByRangeRequests(roBlockByRoot, slotsWithCommitments, indicesByRoot, batchSize)
if err != nil {
return nil, errors.Wrap(err, "craft by range request")
}
@@ -854,7 +854,7 @@ func sendDataColumnSidecarsRequest(
// (Missing blocks or blocks without commitments do count as contiguous)
// If one of this condition is not met, returns nil.
func buildByRangeRequests(
slotByRoot map[[fieldparams.RootLength]byte]primitives.Slot,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
slotsWithCommitments map[primitives.Slot]bool,
indicesByRoot map[[fieldparams.RootLength]byte]map[uint64]bool,
batchSize uint64,
@@ -864,7 +864,7 @@ func buildByRangeRequests(
}
var reference map[uint64]bool
slots := make([]primitives.Slot, 0, len(slotByRoot))
slots := make([]primitives.Slot, 0, len(roBlockByRoot))
for root, indices := range indicesByRoot {
if reference == nil {
reference = indices
@@ -874,12 +874,12 @@ func buildByRangeRequests(
return nil, nil
}
slot, ok := slotByRoot[root]
roBlock, ok := roBlockByRoot[root]
if !ok {
return nil, errors.Errorf("slot not found for block root %#x", root)
}
slots = append(slots, slot)
slots = append(slots, roBlock.Block().Slot())
}
slices.Sort(slots)
@@ -944,6 +944,7 @@ func buildByRootRequest(indicesByRoot map[[fieldparams.RootLength]byte]map[uint6
func verifyDataColumnSidecarsByPeer(
p2p prysmP2P.P2P,
newVerifier verification.NewDataColumnsVerifier,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
roDataColumnsByPeer map[goPeer.ID][]blocks.RODataColumn,
) ([]blocks.VerifiedRODataColumn, error) {
// First optimistically verify all received data columns in a single batch.
@@ -957,7 +958,7 @@ func verifyDataColumnSidecarsByPeer(
roDataColumnSidecars = append(roDataColumnSidecars, columns...)
}
verifiedRoDataColumnSidecars, err := verifyByRootDataColumnSidecars(newVerifier, roDataColumnSidecars)
verifiedRoDataColumnSidecars, err := verifyRPCDataColumnSidecars(newVerifier, roBlockByRoot, roDataColumnSidecars)
if err == nil {
// This is the happy path where all sidecars are verified.
return verifiedRoDataColumnSidecars, nil
@@ -967,7 +968,7 @@ func verifyDataColumnSidecarsByPeer(
// Reverify peer by peer to identify faulty peer(s), reject all its sidecars, and downscore it.
verifiedRoDataColumnSidecars = make([]blocks.VerifiedRODataColumn, 0, count)
for peer, columns := range roDataColumnsByPeer {
peerVerifiedRoDataColumnSidecars, err := verifyByRootDataColumnSidecars(newVerifier, columns)
peerVerifiedRoDataColumnSidecars, err := verifyRPCDataColumnSidecars(newVerifier, roBlockByRoot, columns)
if err != nil {
// This peer has invalid sidecars.
log := log.WithError(err).WithField("peerID", peer)
@@ -982,15 +983,23 @@ func verifyDataColumnSidecarsByPeer(
return verifiedRoDataColumnSidecars, nil
}
// verifyByRootDataColumnSidecars verifies the provided read-only data columns against the
// verifyRPCDataColumnSidecars verifies the provided read-only data columns against the
// requirements for data column sidecars received via the by root request.
func verifyByRootDataColumnSidecars(newVerifier verification.NewDataColumnsVerifier, roDataColumns []blocks.RODataColumn) ([]blocks.VerifiedRODataColumn, error) {
verifier := newVerifier(roDataColumns, verification.ByRootRequestDataColumnSidecarRequirements)
func verifyRPCDataColumnSidecars(
newVerifier verification.NewDataColumnsVerifier,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
roDataColumns []blocks.RODataColumn,
) ([]blocks.VerifiedRODataColumn, error) {
verifier := newVerifier(roDataColumns, verification.RPCDataColumnSidecarRequirements)
if err := verifier.ValidFields(); err != nil {
return nil, errors.Wrap(err, "valid fields")
}
if err := verifier.SidecarRootAndSignatureAligned(roBlockByRoot); err != nil {
return nil, errors.Wrap(err, "sidecar root and signature aligned")
}
if err := verifier.SidecarInclusionProven(); err != nil {
return nil, errors.Wrap(err, "sidecar inclusion proven")
}
@@ -1008,12 +1017,12 @@ func verifyByRootDataColumnSidecars(newVerifier verification.NewDataColumnsVerif
}
// computeIndicesByRootByPeer returns a peers->root->indices map only for
// root and indices given in `indicesByBlockRoot`. It also only selects peers
// root and indices given in `indicesByRoot`. It also only selects peers
// for a given root only if its head state is higher than the block slot.
func computeIndicesByRootByPeer(
p2p prysmP2P.P2P,
slotByBlockRoot map[[fieldparams.RootLength]byte]primitives.Slot,
indicesByBlockRoot map[[fieldparams.RootLength]byte]map[uint64]bool,
roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock,
indicesByRoot map[[fieldparams.RootLength]byte]map[uint64]bool,
peers map[goPeer.ID]bool,
) (map[goPeer.ID]map[[fieldparams.RootLength]byte]map[uint64]bool, error) {
slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch
@@ -1065,10 +1074,10 @@ func computeIndicesByRootByPeer(
// For each block root and its indices, find suitable peers
indicesByRootByPeer := make(map[goPeer.ID]map[[fieldparams.RootLength]byte]map[uint64]bool)
for blockRoot, indices := range indicesByBlockRoot {
blockSlot, ok := slotByBlockRoot[blockRoot]
for root, indices := range indicesByRoot {
roBlock, ok := roBlockByRoot[root]
if !ok {
return nil, errors.Errorf("slot not found for block root %#x", blockRoot)
return nil, errors.Errorf("slot not found for block root %#x", root)
}
for index := range indices {
@@ -1079,7 +1088,7 @@ func computeIndicesByRootByPeer(
return nil, errors.Errorf("head slot not found for peer %s", peer)
}
if peerHeadSlot < blockSlot {
if peerHeadSlot < roBlock.Block().Slot() {
continue
}
@@ -1087,10 +1096,10 @@ func computeIndicesByRootByPeer(
if _, exists := indicesByRootByPeer[peer]; !exists {
indicesByRootByPeer[peer] = make(map[[fieldparams.RootLength]byte]map[uint64]bool)
}
if _, exists := indicesByRootByPeer[peer][blockRoot]; !exists {
indicesByRootByPeer[peer][blockRoot] = make(map[uint64]bool)
if _, exists := indicesByRootByPeer[peer][root]; !exists {
indicesByRootByPeer[peer][root] = make(map[uint64]bool)
}
indicesByRootByPeer[peer][blockRoot][index] = true
indicesByRootByPeer[peer][root][index] = true
}
}
}

View File

@@ -400,12 +400,12 @@ func TestFetchDataColumnSidecarsFromPeers(t *testing.T) {
expectedResponseSidecar, err := blocks.NewRODataColumn(expectedResponseSidecarPb)
require.NoError(t, err)
slotByRoot := map[[fieldparams.RootLength]byte]primitives.Slot{
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
{1}: 1,
{3}: 3,
{4}: 4,
{7}: 7,
}
})
slotsWithCommitments := map[primitives.Slot]bool{
1: true,
@@ -458,7 +458,7 @@ func TestFetchDataColumnSidecarsFromPeers(t *testing.T) {
other.PeerID(): {expectedResponseSidecar},
}
actualResponse := fetchDataColumnSidecarsFromPeers(params, slotByRoot, slotsWithCommitments, indicesByRootByPeer)
actualResponse := fetchDataColumnSidecarsFromPeers(params, roBlockByRoot, slotsWithCommitments, indicesByRootByPeer)
require.Equal(t, len(expectedResponse), len(actualResponse))
for peerID := range expectedResponse {
@@ -508,12 +508,12 @@ func TestSendDataColumnSidecarsRequest(t *testing.T) {
{7}: {1: true, 2: true},
}
slotByRoot := map[[fieldparams.RootLength]byte]primitives.Slot{
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
{1}: 1,
{3}: 3,
{4}: 4,
{7}: 7,
}
})
slotsWithCommitments := map[primitives.Slot]bool{
1: true,
@@ -553,7 +553,7 @@ func TestSendDataColumnSidecarsRequest(t *testing.T) {
RateLimiter: leakybucket.NewCollector(1., 1, time.Second, false /* deleteEmptyBuckets */),
}
actualResponse, err := sendDataColumnSidecarsRequest(params, slotByRoot, slotsWithCommitments, other.PeerID(), indicesByRoot)
actualResponse, err := sendDataColumnSidecarsRequest(params, roBlockByRoot, slotsWithCommitments, other.PeerID(), indicesByRoot)
require.NoError(t, err)
require.DeepEqual(t, expectedResponse, actualResponse[0])
})
@@ -565,11 +565,11 @@ func TestSendDataColumnSidecarsRequest(t *testing.T) {
{7}: {1: true, 2: true},
}
slotByRoot := map[[fieldparams.RootLength]byte]primitives.Slot{
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
expectedResponse.BlockRoot(): 1,
{4}: 4,
{7}: 7,
}
})
slotsWithCommitments := map[primitives.Slot]bool{
1: true,
@@ -620,7 +620,7 @@ func TestSendDataColumnSidecarsRequest(t *testing.T) {
RateLimiter: leakybucket.NewCollector(1., 1, time.Second, false /* deleteEmptyBuckets */),
}
actualResponse, err := sendDataColumnSidecarsRequest(params, slotByRoot, slotsWithCommitments, other.PeerID(), indicesByRoot)
actualResponse, err := sendDataColumnSidecarsRequest(params, roBlockByRoot, slotsWithCommitments, other.PeerID(), indicesByRoot)
require.NoError(t, err)
require.DeepEqual(t, expectedResponse, actualResponse[0])
})
@@ -652,13 +652,13 @@ func TestBuildByRangeRequests(t *testing.T) {
{3}: {2: true, 3: true},
}
slotByRoot := map[[fieldparams.RootLength]byte]primitives.Slot{
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
{1}: 1,
{2}: 2,
{3}: 3,
}
})
actual, err := buildByRangeRequests(slotByRoot, nil, indicesByRoot, nullBatchSize)
actual, err := buildByRangeRequests(roBlockByRoot, nil, indicesByRoot, nullBatchSize)
require.NoError(t, err)
require.Equal(t, 0, len(actual))
})
@@ -669,10 +669,10 @@ func TestBuildByRangeRequests(t *testing.T) {
{2}: {1: true, 2: true},
}
slotByRoot := map[[fieldparams.RootLength]byte]primitives.Slot{
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
{1}: 1,
{2}: 3,
}
})
slotsWithCommitments := map[primitives.Slot]bool{
1: true,
@@ -680,7 +680,7 @@ func TestBuildByRangeRequests(t *testing.T) {
3: true,
}
actual, err := buildByRangeRequests(slotByRoot, slotsWithCommitments, indicesByRoot, nullBatchSize)
actual, err := buildByRangeRequests(roBlockByRoot, slotsWithCommitments, indicesByRoot, nullBatchSize)
require.NoError(t, err)
require.Equal(t, 0, len(actual))
})
@@ -695,12 +695,12 @@ func TestBuildByRangeRequests(t *testing.T) {
{7}: {1: true, 2: true},
}
slotByRoot := map[[fieldparams.RootLength]byte]primitives.Slot{
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
{1}: 1,
{3}: 3,
{4}: 4,
{7}: 7,
}
})
slotsWithCommitments := map[primitives.Slot]bool{
1: true,
@@ -727,7 +727,7 @@ func TestBuildByRangeRequests(t *testing.T) {
},
}
actual, err := buildByRangeRequests(slotByRoot, slotsWithCommitments, indicesByRoot, batchSize)
actual, err := buildByRangeRequests(roBlockByRoot, slotsWithCommitments, indicesByRoot, batchSize)
require.NoError(t, err)
require.DeepEqual(t, expected, actual)
})
@@ -792,7 +792,12 @@ func TestVerifyDataColumnSidecarsByPeer(t *testing.T) {
require.NoError(t, err)
newDataColumnsVerifier := newDataColumnsVerifierFromInitializer(initializer)
actual, err := verifyDataColumnSidecarsByPeer(p2p, newDataColumnsVerifier, roDataColumnsByPeer)
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
roDataColumnSidecars[0].BlockRoot(): roDataColumnSidecars[0].Slot(),
})
actual, err := verifyDataColumnSidecarsByPeer(p2p, newDataColumnsVerifier, roBlockByRoot, roDataColumnsByPeer)
require.NoError(t, err)
require.Equal(t, stop-start, len(actual))
@@ -837,7 +842,12 @@ func TestVerifyDataColumnSidecarsByPeer(t *testing.T) {
require.NoError(t, err)
newDataColumnsVerifier := newDataColumnsVerifierFromInitializer(initializer)
actual, err := verifyDataColumnSidecarsByPeer(p2p, newDataColumnsVerifier, roDataColumnsByPeer)
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
roDataColumnSidecars[0].BlockRoot(): roDataColumnSidecars[0].Slot(),
})
actual, err := verifyDataColumnSidecarsByPeer(p2p, newDataColumnsVerifier, roBlockByRoot, roDataColumnsByPeer)
require.NoError(t, err)
require.Equal(t, middle-start, len(actual))
@@ -881,34 +891,34 @@ func TestComputeIndicesByRootByPeer(t *testing.T) {
peerIDs = append(peerIDs, peerID)
}
slotByBlockRoot := map[[fieldparams.RootLength]byte]primitives.Slot{
[fieldparams.RootLength]byte{1}: 8,
[fieldparams.RootLength]byte{2}: 10,
[fieldparams.RootLength]byte{3}: 9,
[fieldparams.RootLength]byte{4}: 50,
}
roBlockByRoot := createRoBlockByRoot(t, map[[fieldparams.RootLength]byte]primitives.Slot{
{1}: 8,
{2}: 10,
{3}: 9,
{4}: 50,
})
indicesByBlockRoot := map[[fieldparams.RootLength]byte]map[uint64]bool{
[fieldparams.RootLength]byte{1}: {3: true, 4: true, 5: true},
[fieldparams.RootLength]byte{2}: {1: true, 10: true, 37: true, 80: true},
[fieldparams.RootLength]byte{3}: {10: true, 38: true, 39: true, 40: true},
[fieldparams.RootLength]byte{4}: {89: true, 108: true, 122: true},
{1}: {3: true, 4: true, 5: true},
{2}: {1: true, 10: true, 37: true, 80: true},
{3}: {10: true, 38: true, 39: true, 40: true},
{4}: {89: true, 108: true, 122: true},
}
expected := map[peer.ID]map[[fieldparams.RootLength]byte]map[uint64]bool{
peerIDs[0]: {
[fieldparams.RootLength]byte{4}: {89: true, 122: true},
{4}: {89: true, 122: true},
},
peerIDs[1]: {
[fieldparams.RootLength]byte{2}: {1: true, 37: true},
{2}: {1: true, 37: true},
},
peerIDs[2]: {
[fieldparams.RootLength]byte{2}: {37: true},
[fieldparams.RootLength]byte{3}: {38: true},
{2}: {37: true},
{3}: {38: true},
},
peerIDs[3]: {
[fieldparams.RootLength]byte{2}: {10: true},
[fieldparams.RootLength]byte{3}: {10: true},
{2}: {10: true},
{3}: {10: true},
},
}
@@ -917,7 +927,7 @@ func TestComputeIndicesByRootByPeer(t *testing.T) {
peerIDsMap[id] = true
}
actual, err := computeIndicesByRootByPeer(p2p, slotByBlockRoot, indicesByBlockRoot, peerIDsMap)
actual, err := computeIndicesByRootByPeer(p2p, roBlockByRoot, indicesByBlockRoot, peerIDsMap)
require.NoError(t, err)
require.Equal(t, len(expected), len(actual))
@@ -1023,3 +1033,20 @@ func TestComputeTotalCount(t *testing.T) {
actual := computeTotalCount(input)
require.Equal(t, expected, actual)
}
func createRoBlockByRoot(t *testing.T, slotByRoot map[[fieldparams.RootLength]byte]primitives.Slot) map[[fieldparams.RootLength]byte]blocks.ROBlock {
roBlockByRoot := make(map[[fieldparams.RootLength]byte]blocks.ROBlock, len(slotByRoot))
for root, slot := range slotByRoot {
signedBeaconBlockPb := util.NewBeaconBlock()
signedBeaconBlockPb.Block.Slot = slot
signedBeaconBlock, err := blocks.NewSignedBeaconBlock(signedBeaconBlockPb)
require.NoError(t, err)
roBlock, err := blocks.NewROBlockWithRoot(signedBeaconBlock, root)
require.NoError(t, err)
roBlockByRoot[root] = roBlock
}
return roBlockByRoot
}

View File

@@ -214,7 +214,7 @@ var (
prometheus.HistogramOpts{
Name: "beacon_data_column_sidecar_gossip_verification_milliseconds",
Help: "Captures the time taken to verify data column sidecars.",
Buckets: []float64{100, 250, 500, 750, 1000, 1500, 2000, 4000, 8000, 12000, 16000},
Buckets: []float64{2, 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2000},
},
)

View File

@@ -8,6 +8,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/async/abool"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/feed"
@@ -36,7 +37,6 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/libp2p/go-libp2p/core/network"
"github.com/prysmaticlabs/go-bitfield"
logTest "github.com/sirupsen/logrus/hooks/test"
)

View File

@@ -3,6 +3,7 @@ package sync
import (
"context"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/types"
"github.com/OffchainLabs/prysm/v6/config/params"
@@ -14,7 +15,6 @@ import (
libp2pcore "github.com/libp2p/go-libp2p/core"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
)
// metaDataHandler reads the incoming metadata RPC request from the peer.

View File

@@ -6,6 +6,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
db "github.com/OffchainLabs/prysm/v6/beacon-chain/db/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p"
@@ -24,7 +25,6 @@ import (
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/protocol"
libp2pquic "github.com/libp2p/go-libp2p/p2p/transport/quic"
"github.com/prysmaticlabs/go-bitfield"
)
func TestMetaDataRPCHandler_ReceivesMetadata(t *testing.T) {

View File

@@ -12,8 +12,6 @@ import (
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p"
p2ptest "github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/types"
p2pTypes "github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/types"
p2ptypes "github.com/OffchainLabs/prysm/v6/beacon-chain/p2p/types"
"github.com/OffchainLabs/prysm/v6/beacon-chain/startup"
"github.com/OffchainLabs/prysm/v6/beacon-chain/verification"
fieldparams "github.com/OffchainLabs/prysm/v6/config/fieldparams"
@@ -80,7 +78,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) {
}
_, err := stream.Write([]byte{0x01})
assert.NoError(t, err)
msg := p2pTypes.ErrorMessage(processorErr.Error())
msg := types.ErrorMessage(processorErr.Error())
_, err = p2pProvider.Encoding().EncodeWithMaxLength(stream, &msg)
assert.NoError(t, err)
return
@@ -323,7 +321,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
bogusPeer := p2ptest.NewTestP2P(t)
p1.Connect(bogusPeer)
req := &p2pTypes.BeaconBlockByRootsReq{}
req := &types.BeaconBlockByRootsReq{}
_, err := SendBeaconBlocksByRootRequest(ctx, startup.NewClock(time.Now(), [32]byte{}), p1, bogusPeer.PeerID(), req, nil)
assert.ErrorContains(t, "protocols not supported", err)
})
@@ -334,7 +332,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
assert.NoError(t, stream.Close())
}()
req := new(p2pTypes.BeaconBlockByRootsReq)
req := new(types.BeaconBlockByRootsReq)
assert.NoError(t, p2pProvider.Encoding().DecodeWithMaxLength(stream, req))
if len(*req) == 0 {
return
@@ -351,7 +349,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
}
_, err := stream.Write([]byte{0x01})
assert.NoError(t, err)
msg := p2pTypes.ErrorMessage(processorErr.Error())
msg := types.ErrorMessage(processorErr.Error())
_, err = p2pProvider.Encoding().EncodeWithMaxLength(stream, &msg)
assert.NoError(t, err)
return
@@ -372,7 +370,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
p1.Connect(p2)
p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil))
req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]}
req := &types.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]}
blocks, err := SendBeaconBlocksByRootRequest(ctx, startup.NewClock(time.Now(), [32]byte{}), p1, p2.PeerID(), req, nil)
assert.NoError(t, err)
assert.Equal(t, 2, len(blocks))
@@ -385,7 +383,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil))
// No error from block processor.
req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]}
req := &types.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]}
blocksFromProcessor := make([]interfaces.ReadOnlySignedBeaconBlock, 0)
blocks, err := SendBeaconBlocksByRootRequest(ctx, startup.NewClock(time.Now(), [32]byte{}), p1, p2.PeerID(), req, func(block interfaces.ReadOnlySignedBeaconBlock) error {
blocksFromProcessor = append(blocksFromProcessor, block)
@@ -403,7 +401,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil))
// Send error from block processor.
req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]}
req := &types.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]}
errFromProcessor := errors.New("processor error")
_, err := SendBeaconBlocksByRootRequest(ctx, startup.NewClock(time.Now(), [32]byte{}), p1, p2.PeerID(), req, func(block interfaces.ReadOnlySignedBeaconBlock) error {
return errFromProcessor
@@ -418,7 +416,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
p2.SetStreamHandler(pcl, knownBlocksProvider(p2, nil))
// No cap on max roots.
req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1], knownRoots[2], knownRoots[3]}
req := &types.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1], knownRoots[2], knownRoots[3]}
clock := startup.NewClock(time.Now(), [32]byte{})
blocks, err := SendBeaconBlocksByRootRequest(ctx, clock, p1, p2.PeerID(), req, nil)
assert.NoError(t, err)
@@ -457,7 +455,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
return nil
}))
req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1], knownRoots[2], knownRoots[3]}
req := &types.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1], knownRoots[2], knownRoots[3]}
blocks, err := SendBeaconBlocksByRootRequest(ctx, startup.NewClock(time.Now(), [32]byte{}), p1, p2.PeerID(), req, nil)
assert.ErrorContains(t, expectedErr.Error(), err)
assert.Equal(t, 0, len(blocks))
@@ -477,7 +475,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) {
return nil
}))
req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1], knownRoots[2], knownRoots[3]}
req := &types.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1], knownRoots[2], knownRoots[3]}
blocks, err := SendBeaconBlocksByRootRequest(ctx, startup.NewClock(time.Now(), [32]byte{}), p1, p2.PeerID(), req, nil)
assert.NoError(t, err)
assert.Equal(t, 3, len(blocks))
@@ -520,7 +518,7 @@ func TestBlobValidatorFromRootReq(t *testing.T) {
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
r := p2pTypes.BlobSidecarsByRootReq(c.ids)
r := types.BlobSidecarsByRootReq(c.ids)
vf := blobValidatorFromRootReq(&r)
for _, sc := range c.response {
err := vf(sc)
@@ -1201,7 +1199,7 @@ func TestSendDataColumnSidecarsByRootRequest(t *testing.T) {
require.NoError(t, err)
nilTestCases := []struct {
name string
request p2ptypes.DataColumnsByRootIdentifiers
request types.DataColumnsByRootIdentifiers
}{
{
name: "nil request",
@@ -1209,7 +1207,7 @@ func TestSendDataColumnSidecarsByRootRequest(t *testing.T) {
},
{
name: "count is 0",
request: p2ptypes.DataColumnsByRootIdentifiers{{}, {}},
request: types.DataColumnsByRootIdentifiers{{}, {}},
},
}
@@ -1227,7 +1225,7 @@ func TestSendDataColumnSidecarsByRootRequest(t *testing.T) {
cfg.MaxRequestDataColumnSidecars = 4
params.OverrideBeaconConfig(cfg)
request := p2ptypes.DataColumnsByRootIdentifiers{
request := types.DataColumnsByRootIdentifiers{
{Columns: []uint64{1, 2, 3}},
{Columns: []uint64{4, 5, 6}},
}
@@ -1324,7 +1322,7 @@ func TestSendDataColumnSidecarsByRootRequest(t *testing.T) {
blockRoot1, blockRoot2 := expected[0].BlockRoot(), expected[3].BlockRoot()
sentRequest := p2ptypes.DataColumnsByRootIdentifiers{
sentRequest := types.DataColumnsByRootIdentifiers{
{BlockRoot: blockRoot1[:], Columns: []uint64{1, 2, 3}},
{BlockRoot: blockRoot2[:], Columns: []uint64{1, 2, 3}},
}
@@ -1335,7 +1333,7 @@ func TestSendDataColumnSidecarsByRootRequest(t *testing.T) {
p2.SetStreamHandler(protocol, func(stream network.Stream) {
wg.Done()
requestReceived := new(p2ptypes.DataColumnsByRootIdentifiers)
requestReceived := new(types.DataColumnsByRootIdentifiers)
err := p2.Encoding().DecodeWithMaxLength(stream, requestReceived)
assert.NoError(t, err)

View File

@@ -3,6 +3,7 @@ package sync
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/operations/attestations"
lruwrpr "github.com/OffchainLabs/prysm/v6/cache/lru"
@@ -11,7 +12,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/assert"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/prysmaticlabs/go-bitfield"
)
func TestBeaconAggregateProofSubscriber_CanSaveAggregatedAttestation(t *testing.T) {

View File

@@ -3,6 +3,7 @@ package sync
import (
"testing"
"github.com/OffchainLabs/go-bitfield"
"github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain"
"github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/kzg"
chainMock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
@@ -23,7 +24,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/util"
"github.com/OffchainLabs/prysm/v6/time"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
"google.golang.org/protobuf/proto"
)

View File

@@ -7,6 +7,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -29,7 +30,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/util"
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/prysmaticlabs/go-bitfield"
)
func TestVerifyIndexInCommittee_CanVerify(t *testing.T) {

View File

@@ -16,6 +16,7 @@ import (
"github.com/OffchainLabs/prysm/v6/beacon-chain/p2p"
"github.com/OffchainLabs/prysm/v6/beacon-chain/slasher/types"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/config/params"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
"github.com/OffchainLabs/prysm/v6/monitoring/tracing"
@@ -67,7 +68,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
return pubsub.ValidationReject, errWrongMessage
}
if err := helpers.ValidateNilAttestation(att); err != nil {
return pubsub.ValidationReject, err
return pubsub.ValidationReject, wrapAttestationError(err, att)
}
data := att.GetData()
@@ -84,7 +85,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
return pubsub.ValidationIgnore, err
}
if err := helpers.ValidateSlotTargetEpoch(data); err != nil {
return pubsub.ValidationReject, err
return pubsub.ValidationReject, wrapAttestationError(err, att)
}
committeeIndex := att.GetCommitteeIndex()
@@ -106,7 +107,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
s.hasBadBlock(bytesutil.ToBytes32(data.Target.Root)) ||
s.hasBadBlock(bytesutil.ToBytes32(data.Source.Root)) {
attBadBlockCount.Inc()
return pubsub.ValidationReject, errors.New("attestation data references bad block root")
return pubsub.ValidationReject, wrapAttestationError(errors.New("attestation data references bad block root"), att)
}
}
@@ -126,7 +127,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
if err = s.cfg.chain.VerifyLmdFfgConsistency(ctx, att); err != nil {
tracing.AnnotateError(span, err)
attBadLmdConsistencyCount.Inc()
return pubsub.ValidationReject, err
return pubsub.ValidationReject, wrapAttestationError(err, att)
}
preState, err := s.cfg.chain.AttestationTargetState(ctx, data.Target)
@@ -137,7 +138,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
validationRes, err := s.validateUnaggregatedAttTopic(ctx, att, preState, *msg.Topic)
if validationRes != pubsub.ValidationAccept {
return validationRes, err
return validationRes, wrapAttestationError(err, att)
}
committee, err := helpers.BeaconCommitteeFromState(ctx, preState, data.Slot, committeeIndex)
@@ -148,7 +149,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
validationRes, err = validateAttesterData(ctx, att, committee)
if validationRes != pubsub.ValidationAccept {
return validationRes, err
return validationRes, wrapAttestationError(err, att)
}
// Consolidated handling of Electra SingleAttestation vs Phase0 unaggregated attestation
@@ -183,7 +184,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
validationRes, err = s.validateUnaggregatedAttWithState(ctx, attForValidation, preState)
if validationRes != pubsub.ValidationAccept {
return validationRes, err
return validationRes, wrapAttestationError(err, att)
}
if s.slasherEnabled {
@@ -339,7 +340,7 @@ func validateAttestingIndex(
// `attestation.attester_index in get_beacon_committee(state, attestation.data.slot, index)`.
inCommittee := slices.Contains(committee, attestingIndex)
if !inCommittee {
return pubsub.ValidationReject, errors.New("attester is not a member of the committee")
return pubsub.ValidationReject, errors.Errorf("attester %d is not a member of the committee", attestingIndex)
}
return pubsub.ValidationAccept, nil
@@ -392,3 +393,24 @@ func (s *Service) hasBlockAndState(ctx context.Context, blockRoot [32]byte) bool
hasState := hasStateSummary || s.cfg.beaconDB.HasState(ctx, blockRoot)
return hasState && s.cfg.chain.HasBlock(ctx, blockRoot)
}
func wrapAttestationError(err error, att eth.Att) error {
slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch
committeeIndex := att.GetCommitteeIndex()
attData := att.GetData()
slot := attData.Slot
slotInEpoch := slot % slotsPerEpoch
oldCommitteeIndex := attData.CommitteeIndex
blockRoot := fmt.Sprintf("%#x", attData.BeaconBlockRoot)
sourceRoot := fmt.Sprintf("%#x", attData.Source.Root)
sourceEpoch := attData.Source.Epoch
targetEpoch := attData.Target.Epoch
targetRoot := fmt.Sprintf("%#x", attData.Target.Root)
return errors.Wrapf(
err,
"attSlot: %d, attSlotInEpoch: %d, attOldCommitteeIndex: %d, attCommitteeIndex: %d, attBlockRoot: %s, attSource: {root: %s, epoch: %d}, attTarget: {root: %s, epoch: %d}",
slot, slotInEpoch, oldCommitteeIndex, committeeIndex, blockRoot, sourceRoot, sourceEpoch, targetRoot, targetEpoch,
)
}

View File

@@ -7,6 +7,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mockChain "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
@@ -25,7 +26,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/util"
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/prysmaticlabs/go-bitfield"
)
func TestService_validateCommitteeIndexBeaconAttestation(t *testing.T) {

View File

@@ -8,6 +8,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mock "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/signing"
coreTime "github.com/OffchainLabs/prysm/v6/beacon-chain/core/time"
@@ -26,7 +27,6 @@ import (
"github.com/OffchainLabs/prysm/v6/testing/require"
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/prysmaticlabs/go-bitfield"
)
func setupValidProposerSlashing(t *testing.T) (*ethpb.ProposerSlashing, state.BeaconState) {

View File

@@ -6,6 +6,7 @@ import (
"testing"
"time"
"github.com/OffchainLabs/go-bitfield"
mockChain "github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain/testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/altair"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/feed"
@@ -38,7 +39,6 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/prysmaticlabs/go-bitfield"
)
func TestService_ValidateSyncContributionAndProof(t *testing.T) {

View File

@@ -44,6 +44,7 @@ go_library(
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_spf13_afero//:go_default_library",
"@org_golang_x_sync//singleflight:go_default_library",
],
)

View File

@@ -30,6 +30,7 @@ const (
// Data columns specific.
RequireValidFields
RequireCorrectSubnet
RequireSidecarRootAndSignatureAligned
)
var allBlobSidecarRequirements = []Requirement{

View File

@@ -50,6 +50,10 @@ type signatureData struct {
Slot primitives.Slot
}
func (d signatureData) concat() string {
return string(d.Root[:]) + string(d.Signature[:])
}
func (d signatureData) logFields() logrus.Fields {
return logrus.Fields{
"root": fmt.Sprintf("%#x", d.Root),

View File

@@ -21,6 +21,18 @@ func testSignedBlockBlobKeys(t *testing.T, valRoot []byte, slot primitives.Slot,
return block, blobs, sks[0], pks[0]
}
func TestSignatureDataString(t *testing.T) {
const expected = "\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
sigData := signatureData{
Root: [32]byte{1, 2, 3},
Signature: [96]byte{4, 5, 6},
}
actual := sigData.concat()
require.Equal(t, expected, actual)
}
func TestVerifySignature(t *testing.T) {
valRoot := [32]byte{}
_, blobs, _, pk := testSignedBlockBlobKeys(t, valRoot[:], 0, 1)

View File

@@ -39,22 +39,15 @@ var (
RequireSidecarProposerExpected,
}
// ByRangeRequestDataColumnSidecarRequirements defines the set of requirements that DataColumnSidecars received
// via the by range request must satisfy in order to upgrade an RODataColumn to a VerifiedRODataColumn.
// https://github.com/ethereum/consensus-specs/blob/master/specs/fulu/p2p-interface.md#datacolumnsidecarsbyrange-v1
ByRangeRequestDataColumnSidecarRequirements = []Requirement{
RequireValidFields,
RequireSidecarInclusionProven,
RequireSidecarKzgProofVerified,
}
// ByRootRequestDataColumnSidecarRequirements defines the set of requirements that DataColumnSidecars received
// via the by root request must satisfy in order to upgrade an RODataColumn to a VerifiedRODataColumn.
// RPCDataColumnSidecarRequirements defines the set of requirements that DataColumnSidecars received
// via RPC request must satisfy in order to upgrade an RODataColumn to a VerifiedRODataColumn.
// https://github.com/ethereum/consensus-specs/blob/master/specs/fulu/p2p-interface.md#datacolumnsidecarsbyroot-v1
ByRootRequestDataColumnSidecarRequirements = []Requirement{
// https://github.com/ethereum/consensus-specs/blob/master/specs/fulu/p2p-interface.md#datacolumnsidecarsbyrange-v1
RPCDataColumnSidecarRequirements = []Requirement{
RequireValidFields,
RequireSidecarInclusionProven,
RequireSidecarKzgProofVerified,
RequireSidecarRootAndSignatureAligned,
}
// SpectestDataColumnSidecarRequirements is used by the forkchoice spectests when verifying data columns used in the on_block tests.
@@ -257,17 +250,25 @@ func (dv *RODataColumnsVerifier) ValidProposerSignature(ctx context.Context) (er
continue
}
columnVerificationProposerSignatureCache.WithLabelValues("miss").Inc()
// Ensure the expensive signature verification is only performed once for
// concurrent requests for the same signature data.
if _, err, _ = dv.sg.Do(signatureData.concat(), func() (any, error) {
columnVerificationProposerSignatureCache.WithLabelValues("miss").Inc()
// Retrieve the parent state.
parentState, err := dv.parentState(ctx, dataColumn)
if err != nil {
return columnErrBuilder(errors.Wrap(err, "parent state"))
}
// Retrieve the parent state.
parentState, err := dv.state(ctx, dataColumn.ParentRoot())
if err != nil {
return nil, columnErrBuilder(errors.Wrap(err, "parent state"))
}
// Full verification, which will subsequently be cached for anything sharing the signature cache.
if err = dv.sc.VerifySignature(signatureData, parentState); err != nil {
return columnErrBuilder(errors.Wrap(err, "verify signature"))
// Full verification, which will subsequently be cached for anything sharing the signature cache.
if err = dv.sc.VerifySignature(signatureData, parentState); err != nil {
return nil, columnErrBuilder(errors.Wrap(err, "verify signature"))
}
return nil, nil
}); err != nil {
return err
}
}
@@ -470,15 +471,25 @@ func (dv *RODataColumnsVerifier) SidecarProposerExpected(ctx context.Context) (e
idx, cached := dv.pc.Proposer(checkpoint, dataColumnSlot)
if !cached {
// Retrieve the parent state.
parentState, err := dv.parentState(ctx, dataColumn)
if err != nil {
return columnErrBuilder(errors.Wrap(err, "parent state"))
}
parentRoot := dataColumn.ParentRoot()
// Ensure the expensive index computation is only performed once for
// concurrent requests for the same signature data.
if _, err, _ := dv.sg.Do(concatRootSlot(parentRoot, dataColumnSlot), func() (any, error) {
// Retrieve the parent state.
parentState, err := dv.state(ctx, parentRoot)
if err != nil {
return nil, columnErrBuilder(errors.Wrap(err, "parent state"))
}
idx, err = dv.pc.ComputeProposer(ctx, parentRoot, dataColumnSlot, parentState)
if err != nil {
return columnErrBuilder(errors.Wrap(err, "compute proposer"))
// Compute the proposer index.
idx, err = dv.pc.ComputeProposer(ctx, parentRoot, dataColumnSlot, parentState)
if err != nil {
return nil, columnErrBuilder(errors.Wrap(err, "compute proposer"))
}
return nil, nil
}); err != nil {
return err
}
}
@@ -490,23 +501,55 @@ func (dv *RODataColumnsVerifier) SidecarProposerExpected(ctx context.Context) (e
return nil
}
// parentState retrieves the parent state of the data column from the cache if possible, else retrieves it from the state by rooter.
func (dv *RODataColumnsVerifier) parentState(ctx context.Context, dataColumn blocks.RODataColumn) (state.BeaconState, error) {
parentRoot := dataColumn.ParentRoot()
func (dv *RODataColumnsVerifier) SidecarRootAndSignatureAligned(roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock) (err error) {
if ok, err := dv.results.cached(RequireSidecarRootAndSignatureAligned); ok {
return err
}
// If the parent root is already in the cache, return it.
if st, ok := dv.stateByRoot[parentRoot]; ok {
defer dv.recordResult(RequireSidecarRootAndSignatureAligned, &err)
for _, dataColumn := range dv.dataColumns {
// Check if we know the corresponding RO block.
root := dataColumn.BlockRoot()
roBlock, ok := roBlockByRoot[root]
if !ok {
return columnErrBuilder(errors.Errorf("no ro block found for data column with root %#x", root))
}
// Check if the signature aligns.
sidecarSignature := bytesutil.ToBytes96(dataColumn.SignedBlockHeader.Signature)
blockSignature := roBlock.Signature()
if sidecarSignature != blockSignature {
return columnErrBuilder(errUnalignedRootAndSignature)
}
// Check if the root aligns.
// Note, this should always be true since we used the root to lookup the RO block.
blockRoot := roBlock.Root()
if root != blockRoot {
return columnErrBuilder(errUnalignedRootAndSignature)
}
}
return nil
}
// state retrieves the state of the corresponding root from the cache if possible, else retrieves it from the state by rooter.
func (dv *RODataColumnsVerifier) state(ctx context.Context, root [fieldparams.RootLength]byte) (state.BeaconState, error) {
// If the root is already in the cache, return it.
if st, ok := dv.stateByRoot[root]; ok {
return st, nil
}
// Retrieve the parent state from the state by rooter.
st, err := dv.sr.StateByRoot(ctx, parentRoot)
// Retrieve the state from the state by rooter.
st, err := dv.sr.StateByRoot(ctx, root)
if err != nil {
return nil, errors.Wrap(err, "state by root")
}
// Store the parent state in the cache.
dv.stateByRoot[parentRoot] = st
// Store the state in the cache.
dv.stateByRoot[root] = st
return st, nil
}
@@ -561,3 +604,7 @@ func inclusionProofKey(c blocks.RODataColumn) ([32]byte, error) {
return sha256.Sum256(unhashedKey), nil
}
func concatRootSlot(root [fieldparams.RootLength]byte, slot primitives.Slot) string {
return string(root[:]) + fmt.Sprintf("%d", slot)
}

View File

@@ -933,6 +933,77 @@ func TestDataColumnsSidecarProposerExpected(t *testing.T) {
}
}
func TestSidecarRootAndSignatureAligned(t *testing.T) {
const (
columnSlot = 1
blobCount = 1
)
parentRoot := [fieldparams.RootLength]byte{}
columns := GenerateTestDataColumns(t, parentRoot, columnSlot, blobCount)
firstColumn := columns[0]
t.Run("unknown block", func(t *testing.T) {
verifier := new(Initializer).NewDataColumnsVerifier(columns, RPCDataColumnSidecarRequirements)
err := verifier.SidecarRootAndSignatureAligned(nil)
require.NotNil(t, err)
})
t.Run("signatures mismatch", func(t *testing.T) {
signedBeaconBlockPb := util.NewBeaconBlock()
originalSignature := firstColumn.SignedBlockHeader.Signature
alteredSignature := make([]byte, len(originalSignature))
copy(alteredSignature, originalSignature)
alteredSignature[0] ^= 0xFF // Alter the signature
signedBeaconBlockPb.Signature = alteredSignature
signedBeaconBlock, err := blocks.NewSignedBeaconBlock(signedBeaconBlockPb)
require.NoError(t, err)
roBlock, err := blocks.NewROBlock(signedBeaconBlock)
require.NoError(t, err)
verifier := new(Initializer).NewDataColumnsVerifier(columns, RPCDataColumnSidecarRequirements)
err = verifier.SidecarRootAndSignatureAligned(map[[fieldparams.RootLength]byte]blocks.ROBlock{
firstColumn.BlockRoot(): roBlock,
})
require.NotNil(t, err)
})
t.Run("roots mismatch", func(t *testing.T) {
signedBeaconBlockPb := util.NewBeaconBlock()
signedBeaconBlock, err := blocks.NewSignedBeaconBlock(signedBeaconBlockPb)
require.NoError(t, err)
roBlock, err := blocks.NewROBlock(signedBeaconBlock)
require.NoError(t, err)
verifier := new(Initializer).NewDataColumnsVerifier(columns, RPCDataColumnSidecarRequirements)
err = verifier.SidecarRootAndSignatureAligned(map[[fieldparams.RootLength]byte]blocks.ROBlock{
firstColumn.BlockRoot(): roBlock,
})
require.NotNil(t, err)
})
t.Run("nominal", func(t *testing.T) {
signedBeaconBlockPb := util.NewBeaconBlock()
signedBeaconBlock, err := blocks.NewSignedBeaconBlock(signedBeaconBlockPb)
require.NoError(t, err)
roBlock, err := blocks.NewROBlockWithRoot(signedBeaconBlock, firstColumn.BlockRoot())
require.NoError(t, err)
verifier := new(Initializer).NewDataColumnsVerifier(columns, RPCDataColumnSidecarRequirements)
err = verifier.SidecarRootAndSignatureAligned(map[[fieldparams.RootLength]byte]blocks.ROBlock{
roBlock.Root(): roBlock,
})
require.NoError(t, err)
})
}
func TestColumnRequirementSatisfaction(t *testing.T) {
const (
columnSlot = 1
@@ -976,3 +1047,13 @@ func TestColumnRequirementSatisfaction(t *testing.T) {
_, err = verifier.VerifiedRODataColumns()
require.NoError(t, err)
}
func TestConcatRootSlot(t *testing.T) {
root := [fieldparams.RootLength]byte{1, 2, 3}
const slot = primitives.Slot(3210)
const expected = "\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x003210"
actual := concatRootSlot(root, slot)
require.Equal(t, expected, actual)
}

View File

@@ -69,6 +69,10 @@ var (
// errBatchBlockRootMismatch is returned by VerifiedROBlobs in the scenario where the root of the given signed block
// does not match the block header in one of the corresponding sidecars.
errBatchBlockRootMismatch = errors.Join(ErrBlobInvalid, errors.New("sidecar block header root does not match signed block"))
// errUnalignedRootAndSignature is returned by VerifiedRODataColumns when none of the provided RO blocks
// align with the sidecar block header root and signature.
errUnalignedRootAndSignature = errors.Join(ErrBlobInvalid, errors.New("sidecar block header root and signature do not align with any provided ro blocks"))
)
var (

View File

@@ -14,6 +14,7 @@ import (
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"golang.org/x/sync/singleflight"
)
// Forkchoicer represents the forkchoice methods that the verifiers need.
@@ -41,6 +42,7 @@ type sharedResources struct {
pc proposerCache
sr StateByRooter
ic *inclusionProofCache
sg singleflight.Group
}
// Initializer is used to create different Verifiers.

View File

@@ -49,6 +49,7 @@ type DataColumnsVerifier interface {
SidecarInclusionProven() error
SidecarKzgProofVerified() error
SidecarProposerExpected(ctx context.Context) error
SidecarRootAndSignatureAligned(roBlockByRoot map[[fieldparams.RootLength]byte]blocks.ROBlock) error
}
// NewDataColumnsVerifier is a function signature that can be used to mock a setup where a

View File

@@ -79,18 +79,19 @@ func (*MockBlobVerifier) SatisfyRequirement(_ Requirement) {}
// --------------------
type MockDataColumnsVerifier struct {
ErrValidFields error
ErrCorrectSubnet error
ErrNotFromFutureSlot error
ErrSlotAboveFinalized error
ErrSidecarParentSeen error
ErrSidecarParentValid error
ErrValidProposerSignature error
ErrSidecarParentSlotLower error
ErrSidecarDescendsFromFinalized error
ErrSidecarInclusionProven error
ErrSidecarKzgProofVerified error
ErrSidecarProposerExpected error
ErrValidFields error
ErrCorrectSubnet error
ErrNotFromFutureSlot error
ErrSlotAboveFinalized error
ErrSidecarParentSeen error
ErrSidecarParentValid error
ErrValidProposerSignature error
ErrSidecarParentSlotLower error
ErrSidecarDescendsFromFinalized error
ErrSidecarInclusionProven error
ErrSidecarKzgProofVerified error
ErrSidecarProposerExpected error
ErrSidecarRootAndSignatureAligned error
}
var _ DataColumnsVerifier = &MockDataColumnsVerifier{}
@@ -148,3 +149,7 @@ func (m *MockDataColumnsVerifier) SidecarKzgProofVerified() error {
func (m *MockDataColumnsVerifier) SidecarProposerExpected(_ context.Context) error {
return m.ErrSidecarProposerExpected
}
func (m *MockDataColumnsVerifier) SidecarRootAndSignatureAligned(_ map[[fieldparams.RootLength]byte]blocks.ROBlock) error {
return m.ErrSidecarRootAndSignatureAligned
}

View File

@@ -0,0 +1,2 @@
### Fixed
- `SidecarProposerExpected`: Add the slot in the single flight key.

2
changelog/manu-metric.md Normal file
View File

@@ -0,0 +1,2 @@
### Ignored
- `beacon_data_column_sidecar_gossip_verification_milliseconds`: Divide by 10.

View File

@@ -0,0 +1,2 @@
### Fixed
- `RODataColumnsVerifier.ValidProposerSignature`: Ensure the expensive signature verification is only performed once for concurrent requests for the same signature data.

View File

@@ -0,0 +1,3 @@
### Fixed
- use filepath for path operations (clean, join, etc.) to ensure correct behavior on Windows

Some files were not shown because too many files have changed in this diff Show More