Add fulu spec tests for operation and epoch processing (#15284)

* Add fulu spec tets for operation and epoch processing

* Fix operation test version

* Fix RunDepositRequestsTest
This commit is contained in:
terence
2025-05-20 09:18:04 -07:00
committed by GitHub
parent 00bb3ff2b8
commit a8ce85f8de
90 changed files with 1662 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
load("@prysm//tools/go:def.bzl", "go_test")
go_test(
name = "go_default_test",
srcs = [
"effective_balance_updates_test.go",
"eth1_data_reset_test.go",
"historical_summaries_update_test.go",
"inactivity_updates_test.go",
"justification_and_finalization_test.go",
"participation_flag_updates_test.go",
"pending_consolidations_test.go",
"pending_deposits_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 = glob(["*.yaml"]) + [
"@consensus_spec_tests_mainnet//:test_data",
],
deps = ["//testing/spectest/shared/fulu/epoch_processing:go_default_library"],
)

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_fulu_EpochProcessing_EffectiveBalanceUpdates(t *testing.T) {
epoch_processing.RunEffectiveBalanceUpdatesTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_Eth1DataReset(t *testing.T) {
epoch_processing.RunEth1DataResetTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_HistoricalSummariesUpdate(t *testing.T) {
epoch_processing.RunHistoricalSummariesUpdateTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_InactivityUpdates(t *testing.T) {
epoch_processing.RunInactivityUpdatesTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_JustificationAndFinalization(t *testing.T) {
epoch_processing.RunJustificationAndFinalizationTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_ParticipationFlag(t *testing.T) {
epoch_processing.RunParticipationFlagUpdatesTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_PendingConsolidations(t *testing.T) {
epoch_processing.RunPendingConsolidationsTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_PendingDeposits(t *testing.T) {
epoch_processing.RunPendingDepositsTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_RandaoMixesReset(t *testing.T) {
epoch_processing.RunRandaoMixesResetTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_RegistryUpdates(t *testing.T) {
epoch_processing.RunRegistryUpdatesTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_RewardsAndPenalties(t *testing.T) {
epoch_processing.RunRewardsAndPenaltiesTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_SlashingsReset(t *testing.T) {
epoch_processing.RunSlashingsResetTests(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMainnet_Fulu_EpochProcessing_Slashings(t *testing.T) {
epoch_processing.RunSlashingsTests(t, "mainnet")
}

View File

@@ -0,0 +1,24 @@
load("@prysm//tools/go:def.bzl", "go_test")
go_test(
name = "go_default_test",
srcs = [
"attestation_test.go",
"attester_slashing_test.go",
"block_header_test.go",
"bls_to_execution_change_test.go",
"consolidation_test.go",
"deposit_requests_test.go",
"deposit_test.go",
"execution_layer_withdrawals_test.go",
"execution_payload_test.go",
"proposer_slashing_test.go",
"sync_committee_test.go",
"voluntary_exit_test.go",
"withdrawals_test.go",
],
data = glob(["*.yaml"]) + [
"@consensus_spec_tests_mainnet//:test_data",
],
deps = ["//testing/spectest/shared/fulu/operations:go_default_library"],
)

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_Attestation(t *testing.T) {
operations.RunAttestationTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_AttesterSlashing(t *testing.T) {
operations.RunAttesterSlashingTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_BlockHeader(t *testing.T) {
operations.RunBlockHeaderTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_BLSToExecutionChange(t *testing.T) {
operations.RunBLSToExecutionChangeTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_Consolidation(t *testing.T) {
operations.RunConsolidationTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_DepositRequests(t *testing.T) {
operations.RunDepositRequestsTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_Deposit(t *testing.T) {
operations.RunDepositTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_WithdrawalRequest(t *testing.T) {
operations.RunWithdrawalRequestTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_PayloadExecution(t *testing.T) {
operations.RunExecutionPayloadTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_ProposerSlashing(t *testing.T) {
operations.RunProposerSlashingTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_SyncCommittee(t *testing.T) {
operations.RunSyncCommitteeTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_VoluntaryExit(t *testing.T) {
operations.RunVoluntaryExitTest(t, "mainnet")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_Withdrawals(t *testing.T) {
operations.RunWithdrawalsTest(t, "mainnet")
}

View File

@@ -0,0 +1,26 @@
load("@prysm//tools/go:def.bzl", "go_test")
go_test(
name = "go_default_test",
srcs = [
"effective_balance_updates_test.go",
"eth1_data_reset_test.go",
"historical_summaries_update_test.go",
"inactivity_updates_test.go",
"justification_and_finalization_test.go",
"participation_flag_updates_test.go",
"pending_consolidations_test.go",
"pending_deposits_updates_test.go",
"randao_mixes_reset_test.go",
"registry_updates_test.go",
"rewards_and_penalties_test.go",
"slashings_reset_test.go",
"slashings_test.go",
"sync_committee_updates_test.go",
],
data = glob(["*.yaml"]) + [
"@consensus_spec_tests_minimal//:test_data",
],
eth_network = "minimal",
deps = ["//testing/spectest/shared/fulu/epoch_processing:go_default_library"],
)

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_fulu_EpochProcessing_EffectiveBalanceUpdates(t *testing.T) {
epoch_processing.RunEffectiveBalanceUpdatesTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_Eth1DataReset(t *testing.T) {
epoch_processing.RunEth1DataResetTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_HistoricalSummariesUpdate(t *testing.T) {
epoch_processing.RunHistoricalSummariesUpdateTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_InactivityUpdates(t *testing.T) {
epoch_processing.RunInactivityUpdatesTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_JustificationAndFinalization(t *testing.T) {
epoch_processing.RunJustificationAndFinalizationTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_ParticipationFlag(t *testing.T) {
epoch_processing.RunParticipationFlagUpdatesTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_PendingConsolidations(t *testing.T) {
epoch_processing.RunPendingConsolidationsTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_PendingDeposits(t *testing.T) {
epoch_processing.RunPendingDepositsTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_RandaoMixesReset(t *testing.T) {
epoch_processing.RunRandaoMixesResetTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_RegistryUpdates(t *testing.T) {
epoch_processing.RunRegistryUpdatesTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_RewardsAndPenalties(t *testing.T) {
epoch_processing.RunRewardsAndPenaltiesTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_SlashingsReset(t *testing.T) {
epoch_processing.RunSlashingsResetTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_Slashings(t *testing.T) {
epoch_processing.RunSlashingsTests(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package epoch_processing
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing"
)
func TestMinimal_Fulu_EpochProcessing_SyncCommitteeUpdates(t *testing.T) {
epoch_processing.RunSyncCommitteeUpdatesTests(t, "minimal")
}

View File

@@ -0,0 +1,25 @@
load("@prysm//tools/go:def.bzl", "go_test")
go_test(
name = "go_default_test",
srcs = [
"attestation_test.go",
"attester_slashing_test.go",
"block_header_test.go",
"bls_to_execution_change_test.go",
"consolidation_test.go",
"deposit_requests_test.go",
"deposit_test.go",
"execution_layer_withdrawals_test.go",
"execution_payload_test.go",
"proposer_slashing_test.go",
"sync_committee_test.go",
"voluntary_exit_test.go",
"withdrawals_test.go",
],
data = glob(["*.yaml"]) + [
"@consensus_spec_tests_minimal//:test_data",
],
eth_network = "minimal",
deps = ["//testing/spectest/shared/fulu/operations:go_default_library"],
)

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_Attestation(t *testing.T) {
operations.RunAttestationTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_AttesterSlashing(t *testing.T) {
operations.RunAttesterSlashingTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_BlockHeader(t *testing.T) {
operations.RunBlockHeaderTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_BLSToExecutionChange(t *testing.T) {
operations.RunBLSToExecutionChangeTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_Consolidation(t *testing.T) {
operations.RunConsolidationTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMainnet_Fulu_Operations_DepositRequests(t *testing.T) {
operations.RunDepositRequestsTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_Deposit(t *testing.T) {
operations.RunDepositTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_WithdrawalRequest(t *testing.T) {
operations.RunWithdrawalRequestTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_PayloadExecution(t *testing.T) {
operations.RunExecutionPayloadTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_ProposerSlashing(t *testing.T) {
operations.RunProposerSlashingTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_SyncCommittee(t *testing.T) {
operations.RunSyncCommitteeTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_VoluntaryExit(t *testing.T) {
operations.RunVoluntaryExitTest(t, "minimal")
}

View File

@@ -0,0 +1,11 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations"
)
func TestMinimal_Fulu_Operations_Withdrawals(t *testing.T) {
operations.RunWithdrawalsTest(t, "minimal")
}

View File

@@ -16,7 +16,7 @@ import (
func RunDepositRequestsTest(t *testing.T, config string, fork string, block blockWithSSZObject, sszToState SSZToState) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "electra", "operations/deposit_request/pyspec_tests")
testFolders, testsFolderPath := utils.TestFolders(t, config, fork, "operations/deposit_request/pyspec_tests")
for _, folder := range testFolders {
t.Run(folder.Name(), func(t *testing.T) {
folderPath := path.Join(testsFolderPath, folder.Name())

View File

@@ -0,0 +1,42 @@
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_summaries_update.go",
"inactivity_updates.go",
"justification_and_finalization.go",
"participation_flag_updates.go",
"pending_consolidations.go",
"pending_deposit_updates.go",
"randao_mixes_reset.go",
"registry_updates.go",
"rewards_and_penalties.go",
"slashings.go",
"slashings_reset.go",
"sync_committee_updates.go",
],
importpath = "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/epoch_processing",
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/core/electra: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",
"//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",
"@com_github_google_go_cmp//cmp:go_default_library",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@org_golang_google_protobuf//testing/protocmp:go_default_library",
],
)

View File

@@ -0,0 +1,30 @@
package epoch_processing
import (
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", "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) {
err := electra.ProcessEffectiveBalanceUpdates(st)
require.NoError(t, err, "Could not process final updates")
return st, nil
}

View File

@@ -0,0 +1,30 @@
package epoch_processing
import (
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", "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 := electra.ProcessEth1DataReset(st)
require.NoError(t, err, "Could not process final updates")
return st, nil
}

View File

@@ -0,0 +1,78 @@
package epoch_processing
import (
"os"
"path"
"strings"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
state_native "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
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/bazelbuild/rules_go/go/tools/bazel"
"github.com/golang/snappy"
"github.com/google/go-cmp/cmp"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
)
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 := &ethpb.BeaconStateElectra{}
if err := preBeaconStateBase.UnmarshalSSZ(preBeaconStateSSZ); err != nil {
t.Fatalf("Failed to unmarshal: %v", err)
}
preBeaconState, err := state_native.InitializeFromProtoElectra(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 := &ethpb.BeaconStateElectra{}
if err := postBeaconState.UnmarshalSSZ(postBeaconStateSSZ); err != nil {
t.Fatalf("Failed to unmarshal: %v", err)
}
pbState, err := state_native.ProtobufBeaconStateElectra(beaconState.ToProtoUnsafe())
require.NoError(t, err)
if !proto.Equal(pbState, postBeaconState) {
t.Log(cmp.Diff(postBeaconState, pbState, protocmp.Transform()))
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
}
}

View File

@@ -0,0 +1,30 @@
package epoch_processing
import (
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
)
// RunHistoricalSummariesUpdateTests executes "epoch_processing/historical_Summaries_update" tests.
func RunHistoricalSummariesUpdateTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "fulu", "epoch_processing/historical_summaries_update/pyspec_tests")
for _, folder := range testFolders {
t.Run(folder.Name(), func(t *testing.T) {
folderPath := path.Join(testsFolderPath, folder.Name())
RunEpochOperationTest(t, folderPath, processHistoricalSummariesUpdateWrapper)
})
}
}
func processHistoricalSummariesUpdateWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
st, err := electra.ProcessHistoricalDataUpdate(st)
require.NoError(t, err, "Could not process final updates")
return st, nil
}

View File

@@ -0,0 +1,41 @@
package epoch_processing
import (
"context"
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", 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 := electra.InitializePrecomputeValidators(ctx, st)
require.NoError(t, err)
vp, _, err = electra.ProcessEpochParticipation(ctx, st, bp, vp)
require.NoError(t, err)
st, _, err = electra.ProcessInactivityScores(ctx, st, vp)
require.NoError(t, err, "Could not process reward")
return st, nil
}

View File

@@ -0,0 +1,44 @@
package epoch_processing
import (
"context"
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/epoch/precompute"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", 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 := electra.InitializePrecomputeValidators(ctx, st)
require.NoError(t, err)
_, bp, err = electra.ProcessEpochParticipation(ctx, st, bp, vp)
require.NoError(t, err)
activeBal, targetPrevious, targetCurrent, err := st.UnrealizedCheckpointBalances()
require.NoError(t, err)
require.Equal(t, bp.ActiveCurrentEpoch, activeBal)
require.Equal(t, bp.CurrentEpochTargetAttested, targetCurrent)
require.Equal(t, bp.PrevEpochTargetAttested, targetPrevious)
st, err = precompute.ProcessJustificationAndFinalizationPreCompute(st, bp)
require.NoError(t, err, "Could not process justification")
return st, nil
}

View File

@@ -0,0 +1,30 @@
package epoch_processing
import (
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", "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 := electra.ProcessParticipationFlagUpdates(st)
require.NoError(t, err, "Could not process participation flag update")
return st, nil
}

View File

@@ -0,0 +1,28 @@
package epoch_processing
import (
"context"
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
)
func RunPendingConsolidationsTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "fulu", "epoch_processing/pending_consolidations/pyspec_tests")
for _, folder := range testFolders {
t.Run(folder.Name(), func(t *testing.T) {
folderPath := path.Join(testsFolderPath, folder.Name())
RunEpochOperationTest(t, folderPath, processPendingConsolidations)
})
}
}
func processPendingConsolidations(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
return st, electra.ProcessPendingConsolidations(context.TODO(), st)
}

View File

@@ -0,0 +1,35 @@
package epoch_processing
import (
"context"
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
)
func RunPendingDepositsTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "fulu", "epoch_processing/pending_deposits/pyspec_tests")
for _, folder := range testFolders {
t.Run(folder.Name(), func(t *testing.T) {
folderPath := path.Join(testsFolderPath, folder.Name())
RunEpochOperationTest(t, folderPath, processPendingDeposits)
})
}
}
func processPendingDeposits(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
// The caller of this method would normally have the precompute balance values for total
// active balance for this epoch. For ease of test setup, we will compute total active
// balance from the given state.
tab, err := helpers.TotalActiveBalance(st)
require.NoError(t, err)
return st, electra.ProcessPendingDeposits(context.TODO(), st, primitives.Gwei(tab))
}

View File

@@ -0,0 +1,30 @@
package epoch_processing
import (
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", "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 := electra.ProcessRandaoMixesReset(st)
require.NoError(t, err, "Could not process final updates")
return st, nil
}

View File

@@ -0,0 +1,32 @@
package epoch_processing
import (
"context"
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", "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 state, electra.ProcessRegistryUpdates(context.Background(), state)
}

View File

@@ -0,0 +1,41 @@
package epoch_processing
import (
"context"
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", 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 := electra.InitializePrecomputeValidators(ctx, st)
require.NoError(t, err)
vp, bp, err = electra.ProcessEpochParticipation(ctx, st, bp, vp)
require.NoError(t, err)
st, err = electra.ProcessRewardsAndPenaltiesPrecompute(st, bp, vp)
require.NoError(t, err, "Could not process reward")
return st, nil
}

View File

@@ -0,0 +1,31 @@
package epoch_processing
import (
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", "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) {
require.NoError(t, electra.ProcessSlashings(st), "Could not process slashings")
return st, nil
}

View File

@@ -0,0 +1,30 @@
package epoch_processing
import (
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/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, "fulu", "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 := electra.ProcessSlashingsReset(st)
require.NoError(t, err, "Could not process final updates")
return st, nil
}

View File

@@ -0,0 +1,30 @@
package epoch_processing
import (
"context"
"path"
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/helpers"
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
"github.com/OffchainLabs/prysm/v6/testing/require"
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
)
func RunSyncCommitteeUpdatesTests(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "fulu", "epoch_processing/sync_committee_updates/pyspec_tests")
for _, folder := range testFolders {
t.Run(folder.Name(), func(t *testing.T) {
helpers.ClearCache()
folderPath := path.Join(testsFolderPath, folder.Name())
RunEpochOperationTest(t, folderPath, processSyncCommitteeUpdates)
})
}
}
func processSyncCommitteeUpdates(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
return electra.ProcessSyncCommitteeUpdates(context.Background(), st)
}

View File

@@ -0,0 +1,36 @@
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",
"consolidations.go",
"deposit.go",
"deposit_request.go",
"execution_payload.go",
"helpers.go",
"proposer_slashing.go",
"sync_committee.go",
"voluntary_exit.go",
"withdrawal_request.go",
"withdrawals.go",
],
importpath = "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/fulu/operations",
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/core/electra: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",
"//runtime/version:go_default_library",
"//testing/spectest/shared/common/operations:go_default_library",
"//testing/util:go_default_library",
],
)

View File

@@ -0,0 +1,27 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithAttestation(attestationSSZ []byte) (interfaces.SignedBeaconBlock, error) {
att := &ethpb.AttestationElectra{}
if err := att.UnmarshalSSZ(attestationSSZ); err != nil {
return nil, err
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{Attestations: []*ethpb.AttestationElectra{att}}
return blocks.NewSignedBeaconBlock(b)
}
func RunAttestationTest(t *testing.T, config string) {
common.RunAttestationTest(t, config, version.String(version.Fulu), blockWithAttestation, electra.ProcessAttestationsNoVerifySignature, sszToState)
}

View File

@@ -0,0 +1,26 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithAttesterSlashing(asSSZ []byte) (interfaces.SignedBeaconBlock, error) {
as := &ethpb.AttesterSlashingElectra{}
if err := as.UnmarshalSSZ(asSSZ); err != nil {
return nil, err
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{AttesterSlashings: []*ethpb.AttesterSlashingElectra{as}}
return blocks.NewSignedBeaconBlock(b)
}
func RunAttesterSlashingTest(t *testing.T, config string) {
common.RunAttesterSlashingTest(t, config, version.String(version.Fulu), blockWithAttesterSlashing, sszToState)
}

View File

@@ -0,0 +1,12 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
)
func RunBlockHeaderTest(t *testing.T, config string) {
common.RunBlockHeaderTest(t, config, version.String(version.Fulu), sszToBlock, sszToState)
}

View File

@@ -0,0 +1,26 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithBlsChange(ssz []byte) (interfaces.SignedBeaconBlock, error) {
c := &ethpb.SignedBLSToExecutionChange{}
if err := c.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{BlsToExecutionChanges: []*ethpb.SignedBLSToExecutionChange{c}}
return blocks.NewSignedBeaconBlock(b)
}
func RunBLSToExecutionChangeTest(t *testing.T, config string) {
common.RunBLSToExecutionChangeTest(t, config, version.String(version.Fulu), blockWithBlsChange, sszToState)
}

View File

@@ -0,0 +1,30 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithConsolidation(ssz []byte) (interfaces.SignedBeaconBlock, error) {
cr := &enginev1.ConsolidationRequest{}
if err := cr.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
er := &enginev1.ExecutionRequests{
Consolidations: []*enginev1.ConsolidationRequest{cr},
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{ExecutionRequests: er}
return blocks.NewSignedBeaconBlock(b)
}
func RunConsolidationTest(t *testing.T, config string) {
common.RunConsolidationTest(t, config, version.String(version.Fulu), blockWithConsolidation, sszToState)
}

View File

@@ -0,0 +1,27 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/electra"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithDeposit(ssz []byte) (interfaces.SignedBeaconBlock, error) {
d := &ethpb.Deposit{}
if err := d.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{Deposits: []*ethpb.Deposit{d}}
return blocks.NewSignedBeaconBlock(b)
}
func RunDepositTest(t *testing.T, config string) {
common.RunDepositTest(t, config, version.String(version.Fulu), blockWithDeposit, electra.ProcessDeposits, sszToState)
}

View File

@@ -0,0 +1,30 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithDepositRequest(ssz []byte) (interfaces.SignedBeaconBlock, error) {
dr := &enginev1.DepositRequest{}
if err := dr.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
er := &enginev1.ExecutionRequests{
Deposits: []*enginev1.DepositRequest{dr},
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{ExecutionRequests: er}
return blocks.NewSignedBeaconBlock(b)
}
func RunDepositRequestsTest(t *testing.T, config string) {
common.RunDepositRequestsTest(t, config, version.String(version.Fulu), blockWithDepositRequest, sszToState)
}

View File

@@ -0,0 +1,12 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
)
func RunExecutionPayloadTest(t *testing.T, config string) {
common.RunExecutionPayloadTest(t, config, version.String(version.Fulu), sszToBlockBody, sszToState)
}

View File

@@ -0,0 +1,33 @@
package operations
import (
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
state_native "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
)
func sszToState(b []byte) (state.BeaconState, error) {
base := &ethpb.BeaconStateElectra{}
if err := base.UnmarshalSSZ(b); err != nil {
return nil, err
}
return state_native.InitializeFromProtoElectra(base)
}
func sszToBlock(b []byte) (interfaces.SignedBeaconBlock, error) {
base := &ethpb.BeaconBlockElectra{}
if err := base.UnmarshalSSZ(b); err != nil {
return nil, err
}
return blocks.NewSignedBeaconBlock(&ethpb.SignedBeaconBlockElectra{Block: base})
}
func sszToBlockBody(b []byte) (interfaces.ReadOnlyBeaconBlockBody, error) {
base := &ethpb.BeaconBlockBodyElectra{}
if err := base.UnmarshalSSZ(b); err != nil {
return nil, err
}
return blocks.NewBeaconBlockBody(base)
}

View File

@@ -0,0 +1,26 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithProposerSlashing(ssz []byte) (interfaces.SignedBeaconBlock, error) {
ps := &ethpb.ProposerSlashing{}
if err := ps.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{ProposerSlashings: []*ethpb.ProposerSlashing{ps}}
return blocks.NewSignedBeaconBlock(b)
}
func RunProposerSlashingTest(t *testing.T, config string) {
common.RunProposerSlashingTest(t, config, version.String(version.Fulu), blockWithProposerSlashing, sszToState)
}

View File

@@ -0,0 +1,26 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithSyncAggregate(ssz []byte) (interfaces.SignedBeaconBlock, error) {
sa := &ethpb.SyncAggregate{}
if err := sa.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{SyncAggregate: sa}
return blocks.NewSignedBeaconBlock(b)
}
func RunSyncCommitteeTest(t *testing.T, config string) {
common.RunSyncCommitteeTest(t, config, version.String(version.Fulu), blockWithSyncAggregate, sszToState)
}

View File

@@ -0,0 +1,26 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithVoluntaryExit(ssz []byte) (interfaces.SignedBeaconBlock, error) {
e := &ethpb.SignedVoluntaryExit{}
if err := e.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
b := util.NewBeaconBlock()
b.Block.Body = &ethpb.BeaconBlockBody{VoluntaryExits: []*ethpb.SignedVoluntaryExit{e}}
return blocks.NewSignedBeaconBlock(b)
}
func RunVoluntaryExitTest(t *testing.T, config string) {
common.RunVoluntaryExitTest(t, config, version.String(version.Fulu), blockWithVoluntaryExit, sszToState)
}

View File

@@ -0,0 +1,30 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithWithdrawalRequest(ssz []byte) (interfaces.SignedBeaconBlock, error) {
wr := &enginev1.WithdrawalRequest{}
if err := wr.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
er := &enginev1.ExecutionRequests{
Withdrawals: []*enginev1.WithdrawalRequest{wr},
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{ExecutionRequests: er}
return blocks.NewSignedBeaconBlock(b)
}
func RunWithdrawalRequestTest(t *testing.T, config string) {
common.RunWithdrawalRequestTest(t, config, version.String(version.Fulu), blockWithWithdrawalRequest, sszToState)
}

View File

@@ -0,0 +1,27 @@
package operations
import (
"testing"
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v6/consensus-types/interfaces"
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v6/runtime/version"
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/operations"
"github.com/OffchainLabs/prysm/v6/testing/util"
)
func blockWithWithdrawals(ssz []byte) (interfaces.SignedBeaconBlock, error) {
e := &enginev1.ExecutionPayloadDeneb{}
if err := e.UnmarshalSSZ(ssz); err != nil {
return nil, err
}
b := util.NewBeaconBlockElectra()
b.Block.Body = &ethpb.BeaconBlockBodyElectra{ExecutionPayload: e}
return blocks.NewSignedBeaconBlock(b)
}
func RunWithdrawalsTest(t *testing.T, config string) {
common.RunWithdrawalsTest(t, config, version.String(version.Fulu), blockWithWithdrawals, sszToState)
}