mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Spec test: capella and update to v1.3.0-alpha.1 (#11683)
This commit is contained in:
10
WORKSPACE
10
WORKSPACE
@@ -188,7 +188,7 @@ filegroup(
|
||||
url = "https://github.com/eth-clients/slashing-protection-interchange-tests/archive/b8413ca42dc92308019d0d4db52c87e9e125c4e9.tar.gz",
|
||||
)
|
||||
|
||||
consensus_spec_version = "v1.2.0"
|
||||
consensus_spec_version = "v1.3.0-alpha.1"
|
||||
|
||||
bls_test_version = "v0.1.1"
|
||||
|
||||
@@ -204,7 +204,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "eded065f923a99b78372d6f748c9b3f1de8229f8f574c1fec9c5fe76c8affb65",
|
||||
sha256 = "b5a65eb5ecef1c4fca82ff29739936fee019e8a529ef392ea5e46aa39f40a0b2",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/general.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -220,7 +220,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "2ed83783129e93360f4bf9d5d5f606ee28adbe8b458acdfac61b8d99218d16a9",
|
||||
sha256 = "b381bb0184e69cb17d05fbbe75f48c6aec7726957d073e3a65c26671d5d27d37",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/minimal.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -236,7 +236,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "f5eff2adac78c99a4180491f373328465263caa2cba0206308a7c598abf76cda",
|
||||
sha256 = "9466f2a5a2dea039a2deb953f0b5dce5399400028bf3f218ffef03f8ef9c446c",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/mainnet.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -251,7 +251,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "f1a33b7459391716defa4c2b6f0c1bd7ccc38471ce9126d752d3bad767bebf2b",
|
||||
sha256 = "3cc3141651a320a1f5767d15826e85aaa96eb4459d9e1a1d3f5a0cdbc79b8f56",
|
||||
strip_prefix = "consensus-specs-" + consensus_spec_version[1:],
|
||||
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -328,7 +328,7 @@ func reportEpochMetrics(ctx context.Context, postState, headState state.BeaconSt
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case version.Altair, version.Bellatrix:
|
||||
case version.Altair, version.Bellatrix, version.Capella:
|
||||
v, b, err = altair.InitializePrecomputeValidators(ctx, headState)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -87,9 +87,6 @@ func IsExecutionEnabled(st state.BeaconState, body interfaces.BeaconBlockBody) (
|
||||
if IsPreBellatrixVersion(st.Version()) {
|
||||
return false, nil
|
||||
}
|
||||
if st.Version() > version.Bellatrix {
|
||||
return true, nil
|
||||
}
|
||||
header, err := st.LatestExecutionPayloadHeader()
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -253,7 +253,7 @@ func Test_IsExecutionBlockCapella(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
got, err := blocks.IsExecutionBlock(wrappedBlock.Body())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, got)
|
||||
require.Equal(t, false, got)
|
||||
}
|
||||
|
||||
func Test_IsExecutionEnabled(t *testing.T) {
|
||||
@@ -349,6 +349,7 @@ func Test_IsExecutionEnabled(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_IsExecutionEnabledCapella(t *testing.T) {
|
||||
st, _ := util.DeterministicGenesisStateCapella(t, 1)
|
||||
blk := util.NewBeaconBlockCapella()
|
||||
@@ -356,7 +357,7 @@ func Test_IsExecutionEnabledCapella(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
got, err := blocks.IsExecutionEnabled(st, body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, got)
|
||||
require.Equal(t, false, got)
|
||||
}
|
||||
|
||||
func Test_IsExecutionEnabledUsingHeader(t *testing.T) {
|
||||
|
||||
@@ -26,6 +26,4 @@ const (
|
||||
SyncCommitteeAggregationBytesLength = 16 // SyncCommitteeAggregationBytesLength defines the length of sync committee aggregate bytes.
|
||||
SyncAggregateSyncCommitteeBytesLength = 64 // SyncAggregateSyncCommitteeBytesLength defines the length of sync committee bytes in a sync aggregate.
|
||||
MaxWithdrawalsPerPayload = 16 // MaxWithdrawalsPerPayloadLength defines the maximum number of withdrawals that can be included in a payload.
|
||||
WithdrawalQueueLimit = 1099511627776 // WithdrawalQueueLimit defines the maximum number of withdrawals queued in the state.
|
||||
ExecutionAddressLength = 20 // ExecutionAddressLength defines the length of an execution layer address.
|
||||
)
|
||||
|
||||
@@ -25,6 +25,5 @@ const (
|
||||
SlotsPerEpoch = 8 // SlotsPerEpoch defines the number of slots per epoch.
|
||||
SyncCommitteeAggregationBytesLength = 1 // SyncCommitteeAggregationBytesLength defines the sync committee aggregate bytes.
|
||||
SyncAggregateSyncCommitteeBytesLength = 4 // SyncAggregateSyncCommitteeBytesLength defines the length of sync committee bytes in a sync aggregate.
|
||||
MaxWithdrawalsPerPayload = 16 // MaxWithdrawalsPerPayloadLength defines the maximum number of withdrawals that can be included in a payload.
|
||||
WithdrawalQueueLimit = 1099511627776 // WithdrawalQueueLimit defines the maximum number of withdrawals queued in the state.
|
||||
MaxWithdrawalsPerPayload = 4 // MaxWithdrawalsPerPayloadLength defines the maximum number of withdrawals that can be included in a payload.
|
||||
)
|
||||
|
||||
@@ -647,10 +647,6 @@ func PayloadToHeaderCapella(payload interfaces.ExecutionData) (*enginev1.Executi
|
||||
// IsEmptyExecutionData checks if an execution data is empty underneath. If a single field has
|
||||
// a non-zero value, this function will return false.
|
||||
func IsEmptyExecutionData(data interfaces.ExecutionData) (bool, error) {
|
||||
_, ok := data.Proto().(*enginev1.ExecutionPayloadCapella)
|
||||
if ok {
|
||||
return false, nil
|
||||
}
|
||||
if !bytes.Equal(data.ParentHash(), make([]byte, fieldparams.RootLength)) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"effective_balance_updates_test.go",
|
||||
"eth1_data_reset_test.go",
|
||||
"historical_roots_update_test.go",
|
||||
"inactivity_updates_test.go",
|
||||
"justification_and_finalization_test.go",
|
||||
"participation_flag_updates_test.go",
|
||||
"randao_mixes_reset_test.go",
|
||||
"registry_updates_test.go",
|
||||
"rewards_and_penalties_test.go",
|
||||
"slashings_reset_test.go",
|
||||
"slashings_test.go",
|
||||
],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
shard_count = 4,
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/epoch_processing:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_EffectiveBalanceUpdates(t *testing.T) {
|
||||
epoch_processing.RunEffectiveBalanceUpdatesTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_Eth1DataReset(t *testing.T) {
|
||||
epoch_processing.RunEth1DataResetTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_HistoricalRootsUpdate(t *testing.T) {
|
||||
epoch_processing.RunHistoricalRootsUpdateTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_InactivityUpdates(t *testing.T) {
|
||||
epoch_processing.RunInactivityUpdatesTest(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_JustificationAndFinalization(t *testing.T) {
|
||||
epoch_processing.RunJustificationAndFinalizationTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_ParticipationFlag(t *testing.T) {
|
||||
epoch_processing.RunParticipationFlagUpdatesTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_RandaoMixesReset(t *testing.T) {
|
||||
epoch_processing.RunRandaoMixesResetTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_ResetRegistryUpdates(t *testing.T) {
|
||||
epoch_processing.RunRegistryUpdatesTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_RewardsAndPenalties(t *testing.T) {
|
||||
epoch_processing.RunRewardsAndPenaltiesTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_SlashingsReset(t *testing.T) {
|
||||
epoch_processing.RunSlashingsResetTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_Slashings(t *testing.T) {
|
||||
epoch_processing.RunSlashingsTests(t, "mainnet")
|
||||
}
|
||||
14
testing/spectest/mainnet/capella/finality/BUILD.bazel
Normal file
14
testing/spectest/mainnet/capella/finality/BUILD.bazel
Normal file
@@ -0,0 +1,14 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "medium",
|
||||
timeout = "short",
|
||||
srcs = ["finality_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
shard_count = 1,
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/finality:go_default_library"],
|
||||
)
|
||||
11
testing/spectest/mainnet/capella/finality/finality_test.go
Normal file
11
testing/spectest/mainnet/capella/finality/finality_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package finality
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/finality"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Finality(t *testing.T) {
|
||||
finality.RunFinalityTest(t, "mainnet")
|
||||
}
|
||||
13
testing/spectest/mainnet/capella/fork_helper/BUILD.bazel
Normal file
13
testing/spectest/mainnet/capella/fork_helper/BUILD.bazel
Normal file
@@ -0,0 +1,13 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["upgrade_to_capella_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
shard_count = 1,
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/fork:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package fork_helper
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/fork"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_UpgradeToCapella(t *testing.T) {
|
||||
fork.RunUpgradeToCapella(t, "mainnet")
|
||||
}
|
||||
12
testing/spectest/mainnet/capella/fork_transition/BUILD.bazel
Normal file
12
testing/spectest/mainnet/capella/fork_transition/BUILD.bazel
Normal file
@@ -0,0 +1,12 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["transition_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/fork:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package fork_transition
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/fork"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Transition(t *testing.T) {
|
||||
fork.RunForkTransitionTest(t, "mainnet")
|
||||
}
|
||||
17
testing/spectest/mainnet/capella/forkchoice/BUILD.bazel
Normal file
17
testing/spectest/mainnet/capella/forkchoice/BUILD.bazel
Normal file
@@ -0,0 +1,17 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "enormous",
|
||||
timeout = "short",
|
||||
srcs = ["forkchoice_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
tags = ["spectest"],
|
||||
deps = [
|
||||
"//config/features:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"//testing/spectest/shared/common/forkchoice:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
package forkchoice
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/common/forkchoice"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Forkchoice(t *testing.T) {
|
||||
resetCfg := features.InitWithReset(&features.Flags{
|
||||
// Experimental features are disabled by default for spec tests.
|
||||
EnableDefensivePull: false,
|
||||
DisablePullTips: true,
|
||||
})
|
||||
defer resetCfg()
|
||||
forkchoice.Run(t, "mainnet", version.Capella)
|
||||
}
|
||||
21
testing/spectest/mainnet/capella/operations/BUILD.bazel
Normal file
21
testing/spectest/mainnet/capella/operations/BUILD.bazel
Normal file
@@ -0,0 +1,21 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"attestation_test.go",
|
||||
"attester_slashing_test.go",
|
||||
"block_header_test.go",
|
||||
"deposit_test.go",
|
||||
"proposer_slashing_test.go",
|
||||
"sync_committee_test.go",
|
||||
"voluntary_exit_test.go",
|
||||
],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
shard_count = 4,
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/operations:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Operations_Attestation(t *testing.T) {
|
||||
operations.RunAttestationTest(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Operations_AttesterSlashing(t *testing.T) {
|
||||
operations.RunAttesterSlashingTest(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Operations_BlockHeader(t *testing.T) {
|
||||
operations.RunBlockHeaderTest(t, "mainnet")
|
||||
}
|
||||
11
testing/spectest/mainnet/capella/operations/deposit_test.go
Normal file
11
testing/spectest/mainnet/capella/operations/deposit_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Operations_Deposit(t *testing.T) {
|
||||
operations.RunDepositTest(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Operations_ProposerSlashing(t *testing.T) {
|
||||
operations.RunProposerSlashingTest(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Operations_SyncCommittee(t *testing.T) {
|
||||
operations.RunSyncCommitteeTest(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Operations_VoluntaryExit(t *testing.T) {
|
||||
operations.RunVoluntaryExitTest(t, "mainnet")
|
||||
}
|
||||
12
testing/spectest/mainnet/capella/rewards/BUILD.bazel
Normal file
12
testing/spectest/mainnet/capella/rewards/BUILD.bazel
Normal file
@@ -0,0 +1,12 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["rewards_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/rewards:go_default_library"],
|
||||
)
|
||||
11
testing/spectest/mainnet/capella/rewards/rewards_test.go
Normal file
11
testing/spectest/mainnet/capella/rewards/rewards_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package rewards
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/rewards"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Rewards(t *testing.T) {
|
||||
rewards.RunPrecomputeRewardsAndPenaltiesTests(t, "mainnet")
|
||||
}
|
||||
16
testing/spectest/mainnet/capella/sanity/BUILD.bazel
Normal file
16
testing/spectest/mainnet/capella/sanity/BUILD.bazel
Normal file
@@ -0,0 +1,16 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "medium",
|
||||
timeout = "short",
|
||||
srcs = [
|
||||
"blocks_test.go",
|
||||
"slots_test.go",
|
||||
],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/sanity:go_default_library"],
|
||||
)
|
||||
11
testing/spectest/mainnet/capella/sanity/blocks_test.go
Normal file
11
testing/spectest/mainnet/capella/sanity/blocks_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package sanity
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/sanity"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Sanity_Blocks(t *testing.T) {
|
||||
sanity.RunBlockProcessingTest(t, "mainnet", "sanity/blocks/pyspec_tests")
|
||||
}
|
||||
11
testing/spectest/mainnet/capella/sanity/slots_test.go
Normal file
11
testing/spectest/mainnet/capella/sanity/slots_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package sanity
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/sanity"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_Sanity_Slots(t *testing.T) {
|
||||
sanity.RunSlotProcessingTests(t, "mainnet")
|
||||
}
|
||||
12
testing/spectest/mainnet/capella/ssz_static/BUILD.bazel
Normal file
12
testing/spectest/mainnet/capella/ssz_static/BUILD.bazel
Normal file
@@ -0,0 +1,12 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["ssz_static_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
],
|
||||
tags = ["spectest"],
|
||||
deps = ["//testing/spectest/shared/capella/ssz_static:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package ssz_static
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/ssz_static"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_SSZStatic(t *testing.T) {
|
||||
ssz_static.RunSSZStaticTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"effective_balance_updates_test.go",
|
||||
"eth1_data_reset_test.go",
|
||||
"historical_roots_update_test.go",
|
||||
"inactivity_updates_test.go",
|
||||
"justification_and_finalization_test.go",
|
||||
"participation_flag_updates_test.go",
|
||||
"randao_mixes_reset_test.go",
|
||||
"registry_updates_test.go",
|
||||
"rewards_and_penalties_test.go",
|
||||
"slashings_reset_test.go",
|
||||
"slashings_test.go",
|
||||
],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = ["//testing/spectest/shared/capella/epoch_processing:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_EffectiveBalanceUpdates(t *testing.T) {
|
||||
epoch_processing.RunEffectiveBalanceUpdatesTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_Eth1DataReset(t *testing.T) {
|
||||
epoch_processing.RunEth1DataResetTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_HistoricalRootsUpdate(t *testing.T) {
|
||||
epoch_processing.RunHistoricalRootsUpdateTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_InactivityUpdates(t *testing.T) {
|
||||
epoch_processing.RunInactivityUpdatesTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_JustificationAndFinalization(t *testing.T) {
|
||||
epoch_processing.RunJustificationAndFinalizationTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_ParticipationFlag(t *testing.T) {
|
||||
epoch_processing.RunParticipationFlagUpdatesTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_RandaoMixesReset(t *testing.T) {
|
||||
epoch_processing.RunRandaoMixesResetTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_ResetRegistryUpdates(t *testing.T) {
|
||||
epoch_processing.RunRegistryUpdatesTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_RewardsAndPenalties(t *testing.T) {
|
||||
epoch_processing.RunRewardsAndPenaltiesTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_SlashingsReset(t *testing.T) {
|
||||
epoch_processing.RunSlashingsResetTests(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_Slashings(t *testing.T) {
|
||||
epoch_processing.RunSlashingsTests(t, "minimal")
|
||||
}
|
||||
17
testing/spectest/minimal/capella/finality/BUILD.bazel
Normal file
17
testing/spectest/minimal/capella/finality/BUILD.bazel
Normal file
@@ -0,0 +1,17 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["finality_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
shard_count = 1,
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = ["//testing/spectest/shared/capella/finality:go_default_library"],
|
||||
)
|
||||
11
testing/spectest/minimal/capella/finality/finality_test.go
Normal file
11
testing/spectest/minimal/capella/finality/finality_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package finality
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/finality"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Finality(t *testing.T) {
|
||||
finality.RunFinalityTest(t, "minimal")
|
||||
}
|
||||
17
testing/spectest/minimal/capella/fork/BUILD.bazel
Normal file
17
testing/spectest/minimal/capella/fork/BUILD.bazel
Normal file
@@ -0,0 +1,17 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["upgrade_to_capella_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
shard_count = 1,
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = ["//testing/spectest/shared/capella/fork:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package fork
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/fork"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_UpgradeToCapella(t *testing.T) {
|
||||
fork.RunUpgradeToCapella(t, "minimal")
|
||||
}
|
||||
21
testing/spectest/minimal/capella/forkchoice/BUILD.bazel
Normal file
21
testing/spectest/minimal/capella/forkchoice/BUILD.bazel
Normal file
@@ -0,0 +1,21 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "enormous",
|
||||
timeout = "short",
|
||||
srcs = ["forkchoice_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = [
|
||||
"//config/features:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"//testing/spectest/shared/common/forkchoice:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
package forkchoice
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/common/forkchoice"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Forkchoice(t *testing.T) {
|
||||
resetCfg := features.InitWithReset(&features.Flags{
|
||||
EnableDefensivePull: false,
|
||||
DisablePullTips: true,
|
||||
})
|
||||
defer resetCfg()
|
||||
forkchoice.Run(t, "minimal", version.Capella)
|
||||
}
|
||||
26
testing/spectest/minimal/capella/operations/BUILD.bazel
Normal file
26
testing/spectest/minimal/capella/operations/BUILD.bazel
Normal file
@@ -0,0 +1,26 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"attestation_test.go",
|
||||
"attester_slashing_test.go",
|
||||
"block_header_test.go",
|
||||
"bls_to_execution_change_test.go",
|
||||
"deposit_test.go",
|
||||
"proposer_slashing_test.go",
|
||||
"sync_committee_test.go",
|
||||
"voluntary_exit_test.go",
|
||||
"withdrawals_test.go",
|
||||
],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = ["//testing/spectest/shared/capella/operations:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_Attestation(t *testing.T) {
|
||||
operations.RunAttestationTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_AttesterSlashing(t *testing.T) {
|
||||
operations.RunAttesterSlashingTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_BlockHeader(t *testing.T) {
|
||||
operations.RunBlockHeaderTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_BLSToExecutionChange(t *testing.T) {
|
||||
operations.RunBLSToExecutionChangeTest(t, "minimal")
|
||||
}
|
||||
11
testing/spectest/minimal/capella/operations/deposit_test.go
Normal file
11
testing/spectest/minimal/capella/operations/deposit_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_Deposit(t *testing.T) {
|
||||
operations.RunDepositTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_ProposerSlashing(t *testing.T) {
|
||||
operations.RunProposerSlashingTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_SyncCommittee(t *testing.T) {
|
||||
operations.RunProposerSlashingTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_VoluntaryExit(t *testing.T) {
|
||||
operations.RunVoluntaryExitTest(t, "minimal")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Operations_Withdrawals(t *testing.T) {
|
||||
operations.RunWithdrawalsTest(t, "minimal")
|
||||
}
|
||||
16
testing/spectest/minimal/capella/rewards/BUILD.bazel
Normal file
16
testing/spectest/minimal/capella/rewards/BUILD.bazel
Normal file
@@ -0,0 +1,16 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["rewards_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = ["//testing/spectest/shared/capella/rewards:go_default_library"],
|
||||
)
|
||||
11
testing/spectest/minimal/capella/rewards/rewards_test.go
Normal file
11
testing/spectest/minimal/capella/rewards/rewards_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package rewards
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/rewards"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Rewards(t *testing.T) {
|
||||
rewards.RunPrecomputeRewardsAndPenaltiesTests(t, "minimal")
|
||||
}
|
||||
19
testing/spectest/minimal/capella/sanity/BUILD.bazel
Normal file
19
testing/spectest/minimal/capella/sanity/BUILD.bazel
Normal file
@@ -0,0 +1,19 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"blocks_test.go",
|
||||
"slots_test.go",
|
||||
],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = ["//testing/spectest/shared/capella/sanity:go_default_library"],
|
||||
)
|
||||
11
testing/spectest/minimal/capella/sanity/blocks_test.go
Normal file
11
testing/spectest/minimal/capella/sanity/blocks_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package sanity
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/sanity"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Sanity_Blocks(t *testing.T) {
|
||||
sanity.RunBlockProcessingTest(t, "minimal", "sanity/blocks/pyspec_tests")
|
||||
}
|
||||
11
testing/spectest/minimal/capella/sanity/slots_test.go
Normal file
11
testing/spectest/minimal/capella/sanity/slots_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package sanity
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/sanity"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_Sanity_Slots(t *testing.T) {
|
||||
sanity.RunSlotProcessingTests(t, "minimal")
|
||||
}
|
||||
16
testing/spectest/minimal/capella/ssz_static/BUILD.bazel
Normal file
16
testing/spectest/minimal/capella/ssz_static/BUILD.bazel
Normal file
@@ -0,0 +1,16 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_test")
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = ["ssz_static_test.go"],
|
||||
data = [
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
],
|
||||
eth_network = "minimal",
|
||||
tags = [
|
||||
"minimal",
|
||||
"spectest",
|
||||
],
|
||||
deps = ["//testing/spectest/shared/capella/ssz_static:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package ssz_static
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/ssz_static"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_SSZStatic(t *testing.T) {
|
||||
ssz_static.RunSSZStaticTests(t, "minimal")
|
||||
}
|
||||
39
testing/spectest/shared/capella/epoch_processing/BUILD.bazel
Normal file
39
testing/spectest/shared/capella/epoch_processing/BUILD.bazel
Normal file
@@ -0,0 +1,39 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"effective_balance_updates.go",
|
||||
"eth1_data_reset.go",
|
||||
"helpers.go",
|
||||
"historical_roots_update.go",
|
||||
"inactivity_updates.go",
|
||||
"justification_and_finalization.go",
|
||||
"participation_flag_updates.go",
|
||||
"randao_mixes_reset.go",
|
||||
"registry_updates.go",
|
||||
"rewards_and_penalties.go",
|
||||
"slashings.go",
|
||||
"slashings_reset.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing",
|
||||
visibility = ["//testing/spectest:__subpackages__"],
|
||||
deps = [
|
||||
"//beacon-chain/core/altair:go_default_library",
|
||||
"//beacon-chain/core/epoch:go_default_library",
|
||||
"//beacon-chain/core/epoch/precompute:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/spectest/utils:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@in_gopkg_d4l3k_messagediff_v1//:go_default_library",
|
||||
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
||||
"@org_golang_google_protobuf//proto:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunEffectiveBalanceUpdatesTests executes "epoch_processing/effective_balance_updates" tests.
|
||||
func RunEffectiveBalanceUpdatesTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/effective_balance_updates/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/effective_balance_updates/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processEffectiveBalanceUpdatesWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processEffectiveBalanceUpdatesWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessEffectiveBalanceUpdates(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunEth1DataResetTests executes "epoch_processing/eth1_data_reset" tests.
|
||||
func RunEth1DataResetTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/eth1_data_reset/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/eth1_data_reset/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processEth1DataResetWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processEth1DataResetWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessEth1DataReset(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
78
testing/spectest/shared/capella/epoch_processing/helpers.go
Normal file
78
testing/spectest/shared/capella/epoch_processing/helpers.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||
"github.com/golang/snappy"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
state_native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"gopkg.in/d4l3k/messagediff.v1"
|
||||
)
|
||||
|
||||
type epochOperation func(*testing.T, state.BeaconState) (state.BeaconState, error)
|
||||
|
||||
// RunEpochOperationTest takes in the prestate and processes it through the
|
||||
// passed in epoch operation function and checks the post state with the expected post state.
|
||||
func RunEpochOperationTest(
|
||||
t *testing.T,
|
||||
testFolderPath string,
|
||||
operationFn epochOperation,
|
||||
) {
|
||||
preBeaconStateFile, err := util.BazelFileBytes(path.Join(testFolderPath, "pre.ssz_snappy"))
|
||||
require.NoError(t, err)
|
||||
preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
preBeaconStateBase := ðpb.BeaconStateCapella{}
|
||||
if err := preBeaconStateBase.UnmarshalSSZ(preBeaconStateSSZ); err != nil {
|
||||
t.Fatalf("Failed to unmarshal: %v", err)
|
||||
}
|
||||
preBeaconState, err := state_native.InitializeFromProtoCapella(preBeaconStateBase)
|
||||
require.NoError(t, err)
|
||||
|
||||
// If the post.ssz is not present, it means the test should fail on our end.
|
||||
postSSZFilepath, err := bazel.Runfile(path.Join(testFolderPath, "post.ssz_snappy"))
|
||||
postSSZExists := true
|
||||
if err != nil && strings.Contains(err.Error(), "could not locate file") {
|
||||
postSSZExists = false
|
||||
} else if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
beaconState, err := operationFn(t, preBeaconState)
|
||||
if postSSZExists {
|
||||
require.NoError(t, err)
|
||||
|
||||
postBeaconStateFile, err := os.ReadFile(postSSZFilepath) // #nosec G304
|
||||
require.NoError(t, err)
|
||||
postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
postBeaconState := ðpb.BeaconStateCapella{}
|
||||
if err := postBeaconState.UnmarshalSSZ(postBeaconStateSSZ); err != nil {
|
||||
t.Fatalf("Failed to unmarshal: %v", err)
|
||||
}
|
||||
|
||||
pbState, err := state_native.ProtobufBeaconStateCapella(beaconState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
diff, _ := messagediff.PrettyDiff(beaconState.ToProtoUnsafe(), postBeaconState)
|
||||
t.Log(diff)
|
||||
t.Fatal("Post state does not match expected")
|
||||
}
|
||||
} else {
|
||||
// Note: This doesn't test anything worthwhile. It essentially tests
|
||||
// that *any* error has occurred, not any specific error.
|
||||
if err == nil {
|
||||
t.Fatal("Did not fail when expected")
|
||||
}
|
||||
t.Logf("Expected failure; failure reason = %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunHistoricalRootsUpdateTests executes "epoch_processing/historical_roots_update" tests.
|
||||
func RunHistoricalRootsUpdateTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/historical_roots_update/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/historical_roots_update/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processHistoricalRootsUpdateWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processHistoricalRootsUpdateWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessHistoricalRootsUpdate(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunInactivityUpdatesTest executes "epoch_processing/inactivity_updates" tests.
|
||||
func RunInactivityUpdatesTest(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testPath := "epoch_processing/inactivity_updates/pyspec_tests"
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", testPath)
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", testPath)
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
helpers.ClearCache()
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processInactivityUpdates)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processInactivityUpdates(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
ctx := context.Background()
|
||||
vp, bp, err := altair.InitializePrecomputeValidators(ctx, st)
|
||||
require.NoError(t, err)
|
||||
vp, _, err = altair.ProcessEpochParticipation(ctx, st, bp, vp)
|
||||
require.NoError(t, err)
|
||||
|
||||
st, _, err = altair.ProcessInactivityScores(ctx, st, vp)
|
||||
require.NoError(t, err, "Could not process reward")
|
||||
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch/precompute"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunJustificationAndFinalizationTests executes "epoch_processing/justification_and_finalization" tests.
|
||||
func RunJustificationAndFinalizationTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testPath := "epoch_processing/justification_and_finalization/pyspec_tests"
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", testPath)
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", testPath)
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processJustificationAndFinalizationPrecomputeWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processJustificationAndFinalizationPrecomputeWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
ctx := context.Background()
|
||||
vp, bp, err := altair.InitializePrecomputeValidators(ctx, st)
|
||||
require.NoError(t, err)
|
||||
_, bp, err = altair.ProcessEpochParticipation(ctx, st, bp, vp)
|
||||
require.NoError(t, err)
|
||||
|
||||
st, err = precompute.ProcessJustificationAndFinalizationPreCompute(st, bp)
|
||||
require.NoError(t, err, "Could not process justification")
|
||||
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunParticipationFlagUpdatesTests executes "epoch_processing/participation_flag_updates" tests.
|
||||
func RunParticipationFlagUpdatesTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/participation_flag_updates/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/participation_flag_updates/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processParticipationFlagUpdatesWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processParticipationFlagUpdatesWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := altair.ProcessParticipationFlagUpdates(st)
|
||||
require.NoError(t, err, "Could not process participation flag update")
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunRandaoMixesResetTests executes "epoch_processing/randao_mixes_reset" tests.
|
||||
func RunRandaoMixesResetTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/randao_mixes_reset/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/randao_mixes_reset/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processRandaoMixesResetWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processRandaoMixesResetWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessRandaoMixesReset(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunRegistryUpdatesTests executes "epoch_processing/registry_updates" tests.
|
||||
func RunRegistryUpdatesTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/registry_updates/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/registry_updates/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
// Important to clear cache for every test or else the old value of active validator count gets reused.
|
||||
helpers.ClearCache()
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processRegistryUpdatesWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processRegistryUpdatesWrapper(_ *testing.T, state state.BeaconState) (state.BeaconState, error) {
|
||||
return epoch.ProcessRegistryUpdates(context.Background(), state)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunRewardsAndPenaltiesTests executes "epoch_processing/rewards_and_penalties" tests.
|
||||
func RunRewardsAndPenaltiesTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testPath := "epoch_processing/rewards_and_penalties/pyspec_tests"
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", testPath)
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", testPath)
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
helpers.ClearCache()
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processRewardsAndPenaltiesPrecomputeWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processRewardsAndPenaltiesPrecomputeWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
ctx := context.Background()
|
||||
vp, bp, err := altair.InitializePrecomputeValidators(ctx, st)
|
||||
require.NoError(t, err)
|
||||
vp, bp, err = altair.ProcessEpochParticipation(ctx, st, bp, vp)
|
||||
require.NoError(t, err)
|
||||
|
||||
st, err = altair.ProcessRewardsAndPenaltiesPrecompute(st, bp, vp)
|
||||
require.NoError(t, err, "Could not process reward")
|
||||
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunSlashingsTests executes "epoch_processing/slashings" tests.
|
||||
func RunSlashingsTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/slashings/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/slashings/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
helpers.ClearCache()
|
||||
RunEpochOperationTest(t, folderPath, processSlashingsWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processSlashingsWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessSlashings(st, params.BeaconConfig().ProportionalSlashingMultiplierBellatrix)
|
||||
require.NoError(t, err, "Could not process slashings")
|
||||
return st, nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunSlashingsResetTests executes "epoch_processing/slashings_reset" tests.
|
||||
func RunSlashingsResetTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/slashings_reset/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/slashings_reset/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processSlashingsResetWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processSlashingsResetWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessSlashingsReset(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
22
testing/spectest/shared/capella/finality/BUILD.bazel
Normal file
22
testing/spectest/shared/capella/finality/BUILD.bazel
Normal file
@@ -0,0 +1,22 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
testonly = True,
|
||||
srcs = ["finality.go"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/finality",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/transition:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/spectest/utils:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@org_golang_google_protobuf//proto:go_default_library",
|
||||
],
|
||||
)
|
||||
86
testing/spectest/shared/capella/finality/finality.go
Normal file
86
testing/spectest/shared/capella/finality/finality.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package finality
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
state_native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func init() {
|
||||
transition.SkipSlotCache.Disable()
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
BlocksCount int `json:"blocks_count"`
|
||||
}
|
||||
|
||||
// RunFinalityTest executes finality spec tests.
|
||||
func RunFinalityTest(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "finality/finality/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "finality/finality/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
helpers.ClearCache()
|
||||
preBeaconStateFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "pre.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
beaconStateBase := ðpb.BeaconStateCapella{}
|
||||
require.NoError(t, beaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal")
|
||||
beaconState, err := state_native.InitializeFromProtoCapella(beaconStateBase)
|
||||
require.NoError(t, err)
|
||||
|
||||
file, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "meta.yaml")
|
||||
require.NoError(t, err)
|
||||
|
||||
metaYaml := &Config{}
|
||||
require.NoError(t, utils.UnmarshalYaml(file, metaYaml), "Failed to Unmarshal")
|
||||
|
||||
var processedState state.BeaconState
|
||||
var ok bool
|
||||
for i := 0; i < metaYaml.BlocksCount; i++ {
|
||||
filename := fmt.Sprintf("blocks_%d.ssz_snappy", i)
|
||||
blockFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), filename)
|
||||
require.NoError(t, err)
|
||||
blockSSZ, err := snappy.Decode(nil /* dst */, blockFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
block := ðpb.SignedBeaconBlockCapella{}
|
||||
require.NoError(t, block.UnmarshalSSZ(blockSSZ), "Failed to unmarshal")
|
||||
wsb, err := blocks.NewSignedBeaconBlock(block)
|
||||
require.NoError(t, err)
|
||||
processedState, err = transition.ExecuteStateTransition(context.Background(), beaconState, wsb)
|
||||
require.NoError(t, err)
|
||||
beaconState, ok = processedState.(*state_native.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
}
|
||||
|
||||
postBeaconStateFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "post.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
postBeaconState := ðpb.BeaconStateCapella{}
|
||||
require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal")
|
||||
pbState, err := state_native.ProtobufBeaconStateCapella(beaconState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
t.Fatal("Post state does not match expected")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
27
testing/spectest/shared/capella/fork/BUILD.bazel
Normal file
27
testing/spectest/shared/capella/fork/BUILD.bazel
Normal file
@@ -0,0 +1,27 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"transition.go",
|
||||
"upgrade_to_capella.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/fork",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//beacon-chain/core/capella:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/transition:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/spectest/utils:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@org_golang_google_protobuf//proto:go_default_library",
|
||||
],
|
||||
)
|
||||
128
testing/spectest/shared/capella/fork/transition.go
Normal file
128
testing/spectest/shared/capella/fork/transition.go
Normal file
@@ -0,0 +1,128 @@
|
||||
package fork
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
|
||||
state_native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
)
|
||||
|
||||
type ForkConfig struct {
|
||||
PostFork string `json:"post_fork"`
|
||||
ForkEpoch int `json:"fork_epoch"`
|
||||
ForkBlock *int `json:"fork_block"`
|
||||
BlocksCount int `json:"blocks_count"`
|
||||
}
|
||||
|
||||
// RunForkTransitionTest is a helper function that runs capella's transition core tests.
|
||||
func RunForkTransitionTest(t *testing.T, config string) {
|
||||
params.SetupTestConfigCleanup(t)
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "transition/core/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "transition/core/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
helpers.ClearCache()
|
||||
file, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "meta.yaml")
|
||||
require.NoError(t, err)
|
||||
config := &ForkConfig{}
|
||||
require.NoError(t, utils.UnmarshalYaml(file, config), "Failed to Unmarshal")
|
||||
|
||||
preforkBlocks := make([]*ethpb.SignedBeaconBlockBellatrix, 0)
|
||||
postforkBlocks := make([]*ethpb.SignedBeaconBlockCapella, 0)
|
||||
// Fork happens without any pre-fork blocks.
|
||||
if config.ForkBlock == nil {
|
||||
for i := 0; i < config.BlocksCount; i++ {
|
||||
fileName := fmt.Sprint("blocks_", i, ".ssz_snappy")
|
||||
blockFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), fileName)
|
||||
require.NoError(t, err)
|
||||
blockSSZ, err := snappy.Decode(nil /* dst */, blockFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
block := ðpb.SignedBeaconBlockCapella{}
|
||||
require.NoError(t, block.UnmarshalSSZ(blockSSZ), "Failed to unmarshal")
|
||||
postforkBlocks = append(postforkBlocks, block)
|
||||
}
|
||||
// Fork happens with pre-fork blocks.
|
||||
} else {
|
||||
for i := 0; i <= *config.ForkBlock; i++ {
|
||||
fileName := fmt.Sprint("blocks_", i, ".ssz_snappy")
|
||||
blockFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), fileName)
|
||||
require.NoError(t, err)
|
||||
blockSSZ, err := snappy.Decode(nil /* dst */, blockFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
block := ðpb.SignedBeaconBlockBellatrix{}
|
||||
require.NoError(t, block.UnmarshalSSZ(blockSSZ), "Failed to unmarshal")
|
||||
preforkBlocks = append(preforkBlocks, block)
|
||||
}
|
||||
for i := *config.ForkBlock + 1; i < config.BlocksCount; i++ {
|
||||
fileName := fmt.Sprint("blocks_", i, ".ssz_snappy")
|
||||
blockFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), fileName)
|
||||
require.NoError(t, err)
|
||||
blockSSZ, err := snappy.Decode(nil /* dst */, blockFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
block := ðpb.SignedBeaconBlockCapella{}
|
||||
require.NoError(t, block.UnmarshalSSZ(blockSSZ), "Failed to unmarshal")
|
||||
postforkBlocks = append(postforkBlocks, block)
|
||||
}
|
||||
}
|
||||
|
||||
preBeaconStateFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "pre.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
beaconStateBase := ðpb.BeaconStateBellatrix{}
|
||||
require.NoError(t, beaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal")
|
||||
beaconState, err := state_native.InitializeFromProtoBellatrix(beaconStateBase)
|
||||
require.NoError(t, err)
|
||||
|
||||
bc := params.BeaconConfig().Copy()
|
||||
bc.CapellaForkEpoch = types.Epoch(config.ForkEpoch)
|
||||
params.OverrideBeaconConfig(bc)
|
||||
|
||||
ctx := context.Background()
|
||||
var ok bool
|
||||
for _, b := range preforkBlocks {
|
||||
wsb, err := blocks.NewSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
st, err := transition.ExecuteStateTransition(ctx, beaconState, wsb)
|
||||
require.NoError(t, err)
|
||||
beaconState, ok = st.(*state_native.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
}
|
||||
|
||||
for _, b := range postforkBlocks {
|
||||
wsb, err := blocks.NewSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
st, err := transition.ExecuteStateTransition(ctx, beaconState, wsb)
|
||||
require.NoError(t, err)
|
||||
beaconState, ok = st.(*state_native.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
}
|
||||
|
||||
postBeaconStateFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "post.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
postBeaconState := ðpb.BeaconStateCapella{}
|
||||
require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal")
|
||||
|
||||
pbState, err := state_native.ProtobufBeaconStateCapella(beaconState.ToProto())
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, pbState, postBeaconState)
|
||||
})
|
||||
}
|
||||
}
|
||||
61
testing/spectest/shared/capella/fork/upgrade_to_capella.go
Normal file
61
testing/spectest/shared/capella/fork/upgrade_to_capella.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package fork
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/capella"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
state_native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// RunUpgradeToCapella is a helper function that runs capella's fork spec tests.
|
||||
// It unmarshals a pre- and post-state to check `UpgradeToCapella` comply with spec implementation.
|
||||
func RunUpgradeToCapella(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "fork/fork/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "fork/fork/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
helpers.ClearCache()
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
|
||||
preStateFile, err := util.BazelFileBytes(path.Join(folderPath, "pre.ssz_snappy"))
|
||||
require.NoError(t, err)
|
||||
preStateSSZ, err := snappy.Decode(nil /* dst */, preStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
preStateBase := ðpb.BeaconStateBellatrix{}
|
||||
if err := preStateBase.UnmarshalSSZ(preStateSSZ); err != nil {
|
||||
t.Fatalf("Failed to unmarshal: %v", err)
|
||||
}
|
||||
preState, err := state_native.InitializeFromProtoBellatrix(preStateBase)
|
||||
require.NoError(t, err)
|
||||
postState, err := capella.UpgradeToCapella(preState)
|
||||
require.NoError(t, err)
|
||||
postStateFromFunction, err := state_native.ProtobufBeaconStateCapella(postState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
|
||||
postStateFile, err := util.BazelFileBytes(path.Join(folderPath, "post.ssz_snappy"))
|
||||
require.NoError(t, err)
|
||||
postStateSSZ, err := snappy.Decode(nil /* dst */, postStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
postStateFromFile := ðpb.BeaconStateCapella{}
|
||||
if err := postStateFromFile.UnmarshalSSZ(postStateSSZ); err != nil {
|
||||
t.Fatalf("Failed to unmarshal: %v", err)
|
||||
}
|
||||
|
||||
if !proto.Equal(postStateFromFile, postStateFromFunction) {
|
||||
t.Fatal("Post state does not match expected")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
40
testing/spectest/shared/capella/operations/BUILD.bazel
Normal file
40
testing/spectest/shared/capella/operations/BUILD.bazel
Normal file
@@ -0,0 +1,40 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"attestation.go",
|
||||
"attester_slashing.go",
|
||||
"block_header.go",
|
||||
"bls_to_execution_changes.go",
|
||||
"deposit.go",
|
||||
"helpers.go",
|
||||
"proposer_slashing.go",
|
||||
"sync_committee.go",
|
||||
"voluntary_exit.go",
|
||||
"withdrawals.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/operations",
|
||||
visibility = ["//testing/spectest:__subpackages__"],
|
||||
deps = [
|
||||
"//beacon-chain/core/altair:go_default_library",
|
||||
"//beacon-chain/core/blocks:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/spectest/utils:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@in_gopkg_d4l3k_messagediff_v1//:go_default_library",
|
||||
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
||||
"@org_golang_google_protobuf//proto:go_default_library",
|
||||
],
|
||||
)
|
||||
59
testing/spectest/shared/capella/operations/attestation.go
Normal file
59
testing/spectest/shared/capella/operations/attestation.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
|
||||
b "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
)
|
||||
|
||||
func RunAttestationTest(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "operations/attestation/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "operations/attestation/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
attestationFile, err := util.BazelFileBytes(folderPath, "attestation.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
attestationSSZ, err := snappy.Decode(nil /* dst */, attestationFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
att := ðpb.Attestation{}
|
||||
require.NoError(t, att.UnmarshalSSZ(attestationSSZ), "Failed to unmarshal")
|
||||
|
||||
body := ðpb.BeaconBlockBodyCapella{Attestations: []*ethpb.Attestation{att}}
|
||||
processAtt := func(ctx context.Context, st state.BeaconState, blk interfaces.SignedBeaconBlock) (state.BeaconState, error) {
|
||||
st, err = altair.ProcessAttestationsNoVerifySignature(ctx, st, blk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
aSet, err := b.AttestationSignatureBatch(ctx, st, blk.Block().Body().Attestations())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
verified, err := aSet.Verify()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !verified {
|
||||
return nil, errors.New("could not batch verify attestation signature")
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
|
||||
RunBlockOperationTest(t, folderPath, body, processAtt)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/validators"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
)
|
||||
|
||||
func RunAttesterSlashingTest(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "operations/attester_slashing/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "operations/attester_slashing/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
attSlashingFile, err := util.BazelFileBytes(folderPath, "attester_slashing.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
attSlashingSSZ, err := snappy.Decode(nil /* dst */, attSlashingFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
attSlashing := ðpb.AttesterSlashing{}
|
||||
require.NoError(t, attSlashing.UnmarshalSSZ(attSlashingSSZ), "Failed to unmarshal")
|
||||
|
||||
body := ðpb.BeaconBlockBodyCapella{AttesterSlashings: []*ethpb.AttesterSlashing{attSlashing}}
|
||||
RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) {
|
||||
return blocks.ProcessAttesterSlashings(ctx, s, b.Block().Body().AttesterSlashings(), validators.SlashValidator)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
87
testing/spectest/shared/capella/operations/block_header.go
Normal file
87
testing/spectest/shared/capella/operations/block_header.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||
"github.com/golang/snappy"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
state_native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"gopkg.in/d4l3k/messagediff.v1"
|
||||
)
|
||||
|
||||
func RunBlockHeaderTest(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "operations/block_header/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "operations/block_header/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
blockFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "block.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
blockSSZ, err := snappy.Decode(nil /* dst */, blockFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
block := ðpb.BeaconBlockCapella{}
|
||||
require.NoError(t, block.UnmarshalSSZ(blockSSZ), "Failed to unmarshal")
|
||||
|
||||
preBeaconStateFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "pre.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
preBeaconStateBase := ðpb.BeaconStateCapella{}
|
||||
require.NoError(t, preBeaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal")
|
||||
preBeaconState, err := state_native.InitializeFromProtoCapella(preBeaconStateBase)
|
||||
require.NoError(t, err)
|
||||
|
||||
// If the post.ssz is not present, it means the test should fail on our end.
|
||||
postSSZFilepath, err := bazel.Runfile(path.Join(testsFolderPath, folder.Name(), "post.ssz_snappy"))
|
||||
postSSZExists := true
|
||||
if err != nil && strings.Contains(err.Error(), "could not locate file") {
|
||||
postSSZExists = false
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// Spectest blocks are not signed, so we'll call NoVerify to skip sig verification.
|
||||
bodyRoot, err := block.Body.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
beaconState, err := blocks.ProcessBlockHeaderNoVerify(context.Background(), preBeaconState, block.Slot, block.ProposerIndex, block.ParentRoot, bodyRoot[:])
|
||||
if postSSZExists {
|
||||
require.NoError(t, err)
|
||||
|
||||
postBeaconStateFile, err := os.ReadFile(postSSZFilepath) // #nosec G304
|
||||
require.NoError(t, err)
|
||||
postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
|
||||
postBeaconState := ðpb.BeaconStateCapella{}
|
||||
require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal")
|
||||
pbState, err := state_native.ProtobufBeaconStateCapella(beaconState.ToProto())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
diff, _ := messagediff.PrettyDiff(beaconState.ToProto(), postBeaconState)
|
||||
t.Log(diff)
|
||||
t.Fatal("Post state does not match expected")
|
||||
}
|
||||
} else {
|
||||
// Note: This doesn't test anything worthwhile. It essentially tests
|
||||
// that *any* error has occurred, not any specific error.
|
||||
if err == nil {
|
||||
t.Fatal("Did not fail when expected")
|
||||
}
|
||||
t.Logf("Expected failure; failure reason = %v", err)
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
)
|
||||
|
||||
func RunBLSToExecutionChangeTest(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "operations/bls_to_execution_change/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "operations/bls_to_execution_change/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
changeFile, err := util.BazelFileBytes(folderPath, "address_change.ssz_snappy")
|
||||
require.NoError(t, err)
|
||||
changeSSZ, err := snappy.Decode(nil /* dst */, changeFile)
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
change := ðpb.SignedBLSToExecutionChange{}
|
||||
require.NoError(t, change.UnmarshalSSZ(changeSSZ), "Failed to unmarshal")
|
||||
|
||||
body := ðpb.BeaconBlockBodyCapella{
|
||||
BlsToExecutionChanges: []*ethpb.SignedBLSToExecutionChange{change},
|
||||
}
|
||||
RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) {
|
||||
st, err := blocks.ProcessBLSToExecutionChanges(s, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
changes, err := b.Block().Body().BLSToExecutionChanges()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cSet, err := blocks.BLSChangesSignatureBatch(ctx, st, changes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ok, err := cSet.Verify()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !ok {
|
||||
return nil, errors.New("signature did not verify")
|
||||
}
|
||||
return st, nil
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user