Documentation
¶
Index ¶
- func BazelDirectoryNonEmpty(filePath string) (bool, error)
- func BazelFileBytes(filePaths ...string) ([]byte, error)
- func BazelListDirectories(filepath string) ([]string, error)
- func BazelListFiles(filepath string) ([]string, error)
- func BlockSignature(bState state.BeaconState, block *ethpb.BeaconBlock, privKeys []bls.SecretKey) (bls.Signature, error)
- func BlockSignatureAltair(bState state.BeaconStateAltair, block *ethpb.BeaconBlockAltair, ...) (bls.Signature, error)
- func DepositTrieFromDeposits(deposits []*ethpb.Deposit) (*trie.SparseMerkleTrie, [][32]byte, error)
- func DepositTrieSubset(sparseTrie *trie.SparseMerkleTrie, size int) (*trie.SparseMerkleTrie, [][32]byte, error)
- func DepositsWithBalance(balances []uint64) ([]*ethpb.Deposit, *trie.SparseMerkleTrie, error)
- func DeterministicDepositTrie(size int) (*trie.SparseMerkleTrie, [][32]byte, error)
- func DeterministicDepositsAndKeys(numDeposits uint64) ([]*ethpb.Deposit, []bls.SecretKey, error)
- func DeterministicDepositsAndKeysSameValidator(numDeposits uint64) ([]*ethpb.Deposit, []bls.SecretKey, error)
- func DeterministicEth1Data(size int) (*ethpb.Eth1Data, error)
- func DeterministicGenesisState(t testing.TB, numValidators uint64) (state.BeaconState, []bls.SecretKey)
- func DeterministicGenesisStateAltair(t testing.TB, numValidators uint64) (state.BeaconStateAltair, []bls.SecretKey)
- func FillRootsNaturalOpt(state *ethpb.BeaconState) error
- func GenerateAttestations(bState state.BeaconState, privs []bls.SecretKey, numToGen uint64, ...) ([]*ethpb.Attestation, error)
- func GenerateAttesterSlashingForValidator(bState state.BeaconState, priv bls.SecretKey, idx types.ValidatorIndex) (*ethpb.AttesterSlashing, error)
- func GenerateFullBlock(bState state.BeaconState, privs []bls.SecretKey, conf *BlockGenConfig, ...) (*ethpb.SignedBeaconBlock, error)
- func GenerateFullBlockAltair(bState state.BeaconState, privs []bls.SecretKey, conf *BlockGenConfig, ...) (*ethpb.SignedBeaconBlockAltair, error)
- func GenerateProposerSlashingForValidator(bState state.BeaconState, priv bls.SecretKey, idx types.ValidatorIndex) (*ethpb.ProposerSlashing, error)
- func GenesisBeaconState(ctx context.Context, deposits []*ethpb.Deposit, genesisTime uint64, ...) (state.BeaconStateAltair, error)
- func HydrateAttestation(a *ethpb.Attestation) *ethpb.Attestation
- func HydrateAttestationData(d *ethpb.AttestationData) *ethpb.AttestationData
- func HydrateBeaconBlock(b *ethpb.BeaconBlock) *ethpb.BeaconBlock
- func HydrateBeaconBlockAltair(b *ethpb.BeaconBlockAltair) *ethpb.BeaconBlockAltair
- func HydrateBeaconBlockBody(b *ethpb.BeaconBlockBody) *ethpb.BeaconBlockBody
- func HydrateBeaconBlockBodyAltair(b *ethpb.BeaconBlockBodyAltair) *ethpb.BeaconBlockBodyAltair
- func HydrateBeaconHeader(h *ethpb.BeaconBlockHeader) *ethpb.BeaconBlockHeader
- func HydrateIndexedAttestation(a *ethpb.IndexedAttestation) *ethpb.IndexedAttestation
- func HydrateSignedBeaconBlock(b *ethpb.SignedBeaconBlock) *ethpb.SignedBeaconBlock
- func HydrateSignedBeaconBlockAltair(b *ethpb.SignedBeaconBlockAltair) *ethpb.SignedBeaconBlockAltair
- func HydrateSignedBeaconHeader(h *ethpb.SignedBeaconBlockHeader) *ethpb.SignedBeaconBlockHeader
- func HydrateSyncCommittee(s *ethpb.SyncCommitteeMessage) *ethpb.SyncCommitteeMessage
- func HydrateV1Attestation(a *attv1.Attestation) *attv1.Attestation
- func HydrateV1AttestationData(d *attv1.AttestationData) *attv1.AttestationData
- func HydrateV1BeaconBlock(b *v1.BeaconBlock) *v1.BeaconBlock
- func HydrateV1BeaconBlockBody(b *v1.BeaconBlockBody) *v1.BeaconBlockBody
- func HydrateV1SignedBeaconBlock(b *v1.SignedBeaconBlock) *v1.SignedBeaconBlock
- func HydrateV2BeaconBlock(b *v2.BeaconBlockAltair) *v2.BeaconBlockAltair
- func HydrateV2BeaconBlockBody(b *v2.BeaconBlockBodyAltair) *v2.BeaconBlockBodyAltair
- func HydrateV2SignedBeaconBlock(b *v2.SignedBeaconBlockAltair) *v2.SignedBeaconBlockAltair
- func NewAttestation() *ethpb.Attestation
- func NewBeaconBlock() *ethpb.SignedBeaconBlock
- func NewBeaconBlockAltair() *ethpb.SignedBeaconBlockAltair
- func NewBeaconState(options ...func(state *ethpb.BeaconState) error) (*v1.BeaconState, error)
- func RandaoReveal(beaconState state.ReadOnlyBeaconState, epoch types.Epoch, ...) ([]byte, error)
- func Random32Bytes(t *testing.T) []byte
- func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool
- type BlockGenConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BazelDirectoryNonEmpty ¶
BazelDirectoryNonEmpty returns true if directory exists and is not empty.
func BazelFileBytes ¶
BazelFileBytes returns the byte array of the bazel file path given.
func BazelListDirectories ¶
BazelListDirectories lists all of the directories in the given directory. Excludes regular files. Returns error when no directories exist.
func BazelListFiles ¶
BazelListFiles lists all of the file names in a given directory. Excludes directories. Returns an error when no non-directory files exist.
func BlockSignature ¶
func BlockSignature( bState state.BeaconState, block *ethpb.BeaconBlock, privKeys []bls.SecretKey, ) (bls.Signature, error)
BlockSignature calculates the post-state root of the block and returns the signature.
func BlockSignatureAltair ¶
func BlockSignatureAltair( bState state.BeaconStateAltair, block *ethpb.BeaconBlockAltair, privKeys []bls.SecretKey, ) (bls.Signature, error)
BlockSignatureAltair calculates the post-state root of the block and returns the signature.
func DepositTrieFromDeposits ¶
DepositTrieFromDeposits takes an array of deposits and returns the deposit trie.
func DepositTrieSubset ¶
func DepositTrieSubset(sparseTrie *trie.SparseMerkleTrie, size int) (*trie.SparseMerkleTrie, [][32]byte, error)
DepositTrieSubset takes in a full tree and the desired size and returns a subset of the deposit trie.
func DepositsWithBalance ¶
DepositsWithBalance generates N amount of deposits with the balances taken from the passed in balances array. If an empty array is passed,
func DeterministicDepositTrie ¶
func DeterministicDepositTrie(size int) (*trie.SparseMerkleTrie, [][32]byte, error)
DeterministicDepositTrie returns a merkle trie of the requested size from the deterministic deposits.
func DeterministicDepositsAndKeys ¶
DeterministicDepositsAndKeys returns the entered amount of deposits and secret keys. The deposits are configured such that for deposit n the validator account is key n and the withdrawal account is key n+1. As such, if all secret keys for n validators are required then numDeposits should be n+1.
func DeterministicDepositsAndKeysSameValidator ¶
func DeterministicDepositsAndKeysSameValidator(numDeposits uint64) ([]*ethpb.Deposit, []bls.SecretKey, error)
DeterministicDepositsAndKeysSameValidator returns the entered amount of deposits and secret keys of the same validator. This is for negative test cases such as same deposits from same validators in a block don't result in duplicated validator indices.
func DeterministicEth1Data ¶
DeterministicEth1Data takes an array of deposits and returns the eth1Data made from the deposit trie.
func DeterministicGenesisState ¶
func DeterministicGenesisState(t testing.TB, numValidators uint64) (state.BeaconState, []bls.SecretKey)
DeterministicGenesisState returns a genesis state made using the deterministic deposits.
func DeterministicGenesisStateAltair ¶
func DeterministicGenesisStateAltair(t testing.TB, numValidators uint64) (state.BeaconStateAltair, []bls.SecretKey)
DeterministicGenesisStateAltair returns a genesis state in hard fork 1 format made using the deterministic deposits.
func FillRootsNaturalOpt ¶
func FillRootsNaturalOpt(state *ethpb.BeaconState) error
FillRootsNaturalOpt is meant to be used as an option when calling NewBeaconState. It fills state and block roots with hex representations of natural numbers starting with 0. Example: 16 becomes 0x00...0f.
func GenerateAttestations ¶
func GenerateAttestations( bState state.BeaconState, privs []bls.SecretKey, numToGen uint64, slot types.Slot, randomRoot bool, ) ([]*ethpb.Attestation, error)
GenerateAttestations creates attestations that are entirely valid, for all the committees of the current state slot. This function expects attestations requested to be cleanly divisible by committees per slot. If there is 1 committee in the slot, and numToGen is set to 4, then it will return 4 attestations for the same data with their aggregation bits split uniformly.
If you request 4 attestations, but there are 8 committees, you will get 4 fully aggregated attestations.
func GenerateAttesterSlashingForValidator ¶
func GenerateAttesterSlashingForValidator( bState state.BeaconState, priv bls.SecretKey, idx types.ValidatorIndex, ) (*ethpb.AttesterSlashing, error)
GenerateAttesterSlashingForValidator for a specific validator index.
func GenerateFullBlock ¶
func GenerateFullBlock( bState state.BeaconState, privs []bls.SecretKey, conf *BlockGenConfig, slot types.Slot, ) (*ethpb.SignedBeaconBlock, error)
GenerateFullBlock generates a fully valid block with the requested parameters. Use BlockGenConfig to declare the conditions you would like the block generated under.
func GenerateFullBlockAltair ¶
func GenerateFullBlockAltair( bState state.BeaconState, privs []bls.SecretKey, conf *BlockGenConfig, slot types.Slot, ) (*ethpb.SignedBeaconBlockAltair, error)
GenerateFullBlockAltair generates a fully valid block with the requested parameters. Use BlockGenConfig to declare the conditions you would like the block generated under.
func GenerateProposerSlashingForValidator ¶
func GenerateProposerSlashingForValidator( bState state.BeaconState, priv bls.SecretKey, idx types.ValidatorIndex, ) (*ethpb.ProposerSlashing, error)
GenerateProposerSlashingForValidator for a specific validator index.
func GenesisBeaconState ¶
func GenesisBeaconState(ctx context.Context, deposits []*ethpb.Deposit, genesisTime uint64, eth1Data *ethpb.Eth1Data) (state.BeaconStateAltair, error)
GenesisBeaconState returns the genesis beacon state.
func HydrateAttestation ¶
func HydrateAttestation(a *ethpb.Attestation) *ethpb.Attestation
HydrateAttestation hydrates an attestation object with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateAttestationData ¶
func HydrateAttestationData(d *ethpb.AttestationData) *ethpb.AttestationData
HydrateAttestationData hydrates an attestation data object with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateBeaconBlock ¶
func HydrateBeaconBlock(b *ethpb.BeaconBlock) *ethpb.BeaconBlock
HydrateBeaconBlock hydrates a beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateBeaconBlockAltair ¶
func HydrateBeaconBlockAltair(b *ethpb.BeaconBlockAltair) *ethpb.BeaconBlockAltair
HydrateBeaconBlockAltair hydrates a beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateBeaconBlockBody ¶
func HydrateBeaconBlockBody(b *ethpb.BeaconBlockBody) *ethpb.BeaconBlockBody
HydrateBeaconBlockBody hydrates a beacon block body with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateBeaconBlockBodyAltair ¶
func HydrateBeaconBlockBodyAltair(b *ethpb.BeaconBlockBodyAltair) *ethpb.BeaconBlockBodyAltair
HydrateBeaconBlockBodyAltair hydrates a beacon block body with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateBeaconHeader ¶
func HydrateBeaconHeader(h *ethpb.BeaconBlockHeader) *ethpb.BeaconBlockHeader
HydrateBeaconHeader hydrates a beacon block header with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateIndexedAttestation ¶
func HydrateIndexedAttestation(a *ethpb.IndexedAttestation) *ethpb.IndexedAttestation
HydrateIndexedAttestation hydrates an indexed attestation with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateSignedBeaconBlock ¶
func HydrateSignedBeaconBlock(b *ethpb.SignedBeaconBlock) *ethpb.SignedBeaconBlock
HydrateSignedBeaconBlock hydrates a signed beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateSignedBeaconBlockAltair ¶
func HydrateSignedBeaconBlockAltair(b *ethpb.SignedBeaconBlockAltair) *ethpb.SignedBeaconBlockAltair
HydrateSignedBeaconBlockAltair hydrates a signed beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateSignedBeaconHeader ¶
func HydrateSignedBeaconHeader(h *ethpb.SignedBeaconBlockHeader) *ethpb.SignedBeaconBlockHeader
HydrateSignedBeaconHeader hydrates a signed beacon block header with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateSyncCommittee ¶
func HydrateSyncCommittee(s *ethpb.SyncCommitteeMessage) *ethpb.SyncCommitteeMessage
HydrateSyncCommittee hydrates the provided sync committee message.
func HydrateV1Attestation ¶
func HydrateV1Attestation(a *attv1.Attestation) *attv1.Attestation
HydrateV1Attestation hydrates a v1 attestation object with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateV1AttestationData ¶
func HydrateV1AttestationData(d *attv1.AttestationData) *attv1.AttestationData
HydrateV1AttestationData hydrates a v1 attestation data object with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateV1BeaconBlock ¶
func HydrateV1BeaconBlock(b *v1.BeaconBlock) *v1.BeaconBlock
HydrateV1BeaconBlock hydrates a beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateV1BeaconBlockBody ¶
func HydrateV1BeaconBlockBody(b *v1.BeaconBlockBody) *v1.BeaconBlockBody
HydrateV1BeaconBlockBody hydrates a beacon block body with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateV1SignedBeaconBlock ¶
func HydrateV1SignedBeaconBlock(b *v1.SignedBeaconBlock) *v1.SignedBeaconBlock
HydrateV1SignedBeaconBlock hydrates a signed beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateV2BeaconBlock ¶
func HydrateV2BeaconBlock(b *v2.BeaconBlockAltair) *v2.BeaconBlockAltair
HydrateV2BeaconBlock hydrates a beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateV2BeaconBlockBody ¶
func HydrateV2BeaconBlockBody(b *v2.BeaconBlockBodyAltair) *v2.BeaconBlockBodyAltair
HydrateV2BeaconBlockBody hydrates a beacon block body with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func HydrateV2SignedBeaconBlock ¶
func HydrateV2SignedBeaconBlock(b *v2.SignedBeaconBlockAltair) *v2.SignedBeaconBlockAltair
HydrateV2SignedBeaconBlock hydrates a signed beacon block with correct field length sizes to comply with fssz marshalling and unmarshalling rules.
func NewAttestation ¶
func NewAttestation() *ethpb.Attestation
NewAttestation creates an attestation block with minimum marshalable fields.
func NewBeaconBlock ¶
func NewBeaconBlock() *ethpb.SignedBeaconBlock
NewBeaconBlock creates a beacon block with minimum marshalable fields.
func NewBeaconBlockAltair ¶
func NewBeaconBlockAltair() *ethpb.SignedBeaconBlockAltair
NewBeaconBlockAltair creates a beacon block with minimum marshalable fields.
func NewBeaconState ¶
func NewBeaconState(options ...func(state *ethpb.BeaconState) error) (*v1.BeaconState, error)
NewBeaconState creates a beacon state with minimum marshalable fields.
func RandaoReveal ¶
func RandaoReveal(beaconState state.ReadOnlyBeaconState, epoch types.Epoch, privKeys []bls.SecretKey) ([]byte, error)
RandaoReveal returns a signature of the requested epoch using the beacon proposer private key.
func Random32Bytes ¶
Random32Bytes generates a random 32 byte slice.
Types ¶
type BlockGenConfig ¶
type BlockGenConfig struct { NumProposerSlashings uint64 NumAttesterSlashings uint64 NumAttestations uint64 NumDeposits uint64 NumVoluntaryExits uint64 }
BlockGenConfig is used to define the requested conditions for block generation.
func DefaultBlockGenConfig ¶
func DefaultBlockGenConfig() *BlockGenConfig
DefaultBlockGenConfig returns the block config that utilizes the current params in the beacon config.