Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo/run-validator.sh #494

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions cmd/opera/launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"
"reflect"
"strings"
"time"

"github.com/Fantom-foundation/lachesis-base/abft"
"github.com/Fantom-foundation/lachesis-base/utils/cachescale"
Expand Down Expand Up @@ -206,10 +207,7 @@ func loadAllConfigs(file string, cfg *config) error {
func mayGetGenesisStore(ctx *cli.Context) *genesisstore.Store {
switch {
case ctx.GlobalIsSet(FakeNetFlag.Name):
_, num, err := parseFakeGen(ctx.GlobalString(FakeNetFlag.Name))
if err != nil {
log.Crit("Invalid flag", "flag", FakeNetFlag.Name, "err", err)
}
num := getFakeValidatorCount(ctx)
return makefakegenesis.FakeGenesisStore(num, futils.ToFtm(1000000000), futils.ToFtm(5000000))
case ctx.GlobalIsSet(GenesisFlag.Name):
genesisPath := ctx.GlobalString(GenesisFlag.Name)
Expand Down Expand Up @@ -271,10 +269,7 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
case ctx.GlobalIsSet(DataDirFlag.Name):
cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
case ctx.GlobalIsSet(FakeNetFlag.Name):
_, num, err := parseFakeGen(ctx.GlobalString(FakeNetFlag.Name))
if err != nil {
log.Crit("Invalid flag", "flag", FakeNetFlag.Name, "err", err)
}
num := getFakeValidatorCount(ctx)
cfg.DataDir = filepath.Join(defaultDataDir, fmt.Sprintf("fakenet-%d", num))
}
}
Expand Down Expand Up @@ -497,11 +492,13 @@ func mayMakeAllConfigs(ctx *cli.Context) (*config, error) {
}

if ctx.GlobalIsSet(FakeNetFlag.Name) {
_, num, err := parseFakeGen(ctx.GlobalString(FakeNetFlag.Name))
if err != nil {
return nil, fmt.Errorf("invalid fakenet flag")
// don't wait long in fakenet
cfg.Emitter.EmitIntervals.Max = 10 * time.Second
cfg.Emitter.EmitIntervals.DoublesignProtection = 5 * time.Second
if getFakeValidatorCount(ctx) <= 1 {
// disable self-fork protection if fakenet 1/1
cfg.Emitter.EmitIntervals.DoublesignProtection = 0
}
cfg.Emitter = emitter.FakeConfig(num)
setBootnodes(ctx, []string{}, &cfg.Node)
} else {
// "asDefault" means set network defaults
Expand Down
38 changes: 32 additions & 6 deletions cmd/opera/launcher/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import (
"strconv"
"strings"

"github.com/Fantom-foundation/go-opera/inter/validatorpk"
"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
cli "gopkg.in/urfave/cli.v1"

"github.com/Fantom-foundation/go-opera/integration/makefakegenesis"
Expand All @@ -15,17 +18,34 @@ import (
// FakeNetFlag enables special testnet, where validators are automatically created
var FakeNetFlag = cli.StringFlag{
Name: "fakenet",
Usage: "'n/N' - sets coinbase as fake n-th key from genesis of N validators.",
Usage: "'n/N' - sets coinbase as fake n-th key from genesis of [1..N] validators. Use n=0 for non-validator node",
}

func getFakeValidatorID(ctx *cli.Context) idx.ValidatorID {
id, _, err := parseFakeGen(ctx.GlobalString(FakeNetFlag.Name))
if err != nil {
log.Crit("Invalid flag", "flag", FakeNetFlag.Name, "err", err)
}
return id
}

func getFakeValidatorKey(ctx *cli.Context) *ecdsa.PrivateKey {
id, _, err := parseFakeGen(ctx.GlobalString(FakeNetFlag.Name))
if err != nil || id == 0 {
return nil
if err != nil {
log.Crit("Invalid flag", "flag", FakeNetFlag.Name, "err", err)
}
return makefakegenesis.FakeKey(id)
}

func getFakeValidatorCount(ctx *cli.Context) idx.Validator {
_, num, err := parseFakeGen(ctx.GlobalString(FakeNetFlag.Name))
if err != nil {
log.Crit("Invalid flag", "flag", FakeNetFlag.Name, "err", err)
return 0
}
return num
}

func parseFakeGen(s string) (id idx.ValidatorID, num idx.Validator, err error) {
parts := strings.SplitN(s, "/", 2)
if len(parts) != 2 {
Expand All @@ -41,11 +61,17 @@ func parseFakeGen(s string) (id idx.ValidatorID, num idx.Validator, err error) {
id = idx.ValidatorID(u32)

u32, err = strconv.ParseUint(parts[1], 10, 32)
num = idx.Validator(u32)
if num < 0 || idx.Validator(id) > num {
err = fmt.Errorf("key-num should be in range from 1 to validators (<key-num>/<validators>), or should be zero for non-validator node")
if err != nil {
return
}
num = idx.Validator(u32)

return
}

func fakeValidatorPubKey(id idx.ValidatorID) validatorpk.PubKey {
return validatorpk.PubKey{
Raw: crypto.FromECDSAPub(&makefakegenesis.FakeKey(id).PublicKey),
Type: validatorpk.Types.Secp256k1,
}
}
15 changes: 3 additions & 12 deletions cmd/opera/launcher/fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"

"github.com/Fantom-foundation/go-opera/integration/makefakegenesis"
"github.com/Fantom-foundation/go-opera/inter/validatorpk"
)

Expand Down Expand Up @@ -101,18 +99,11 @@ To exit, press ctrl-d
}
}

func readFakeValidator(fakenet string) *validatorpk.PubKey {
n, _, err := parseFakeGen(fakenet)
func readFakeValidator(fakenet string) validatorpk.PubKey {
id, _, err := parseFakeGen(fakenet)
if err != nil {
panic(err)
}

if n < 1 {
return nil
}

return &validatorpk.PubKey{
Raw: crypto.FromECDSAPub(&makefakegenesis.FakeKey(n).PublicKey),
Type: validatorpk.Types.Secp256k1,
}
return fakeValidatorPubKey(id)
}
10 changes: 6 additions & 4 deletions cmd/opera/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import (
"github.com/ethereum/go-ethereum/console/prompt"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
evmetrics "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/discover/discfilter"
"github.com/ethereum/go-ethereum/params"
"gopkg.in/urfave/cli.v1"

evmetrics "github.com/ethereum/go-ethereum/metrics"

"github.com/Fantom-foundation/go-opera/cmd/opera/launcher/metrics"
"github.com/Fantom-foundation/go-opera/cmd/opera/launcher/tracing"
"github.com/Fantom-foundation/go-opera/debug"
Expand All @@ -29,6 +28,7 @@ import (
"github.com/Fantom-foundation/go-opera/gossip"
"github.com/Fantom-foundation/go-opera/gossip/emitter"
"github.com/Fantom-foundation/go-opera/integration"
"github.com/Fantom-foundation/go-opera/inter/validatorpk"
"github.com/Fantom-foundation/go-opera/opera/genesis"
"github.com/Fantom-foundation/go-opera/opera/genesisstore"
"github.com/Fantom-foundation/go-opera/utils/errlock"
Expand Down Expand Up @@ -322,9 +322,11 @@ func makeNode(ctx *cli.Context, cfg *config, genesisStore *genesisstore.Store) (

valKeystore := valkeystore.NewDefaultFileKeystore(path.Join(getValKeystoreDir(cfg.Node), "validator"))
valPubkey := cfg.Emitter.Validator.PubKey
if key := getFakeValidatorKey(ctx); key != nil && cfg.Emitter.Validator.ID != 0 {

if ctx.GlobalIsSet(FakeNetFlag.Name) && !valPubkey.Empty() {
key := getFakeValidatorKey(ctx)
addFakeValidatorKey(ctx, key, valPubkey, valKeystore)
coinbase := integration.SetAccountKey(stack.AccountManager(), key, "fakepassword")
coinbase := integration.SetAccountKey(stack.AccountManager(), key, validatorpk.FakePassword)
log.Info("Unlocked fake validator account", "address", coinbase.Address.Hex())
}

Expand Down
19 changes: 7 additions & 12 deletions cmd/opera/launcher/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/Fantom-foundation/lachesis-base/inter/idx"

"github.com/Fantom-foundation/go-opera/gossip/emitter"
"github.com/Fantom-foundation/go-opera/integration/makefakegenesis"
"github.com/Fantom-foundation/go-opera/inter/validatorpk"
)

Expand All @@ -34,18 +33,14 @@ var validatorPasswordFlag = cli.StringFlag{
func setValidator(ctx *cli.Context, cfg *emitter.Config) error {
// Extract the current validator address, new flag overriding legacy one
if ctx.GlobalIsSet(FakeNetFlag.Name) {
id, num, err := parseFakeGen(ctx.GlobalString(FakeNetFlag.Name))
if err != nil {
return err
id := getFakeValidatorID(ctx)
if id != 0 {
if ctx.GlobalIsSet(validatorIDFlag.Name) {
return errors.New("specified validator ID with both --fakenet and --validator.id")
}
cfg.Validator.ID = id
cfg.Validator.PubKey = fakeValidatorPubKey(id)
}

if ctx.GlobalIsSet(validatorIDFlag.Name) && id != 0 {
return errors.New("specified validator ID with both --fakenet and --validator.id")
}

cfg.Validator.ID = id
validators := makefakegenesis.GetFakeValidators(num)
cfg.Validator.PubKey = validators.Map()[cfg.Validator.ID].PubKey
}

if ctx.GlobalIsSet(validatorIDFlag.Name) {
Expand Down
6 changes: 4 additions & 2 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Demo

This directory contains the scripts to run fakenet (private testing network) with N local nodes,
This directory contains the scripts to run fakenet (private testing network) with N+M local nodes,
primarily for benchmarking purposes.

## Scripts

- start network: `./start.sh`;
- stop network: `./stop.sh`;
- run new validator node: `./run-validator.sh 3`;
- clean data and logs: `./clean.sh`;

You can specify number of genesis validators by setting N environment variable.
You can specify number of genesis validators by setting N environment variable
and M for additional nodes.

## Balance transfer example

Expand Down
32 changes: 28 additions & 4 deletions demo/_params.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
#!/usr/bin/env bash

declare -ri N="${N:-3}"
declare -ri M="${M:-2}"
declare -ri M="${M:-0}"
declare -r TAG="${TAG:-latest}"

PORT_BASE=3000
RPCP_BASE=4000
WSP_BASE=4500

data_dir() {
local i=$1
echo "${PWD}/opera$i.datadir"
}

run_opera_node() {
local i=$1
local ACC=$(($i+1))
local DATADIR="$(data_dir $i)"
local PORT=$(($PORT_BASE+$i))
local RPCP=$(($RPCP_BASE+$i))
local WSP=$(($WSP_BASE+$i))

../build/demo_opera \
--datadir=${DATADIR} \
--fakenet=${ACC}/$N \
--port=${PORT} \
--nat extip:127.0.0.1 \
--http --http.addr="127.0.0.1" --http.port=${RPCP} --http.corsdomain="*" --http.api="eth,debug,net,admin,web3,personal,txpool,ftm,dag" \
--ws --ws.addr="127.0.0.1" --ws.port=${WSP} --ws.origins="*" --ws.api="eth,debug,net,admin,web3,personal,txpool,ftm,dag" \
--metrics --metrics.addr=127.0.0.1 --metrics.port=$(($RPCP+1100)) \
--verbosity=3 --tracing >> opera$i.log 2>&1
}

attach_and_exec() {
local i=$1
local CMD=$2
local RPCP=$(($RPCP_BASE+$i))
local DATADIR="$(data_dir $i)"
local CMD=$2

for attempt in $(seq 40)
do
Expand All @@ -20,7 +44,7 @@ attach_and_exec() {
echo " - attempt ${attempt}: " >&2
fi

res=$(../build/demo_opera --exec "${CMD}" attach http://127.0.0.1:${RPCP} 2> /dev/null)
res=$(../build/demo_opera --exec "${CMD}" attach ${DATADIR}/opera.ipc 2> /dev/null)
if [ $? -eq 0 ]
then
#echo "success" >&2
Expand Down
44 changes: 44 additions & 0 deletions demo/run-validator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
cd $(dirname $0)
. ./_params.sh

set -e

TOTAL=$((N+M))
i=$1
DATADIR="$(data_dir $i)"
if [ -d ${DATADIR} ]; then
echo "${DATADIR} already exists!"
exit 1
fi
mkdir -p "${DATADIR}"

echo -e "\nStart additional node $i:\n"
run_opera_node $i &
echo -e "\tnode$i ok"

echo -e "\nConnect to existing nodes:\n"
for ((n=0;n<$TOTAL;n+=1))
do
enode=$(attach_and_exec $n 'admin.nodeInfo.enode')
echo " p2p address = ${enode}"

echo " connecting node-$i to node-$n:"
res=$(attach_and_exec $i "admin.addPeer(${enode})")
echo " result = ${res}"
done
sleep 5

VPKEY=$(grep "Unlocked validator key" opera$i.log | head -n 1 | sed 's/.* pubkey=\(0x.*\)$/\1/')
VADDR=$(grep "Unlocked fake validator account" opera$i.log | head -n 1 | sed 's/.* address=\(0x.*\)$/\1/')

echo -e "\nFund new validator acc ${VADDR}:\n"
attach_and_exec 0 "ftm.sendTransaction({from: personal.listAccounts[0], to: \"${VADDR}\", value: web3.toWei(\"510000.0\", \"ftm\")})"
sleep 5

echo -e "\nCall SFC to create validator ${VPKEY}:\n"
../build/demo_opera attach "${DATADIR}/opera.ipc" << JS
abi = JSON.parse('[{"constant":false,"inputs":[{"internalType":"bytes","name":"pubkey","type":"bytes"}],"name":"createValidator","outputs":[],"payable":true,"stateMutability":"payable","type":"function"}]');
sfcc = web3.ftm.contract(abi).at("0xfc00face00000000000000000000000000000000");
sfcc.createValidator("${VPKEY}", {from:"${VADDR}", value: web3.toWei("500000.0", "ftm")});
JS
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that restarting the node in validator mode is still required here, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it works ok without restart. New validator node starts to emit right from the next epoch.

Copy link

@xdfdm xdfdm Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rus-alex @hadv @uprendis
is it possible:

  • to start several fakenet nodes by start.sh
  • then do export genesis genesisfile.g
  • start a new node with --genesis genesisfile.g (and without --fakenet flag)
  • and make it a validator as in the instructions here (need to send some ftm from one of the fake validator nodes to new account for staking)
    ?

why doesn't this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xdfdm , it works for me. Share full commands with outputs you did to find a mistake.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rus-alex

  1. run 3 fake nodes:
    cd demo
    ./start.sh
  2. stop it. and export genesis
    ./stop.sh
    ../build/demo_opera --datadir opera0.datadir export genesis genesis.g
    output:
WARN [08-22|21:03:12.624] Please add '--cache 3826' flag to allocate more cache for Opera. Total memory is 7653 MB. 
INFO [08-22|21:03:12.624] Maximum peer count                       total=50
INFO [08-22|21:03:12.625] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
WARN [08-22|21:03:12.909] Attempting genesis export not in a beginning of an epoch. Genesis file output may contain excessive data. 
INFO [08-22|21:03:12.910] Exporting epochs                         from=1 to=3
WARN [08-22|21:03:12.910] No epoch record                          epoch=1
INFO [08-22|21:03:12.912] Exported epochs 
- Epochs hash: 0xd92a6000dbc3d5848308f76dde52c0f1394f272c68aa10ee618ff8b28036af9e 
INFO [08-22|21:03:12.912] Exporting blocks                         from=1 to=2
INFO [08-22|21:03:12.916] Exported blocks 
- Blocks hash: 0x86ae345365c45d48e7dabe2df2fb28e7dd2f4382eb0dd8fc85d4d3409b915133 
INFO [08-22|21:03:12.916] Exporting EVM data 
INFO [08-22|21:03:12.941] Exported EVM data 
- EVM hash: 0xe22d5fe99ddf119ccff4d185410ba1890c45dce70c4b11ae146617f173d03e80

start nodes again
./start.sh

  1. run opera node from genesis with opera0 bootnode
    cd ../build
    nohup ./opera --port 3100 --nat any --genesis.allowExperimental --genesis ../demo/genesis.g --http --http.addr=127.0.0.1 --http.port=4100 --http.corsdomain=* --http.vhosts=* --http.api=eth,debug,net,admin,web3,personal,txpool,ftm,dag,sfc --bootnodes enode://096519e2fdf150789a39074250b5f0b8250719044bf6a79ff2027e29688271d8a1ddd23266bb44ee8b2d3df85ff59d0b8cddd774fc09e027de2bd34a8efbcd1b@127.0.0.1:3000 --allow-insecure-unlock > opera_node.log &

  2. according this
    ./opera account new
    set password
    output :

...
Public address of the key:   0xAccount

then
./opera validator new
output:

...
Public key:                  0xPublicKey
  1. send some tokens from validator to new account
    ./opera --datadir ../demo/opera0.datadir attach
> personal
get account address in 
listAccounts: ["0xOpera0AccAddr"],

> ftm.sendTransaction({from: "0xOpera0AccAddr", to: "0xAccount, value: web3.toWei("100000000", "ftm")})
  1. create validator
    ./opera attach
> personal.unlockAccount("0xAccount", "password", 3600)
true

> abi = ....
large json output

> sfcc = web3.ftm.contract(abi).at("0xfc00face00000000000000000000000000000000")
long output

>sfcc.lastValidatorID()
3

> tx = sfcc.createValidator("0xPublicKey", {from:"0xAccount", value: web3.toWei("90000000", "ftm")}) 
0xtx_hash

> ftm.getTransactionRecepit("0xtx_hash")
...
status: “0x1”
...

> sfcc.getValidatorID("0xAccount")
4
  1. restart node in validator mode
    ps aux | grep opera
    get PID of our new node
    kill opera_pid
    set password to file
    echo password > pass.txt
    start opera in validator mode
    nohup ./opera --port 3100 --nat any --genesis.allowExperimental --genesis ../demo/genesis.g --http --http.addr=127.0.0.1 --http.port=4100 --http.corsdomain=* --http.vhosts=* --http.api=eth,debug,net,admin,web3,personal,txpool,ftm,dag,sfc --allow-insecure-unlock --validator.id 4 --validator.pubkey 0xPublicKey --validator.password ./pass.txt > validator.log &

output:

WARN [08-22|16:49:38.055] Please add '--cache 3826' flag to allocate more cache for Opera. Total memory is 7653 MB.
INFO [08-22|16:49:38.056] Maximum peer count                       total=50
INFO [08-22|16:49:38.056] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
WARN [08-22|16:49:38.056] Option nousb is deprecated and USB is deactivated by default. Use --usb to enable
WARN [08-22|16:49:38.056] Genesis file doesn't refer to any trusted preset
INFO [08-22|16:49:38.599] Genesis is already written               name=fake id=4003 genesis=0x24841db8ad0e6d5b66de059536e9bb41d5d285c2b272421cee9b1a66b5de430e
INFO [08-22|16:49:39.627] Unlocked validator key                   pubkey=0xc00480a18d19907cb8c411a475a56c3f3c6389b8bd9e4a1039488c7b04a64abfc8710f99d127fd3f162cfc4ad04f2005>
INFO [08-22|16:49:39.627] Loaded local transaction journal         transactions=0 dropped=0
INFO [08-22|16:49:39.628] Regenerated local transaction journal    transactions=0 accounts=0
INFO [08-22|16:49:39.629] Starting peer-to-peer node               instance=go-opera/v1.1.3-rc.2-71882c85-1692246427/linux-amd64/go1.21.0
INFO [08-22|16:49:39.661] New local node record                    seq=5 id=e136ac220f1e7c32 ip=127.0.0.1 udp=3100 tcp=3100
INFO [08-22|16:49:39.667] IPC endpoint opened                      url=/home/ubuntu/.opera/opera.ipc
INFO [08-22|16:49:39.667] EVM snapshot                             module=gossip-store at=22a3e3..12329d generating=false
INFO [08-22|16:49:39.667] Start/Switch to fullsync mode...         module=PM
INFO [08-22|16:49:39.671] Started P2P networking                   self=enode://146dc366fe93028e2b651583ba4b9bbe5e8126797d2295223bea889f9365a3a9e56fa25f998fbfc98666057443d4>
INFO [08-22|16:49:39.680] Emitting is paused                       reason="waiting additional time" wait=29m45.167544632s
INFO [08-22|16:49:40.689] New DAG summary                          new=1 last_id=5:52:bdc1d3 age=1h38m5.711s t="161.218µs"
INFO [08-22|16:49:46.690] Emitting is paused                       reason="waiting additional time" wait=29m38.158112963s
INFO [08-22|16:49:53.697] Emitting is paused                       reason="waiting additional time" wait=29m31.151045218s
INFO [08-22|16:49:56.317] New LLR summary                          last_epoch=5 last_block=0 new_evs=1 new_ers=0 new_bvs=0 new_brs=0 age=none
INFO [08-22|16:49:56.317] New DAG summary                          new=354 last_id=5:406:4f0b41 age=1.601ms     t=22.980ms
INFO [08-22|16:50:00.707] Emitting is paused                       reason="waiting additional time" wait=29m24.14077659s
INFO [08-22|16:50:06.044] New DAG summary                          new=3   last_id=5:409:e2a8b5 age=1.464ms     t="272.841µs"
INFO [08-22|16:50:07.715] Emitting is paused                       reason="waiting additional time" wait=29m17.133153447s
INFO [08-22|16:50:14.718] Emitting is paused                       reason="waiting additional time" wait=29m10.130237782s


....

INFO [08-22|17:19:06.248] New DAG summary                          new=3   last_id=5:943:cc864b age=1.464ms     t="230.914µs"
INFO [08-22|17:19:12.118] Emitting is paused                       reason="waiting additional time" wait=12.729872806s
INFO [08-22|17:19:16.078] New DAG summary                          new=3   last_id=5:946:66d75e age="961.106µs" t="240.793µs"
INFO [08-22|17:19:19.127] Emitting is paused                       reason="waiting additional time" wait=5.720710269s
INFO [08-22|17:19:24.853] New event emitted                        id=5:949:04d192     parents=1 by=4 frame=1 txs=0 age=4.632ms     t=1.800ms
INFO [08-22|17:19:24.853] New DAG summary                          new=3   last_id=5:949:04d192 age=4.632ms     t=1.991ms
INFO [08-22|17:19:35.733] New DAG summary                          new=4   last_id=5:953:fe13e7 age=1.375ms     t="374.277µs"
INFO [08-22|17:19:45.507] New DAG summary                          new=3   last_id=5:956:131146 age=1.477ms     t="232.664µs"
INFO [08-22|17:19:55.232] New DAG summary                          new=3   last_id=5:959:34517b age="850.859µs" t="227.502µs"
INFO [08-22|17:20:04.954] New DAG summary                          new=3   last_id=5:962:b19e07 age="876.605µs" t="251.701µs"
INFO [08-22|17:20:14.676] New DAG summary                          new=3   last_id=5:965:7534f2 age="907.079µs" t="270.476µs"
INFO [08-22|17:20:24.400] New DAG summary                          new=3   last_id=5:968:a2ebc1 age=1.231ms     t="277.723µs"
INFO [08-22|17:20:34.127] New DAG summary                          new=3   last_id=5:971:cc9005 age=1.435ms     t="305.08µs"
INFO [08-22|17:20:43.857] New DAG summary                          new=3   last_id=5:974:5b3595 age=1.427ms     t="220.279µs"
INFO [08-22|17:20:53.577] New DAG summary                          new=3   last_id=5:977:4ddda8 age=1.153ms     t="390.272µs"
...

INFO [08-22|17:38:23.965] New DAG summary                          new=3   last_id=6:167:9b6be5  age="895.374µs" t="366.482µs"
INFO [08-22|17:38:33.695] New DAG summary                          new=3   last_id=6:170:4bd8ce  age=1.374ms     t="224.364µs"
INFO [08-22|17:38:43.422] New DAG summary                          new=3   last_id=6:173:7bbb65  age=1.295ms     t="253.877µs"
INFO [08-22|17:38:53.145] New DAG summary                          new=3   last_id=6:176:baaac1  age=1.462ms     t="454.296µs"
INFO [08-22|17:39:02.866] New DAG summary                          new=3   last_id=6:179:b50d4f  age=1.490ms     t="287.703µs"
ERROR[08-22|17:39:12.093] Emitted incorrect event                  err="event creator isn't a validator"
INFO [08-22|17:39:12.596] New DAG summary                          new=3   last_id=6:182:6a6fac  age=1.961ms     t="189.836µs"
ERROR[08-22|17:39:13.099] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:14.105] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:15.107] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:16.109] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:17.114] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:18.118] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:19.122] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:20.126] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:21.133] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:22.137] Emitted incorrect event                  err="event creator isn't a validator"
INFO [08-22|17:39:22.318] New DAG summary                          new=3   last_id=6:185:6fcc4c  age=1.390ms     t="333.654µs"
ERROR[08-22|17:39:23.141] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:24.148] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:25.153] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:26.159] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:27.164] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:28.167] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:29.173] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:30.180] Emitted incorrect event                  err="event creator isn't a validator"
ERROR[08-22|17:39:31.185] Emitted incorrect event                  err="event creator isn't a validator"
INFO [08-22|17:39:32.048] New DAG summary                          new=3   last_id=6:188:c50a45  age=1.460ms     t="255.634µs"
ERROR[08-22|17:39:32.192] Emitted incorrect event                  err="event creator isn't a validator"
...

if check epoch and block
./opera --datadir ../demo/opera0.datadir --exec admin.nodeInfo.protocols attach
you can see that the blocks are no longer added. Everything is stucked.

40 changes: 11 additions & 29 deletions demo/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,27 @@ cd $(dirname $0)

set -e

echo -e "\nStart $N nodes:\n"
TOTAL=$((N+M))
echo -e "\nStart ${TOTAL} validators on $N-validator genesis:\n"

go build -o ../build/demo_opera ../cmd/opera

rm -f ./transactions.rlp
for ((i=0;i<$N;i+=1))
do
DATADIR="${PWD}/opera$i.datadir"
mkdir -p ${DATADIR}

PORT=$(($PORT_BASE+$i))
RPCP=$(($RPCP_BASE+$i))
WSP=$(($WSP_BASE+$i))
ACC=$(($i+1))
(../build/demo_opera \
--datadir=${DATADIR} \
--fakenet=${ACC}/$N \
--port=${PORT} \
--nat extip:127.0.0.1 \
--http --http.addr="127.0.0.1" --http.port=${RPCP} --http.corsdomain="*" --http.api="eth,debug,net,admin,web3,personal,txpool,ftm,dag" \
--ws --ws.addr="127.0.0.1" --ws.port=${WSP} --ws.origins="*" --ws.api="eth,debug,net,admin,web3,personal,txpool,ftm,dag" \
--metrics --metrics.addr=127.0.0.1 --metrics.port=$(($RPCP+1100)) \
--verbosity=3 --tracing >> opera$i.log 2>&1)&

for ((i=0;i<${TOTAL};i+=1))
do
run_opera_node $i &
echo -e "\tnode$i ok"
done

echo -e "\nConnect nodes to ring:\n"
for ((i=0;i<$N;i+=1))
for ((i=0;i<${TOTAL};i+=1))
do
for ((n=0;n<$M;n+=1))
do
j=$(((i+n+1) % N))
j=$(((i+n+1) % TOTAL))

enode=$(attach_and_exec $j 'admin.nodeInfo.enode')
echo " p2p address = ${enode}"
echo " p2p address = ${enode}"

echo " connecting node-$i to node-$j:"
res=$(attach_and_exec $i "admin.addPeer(${enode})")
echo " result = ${res}"
done
echo " connecting node-$i to node-$j:"
res=$(attach_and_exec $i "admin.addPeer(${enode})")
echo " result = ${res}"
done
Loading