mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
miner: fix miner stress test (#18039)
This commit is contained in:
parent
79c7a69ac8
commit
e2640a96d4
@ -22,7 +22,6 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/ecdsa"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
@ -40,7 +39,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
@ -62,11 +61,11 @@ func main() {
|
||||
|
||||
var (
|
||||
nodes []*node.Node
|
||||
enodes []string
|
||||
enodes []*enode.Node
|
||||
)
|
||||
for _, sealer := range sealers {
|
||||
// Start the node and wait until it's up
|
||||
node, err := makeSealer(genesis, enodes)
|
||||
node, err := makeSealer(genesis)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -76,18 +75,12 @@ func main() {
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
}
|
||||
// Connect the node to al the previous ones
|
||||
for _, enode := range enodes {
|
||||
enode, err := discover.ParseNode(enode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
for _, n := range enodes {
|
||||
node.Server().AddPeer(n)
|
||||
}
|
||||
node.Server().AddPeer(enode)
|
||||
}
|
||||
// Start tracking the node and it's enode url
|
||||
// Start tracking the node and it's enode
|
||||
nodes = append(nodes, node)
|
||||
|
||||
enode := fmt.Sprintf("enode://%s@127.0.0.1:%d", node.Server().NodeInfo().ID, node.Server().NodeInfo().Ports.Listener)
|
||||
enodes = append(enodes, enode)
|
||||
enodes = append(enodes, node.Server().Self())
|
||||
|
||||
// Inject the signer key and start sealing with it
|
||||
store := node.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
||||
@ -177,7 +170,7 @@ func makeGenesis(faucets []*ecdsa.PrivateKey, sealers []*ecdsa.PrivateKey) *core
|
||||
return genesis
|
||||
}
|
||||
|
||||
func makeSealer(genesis *core.Genesis, nodes []string) (*node.Node, error) {
|
||||
func makeSealer(genesis *core.Genesis) (*node.Node, error) {
|
||||
// Define the basic configurations for the Ethereum node
|
||||
datadir, _ := ioutil.TempDir("", "")
|
||||
|
||||
|
@ -21,7 +21,6 @@ package main
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
@ -41,7 +40,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
@ -62,11 +61,11 @@ func main() {
|
||||
|
||||
var (
|
||||
nodes []*node.Node
|
||||
enodes []string
|
||||
enodes []*enode.Node
|
||||
)
|
||||
for i := 0; i < 4; i++ {
|
||||
// Start the node and wait until it's up
|
||||
node, err := makeMiner(genesis, enodes)
|
||||
node, err := makeMiner(genesis)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -76,18 +75,12 @@ func main() {
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
}
|
||||
// Connect the node to al the previous ones
|
||||
for _, enode := range enodes {
|
||||
enode, err := discover.ParseNode(enode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
for _, n := range enodes {
|
||||
node.Server().AddPeer(n)
|
||||
}
|
||||
node.Server().AddPeer(enode)
|
||||
}
|
||||
// Start tracking the node and it's enode url
|
||||
// Start tracking the node and it's enode
|
||||
nodes = append(nodes, node)
|
||||
|
||||
enode := fmt.Sprintf("enode://%s@127.0.0.1:%d", node.Server().NodeInfo().ID, node.Server().NodeInfo().Ports.Listener)
|
||||
enodes = append(enodes, enode)
|
||||
enodes = append(enodes, node.Server().Self())
|
||||
|
||||
// Inject the signer key and start sealing with it
|
||||
store := node.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
||||
@ -155,7 +148,7 @@ func makeGenesis(faucets []*ecdsa.PrivateKey) *core.Genesis {
|
||||
return genesis
|
||||
}
|
||||
|
||||
func makeMiner(genesis *core.Genesis, nodes []string) (*node.Node, error) {
|
||||
func makeMiner(genesis *core.Genesis) (*node.Node, error) {
|
||||
// Define the basic configurations for the Ethereum node
|
||||
datadir, _ := ioutil.TempDir("", "")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user