LiskArchive / lisk-elements

⚙️ Library for sending Lisk transactions from the client or server
https://lisk.io/
GNU General Public License v3.0
250 stars 64 forks source link

Cannot send request with rpc-timeout #1155

Closed shuse2 closed 5 years ago

shuse2 commented 5 years ago

Expected behavior

Should be able to send a request to peers.

Actual behavior

After instantiating the P2P, try to request blocks. It returns timeout error. Also, it seems updateMySelf endpoint is returning error missing required propertystate``

Steps to reproduce

new P2P({
            blacklistedPeers: [],
            connectTimeout: 5000,
            seedPeers: [
                {
                    ipAddress: '83.136.254.92',
                    wsPort: 8001,
                },
                {
                    ipAddress: '83.136.249.76',
                    wsPort: 8001,
                },
            ],
            wsEngine: 'ws',
            nodeInfo: {
                wsPort: 8001,
                nethash: genesis.payloadHash,
                version: '1.4.1',
                os: os.platform(),
                height: 1,
                state: 1,
                httpPort: 8000,
                broadhash:
                    '2768b267ae621a9ed3b3034e2e8a1bed40895c621bbb1bbd613d92b9d24e54b5',
                nonce: crypto.randomBytes(8).toString('hex'),
            },
        });

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

ishantiw commented 5 years ago

The problem is that when we make RPC request { procedure: 'blocks' }, a node returns a block that has 8176 number of transactions in mainnet This takes a lot of time to process for a peer to select and respond within 2000 ms (i.e, the default value of ackTimeout). It is able to respond when we set the value of ackTimeout to 10000 ms. For any other RPC call it doesn't timeout even with 2000 ms acknowledgment timeout. peer.ts#L78

export const DEFAULT_ACK_TIMEOUT = 2000;

So either we put a limit to number of blocks being returned for blocks rpc call by size (or total number of transactions in total) or we explicitly increase the ackTimeout value to 10000 ms in order to make a successful call.

ishantiw commented 5 years ago

In mainnet, we are receiving this block below that has 8176 transactions. BlockId:13658550407518916215

shuse2 commented 5 years ago

genesis block =)

ishantiw commented 5 years ago

Its a Genesis block

shuse2 commented 5 years ago

Closing issue because behavior is correct and the fix is not related to the library