Documentation ¶
Index ¶
- Variables
- type BlsAggregateVerify
- type EpochProcessing
- type ForkChoice
- type ForkChoiceChecks
- type ForkChoicePayloadStatus
- type ForkChoiceStep
- func (f *ForkChoiceStep) GetAttestation() string
- func (f *ForkChoiceStep) GetAttesterSlashing() string
- func (f *ForkChoiceStep) GetBlobs() string
- func (f *ForkChoiceStep) GetBlock() string
- func (f *ForkChoiceStep) GetBlockHash() string
- func (f *ForkChoiceStep) GetChecks() *ForkChoiceChecks
- func (f *ForkChoiceStep) GetPayloadStatus() *ForkChoicePayloadStatus
- func (f *ForkChoiceStep) GetPowBlock() string
- func (f *ForkChoiceStep) GetTick() int
- func (f *ForkChoiceStep) GetValid() bool
- func (f *ForkChoiceStep) StepType() string
- type LcBranch
- type MPTBranch
- type RewardsCore
- type Root
- type ShufflingCore
- type TransitionCore
Constants ¶
This section is empty.
Variables ¶
View Source
var Eip4844MerkleProof = spectest.HandlerFunc(func(t *testing.T, root fs.FS, c spectest.TestCase) (err error) { proofYaml := MPTBranch{} err = spectest.ReadYml(root, "proof.yaml", &proofYaml) require.NoError(t, err) branch := make([][32]byte, len(proofYaml.Branch)) for i, b := range proofYaml.Branch { branch[i] = libcommon.HexToHash(b) } leaf := libcommon.HexToHash(proofYaml.Leaf) beaconBody := cltypes.NewBeaconBody(&clparams.MainnetBeaconConfig, clparams.DenebVersion) require.NoError(t, spectest.ReadSsz(root, c.Version(), spectest.ObjectSSZ, beaconBody)) proof, err := beaconBody.KzgCommitmentMerkleProof(0) require.NoError(t, err) require.Equal(t, branch, proof) bodyRoot, err := beaconBody.HashSSZ() require.NoError(t, err) proofHashes := make([]libcommon.Hash, len(proof)) for i := range proof { proofHashes[i] = libcommon.Hash(proof[i]) } require.True(t, utils.IsValidMerkleBranch(leaf, proofHashes, 17, proofYaml.LeafIndex, bodyRoot)) hashList := solid.NewHashVector(17) for i, h := range proof { hashList.Set(i, libcommon.Hash(h)) } require.True(t, cltypes.VerifyCommitmentInclusionProof(libcommon.Bytes48(*beaconBody.BlobKzgCommitments.Get(0)), hashList, 0, c.Version(), bodyRoot)) return nil })
View Source
var FinalityFinality = spectest.HandlerFunc(func(t *testing.T, root fs.FS, c spectest.TestCase) (err error) { testState, err := spectest.ReadBeaconState(root, c.Version(), spectest.PreSsz) require.NoError(t, err) expectedState, err := spectest.ReadBeaconState(root, c.Version(), spectest.PostSsz) require.NoError(t, err) blocks, err := spectest.ReadBlocks(root, c.Version()) if err != nil { return err } startSlot := testState.Slot() for _, block := range blocks { if err := machine.TransitionState(c.Machine, testState, block); err != nil { require.NoError(t, fmt.Errorf("cannot transition state: %w. slot=%d. start_slot=%d", err, block.Block.Slot, startSlot)) } } expectedRoot, err := testState.HashSSZ() assert.NoError(t, err) haveRoot, err := expectedState.HashSSZ() assert.NoError(t, err) assert.EqualValues(t, haveRoot, expectedRoot, "state root") return nil })
View Source
var ForksFork = spectest.HandlerFunc(func(t *testing.T, root fs.FS, c spectest.TestCase) (err error) { preState, err := spectest.ReadBeaconState(root, c.Version()-1, spectest.PreSsz) require.NoError(t, err) postState, err := spectest.ReadBeaconState(root, c.Version(), spectest.PostSsz) expectedError := os.IsNotExist(err) if !expectedError { require.NoError(t, err) } switch preState.Version() { case clparams.Phase0Version: err = preState.UpgradeToAltair() case clparams.AltairVersion: err = preState.UpgradeToBellatrix() case clparams.BellatrixVersion: err = preState.UpgradeToCapella() case clparams.CapellaVersion: err = preState.UpgradeToDeneb() case clparams.DenebVersion: err = preState.UpgradeToElectra() default: err = spectest.ErrHandlerNotImplemented(fmt.Sprintf("block state %v", preState.Version())) } if expectedError { assert.Error(t, err) } haveRoot, err := preState.HashSSZ() assert.NoError(t, err) expectedRoot, err := postState.HashSSZ() assert.NoError(t, err) assert.EqualValues(t, haveRoot, expectedRoot, "state root") return nil })
View Source
var LightClientBeaconBlockBodyExecutionMerkleProof = spectest.HandlerFunc(func(t *testing.T, root fs.FS, c spectest.TestCase) (err error) { var proof [][32]byte switch c.CaseName { case "execution_merkle_proof": beaconBody := cltypes.NewBeaconBody(&clparams.MainnetBeaconConfig, clparams.DenebVersion) require.NoError(t, spectest.ReadSsz(root, c.Version(), spectest.ObjectSSZ, beaconBody)) proof, err = beaconBody.ExecutionPayloadMerkleProof() require.NoError(t, err) case "current_sync_committee_merkle_proof": state := state.New(&clparams.MainnetBeaconConfig) require.NoError(t, spectest.ReadSsz(root, c.Version(), spectest.ObjectSSZ, state)) proof, err = state.CurrentSyncCommitteeBranch() require.NoError(t, err) case "next_sync_committee_merkle_proof": state := state.New(&clparams.MainnetBeaconConfig) require.NoError(t, spectest.ReadSsz(root, c.Version(), spectest.ObjectSSZ, state)) proof, err = state.NextSyncCommitteeBranch() require.NoError(t, err) case "finality_root_merkle_proof": state := state.New(&clparams.MainnetBeaconConfig) require.NoError(t, spectest.ReadSsz(root, c.Version(), spectest.ObjectSSZ, state)) proof, err = state.FinalityRootBranch() require.NoError(t, err) default: t.Skip("skipping: ", c.CaseName) } proofYaml := LcBranch{} err = spectest.ReadYml(root, "proof.yaml", &proofYaml) require.NoError(t, err) branch := make([][32]byte, len(proofYaml.Branch)) for i, b := range proofYaml.Branch { branch[i] = libcommon.HexToHash(b) } require.Equal(t, branch, proof) return nil })
View Source
var SanityBlocks = spectest.HandlerFunc(func(t *testing.T, root fs.FS, c spectest.TestCase) (err error) { var meta struct { Description string `yaml:"description"` BlsSetting int `yaml:"bls_settings"` RevealDeadlinesSetting int `yaml:"reveal_deadlines_setting"` BlocksCount int `yaml:"blocks_count"` } err = spectest.ReadMeta(root, "meta.yaml", &meta) require.NoError(t, err) testState, err := spectest.ReadBeaconState(root, c.Version(), spectest.PreSsz) require.NoError(t, err) var expectedError bool expectedState, err := spectest.ReadBeaconState(root, c.Version(), spectest.PostSsz) if os.IsNotExist(err) { expectedError = true } else { require.NoError(t, err) } blocks, err := spectest.ReadBlocks(root, c.Version()) require.NoError(t, err) var block *cltypes.SignedBeaconBlock for _, block = range blocks { err = machine.TransitionState(c.Machine, testState, block) if err != nil { break } } if expectedError { require.Error(t, err) return nil } else { require.NoError(t, err) } finalRoot, err := expectedState.HashSSZ() require.NoError(t, err) haveRoot, err := testState.HashSSZ() require.NoError(t, err) assert.EqualValues(t, finalRoot, haveRoot) return nil })
View Source
var SanitySlots = spectest.HandlerFunc(func(t *testing.T, root fs.FS, c spectest.TestCase) (err error) { // TODO: this is unused, why? var slots int err = spectest.ReadMeta(root, "slots.yaml", &slots) require.NoError(t, err) testState, err := spectest.ReadBeaconState(root, c.Version(), spectest.PreSsz) require.NoError(t, err) expectedState, err := spectest.ReadBeaconState(root, c.Version(), spectest.PostSsz) require.NoError(t, err) err = c.Machine.ProcessSlots(testState, expectedState.Slot()) require.NoError(t, err) expectedRoot, err := expectedState.HashSSZ() require.NoError(t, err) haveRoot, err := testState.HashSSZ() require.NoError(t, err) assert.EqualValues(t, expectedRoot, haveRoot) return nil })
View Source
var TestFormats = spectest.Appendix{}
Functions ¶
This section is empty.
Types ¶
type BlsAggregateVerify ¶
type BlsAggregateVerify struct { }
type EpochProcessing ¶
type EpochProcessing struct {
Fn func(s abstract.BeaconState) error
}
func NewEpochProcessing ¶
func NewEpochProcessing(fn func(s abstract.BeaconState) error) *EpochProcessing
type ForkChoice ¶
type ForkChoice struct { }
func NewForkChoice ¶
func NewForkChoice(fn func(s abstract.BeaconState) error) *ForkChoice
type ForkChoiceChecks ¶
type ForkChoiceChecks struct { Head *struct { Slot *int `yaml:"slot,omitempty"` Root *common.Hash `yaml:"root,omitempty"` } `yaml:"head,omitempty"` Time *int `yaml:"time,omitempty"` GenesisTime *int `yaml:"genesis_time,omitempty"` JustifiedCheckpoint *struct { Epoch *int `yaml:"epoch,omitempty"` Root *common.Hash `yaml:"root,omitempty"` } `yaml:"justified_checkpoint,omitempty"` FinalizedCheckpoint *struct { Epoch *int `yaml:"epoch,omitempty"` Root *common.Hash `yaml:"root,omitempty"` } `yaml:"finalized_checkpoint,omitempty"` ProposerBoostRoot *common.Hash `yaml:"proposer_boost_root,omitempty"` }
type ForkChoicePayloadStatus ¶
type ForkChoiceStep ¶
type ForkChoiceStep struct { Tick *int `yaml:"tick,omitempty"` Valid *bool `yaml:"valid,omitempty"` Attestation *string `yaml:"attestation,omitempty"` Block *string `yaml:"block,omitempty"` Blobs *string `yaml:"blobs,omitempty"` Proofs []string `yaml:"proofs,omitempty"` PowBlock *string `yaml:"pow_block,omitempty"` AttesterSlashing *string `yaml:"attester_slashing,omitempty"` BlockHash *string `yaml:"block_hash,omitempty"` PayloadStatus *ForkChoicePayloadStatus `yaml:"payload_status,omitempty"` Checks *ForkChoiceChecks `yaml:"checks,omitempty"` }
func (*ForkChoiceStep) GetAttestation ¶
func (f *ForkChoiceStep) GetAttestation() string
func (*ForkChoiceStep) GetAttesterSlashing ¶
func (f *ForkChoiceStep) GetAttesterSlashing() string
func (*ForkChoiceStep) GetBlobs ¶
func (f *ForkChoiceStep) GetBlobs() string
func (*ForkChoiceStep) GetBlock ¶
func (f *ForkChoiceStep) GetBlock() string
func (*ForkChoiceStep) GetBlockHash ¶
func (f *ForkChoiceStep) GetBlockHash() string
func (*ForkChoiceStep) GetChecks ¶
func (f *ForkChoiceStep) GetChecks() *ForkChoiceChecks
func (*ForkChoiceStep) GetPayloadStatus ¶
func (f *ForkChoiceStep) GetPayloadStatus() *ForkChoicePayloadStatus
func (*ForkChoiceStep) GetPowBlock ¶
func (f *ForkChoiceStep) GetPowBlock() string
func (*ForkChoiceStep) GetTick ¶
func (f *ForkChoiceStep) GetTick() int
func (*ForkChoiceStep) GetValid ¶
func (f *ForkChoiceStep) GetValid() bool
func (*ForkChoiceStep) StepType ¶
func (f *ForkChoiceStep) StepType() string
type RewardsCore ¶
type RewardsCore struct { }
type ShufflingCore ¶
type ShufflingCore struct { }
Click to show internal directories.
Click to hide internal directories.