mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-17 15:28:45 +00:00
927e338f9e
* Fix finding terminal block hash calculation * Update mainnet_config.go * Update beacon_block.pb.go * Various fixes to pass all spec tests for Merge (#9777) * Proper upgrade altair to merge state * Use uint64 for ttd * Correctly upgrade to merge state + object mapping fixes * Use proper receive block path for initial syncing * Disable contract lookback * Disable deposit contract lookback * Go fmt * Merge: switch from go bindings to raw rpc calls (#9803) * Disable genesis ETH1.0 chain header logging * Update htrutils.go * all gossip tests passing * Remove gas validations * Update penalty params for Merge * Fix gossip and tx size limits for the merge part 1 * Remove extraneous p2p condition * Add and use * Add and use TBH_ACTIVATION_EPOCH * Update WORKSPACE * Update Kintsugi engine API (#9865) * Kintsugi ssz (#9867) * All spec tests pass * Update spec test shas * Update Kintsugi consensus implementations (#9872) * Remove secp256k1 * Remove unused merge genesis state gen tool * Manually override nil transaction field. M2 works * Fix bad hex conversion * Change Gossip message size and Chunk SIze from 1 MB t0 10MB (#9860) * change gossip size and chunk size after merge * change ssz to accomodate both changes * gofmt config file * add testcase for merge MsgId * Update beacon-chain/p2p/message_id.go Change MB to Mib in comment Co-authored-by: terence tsao <terence@prysmaticlabs.com> * change function name from altairMsgID to postAltairMsgID Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Sync with develop * Merge branch 'develop' of github.com:prysmaticlabs/prysm into kintsugi * Update state_trie.go * Clean up conflicts * Fix build * Update config to devnet1 * Fix state merge * Handle merge test case for update balance * Fix build * State pkg cleanup * Fix a bug with loading mainnet state * Fix transactions root * Add v2 endpoint for merge blocks (#9802) * Add V2 blocks endpoint for merge blocks * Update beacon-chain/rpc/apimiddleware/structs.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * go mod * fix transactions * Terence's comments * add missing file Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Sync * Go mod tidy * change EP field names * latest kintusgi execution api * fix conflicts * converting base fee to big endian format (#10018) * ReverseByteOrder function does not mess the input * sync with develop * use merge gossip sizes * correct gossip sizes this time * visibility * clean ups * Sync with develop, fix payload nil check bug * Speed up syncing, hide cosmetic errors * Sync with develop * Clean up after sync * Update generate_keys.go * sync with develop * Update mainnet_config.go * Clean ups * Sync optimistically candidate blocks (#10193) * Revert "Sync optimistically candidate blocks (#10193)" This reverts commit f99a0419ef1efc4bda0be77f22165b8fe4377c0d. * Sync optimistically candidate blocks (#10193) * allow optimistic sync * Fix merge transition block validation * Update proposer.go * Sync with develop * delete deprecated client, update testnet flag * Change optimistic logic (#10194) * Logs and err handling * Fix build * Clean ups * Add back get payload * c * Done * Rm uncommented * Optimistic sync: prysm validator rpcs (#10200) * Logs to reproduce * Use pointers * Use pointers * Use pointers * Update json_marshal_unmarshal.go * Fix marshal * Update json_marshal_unmarshal.go * Log * string total diff * str * marshal un * set string * json * gaz * Comment out optimistic status * remove kiln flag here (#10269) * Sync with devleop * Sync with develop * clean ups * refactor engine calls * Update process_block.go * Fix deadlock, uncomment duty opt sync * Update proposer_execution_payload.go * Sync with develop * Rm post state check * Bypass eth1 data checks * Update proposer_execution_payload.go * Return early if ttd is not reached * Sync with devleop * Update process_block.go * Update receive_block.go * Update bzl * Revert "Update receive_block.go" This reverts commit 5b4a87c512325d9f26de4db7f941dcd7303cd0d8. * Fix run time * add in all the fixes * fix evaluator bugs * latest fixes * sum * fix to be configurable * Update go.mod * Fix AltairCompatible to account for future state version * Update proposer_execution_payload.go * fix broken conditional checks * fix all issues * Handle pre state Altair with valid payload * Handle pre state Altair with valid payload * Log bellatrix fields * Update log.go * Revert "fix broken conditional checks" This reverts commit e118db6c20172783a3bb573d2f78670f0207ec1e. * LH multiclient working * Friendly fee recipient log * Remove extra SetOptimisticToValid * fix race * fix test * Fix base fee per gas * Fix notifypayload headroot * tx fuzzer * clean up with develop branch * save progress * 200tx/block * add LH flags * Sync with devleop * cleanup * cleanup * hash * fix build * fix test * fix go check * fmt * gosec * add deps * cleanup * fix up * change gas price * remove flag * last fix * use new LH version * fix up * fix finalized block panic Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: Zahoor Mohamed <zahoor@zahoor.in> Co-authored-by: kasey <489222+kasey@users.noreply.github.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: Zahoor Mohamed <zahoor@prysmaticlabs.com> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
204 lines
7.1 KiB
Go
204 lines
7.1 KiB
Go
// Package components defines utilities to spin up actual
|
|
// beacon node and validator processes as needed by end to end tests.
|
|
package components
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
|
cmdshared "github.com/prysmaticlabs/prysm/cmd"
|
|
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
|
"github.com/prysmaticlabs/prysm/config/features"
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
"github.com/prysmaticlabs/prysm/testing/endtoend/helpers"
|
|
e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params"
|
|
e2etypes "github.com/prysmaticlabs/prysm/testing/endtoend/types"
|
|
)
|
|
|
|
var _ e2etypes.ComponentRunner = (*BeaconNode)(nil)
|
|
var _ e2etypes.ComponentRunner = (*BeaconNodeSet)(nil)
|
|
var _ e2etypes.BeaconNodeSet = (*BeaconNodeSet)(nil)
|
|
|
|
// BeaconNodeSet represents set of beacon nodes.
|
|
type BeaconNodeSet struct {
|
|
e2etypes.ComponentRunner
|
|
config *e2etypes.E2EConfig
|
|
enr string
|
|
ids []string
|
|
started chan struct{}
|
|
}
|
|
|
|
// SetENR assigns ENR to the set of beacon nodes.
|
|
func (s *BeaconNodeSet) SetENR(enr string) {
|
|
s.enr = enr
|
|
}
|
|
|
|
// NewBeaconNodes creates and returns a set of beacon nodes.
|
|
func NewBeaconNodes(config *e2etypes.E2EConfig) *BeaconNodeSet {
|
|
return &BeaconNodeSet{
|
|
config: config,
|
|
started: make(chan struct{}, 1),
|
|
}
|
|
}
|
|
|
|
// Start starts all the beacon nodes in set.
|
|
func (s *BeaconNodeSet) Start(ctx context.Context) error {
|
|
if s.enr == "" {
|
|
return errors.New("empty ENR")
|
|
}
|
|
|
|
// Create beacon nodes.
|
|
nodes := make([]e2etypes.ComponentRunner, e2e.TestParams.BeaconNodeCount)
|
|
for i := 0; i < e2e.TestParams.BeaconNodeCount; i++ {
|
|
nodes[i] = NewBeaconNode(s.config, i, s.enr)
|
|
}
|
|
|
|
// Wait for all nodes to finish their job (blocking).
|
|
// Once nodes are ready passed in handler function will be called.
|
|
return helpers.WaitOnNodes(ctx, nodes, func() {
|
|
if s.config.UseFixedPeerIDs {
|
|
for i := 0; i < len(nodes); i++ {
|
|
s.ids = append(s.ids, nodes[i].(*BeaconNode).peerID)
|
|
}
|
|
s.config.PeerIDs = s.ids
|
|
}
|
|
// All nodes stated, close channel, so that all services waiting on a set, can proceed.
|
|
close(s.started)
|
|
})
|
|
}
|
|
|
|
// Started checks whether beacon node set is started and all nodes are ready to be queried.
|
|
func (s *BeaconNodeSet) Started() <-chan struct{} {
|
|
return s.started
|
|
}
|
|
|
|
// BeaconNode represents beacon node.
|
|
type BeaconNode struct {
|
|
e2etypes.ComponentRunner
|
|
config *e2etypes.E2EConfig
|
|
started chan struct{}
|
|
index int
|
|
enr string
|
|
peerID string
|
|
}
|
|
|
|
// NewBeaconNode creates and returns a beacon node.
|
|
func NewBeaconNode(config *e2etypes.E2EConfig, index int, enr string) *BeaconNode {
|
|
return &BeaconNode{
|
|
config: config,
|
|
index: index,
|
|
enr: enr,
|
|
started: make(chan struct{}, 1),
|
|
}
|
|
}
|
|
|
|
// Start starts a fresh beacon node, connecting to all passed in beacon nodes.
|
|
func (node *BeaconNode) Start(ctx context.Context) error {
|
|
binaryPath, found := bazel.FindBinary("cmd/beacon-chain", "beacon-chain")
|
|
if !found {
|
|
log.Info(binaryPath)
|
|
return errors.New("beacon chain binary not found")
|
|
}
|
|
|
|
config, index, enr := node.config, node.index, node.enr
|
|
stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, fmt.Sprintf(e2e.BeaconNodeLogFileName, index))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
expectedNumOfPeers := e2e.TestParams.BeaconNodeCount + e2e.TestParams.LighthouseBeaconNodeCount - 1
|
|
if node.config.TestSync {
|
|
expectedNumOfPeers += 1
|
|
}
|
|
jwtPath := path.Join(e2e.TestParams.TestPath, "eth1data/"+strconv.Itoa(node.index)+"/")
|
|
if index == 0 {
|
|
jwtPath = path.Join(e2e.TestParams.TestPath, "eth1data/miner/")
|
|
}
|
|
jwtPath = path.Join(jwtPath, "geth/jwtsecret")
|
|
args := []string{
|
|
fmt.Sprintf("--%s=%s/eth2-beacon-node-%d", cmdshared.DataDirFlag.Name, e2e.TestParams.TestPath, index),
|
|
fmt.Sprintf("--%s=%s", cmdshared.LogFileName.Name, stdOutFile.Name()),
|
|
fmt.Sprintf("--%s=%s", flags.DepositContractFlag.Name, e2e.TestParams.ContractAddress.Hex()),
|
|
fmt.Sprintf("--%s=%d", flags.RPCPort.Name, e2e.TestParams.Ports.PrysmBeaconNodeRPCPort+index),
|
|
fmt.Sprintf("--%s=http://127.0.0.1:%d", flags.HTTPWeb3ProviderFlag.Name, e2e.TestParams.Ports.Eth1RPCPort),
|
|
fmt.Sprintf("--%s=%s", flags.ExecutionJWTSecretFlag.Name, jwtPath),
|
|
fmt.Sprintf("--%s=%d", flags.MinSyncPeers.Name, 1),
|
|
fmt.Sprintf("--%s=%d", cmdshared.P2PUDPPort.Name, e2e.TestParams.Ports.PrysmBeaconNodeUDPPort+index),
|
|
fmt.Sprintf("--%s=%d", cmdshared.P2PTCPPort.Name, e2e.TestParams.Ports.PrysmBeaconNodeTCPPort+index),
|
|
fmt.Sprintf("--%s=%d", cmdshared.P2PMaxPeers.Name, expectedNumOfPeers),
|
|
fmt.Sprintf("--%s=%d", flags.MonitoringPortFlag.Name, e2e.TestParams.Ports.PrysmBeaconNodeMetricsPort+index),
|
|
fmt.Sprintf("--%s=%d", flags.GRPCGatewayPort.Name, e2e.TestParams.Ports.PrysmBeaconNodeGatewayPort+index),
|
|
fmt.Sprintf("--%s=%d", flags.ContractDeploymentBlock.Name, 0),
|
|
fmt.Sprintf("--%s=%d", flags.MinPeersPerSubnet.Name, 0),
|
|
fmt.Sprintf("--%s=%d", cmdshared.RPCMaxPageSizeFlag.Name, params.BeaconConfig().MinGenesisActiveValidatorCount),
|
|
fmt.Sprintf("--%s=%s", cmdshared.BootstrapNode.Name, enr),
|
|
fmt.Sprintf("--%s=%s", cmdshared.VerbosityFlag.Name, "debug"),
|
|
"--" + cmdshared.ForceClearDB.Name,
|
|
"--" + cmdshared.E2EConfigFlag.Name,
|
|
"--" + cmdshared.AcceptTosFlag.Name,
|
|
"--" + flags.EnableDebugRPCEndpoints.Name,
|
|
}
|
|
if config.UsePprof {
|
|
args = append(args, "--pprof", fmt.Sprintf("--pprofport=%d", e2e.TestParams.Ports.PrysmBeaconNodePprofPort+index))
|
|
}
|
|
// Only add in the feature flags if we either aren't performing a control test
|
|
// on our features or the beacon index is a power of 2.
|
|
if !config.TestFeature || index%2 == 0 {
|
|
args = append(args, features.E2EBeaconChainFlags...)
|
|
}
|
|
args = append(args, config.BeaconFlags...)
|
|
|
|
cmd := exec.CommandContext(ctx, binaryPath, args...) // #nosec G204 -- Safe
|
|
// Write stdout and stderr to log files.
|
|
stdout, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("beacon_node_%d_stdout.log", index)))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
stderr, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("beacon_node_%d_stderr.log", index)))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer func() {
|
|
if err := stdout.Close(); err != nil {
|
|
log.WithError(err).Error("Failed to close stdout file")
|
|
}
|
|
if err := stderr.Close(); err != nil {
|
|
log.WithError(err).Error("Failed to close stderr file")
|
|
}
|
|
}()
|
|
cmd.Stdout = stdout
|
|
cmd.Stderr = stderr
|
|
log.Infof("Starting beacon chain %d with flags: %s", index, strings.Join(args[2:], " "))
|
|
if err = cmd.Start(); err != nil {
|
|
return fmt.Errorf("failed to start beacon node: %w", err)
|
|
}
|
|
|
|
if err = helpers.WaitForTextInFile(stdOutFile, "gRPC server listening on port"); err != nil {
|
|
return fmt.Errorf("could not find multiaddr for node %d, this means the node had issues starting: %w", index, err)
|
|
}
|
|
|
|
if config.UseFixedPeerIDs {
|
|
peerId, err := helpers.FindFollowingTextInFile(stdOutFile, "Running node with peer id of ")
|
|
if err != nil {
|
|
return fmt.Errorf("could not find peer id: %w", err)
|
|
}
|
|
node.peerID = peerId
|
|
}
|
|
|
|
// Mark node as ready.
|
|
close(node.started)
|
|
|
|
return cmd.Wait()
|
|
}
|
|
|
|
// Started checks whether beacon node is started and ready to be queried.
|
|
func (node *BeaconNode) Started() <-chan struct{} {
|
|
return node.started
|
|
}
|