mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
* Add the new Fulu state with the new field * fix the hasher for the fulu state * Fix ToProto() and ToProtoUnsafe() * Add the fields as shared * Add epoch transition code * short circuit the proposer cache to use the state * Marshal the state JSON * update spectests to 1.6.0-alpha.1 * Remove deneb and electra entries from blob schedule This was cherry picked from PR #15364 and edited to remove the minimal cases * Fix minimal tests * Increase deadling for processing blocks in spectests * Preston's review * review --------- Co-authored-by: terence tsao <terence@prysmaticlabs.com>
169 lines
5.1 KiB
Go
169 lines
5.1 KiB
Go
package ssz_static
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
state_native "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
|
|
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
|
|
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
|
|
"github.com/OffchainLabs/prysm/v6/testing/require"
|
|
common "github.com/OffchainLabs/prysm/v6/testing/spectest/shared/common/ssz_static"
|
|
fssz "github.com/prysmaticlabs/fastssz"
|
|
)
|
|
|
|
// RunSSZStaticTests executes "ssz_static" tests.
|
|
func RunSSZStaticTests(t *testing.T, config string) {
|
|
common.RunSSZStaticTests(t, config, "fulu", UnmarshalledSSZ, customHtr)
|
|
}
|
|
|
|
func customHtr(t *testing.T, htrs []common.HTR, object interface{}) []common.HTR {
|
|
_, ok := object.(*ethpb.BeaconStateFulu)
|
|
if !ok {
|
|
return htrs
|
|
}
|
|
|
|
htrs = append(htrs, func(s interface{}) ([32]byte, error) {
|
|
beaconState, err := state_native.InitializeFromProtoFulu(s.(*ethpb.BeaconStateFulu))
|
|
require.NoError(t, err)
|
|
return beaconState.HashTreeRoot(context.Background())
|
|
})
|
|
return htrs
|
|
}
|
|
|
|
// UnmarshalledSSZ unmarshalls serialized input.
|
|
func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (interface{}, error) {
|
|
var obj interface{}
|
|
switch folderName {
|
|
case "ExecutionPayload":
|
|
obj = &enginev1.ExecutionPayloadDeneb{}
|
|
case "ExecutionPayloadHeader":
|
|
obj = &enginev1.ExecutionPayloadHeaderDeneb{}
|
|
case "Attestation":
|
|
obj = ðpb.AttestationElectra{}
|
|
case "AttestationData":
|
|
obj = ðpb.AttestationData{}
|
|
case "AttesterSlashing":
|
|
obj = ðpb.AttesterSlashingElectra{}
|
|
case "AggregateAndProof":
|
|
obj = ðpb.AggregateAttestationAndProofElectra{}
|
|
case "BeaconBlock":
|
|
obj = ðpb.BeaconBlockElectra{}
|
|
case "BeaconBlockBody":
|
|
obj = ðpb.BeaconBlockBodyElectra{}
|
|
case "BeaconBlockHeader":
|
|
obj = ðpb.BeaconBlockHeader{}
|
|
case "BeaconState":
|
|
obj = ðpb.BeaconStateFulu{}
|
|
case "Checkpoint":
|
|
obj = ðpb.Checkpoint{}
|
|
case "Deposit":
|
|
obj = ðpb.Deposit{}
|
|
case "DepositMessage":
|
|
obj = ðpb.DepositMessage{}
|
|
case "DepositData":
|
|
obj = ðpb.Deposit_Data{}
|
|
case "Eth1Data":
|
|
obj = ðpb.Eth1Data{}
|
|
case "Eth1Block":
|
|
t.Skip("Unused type")
|
|
return nil, nil
|
|
case "Fork":
|
|
obj = ðpb.Fork{}
|
|
case "ForkData":
|
|
obj = ðpb.ForkData{}
|
|
case "HistoricalBatch":
|
|
obj = ðpb.HistoricalBatch{}
|
|
case "IndexedAttestation":
|
|
obj = ðpb.IndexedAttestationElectra{}
|
|
case "PendingAttestation":
|
|
obj = ðpb.PendingAttestation{}
|
|
case "ProposerSlashing":
|
|
obj = ðpb.ProposerSlashing{}
|
|
case "SignedAggregateAndProof":
|
|
obj = ðpb.SignedAggregateAttestationAndProofElectra{}
|
|
case "SignedBeaconBlock":
|
|
obj = ðpb.SignedBeaconBlockElectra{}
|
|
case "SignedBeaconBlockHeader":
|
|
obj = ðpb.SignedBeaconBlockHeader{}
|
|
case "SignedVoluntaryExit":
|
|
obj = ðpb.SignedVoluntaryExit{}
|
|
case "SigningData":
|
|
obj = ðpb.SigningData{}
|
|
case "Validator":
|
|
obj = ðpb.Validator{}
|
|
case "VoluntaryExit":
|
|
obj = ðpb.VoluntaryExit{}
|
|
case "SyncCommitteeMessage":
|
|
obj = ðpb.SyncCommitteeMessage{}
|
|
case "SyncCommitteeContribution":
|
|
obj = ðpb.SyncCommitteeContribution{}
|
|
case "ContributionAndProof":
|
|
obj = ðpb.ContributionAndProof{}
|
|
case "SignedContributionAndProof":
|
|
obj = ðpb.SignedContributionAndProof{}
|
|
case "SingleAttestation":
|
|
obj = ðpb.SingleAttestation{}
|
|
case "SyncAggregate":
|
|
obj = ðpb.SyncAggregate{}
|
|
case "SyncAggregatorSelectionData":
|
|
obj = ðpb.SyncAggregatorSelectionData{}
|
|
case "SyncCommittee":
|
|
obj = ðpb.SyncCommittee{}
|
|
case "LightClientOptimisticUpdate":
|
|
obj = ðpb.LightClientOptimisticUpdateDeneb{}
|
|
case "LightClientFinalityUpdate":
|
|
obj = ðpb.LightClientFinalityUpdateElectra{}
|
|
case "LightClientBootstrap":
|
|
obj = ðpb.LightClientBootstrapElectra{}
|
|
case "LightClientUpdate":
|
|
obj = ðpb.LightClientUpdateElectra{}
|
|
case "LightClientHeader":
|
|
obj = ðpb.LightClientHeaderDeneb{}
|
|
case "BlobIdentifier":
|
|
obj = ðpb.BlobIdentifier{}
|
|
case "BlobSidecar":
|
|
obj = ðpb.BlobSidecar{}
|
|
case "PowBlock":
|
|
obj = ðpb.PowBlock{}
|
|
case "Withdrawal":
|
|
obj = &enginev1.Withdrawal{}
|
|
case "HistoricalSummary":
|
|
obj = ðpb.HistoricalSummary{}
|
|
case "BLSToExecutionChange":
|
|
obj = ðpb.BLSToExecutionChange{}
|
|
case "SignedBLSToExecutionChange":
|
|
obj = ðpb.SignedBLSToExecutionChange{}
|
|
case "PendingDeposit":
|
|
obj = ðpb.PendingDeposit{}
|
|
case "PendingPartialWithdrawal":
|
|
obj = ðpb.PendingPartialWithdrawal{}
|
|
case "PendingConsolidation":
|
|
obj = ðpb.PendingConsolidation{}
|
|
case "WithdrawalRequest":
|
|
obj = &enginev1.WithdrawalRequest{}
|
|
case "DepositRequest":
|
|
obj = &enginev1.DepositRequest{}
|
|
case "ConsolidationRequest":
|
|
obj = &enginev1.ConsolidationRequest{}
|
|
case "ExecutionRequests":
|
|
obj = &enginev1.ExecutionRequests{}
|
|
case "DataColumnSidecar":
|
|
obj = ðpb.DataColumnSidecar{}
|
|
case "DataColumnsByRootIdentifier":
|
|
obj = ðpb.DataColumnsByRootIdentifier{}
|
|
case "MatrixEntry":
|
|
t.Skip("Unused type")
|
|
default:
|
|
return nil, errors.New("type not found")
|
|
}
|
|
var err error
|
|
if o, ok := obj.(fssz.Unmarshaler); ok {
|
|
err = o.UnmarshalSSZ(serializedBytes)
|
|
} else {
|
|
err = errors.New("could not unmarshal object, not a fastssz compatible object")
|
|
}
|
|
return obj, err
|
|
}
|