mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
* block protos * proto and ssz * stubs * Enable Electra spec test * Pull in EIP-7251 protobuf changes From: https://github.com/prysmaticlabs/prysm/pull/13903 * All EIP7549 containers are passing * All EIP7251 containers passing * including changes from eip7002 * Everything passing except for beacon state hash tree root * fixing eletra state to use electra payload * Fix minimal test. Skip beacon state test * Perston's feedback --------- Co-authored-by: rkapka <radoslaw.kapka@gmail.com> Co-authored-by: james-prysm <james@prysmaticlabs.com>
171 lines
5.3 KiB
Go
171 lines
5.3 KiB
Go
package ssz_static
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
fssz "github.com/prysmaticlabs/fastssz"
|
|
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
|
|
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
common "github.com/prysmaticlabs/prysm/v5/testing/spectest/shared/common/ssz_static"
|
|
)
|
|
|
|
// RunSSZStaticTests executes "ssz_static" tests.
|
|
func RunSSZStaticTests(t *testing.T, config string) {
|
|
common.RunSSZStaticTests(t, config, "electra", UnmarshalledSSZ, customHtr)
|
|
}
|
|
|
|
func customHtr(t *testing.T, htrs []common.HTR, object interface{}) []common.HTR {
|
|
// TODO: Replace BeaconStateDeneb with BeaconStateElectra below and uncomment the code
|
|
//_, ok := object.(*ethpb.BeaconStateDeneb)
|
|
//if !ok {
|
|
// return htrs
|
|
//}
|
|
//
|
|
//htrs = append(htrs, func(s interface{}) ([32]byte, error) {
|
|
// beaconState, err := state_native.InitializeFromProtoDeneb(s.(*ethpb.BeaconStateDeneb))
|
|
// 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) {
|
|
// TODO: Remove this check once BeaconState custom HTR function is ready
|
|
if folderName == "BeaconState" {
|
|
t.Skip("BeaconState is not ready")
|
|
}
|
|
var obj interface{}
|
|
switch folderName {
|
|
case "ExecutionPayload":
|
|
obj = &enginev1.ExecutionPayloadElectra{}
|
|
case "ExecutionPayloadHeader":
|
|
obj = &enginev1.ExecutionPayloadHeaderElectra{}
|
|
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.BeaconStateElectra{}
|
|
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 "SyncAggregate":
|
|
obj = ðpb.SyncAggregate{}
|
|
case "SyncAggregatorSelectionData":
|
|
obj = ðpb.SyncAggregatorSelectionData{}
|
|
case "SyncCommittee":
|
|
obj = ðpb.SyncCommittee{}
|
|
case "LightClientOptimisticUpdate":
|
|
t.Skip("not a beacon node type, this is a light node type")
|
|
return nil, nil
|
|
case "LightClientFinalityUpdate":
|
|
t.Skip("not a beacon node type, this is a light node type")
|
|
return nil, nil
|
|
case "LightClientBootstrap":
|
|
t.Skip("not a beacon node type, this is a light node type")
|
|
return nil, nil
|
|
case "LightClientSnapshot":
|
|
t.Skip("not a beacon node type, this is a light node type")
|
|
return nil, nil
|
|
case "LightClientUpdate":
|
|
t.Skip("not a beacon node type, this is a light node type")
|
|
return nil, nil
|
|
case "LightClientHeader":
|
|
t.Skip("not a beacon node type, this is a light node type")
|
|
return nil, nil
|
|
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 "PendingBalanceDeposit":
|
|
obj = ðpb.PendingBalanceDeposit{}
|
|
case "PendingPartialWithdrawal":
|
|
obj = ðpb.PendingPartialWithdrawal{}
|
|
case "Consolidation":
|
|
obj = ðpb.Consolidation{}
|
|
case "SignedConsolidation":
|
|
obj = ðpb.SignedConsolidation{}
|
|
case "PendingConsolidation":
|
|
obj = ðpb.PendingConsolidation{}
|
|
case "ExecutionLayerWithdrawalRequest":
|
|
obj = &enginev1.ExecutionLayerWithdrawalRequest{}
|
|
case "DepositReceipt":
|
|
obj = &enginev1.DepositReceipt{}
|
|
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
|
|
}
|