mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
74 lines
1.9 KiB
Go
74 lines
1.9 KiB
Go
package testing
|
|
|
|
import (
|
|
"context"
|
|
"math/big"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v3/async/event"
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/execution/types"
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
|
v1 "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/v1"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
// FaultyExecutionChain defines an incorrectly functioning powchain service.
|
|
type FaultyExecutionChain struct {
|
|
ChainFeed *event.Feed
|
|
HashesByHeight map[int][]byte
|
|
}
|
|
|
|
// Eth2GenesisPowchainInfo --
|
|
func (*FaultyExecutionChain) Eth2GenesisPowchainInfo() (uint64, *big.Int) {
|
|
return 0, big.NewInt(0)
|
|
}
|
|
|
|
// BlockExists --
|
|
func (f *FaultyExecutionChain) BlockExists(context.Context, common.Hash) (bool, *big.Int, error) {
|
|
if f.HashesByHeight == nil {
|
|
return false, big.NewInt(1), errors.New("failed")
|
|
}
|
|
|
|
return true, big.NewInt(1), nil
|
|
}
|
|
|
|
// BlockHashByHeight --
|
|
func (*FaultyExecutionChain) BlockHashByHeight(context.Context, *big.Int) (common.Hash, error) {
|
|
return [32]byte{}, errors.New("failed")
|
|
}
|
|
|
|
// BlockTimeByHeight --
|
|
func (*FaultyExecutionChain) BlockTimeByHeight(context.Context, *big.Int) (uint64, error) {
|
|
return 0, errors.New("failed")
|
|
}
|
|
|
|
// BlockByTimestamp --
|
|
func (*FaultyExecutionChain) BlockByTimestamp(context.Context, uint64) (*types.HeaderInfo, error) {
|
|
return &types.HeaderInfo{Number: big.NewInt(0)}, nil
|
|
}
|
|
|
|
// ChainStartEth1Data --
|
|
func (*FaultyExecutionChain) ChainStartEth1Data() *ethpb.Eth1Data {
|
|
return ðpb.Eth1Data{}
|
|
}
|
|
|
|
// PreGenesisState --
|
|
func (*FaultyExecutionChain) PreGenesisState() state.BeaconState {
|
|
s, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
|
if err != nil {
|
|
panic("could not initialize state")
|
|
}
|
|
return s
|
|
}
|
|
|
|
// ClearPreGenesisData --
|
|
func (*FaultyExecutionChain) ClearPreGenesisData() {
|
|
// no-op
|
|
}
|
|
|
|
// IsConnectedToETH1 --
|
|
func (*FaultyExecutionChain) IsConnectedToETH1() bool {
|
|
return true
|
|
}
|