Lisk-sdk: Blockchain verification process should not connect to network

Created on 24 May 2019  路  7Comments  路  Source: LiskHQ/lisk-sdk

Expected behavior

Blockchain verification process should not connect to the network. it should not make any outbound connection or not connect to any peers at all(including itself).

Actual behavior

While running blockchain verification processes the nodes receive requests from outbound peers, the node is connected to other nodes.

{"name":"lisk-framework","hostname":"ams3-manu-mainnet-snapshotting","pid":15048,"level":30,"msg":"Received inbound request for procedure updateMyself","time":"2019-05-24T08:07:41.377Z","v":0}
{"name":"lisk-framework","hostname":"ams3-manu-mainnet-snapshotting","pid":15048,"level":30,"msg":"Updated info of peer 80.211.154.39:8001 to {\"os\":\"linux4.4.0-116-generic\",\"version\":\"1.6.0\",\"wsPort\":8001,\"httpPort\":8000,\"minVersion\":\"1.0.0\",\"protocolVersion\":\"1.0\",\"height\":9212879,\"nethash\":\"ed14889723f24ecc54871d058d98ce91ff2f973192075c0155ba2b7b70ad2511\",\"broadhash\":\"5b218d31795aa19dacd407cb174b55c4481ccdf699b9efe1a56c3ca66ea6592d\",\"nonce\":\"6aSi0iRokguGNNA5\",\"state\":2,\"ipAddress\":\"80.211.154.39\"}","time":"2019-05-24T08:07:41.429Z","v":0}

Steps to reproduce

Deploy 2.0.0-alpha.10 node and run node dist/index.js -b 80000 -n mainnet

Which version(s) does this affect? (Environment, OS, etc...)

2.0.0

bug

All 7 comments

@ManuGowda this behaviour has not been introduced with 2.0; in the past we've used different configuration file (pm2, lisk) to work around this problem.

@ManuGowda this behaviour has not been introduced with 2.0; in the past we've used different configuration file (pm2, lisk) to work around this problem.

ok so for verification process I should use different config? like this https://github.com/LiskHQ/lisk-sdk/blob/v1.6.0/build/target/etc/snapshot.json?

@ManuGowda that's a workaround that used to work, you might want to try it.

after the investigation found that p2p still makes the connection with the network.
here the configuration

{
    "components": {
        "logger": {},
        "cache": {}
    },
    "modules": {
        "chain": {
            "exceptions": {
                "precedent": {
                    "disableDappTransfer": 9000000
                }
            },
            "loading": {
                        "loadPerIteration": 101
                }
        },
        "http_api": {
            "access": {
                "whiteList": [
                ]
            }
        },
        "network": {
            "seedPeers": []
        }
    }
}

here the command used for verification node dist/index.js -b 90000 -n mainnet -c config.json
here the connection details

lisk@ubuntu-s-4vcpu-8gb-sgp1-01:~/lisk-main$ netstat -np | grep 8001 | wc -l
621

@shuse2 please assign this issue to someone, we need to fix this issue.

So even if we pass blank seed peers, there are 2 ways that a peer could be added or connected due to nature and the way P2P class is initialized.
1) During the cleanup of the network module, we save peers to DB and when we restart a node we load these peers back from the database and try to connect with them as its independent of the verification process and done in P2P lib.
2) If other peers have our ip and port in their peer list then they will try to connect to us during the discovery process so we will receive inbound request like updateMyself mentioned in this issue.

To avoid this,
1) we make sure we don't have any peers in DB or clean up peer from DB.
2) we can disable not to listen to incoming connections by passing a flag that will ignore all the incoming connections.

@ishantiw That's the behaviour from lodash defaultsDeep it tries to deep merge the array attribute.

// Load the full build of lodash
var _ = require('lodash');

const config1 = {
 modules: {
   network: {
    seedPeers: [ {ip: 'a', port: 123}, {ip: 'b', port: 145} ]
   }
 }
}

const config2 = {
 modules: {
   network: {
    seedPeers: [ {ip: 'c', port: 456} ]
   }
 }
}



// merge objects
console.log(
    _.defaultsDeep({}, config2, config1)
)
// seedPeers: [ {ip: 'c', port: 456}, {ip: 'b', port: 145} ]

That's the line which is responsible for calling lodash

https://github.com/LiskHQ/lisk-sdk/blob/66ba821e1568f7e1a8d2941c7c0524bd56cff928/framework/src/controller/configurator/configurator.js#L78

If that's not what you wanted then use _.extendWith with customizer that don't completely override array values. This change will effect all config attributes which are array type, so do it with care.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MaciejBaj picture MaciejBaj  路  4Comments

diego-G picture diego-G  路  3Comments

slaweet picture slaweet  路  3Comments

yatki picture yatki  路  3Comments

hendrikhofstadt picture hendrikhofstadt  路  4Comments