caliper icon indicating copy to clipboard operation
caliper copied to clipboard

Allow Ethereum Benchmarking With Multiple Address

Open steventranjs opened this issue 5 years ago • 7 comments

Context

Currently, the Ethereum benchmark configuration only allow to send transactions from 1 single address (fromAddress) and all workers using this same address to send transactions

Proposed Enhancement

Allow to add multiple addreses for Ethereum benchmark that run in multiple workers. A sample configuration is as below

{
    "caliper": {
        "blockchain": "ethereum"
    },
    "ethereum": {
        ...
        "fromAddress": "{fromAddress1},{fromAddress2},{fromAddress3}",
        "fromAddressPrivateKey": "{fromAddressPrivateKey1},{fromAddressPrivateKey2},{fromAddressPrivateKey3}"
        "fromAddressPassword": "{fromAddressPassword1},{fromAddressPassword2},{fromAddressPassword3}"
        ...
    }
}
  • fromAddress is allowed to have comma separator beside single address string format
  • fromAddressPrivateKey and fromAddressPassword also changed accordingly, validation will ensure numbers of addressed and its private keys / passwords are same
  • This is not broken changes, existing configuration with single address should be working fine

How To Assign Parallel Addresses To Workers

If numbers of workers LESS than the number of addresses

  • Each worker is assigned to address that has same index sequence. The un-assigned addresses will be ignored
  • For example: If nums of workers = 2 and nums of addresses = 3 then we assign worker 1,2 to address 1,2 accordingly and ignore address 3

If numbers of workers MORE than the number of addresses

  • Each worker is assigned to address that has same index sequence. The un-assigned workers with take a random address from the list
  • For example: If nums of workers = 3 and nums of addresses = 2 then we assign worker 1,2 to address 1,2 accordingly and worker 3 will take a random one (either address 1 or address 2)

P/S: If this proposal is accepted, I would like to send a pull request as I alrd prepared code changes from my side

steventranjs avatar Aug 20 '20 19:08 steventranjs

+1

tiepcyber avatar Aug 21 '20 01:08 tiepcyber

+1

tonybka avatar Aug 21 '20 03:08 tonybka

@nklincoln thanks for approve my proposal as an enhancement. May I know when can I have permission to make Pull Request on this? Thanks

steventranjs avatar Aug 22 '20 03:08 steventranjs

+1

hoang-ng avatar Aug 22 '20 03:08 hoang-ng

@steventranjs I'm so sorry for only just noticing your message - we are always willing to accept PRs.

Please feel free to contact us directly in rocket chat on the following channel: https://chat.hyperledger.org/channel/caliper-contributors

nklincoln avatar Oct 06 '20 09:10 nklincoln

Does this work? May I apply your proposal as I am using caliper 0.4.2?

toutou8148 avatar Mar 29 '21 19:03 toutou8148

I have already applied the idea with an easy way. All you need is to edit the network configuration file by setting fromAddress key with a table of addresses. Then, in EthereumConnector, in getContext() method, access to address using "this.ethereumConfig.fromAddress[this.workerIndex]" instead of "this.ethereumConfig.fromAddress;"

toutou8148 avatar Mar 30 '21 10:03 toutou8148