Documentation
¶
Overview ¶
Package backend contains utilities for simulating an entire ETH 2.0 beacon chain for e2e tests and benchmarking purposes.
Index ¶
- type ForkChoiceTest
- type ForkChoiceTestCase
- type ForkChoiceTestConfig
- type ForkChoiceTestResult
- type ForkChoiceTestSlot
- type ShuffleTest
- type ShuffleTestCase
- type SimulatedBackend
- func (sb *SimulatedBackend) GenerateBlockAndAdvanceChain(objects *SimulatedObjects) error
- func (sb *SimulatedBackend) GenerateNilBlockAndAdvanceChain() error
- func (sb *SimulatedBackend) InitializeChain() error
- func (sb *SimulatedBackend) RunForkChoiceTest(testCase *ForkChoiceTestCase) error
- func (sb *SimulatedBackend) RunShuffleTest(testCase *ShuffleTestCase) error
- func (sb *SimulatedBackend) RunStateTransitionTest(testCase *StateTestCase) error
- func (sb *SimulatedBackend) Shutdown() error
- type SimulatedObjects
- type StateTest
- type StateTestAttesterSlashing
- type StateTestCase
- type StateTestConfig
- type StateTestDeposit
- type StateTestProposerSlashing
- type StateTestResults
- type StateTestValidatorExit
- type TestAttestation
- type TestBlock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ForkChoiceTest ¶
type ForkChoiceTest struct { Title string Summary string TestSuite string `yaml:"test_suite"` TestCases []*ForkChoiceTestCase `yaml:"test_cases"` }
ForkChoiceTest --
type ForkChoiceTestCase ¶
type ForkChoiceTestCase struct { Config *ForkChoiceTestConfig `yaml:"config"` Slots []*ForkChoiceTestSlot `yaml:"slots,flow"` Results *ForkChoiceTestResult `yaml:"results"` }
ForkChoiceTestCase --
type ForkChoiceTestConfig ¶
type ForkChoiceTestConfig struct { ValidatorCount uint64 `yaml:"validator_count"` CycleLength uint64 `yaml:"cycle_length"` ShardCount uint64 `yaml:"shard_count"` MinCommitteeSize uint64 `yaml:"min_committee_size"` }
ForkChoiceTestConfig --
type ForkChoiceTestResult ¶
type ForkChoiceTestResult struct { Head string LastJustifiedBlock string `yaml:"last_justified_block"` LastFinalizedBlock string `yaml:"last_finalized_block"` }
ForkChoiceTestResult --
type ForkChoiceTestSlot ¶
type ForkChoiceTestSlot struct { SlotNumber uint64 `yaml:"slot_number"` NewBlock *TestBlock `yaml:"new_block"` Attestations []*TestAttestation `yaml:",flow"` }
ForkChoiceTestSlot --
type ShuffleTest ¶
type ShuffleTest struct { Title string `yaml:"title"` Summary string `yaml:"summary"` TestSuite string `yaml:"test_suite"` Fork string `yaml:"fork"` Version string `yaml:"version"` TestCases []*ShuffleTestCase `yaml:"test_cases"` }
ShuffleTest --
type ShuffleTestCase ¶
type ShuffleTestCase struct { Input []uint64 `yaml:"input,flow"` Output []uint64 `yaml:"output,flow"` Seed string }
ShuffleTestCase --
type SimulatedBackend ¶
type SimulatedBackend struct {
// contains filtered or unexported fields
}
SimulatedBackend allowing for a programmatic advancement of an in-memory beacon chain for client test runs and other e2e use cases.
func NewSimulatedBackend ¶
func NewSimulatedBackend() (*SimulatedBackend, error)
NewSimulatedBackend creates an instance by initializing a chain service utilizing a mockDB which will act according to test run parameters specified in the common ETH 2.0 client test YAML format.
func (*SimulatedBackend) GenerateBlockAndAdvanceChain ¶
func (sb *SimulatedBackend) GenerateBlockAndAdvanceChain(objects *SimulatedObjects) error
GenerateBlockAndAdvanceChain generates a simulated block and runs that block though state transition.
func (*SimulatedBackend) GenerateNilBlockAndAdvanceChain ¶
func (sb *SimulatedBackend) GenerateNilBlockAndAdvanceChain() error
GenerateNilBlockAndAdvanceChain would trigger a state transition with a nil block.
func (*SimulatedBackend) InitializeChain ¶
func (sb *SimulatedBackend) InitializeChain() error
InitializeChain sets up the whole backend to be able to run a mock beacon state and chain.
func (*SimulatedBackend) RunForkChoiceTest ¶
func (sb *SimulatedBackend) RunForkChoiceTest(testCase *ForkChoiceTestCase) error
RunForkChoiceTest uses a parsed set of chaintests from a YAML file according to the ETH 2.0 client chain test specification and runs them against the simulated backend.
func (*SimulatedBackend) RunShuffleTest ¶
func (sb *SimulatedBackend) RunShuffleTest(testCase *ShuffleTestCase) error
RunShuffleTest uses validator set specified from a YAML file, runs the validator shuffle algorithm, then compare the output with the expected output from the YAML file.
func (*SimulatedBackend) RunStateTransitionTest ¶
func (sb *SimulatedBackend) RunStateTransitionTest(testCase *StateTestCase) error
RunStateTransitionTest advances a beacon chain state transition an N amount of slots from a genesis state, with a block being processed at every iteration of the state transition function.
func (*SimulatedBackend) Shutdown ¶
func (sb *SimulatedBackend) Shutdown() error
Shutdown closes the db associated with the simulated backend.
type SimulatedObjects ¶
type SimulatedObjects struct {
// contains filtered or unexported fields
}
SimulatedObjects is a container to hold the required primitives for generation of a beacon block.
type StateTest ¶
type StateTest struct { Title string Summary string Fork string `yaml:"fork"` Version string `yaml:"version"` TestSuite string `yaml:"test_suite"` TestCases []*StateTestCase `yaml:"test_cases"` }
StateTest --
type StateTestAttesterSlashing ¶
type StateTestAttesterSlashing struct { Slot uint64 `yaml:"slot"` SlashableVote1Slot uint64 `yaml:"slashable_vote_1_slot"` SlashableVote1JustifiedSlot uint64 `yaml:"slashable_vote_1_justified_slot"` SlashableVote1ValidatorIndices []uint64 `yaml:"slashable_vote_1_validator_indices"` SlashableVote1CustodyBitField string `yaml:"slashable_vote_1_custody_bitfield"` SlashableVote2Slot uint64 `yaml:"slashable_vote_2_slot"` SlashableVote2JustifiedSlot uint64 `yaml:"slashable_vote_2_justified_slot"` SlashableVote2ValidatorIndices []uint64 `yaml:"slashable_vote_2_validator_indices"` SlashableVote2CustodyBitField string `yaml:"slashable_vote_2_custody_bitfield"` }
StateTestAttesterSlashing --
type StateTestCase ¶
type StateTestCase struct { Config *StateTestConfig `yaml:"config"` Results *StateTestResults `yaml:"results"` }
StateTestCase --
type StateTestConfig ¶
type StateTestConfig struct { SkipSlots []uint64 `yaml:"skip_slots"` DepositSlots []uint64 `yaml:"deposit_slots"` Deposits []*StateTestDeposit `yaml:"deposits"` ProposerSlashings []*StateTestProposerSlashing `yaml:"proposer_slashings"` AttesterSlashings []*StateTestAttesterSlashing `yaml:"attester_slashings"` ValidatorExits []*StateTestValidatorExit `yaml:"validator_exits"` EpochLength uint64 `yaml:"epoch_length"` ShardCount uint64 `yaml:"shard_count"` DepositsForChainStart uint64 `yaml:"deposits_for_chain_start"` NumSlots uint64 `yaml:"num_slots"` }
StateTestConfig --
type StateTestDeposit ¶
type StateTestDeposit struct { Slot uint64 `yaml:"slot"` Amount uint64 `yaml:"amount"` MerkleIndex uint64 `yaml:"merkle_index"` Pubkey string `yaml:"pubkey"` }
StateTestDeposit --
type StateTestProposerSlashing ¶
type StateTestProposerSlashing struct { Slot uint64 `yaml:"slot"` ProposerIndex uint64 `yaml:"proposer_index"` Proposal1Shard uint64 `yaml:"proposal_1_shard"` Proposal2Shard uint64 `yaml:"proposal_2_shard"` Proposal1Slot uint64 `yaml:"proposal_1_slot"` Proposal2Slot uint64 `yaml:"proposal_2_slot"` Proposal1Root string `yaml:"proposal_1_root"` Proposal2Root string `yaml:"proposal_2_root"` }
StateTestProposerSlashing --
type StateTestResults ¶
type StateTestResults struct { Slot uint64 NumValidators int `yaml:"num_validators"` PenalizedValidators []uint64 `yaml:"penalized_validators"` ExitedValidators []uint64 `yaml:"exited_validators"` }
StateTestResults --
type StateTestValidatorExit ¶
type StateTestValidatorExit struct { Slot uint64 `yaml:"slot"` ValidatorIndex uint64 `yaml:"validator_index"` }
StateTestValidatorExit --
type TestAttestation ¶
type TestAttestation struct { Block string `yaml:"block"` ValidatorRegistry string `yaml:"validators"` CommitteeSlot uint64 `yaml:"committee_slot"` }
TestAttestation --