types

package
v0.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttackerCommand

type AttackerCommand int
const (
	CMD_NULL AttackerCommand = iota
	CMD_CONTINUE
	CMD_RETURN
	CMD_ABORT
	CMD_SKIP
	CMD_ROLE_TO_NORMAL   // 角色转换为普通节点
	CMD_ROLE_TO_ATTACKER // 角色转换为攻击者
	CMD_EXIT
	CMD_UPDATE_STATE
)

type AttackerResponse

type AttackerResponse struct {
	Cmd    AttackerCommand `json:"cmd"`
	Result string          `json:"result"`
}

type AttestDuty added in v0.0.23

type AttestDuty struct {
	Pubkey                  string `json:"pubkey"`
	ValidatorIndex          string `json:"validator_index"`
	CommitteeIndex          string `json:"committee_index"`
	CommitteeLength         string `json:"committee_length"`
	CommitteesAtSlot        string `json:"committees_at_slot"`
	ValidatorCommitteeIndex string `json:"validator_committee_index"`
	Slot                    string `json:"slot"`
}

type AttestStrategy added in v0.0.23

type AttestStrategy struct {
	DelayEnable    bool  `json:"delay_enable"`
	BroadCastDelay int64 `json:"broad_cast_delay"` // unit millisecond
	ModifyEnable   bool  `json:"modify_enable"`
}

type BeaconBackend added in v0.0.23

type BeaconBackend interface {
	GetCurrentEpochProposeDuties() ([]ProposerDuty, error)
	GetSlotsPerEpoch() int
	SlotsPerEpoch() int
	GetIntervalPerSlot() int
	GetValidatorByProposeSlot(slot uint64) (int, error)
	GetProposeDuties(epoch int) ([]ProposerDuty, error)
}

type BeaconHeaderInfo added in v0.0.23

type BeaconHeaderInfo struct {
	Header struct {
		Message struct {
			Slot          string `json:"slot"`
			ProposerIndex string `json:"proposer_index"`
			ParentRoot    string `json:"parent_root"`
			StateRoot     string `json:"state_root"`
			BodyRoot      string `json:"body_root"`
		} `json:"message"`
		Signature string `json:"signature"`
	} `json:"header"`
	Root      string `json:"root"`
	Canonical bool   `json:"canonical"`
}

type BeaconResponse added in v0.0.23

type BeaconResponse struct {
	Data json.RawMessage `json:"data"`
}

type BlockStrategy added in v0.0.23

type BlockStrategy struct {
	DelayEnable    bool  `json:"delay_enable"`
	BroadCastDelay int64 `json:"broad_cast_delay"` // unit millisecond
	ModifyEnable   bool  `json:"modify_enable"`
}

type CacheBackend added in v0.0.23

type CacheBackend interface {
	AddSignedAttestation(slot uint64, pubkey string, attestation *ethpb.Attestation)
	AddSignedBlock(slot uint64, pubkey string, block *ethpb.GenericSignedBeaconBlock)
	GetAttestSet(slot uint64) *SlotAttestSet
	GetBlockSet(slot uint64) *SlotBlockSet
	GetValidatorDataSet() *ValidatorDataSet

	GetValidatorRole(slot int, valIdx int) RoleType
	GetValidatorRoleByPubkey(slot int, pubkey string) RoleType
}

type ClientInfo

type ClientInfo struct {
	UUID           string `json:"uuid"`
	ValidatorIndex int    `json:"validatorIndex"`
}

func ToClientInfo

func ToClientInfo(cliInfo string) ClientInfo

type ExecuteBackend added in v0.0.23

type ExecuteBackend interface {
	// get data from execute node.
	GetBlockHeight() (uint64, error)
	GetBlockByNumber(number *big.Int) (*ethtype.Block, error)
	GetHeightByNumber(number *big.Int) (*ethtype.Header, error)
}

type ProposerAtts added in v0.0.10

type ProposerAtts []*ethpb.Attestation

func (ProposerAtts) Dedup added in v0.0.10

func (a ProposerAtts) Dedup() (ProposerAtts, error)

Dedup removes duplicate attestations (ones with the same bits set on). Important: not only exact duplicates are removed, but proper subsets are removed too (their known bits are redundant and are already contained in their supersets).

func (ProposerAtts) Filter added in v0.0.10

Filter separates attestation list into two groups: valid and invalid attestations. The first group passes the all the required checks for attestation to be considered for proposing. And attestations from the second group should be deleted.

func (ProposerAtts) LimitToMaxAttestations added in v0.0.10

func (a ProposerAtts) LimitToMaxAttestations() ProposerAtts

LimitToMaxAttestations limits attestations to maximum attestations per block.

func (ProposerAtts) SortByProfitability added in v0.0.10

func (a ProposerAtts) SortByProfitability() (ProposerAtts, error)

SortByProfitability orders attestations by highest slot and by highest aggregation bit count.

func (ProposerAtts) SortByProfitabilityUsingMaxCover added in v0.0.10

func (a ProposerAtts) SortByProfitabilityUsingMaxCover() (ProposerAtts, error)

SortByProfitabilityUsingMaxCover orders attestations by highest slot and by highest aggregation bit count. Duplicate bits are counted only once, using max-cover algorithm.

type ProposerDuty added in v0.0.23

type ProposerDuty struct {
	Pubkey         string `json:"pubkey"`
	ValidatorIndex string `json:"validator_index"`
	Slot           string `json:"slot"`
}

type RewardInfo added in v0.0.23

type RewardInfo struct {
	TotalRewards []TotalReward `json:"total_rewards"`
}

type RoleType

type RoleType int
const (
	NormalRole RoleType = iota
	AttackerRole
)

type ServiceBackend added in v0.0.23

type ServiceBackend interface {
	ExecuteBackend
	BeaconBackend
	CacheBackend
	StrategyBackend
}

ServiceBackend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.

type SlotAttestSet added in v0.0.23

type SlotAttestSet struct {
	Attestations map[string]*ethpb.Attestation
}

type SlotBlockSet added in v0.0.23

type SlotBlockSet struct {
	Blocks map[string]*ethpb.GenericSignedBeaconBlock
}

type SlotStrategy added in v0.0.24

type SlotStrategy struct {
	Slot    string            `json:"slot"`
	Level   int               `json:"level"`
	Actions map[string]string `json:"actions"`
}

type Strategy added in v0.0.23

type Strategy struct {
	Slots      []SlotStrategy      `json:"slots"`
	Validators []ValidatorStrategy `json:"validator"`
	Block      BlockStrategy       `json:"block"`
	Attest     AttestStrategy      `json:"attest"`
}

func (*Strategy) GetValidatorRole added in v0.0.23

func (s *Strategy) GetValidatorRole(valIdx int, slot int64) RoleType

type StrategyBackend added in v0.0.23

type StrategyBackend interface {
	// update strategy
	GetStrategy() *Strategy
	UpdateBlockBroadDelay(milliSecond int64) error
	UpdateAttestBroadDelay(milliSecond int64) error
}

type TotalReward added in v0.0.23

type TotalReward struct {
	ValidatorIndex string `json:"validator_index"`
	Head           string `json:"head"`
	Target         string `json:"target"`
	Source         string `json:"source"`
	InclusionDelay string `json:"inclusion_delay"`
	Inactivity     string `json:"inactivity"`
}

type ValidatorAttestSet added in v0.0.23

type ValidatorAttestSet struct {
	Attestations map[uint64]*ethpb.Attestation
}

type ValidatorBlockSet added in v0.0.23

type ValidatorBlockSet struct {
	Blocks map[uint64]ethpb.GenericBeaconBlock
}

type ValidatorDataSet added in v0.0.23

type ValidatorDataSet struct {
	ValidatorByIndex  sync.Map                  //map[int]*ValidatorInfo
	ValidatorByPubkey sync.Map                  //map[string]*ValidatorInfo
	AttestSet         map[uint64]*SlotAttestSet // epoch -> attestation
	BlockSet          map[uint64]*SlotBlockSet  // epoch -> block
	// contains filtered or unexported fields
}

func NewValidatorSet added in v0.0.23

func NewValidatorSet() *ValidatorDataSet

func (*ValidatorDataSet) AddSignedAttestation added in v0.0.23

func (vs *ValidatorDataSet) AddSignedAttestation(slot uint64, pubkey string, attestation *ethpb.Attestation)

func (*ValidatorDataSet) AddSignedBlock added in v0.0.23

func (vs *ValidatorDataSet) AddSignedBlock(slot uint64, pubkey string, block *ethpb.GenericSignedBeaconBlock)

func (*ValidatorDataSet) AddValidator added in v0.0.23

func (vs *ValidatorDataSet) AddValidator(index int, pubkey string)

func (*ValidatorDataSet) GetAttestSet added in v0.0.23

func (vs *ValidatorDataSet) GetAttestSet(slot uint64) *SlotAttestSet

func (*ValidatorDataSet) GetBlockSet added in v0.0.23

func (vs *ValidatorDataSet) GetBlockSet(slot uint64) *SlotBlockSet

func (*ValidatorDataSet) GetValidatorByIndex added in v0.0.23

func (vs *ValidatorDataSet) GetValidatorByIndex(index int) *ValidatorInfo

func (*ValidatorDataSet) GetValidatorByPubkey added in v0.0.23

func (vs *ValidatorDataSet) GetValidatorByPubkey(pubkey string) *ValidatorInfo

type ValidatorInfo added in v0.0.23

type ValidatorInfo struct {
	Index  int64  `json:"index"`
	Pubkey string `json:"pubkey"`
}

type ValidatorStrategy added in v0.0.23

type ValidatorStrategy struct {
	ValidatorIndex    int `json:"validator_index"`
	AttackerStartSlot int `json:"attacker_start_slot"`
	AttackerEndSlot   int `json:"attacker_end_slot"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL